Initial commit of data center code to receive HTTP Posts from remote card readers and write them into the database.
Also supports Get request for /api/users and /api/users?userId=x and /api/timelogs?userId=x and /api/stats stats needs fleshing out. also logic behind when someone is checking in/out..
44
DataCenter/DataCenterService.sln
Normal file
@ -0,0 +1,44 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.25420.1
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataCenterService", "DataCenterService\DataCenterService.csproj", "{4CF915B3-0D58-4BA1-9530-32C25085ABBF}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|ARM = Debug|ARM
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Release|ARM = Release|ARM
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{4CF915B3-0D58-4BA1-9530-32C25085ABBF}.Debug|Any CPU.ActiveCfg = Debug|x86
|
||||
{4CF915B3-0D58-4BA1-9530-32C25085ABBF}.Debug|ARM.ActiveCfg = Debug|ARM
|
||||
{4CF915B3-0D58-4BA1-9530-32C25085ABBF}.Debug|ARM.Build.0 = Debug|ARM
|
||||
{4CF915B3-0D58-4BA1-9530-32C25085ABBF}.Debug|ARM.Deploy.0 = Debug|ARM
|
||||
{4CF915B3-0D58-4BA1-9530-32C25085ABBF}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{4CF915B3-0D58-4BA1-9530-32C25085ABBF}.Debug|x64.Build.0 = Debug|x64
|
||||
{4CF915B3-0D58-4BA1-9530-32C25085ABBF}.Debug|x64.Deploy.0 = Debug|x64
|
||||
{4CF915B3-0D58-4BA1-9530-32C25085ABBF}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{4CF915B3-0D58-4BA1-9530-32C25085ABBF}.Debug|x86.Build.0 = Debug|x86
|
||||
{4CF915B3-0D58-4BA1-9530-32C25085ABBF}.Debug|x86.Deploy.0 = Debug|x86
|
||||
{4CF915B3-0D58-4BA1-9530-32C25085ABBF}.Release|Any CPU.ActiveCfg = Release|x86
|
||||
{4CF915B3-0D58-4BA1-9530-32C25085ABBF}.Release|ARM.ActiveCfg = Release|ARM
|
||||
{4CF915B3-0D58-4BA1-9530-32C25085ABBF}.Release|ARM.Build.0 = Release|ARM
|
||||
{4CF915B3-0D58-4BA1-9530-32C25085ABBF}.Release|ARM.Deploy.0 = Release|ARM
|
||||
{4CF915B3-0D58-4BA1-9530-32C25085ABBF}.Release|x64.ActiveCfg = Release|x64
|
||||
{4CF915B3-0D58-4BA1-9530-32C25085ABBF}.Release|x64.Build.0 = Release|x64
|
||||
{4CF915B3-0D58-4BA1-9530-32C25085ABBF}.Release|x64.Deploy.0 = Release|x64
|
||||
{4CF915B3-0D58-4BA1-9530-32C25085ABBF}.Release|x86.ActiveCfg = Release|x86
|
||||
{4CF915B3-0D58-4BA1-9530-32C25085ABBF}.Release|x86.Build.0 = Release|x86
|
||||
{4CF915B3-0D58-4BA1-9530-32C25085ABBF}.Release|x86.Deploy.0 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
3
DataCenter/DataCenterService/ApplicationInsights.config
Normal file
@ -0,0 +1,3 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ApplicationInsights xmlns = "http://schemas.microsoft.com/ApplicationInsights/2013/Settings">
|
||||
</ApplicationInsights>
|
||||
BIN
DataCenter/DataCenterService/Assets/LockScreenLogo.scale-200.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
DataCenter/DataCenterService/Assets/SplashScreen.scale-200.png
Normal file
|
After Width: | Height: | Size: 7.5 KiB |
|
After Width: | Height: | Size: 2.9 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
BIN
DataCenter/DataCenterService/Assets/StoreLogo.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 3.1 KiB |
13
DataCenter/DataCenterService/ConfigObject.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WebSocketService
|
||||
{
|
||||
public sealed class ConfigObject
|
||||
{
|
||||
public string DatabaseStorageFolderId { get; set; }
|
||||
}
|
||||
}
|
||||
160
DataCenter/DataCenterService/DataCenterService.csproj
Normal file
@ -0,0 +1,160 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
||||
<ProjectGuid>{4CF915B3-0D58-4BA1-9530-32C25085ABBF}</ProjectGuid>
|
||||
<OutputType>winmdobj</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>WebSocketService</RootNamespace>
|
||||
<AssemblyName>WebSocketService</AssemblyName>
|
||||
<DefaultLanguage>en-US</DefaultLanguage>
|
||||
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
|
||||
<TargetPlatformVersion>10.0.10586.0</TargetPlatformVersion>
|
||||
<TargetPlatformMinVersion>10.0.10240.0</TargetPlatformMinVersion>
|
||||
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<PackageCertificateKeyFile>WebSocketService_TemporaryKey.pfx</PackageCertificateKeyFile>
|
||||
<AppxPackage>true</AppxPackage>
|
||||
<ContainsStartupTask>true</ContainsStartupTask>
|
||||
<PackageCertificateThumbprint>5429F8FB168AB4AA285001CCC5529EC149023E6E</PackageCertificateThumbprint>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
<UseDotNetNativeToolchain>false</UseDotNetNativeToolchain>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||
<OutputPath>bin\x86\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\ARM\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>ARM</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
|
||||
<OutputPath>bin\ARM\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>ARM</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<OutputPath>bin\x64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<!-- A reference to the entire .Net Framework and Windows SDK are automatically included -->
|
||||
<Content Include="ApplicationInsights.config">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<None Include="DataCenterService.snk" />
|
||||
<None Include="project.json" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ConfigObject.cs" />
|
||||
<Compile Include="DataReceived.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="RestService_Get.cs" />
|
||||
<Compile Include="RestService_Post.cs" />
|
||||
<Compile Include="StartupTask.cs" />
|
||||
<Compile Include="DataObjects.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AppxManifest Include="Package.appxmanifest">
|
||||
<SubType>Designer</SubType>
|
||||
</AppxManifest>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Properties\Default.rd.xml" />
|
||||
<Content Include="Assets\LockScreenLogo.scale-200.png" />
|
||||
<Content Include="Assets\SplashScreen.scale-200.png" />
|
||||
<Content Include="Assets\Square150x150Logo.scale-200.png" />
|
||||
<Content Include="Assets\Square44x44Logo.scale-200.png" />
|
||||
<Content Include="Assets\Square44x44Logo.targetsize-24_altform-unplated.png" />
|
||||
<Content Include="Assets\StoreLogo.png" />
|
||||
<Content Include="Assets\Wide310x150Logo.scale-200.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<SDKReference Include="Microsoft.VCLibs, Version=14.0">
|
||||
<Name>Visual C++ 2015 Runtime for Universal Windows Platform Apps</Name>
|
||||
</SDKReference>
|
||||
<SDKReference Include="SQLite.UWP.2015, Version=3.12.2">
|
||||
<Name>SQLite for Universal Windows Platform</Name>
|
||||
</SDKReference>
|
||||
<SDKReference Include="WindowsIoT, Version=10.0.10586.0">
|
||||
<Name>Windows IoT Extensions for the UWP %28WindowsIoT, Version=10.0.10586.0%29</Name>
|
||||
</SDKReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Website\" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '14.0' ">
|
||||
<VisualStudioVersion>14.0</VisualStudioVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<StartupObject />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SignAssembly>true</SignAssembly>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<AssemblyOriginatorKeyFile>DataCenterService.snk</AssemblyOriginatorKeyFile>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
22
DataCenter/DataCenterService/DataCenterService.csproj.user
Normal file
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
|
||||
<DeviceId>30F105C9-681E-420b-A277-7C086EAD8A4E</DeviceId>
|
||||
<UseEmulator>false</UseEmulator>
|
||||
<RemoteDebugMachine>minwinpc</RemoteDebugMachine>
|
||||
<AuthenticationMode>Universal</AuthenticationMode>
|
||||
<RemoteDebugEnabled>true</RemoteDebugEnabled>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<RemoteDebugMachine>minwinpc</RemoteDebugMachine>
|
||||
<AuthenticationMode>Universal</AuthenticationMode>
|
||||
<RemoteDebugEnabled>true</RemoteDebugEnabled>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
|
||||
<DeviceId>30F105C9-681E-420b-A277-7C086EAD8A4E</DeviceId>
|
||||
<UseEmulator>false</UseEmulator>
|
||||
<RemoteDebugMachine>minwinpc</RemoteDebugMachine>
|
||||
<AuthenticationMode>Universal</AuthenticationMode>
|
||||
<RemoteDebugEnabled>true</RemoteDebugEnabled>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
BIN
DataCenter/DataCenterService/DataCenterService.snk
Normal file
29
DataCenter/DataCenterService/DataObjects.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using SQLite.Net.Attributes;
|
||||
using System;
|
||||
|
||||
|
||||
namespace WebSocketService
|
||||
{
|
||||
public sealed class CardDataPostDto
|
||||
{
|
||||
public string CardUId { get; set; }
|
||||
}
|
||||
|
||||
public sealed class UserIdentity
|
||||
{
|
||||
[PrimaryKey, AutoIncrement]
|
||||
public int Id { get; set; }
|
||||
public string CardUId { get; set; }
|
||||
public string FirstName { get; set; }
|
||||
public string LastName { get; set; }
|
||||
public float HoursPerWeek { get; set; }
|
||||
}
|
||||
|
||||
public sealed class TimeLog
|
||||
{
|
||||
[PrimaryKey, AutoIncrement]
|
||||
public int Id { get; set; }
|
||||
public int UserId_FK { get; set; }
|
||||
public DateTimeOffset SwipeEventDateTime { get; set; }
|
||||
}
|
||||
}
|
||||
14
DataCenter/DataCenterService/DataReceived.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WebSocketService
|
||||
{
|
||||
public sealed class DataReceived
|
||||
{
|
||||
public int ID { get; set; }
|
||||
public string PropName { get; set; }
|
||||
}
|
||||
}
|
||||
38
DataCenter/DataCenterService/Package.appxmanifest
Normal file
@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:iot="http://schemas.microsoft.com/appx/manifest/iot/windows10" IgnorableNamespaces="uap mp iot">
|
||||
<Identity Name="WeatherStationDataService" Publisher="CN=Chris Watts" Version="1.0.0.0" />
|
||||
<mp:PhoneIdentity PhoneProductId="98fa64ba-5904-4840-a608-1c120ff4ec60" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
|
||||
<Properties>
|
||||
<DisplayName>WeatherStationDataService</DisplayName>
|
||||
<PublisherDisplayName>ChrisWatts</PublisherDisplayName>
|
||||
<Logo>Assets\StoreLogo.png</Logo>
|
||||
</Properties>
|
||||
<Dependencies>
|
||||
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
|
||||
</Dependencies>
|
||||
<Resources>
|
||||
<Resource Language="x-generate" />
|
||||
</Resources>
|
||||
<Applications>
|
||||
<Application Id="App">
|
||||
<uap:VisualElements DisplayName="WebSocketService" Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png" Description="WebSocketService" BackgroundColor="transparent" AppListEntry="none">
|
||||
<uap:SplashScreen Image="Assets\SplashScreen.png" />
|
||||
</uap:VisualElements>
|
||||
<Extensions>
|
||||
<Extension Category="windows.backgroundTasks" EntryPoint="WebSocketService.StartupTask">
|
||||
<BackgroundTasks>
|
||||
<iot:Task Type="startup" />
|
||||
</BackgroundTasks>
|
||||
</Extension>
|
||||
</Extensions>
|
||||
</Application>
|
||||
</Applications>
|
||||
<Capabilities>
|
||||
<Capability Name="internetClient" />
|
||||
<Capability Name="internetClientServer" />
|
||||
<Capability Name="privateNetworkClientServer" />
|
||||
<uap:Capability Name="removableStorage" />
|
||||
<uap:Capability Name="videosLibrary" />
|
||||
<uap:Capability Name="musicLibrary" />
|
||||
</Capabilities>
|
||||
</Package>
|
||||
29
DataCenter/DataCenterService/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("WebSocketService")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("WebSocketService")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2016")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
[assembly: ComVisible(false)]
|
||||
31
DataCenter/DataCenterService/Properties/Default.rd.xml
Normal file
@ -0,0 +1,31 @@
|
||||
<!--
|
||||
This file contains Runtime Directives used by .NET Native. The defaults here are suitable for most
|
||||
developers. However, you can modify these parameters to modify the behavior of the .NET Native
|
||||
optimizer.
|
||||
|
||||
Runtime Directives are documented at http://go.microsoft.com/fwlink/?LinkID=391919
|
||||
|
||||
To fully enable reflection for App1.MyClass and all of its public/private members
|
||||
<Type Name="App1.MyClass" Dynamic="Required All"/>
|
||||
|
||||
To enable dynamic creation of the specific instantiation of AppClass<T> over System.Int32
|
||||
<TypeInstantiation Name="App1.AppClass" Arguments="System.Int32" Activate="Required Public" />
|
||||
|
||||
Using the Namespace directive to apply reflection policy to all the types in a particular namespace
|
||||
<Namespace Name="DataClasses.ViewModels" Seralize="All" />
|
||||
-->
|
||||
|
||||
<Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata">
|
||||
<Application>
|
||||
<!--
|
||||
An Assembly element with Name="*Application*" applies to all assemblies in
|
||||
the application package. The asterisks are not wildcards.
|
||||
-->
|
||||
<Assembly Name="*Application*" Dynamic="Required All" />
|
||||
|
||||
|
||||
<!-- Add your application specific runtime directives here. -->
|
||||
|
||||
|
||||
</Application>
|
||||
</Directives>
|
||||
56
DataCenter/DataCenterService/RestService_Get.cs
Normal file
@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Devkoes.Restup.WebServer.Attributes;
|
||||
using Devkoes.Restup.WebServer.Models.Schemas;
|
||||
|
||||
namespace WebSocketService
|
||||
{
|
||||
internal partial class RestService
|
||||
{
|
||||
[UriFormat("/users")]
|
||||
public GetResponse GetAllUsers()
|
||||
{
|
||||
var query = _conn.Table<UserIdentity>();
|
||||
if (query.Any())
|
||||
{
|
||||
return new GetResponse(GetResponse.ResponseStatus.OK, query.ToArray());
|
||||
}
|
||||
return new GetResponse(GetResponse.ResponseStatus.NotFound);
|
||||
}
|
||||
|
||||
[UriFormat("/users?userid={id}")]
|
||||
public GetResponse GetUserById(int id)
|
||||
{
|
||||
var userQuery = _conn.Query<UserIdentity>(
|
||||
"select * from UserIdentity where Id = ?",
|
||||
id);
|
||||
if (userQuery.Any())
|
||||
{
|
||||
return new GetResponse(GetResponse.ResponseStatus.OK, userQuery.First());
|
||||
}
|
||||
return new GetResponse(GetResponse.ResponseStatus.NotFound);
|
||||
}
|
||||
|
||||
[UriFormat("/timelogs?userid={id}")]
|
||||
public GetResponse GetTimeLogsByUserId(int id)
|
||||
{
|
||||
var timeLogQuery = _conn.Query<TimeLog>(
|
||||
"select * from TimeLog where UserId_FK = ?",
|
||||
id);
|
||||
if (timeLogQuery.Any())
|
||||
{
|
||||
return new GetResponse(GetResponse.ResponseStatus.OK, timeLogQuery.ToArray());
|
||||
}
|
||||
return new GetResponse(GetResponse.ResponseStatus.NotFound);
|
||||
}
|
||||
|
||||
[UriFormat("/stats")]
|
||||
public GetResponse GetTimeLogStatistics()
|
||||
{
|
||||
return new GetResponse(GetResponse.ResponseStatus.NotFound);
|
||||
}
|
||||
}
|
||||
}
|
||||
83
DataCenter/DataCenterService/RestService_Post.cs
Normal file
@ -0,0 +1,83 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Devkoes.Restup.WebServer.Models.Schemas;
|
||||
using Devkoes.Restup.WebServer.Attributes;
|
||||
using System.IO;
|
||||
|
||||
namespace WebSocketService
|
||||
{
|
||||
[RestController(InstanceCreationType.Singleton)]
|
||||
internal partial class RestService
|
||||
{
|
||||
private static SQLite.Net.SQLiteConnection _conn;
|
||||
private static string _path;
|
||||
|
||||
public RestService()
|
||||
{
|
||||
if (string.IsNullOrEmpty(_path))
|
||||
_path = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");
|
||||
if (_conn == null)
|
||||
{
|
||||
_conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), _path);
|
||||
_conn.CreateTable<UserIdentity>();
|
||||
_conn.CreateTable<TimeLog>();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Make sure the number of parameters in your UriFormat match the parameters in your method and
|
||||
/// the names (case sensitive) and order are respected.
|
||||
/// </summary>
|
||||
[UriFormat("/simpleparameter/{id}/property/{propName}")]
|
||||
public GetResponse GetWithSimpleParameters(int id, string propName)
|
||||
{
|
||||
return new GetResponse(
|
||||
GetResponse.ResponseStatus.OK,
|
||||
new DataReceived()
|
||||
{
|
||||
ID = id,
|
||||
PropName = propName
|
||||
});
|
||||
}
|
||||
|
||||
[UriFormat("/postTest")]
|
||||
public PostResponse Post([FromContent] DataReceived rcv)
|
||||
{
|
||||
return new PostResponse(PostResponse.ResponseStatus.Created, $"/simpleparameter/{rcv.ID}/property/{rcv.PropName}");
|
||||
}
|
||||
|
||||
//This is the method you need.
|
||||
[UriFormat("/postSwipeData")]
|
||||
public PostResponse PostWeather([FromContent] CardDataPostDto cardData)
|
||||
{
|
||||
var userQuery = _conn.Query<UserIdentity>(
|
||||
"select * from UserIdentity where CardUId = ?",
|
||||
cardData.CardUId);
|
||||
|
||||
var userId = 0;
|
||||
if (!userQuery.Any())
|
||||
{
|
||||
userId = _conn.Insert(new UserIdentity
|
||||
{
|
||||
CardUId = cardData.CardUId,
|
||||
FirstName = "?",
|
||||
LastName = "?",
|
||||
HoursPerWeek = 37.0f
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
userId = userQuery.First().Id;
|
||||
}
|
||||
|
||||
var timeLog = new TimeLog
|
||||
{
|
||||
SwipeEventDateTime = DateTime.UtcNow,
|
||||
UserId_FK = userId
|
||||
};
|
||||
|
||||
var tLogId = _conn.Insert(timeLog);
|
||||
return new PostResponse(PostResponse.ResponseStatus.Created);
|
||||
}
|
||||
}
|
||||
}
|
||||
72
DataCenter/DataCenterService/StartupTask.cs
Normal file
@ -0,0 +1,72 @@
|
||||
using Devkoes.Restup.WebServer.Http;
|
||||
using Devkoes.Restup.WebServer.Rest;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.ApplicationModel.Background;
|
||||
using Windows.Storage;
|
||||
using Newtonsoft.Json;
|
||||
using Windows.Foundation;
|
||||
using Devkoes.Restup.WebServer.File;
|
||||
using Microsoft.Practices.Unity;
|
||||
using Interfaces;
|
||||
|
||||
namespace WebSocketService
|
||||
{
|
||||
public sealed class StartupTask : IBackgroundTask
|
||||
{
|
||||
private const string APP_DB_DIR_NAME = "DataCenterService";
|
||||
private RestRouteHandler _restRouteHandler;
|
||||
|
||||
private HttpServer _httpServer;
|
||||
|
||||
private BackgroundTaskDeferral _deferral;
|
||||
|
||||
private SQLite.Net.SQLiteConnection _conn;
|
||||
private string _path;
|
||||
|
||||
/// <remarks>
|
||||
/// If you start any asynchronous methods here, prevent the task
|
||||
/// from closing prematurely by using BackgroundTaskDeferral as
|
||||
/// described in http://aka.ms/backgroundtaskdeferral
|
||||
/// </remarks>
|
||||
public async void Run(IBackgroundTaskInstance taskInstance)
|
||||
{
|
||||
// This deferral should have an instance reference, if it doesn't... the GC will
|
||||
// come some day, see that this method is not active anymore and the local variable
|
||||
// should be removed. Which results in the application being closed.
|
||||
_deferral = taskInstance.GetDeferral();
|
||||
|
||||
var httpServer = new HttpServer(8800);
|
||||
_httpServer = httpServer;
|
||||
|
||||
_restRouteHandler = new RestRouteHandler();
|
||||
_restRouteHandler.RegisterController<RestService>();
|
||||
|
||||
//register the route to handle the api
|
||||
httpServer.RegisterRoute("api", _restRouteHandler);
|
||||
//register the route to handle the base web pages..
|
||||
httpServer.RegisterRoute(new StaticFileRouteHandler(@"Website"));
|
||||
|
||||
_path = Path.Combine(ApplicationData.Current.LocalFolder.Path, "db.sqlite");
|
||||
try
|
||||
{
|
||||
_conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), _path);
|
||||
_conn.CreateTable<UserIdentity>();
|
||||
_conn.CreateTable<TimeLog>();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine(ex.Message);
|
||||
}
|
||||
|
||||
await httpServer.StartServerAsync();
|
||||
|
||||
// Dont release deferral, otherwise app will stop
|
||||
}
|
||||
}
|
||||
}
|
||||
23
DataCenter/DataCenterService/project.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"Microsoft.ApplicationInsights": "1.0.0",
|
||||
"Microsoft.ApplicationInsights.PersistenceChannel": "1.0.0",
|
||||
"Microsoft.ApplicationInsights.WindowsApps": "1.0.0",
|
||||
"Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0",
|
||||
"Newtonsoft.Json": "8.0.3",
|
||||
"Restup": "1.0.0-beta4",
|
||||
"SQLite.Net-pcl": "3.1.1",
|
||||
"Unity": "4.0.1"
|
||||
},
|
||||
"frameworks": {
|
||||
"uap10.0": {}
|
||||
},
|
||||
"runtimes": {
|
||||
"win10-arm": {},
|
||||
"win10-arm-aot": {},
|
||||
"win10-x86": {},
|
||||
"win10-x86-aot": {},
|
||||
"win10-x64": {},
|
||||
"win10-x64-aot": {}
|
||||
}
|
||||
}
|
||||