aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2020-11-16 14:35:19 +0200
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2020-11-16 14:35:19 +0200
commit0ee81ef847af3702b3b37f94cc62e835f9294e55 (patch)
treee3cc6daea355c8cc7a5dbf48f5e0c594230d90fb
parent76b22e4d05cbd8d771f678e4b5adc2dc5159afa8 (diff)
downloadTango-0ee81ef847af3702b3b37f94cc62e835f9294e55.tar.gz
Tango-0ee81ef847af3702b3b37f94cc62e835f9294e55.zip
Working on DataStore WebAPI & CLI.
-rw-r--r--Software/Visual_Studio/DataStore/Tango.DataStore.CLI/App.config28
-rw-r--r--Software/Visual_Studio/DataStore/Tango.DataStore.CLI/Options.cs51
-rw-r--r--Software/Visual_Studio/DataStore/Tango.DataStore.CLI/Program.cs49
-rw-r--r--Software/Visual_Studio/DataStore/Tango.DataStore.CLI/Properties/AssemblyInfo.cs36
-rw-r--r--Software/Visual_Studio/DataStore/Tango.DataStore.CLI/Tango.DataStore.CLI.csproj86
-rw-r--r--Software/Visual_Studio/DataStore/Tango.DataStore.CLI/packages.config5
-rw-r--r--Software/Visual_Studio/DataStore/Tango.DataStore.EF/EFDataStoreCollection.cs15
-rw-r--r--Software/Visual_Studio/DataStore/Tango.DataStore/DataStoreProtoObject.cs2
-rw-r--r--Software/Visual_Studio/Tango.sln35
-rw-r--r--Software/Visual_Studio/Web/Tango.MachineService/Controllers/DataStoreController.cs150
-rw-r--r--Software/Visual_Studio/Web/Tango.MachineService/DataStore/DataStoreWebItem.cs26
-rw-r--r--Software/Visual_Studio/Web/Tango.MachineService/DataStore/DataStoreWebItemType.cs14
-rw-r--r--Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj13
13 files changed, 500 insertions, 10 deletions
diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore.CLI/App.config b/Software/Visual_Studio/DataStore/Tango.DataStore.CLI/App.config
new file mode 100644
index 000000000..a46da65da
--- /dev/null
+++ b/Software/Visual_Studio/DataStore/Tango.DataStore.CLI/App.config
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+ <configSections>
+ <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
+ <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
+ </configSections>
+ <startup>
+ <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
+ </startup>
+ <entityFramework>
+ <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
+ <providers>
+ <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
+ </providers>
+ </entityFramework>
+ <runtime>
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <dependentAssembly>
+ <assemblyIdentity name="Microsoft.IdentityModel.Clients.ActiveDirectory" publicKeyToken="31bf3856ad364e35" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-5.0.5.0" newVersion="5.0.5.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="Z.EntityFramework.Extensions" publicKeyToken="59b66d028979105b" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.50.0" newVersion="4.0.50.0" />
+ </dependentAssembly>
+ </assemblyBinding>
+ </runtime>
+</configuration> \ No newline at end of file
diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore.CLI/Options.cs b/Software/Visual_Studio/DataStore/Tango.DataStore.CLI/Options.cs
new file mode 100644
index 000000000..80b3caf7e
--- /dev/null
+++ b/Software/Visual_Studio/DataStore/Tango.DataStore.CLI/Options.cs
@@ -0,0 +1,51 @@
+using CommandLine;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.Web;
+
+namespace Tango.DataStore.CLI
+{
+ public class OptionsBase
+ {
+ [Option(longName: "email", HelpText = "Email address", Required = true)]
+ public String Email { get; set; }
+
+ [Option(longName: "password", HelpText = "Password")]
+ public String Password { get; set; }
+
+ [Option(longName: "env", HelpText = "Environment")]
+ public DeploymentSlot Environment { get; set; }
+ }
+
+ [Verb("get", HelpText = "Get a data store item.")]
+ public class GetOptions : OptionsBase
+ {
+ [Option(longName: "sn", HelpText = "Machine serial number")]
+ public String MachineSerialNumber { get; set; }
+
+ [Option(longName: "collection", HelpText = "Collection name")]
+ public String Collection { get; set; }
+
+ [Option(longName: "key", HelpText = "Item key")]
+ public String Key { get; set; }
+ }
+
+ [Verb("put", HelpText = "Get a data store item.")]
+ public class PutOptions : OptionsBase
+ {
+ [Option(longName: "sn", HelpText = "Machine serial number")]
+ public String MachineSerialNumber { get; set; }
+
+ [Option(longName: "collection", HelpText = "Collection name")]
+ public String Collection { get; set; }
+
+ [Option(longName: "key", HelpText = "Item key")]
+ public String Key { get; set; }
+
+ [Option(longName: "value", HelpText = "Item value")]
+ public String Value { get; set; }
+ }
+}
diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore.CLI/Program.cs b/Software/Visual_Studio/DataStore/Tango.DataStore.CLI/Program.cs
new file mode 100644
index 000000000..e27f76c79
--- /dev/null
+++ b/Software/Visual_Studio/DataStore/Tango.DataStore.CLI/Program.cs
@@ -0,0 +1,49 @@
+using CommandLine;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.BL;
+
+namespace Tango.DataStore.CLI
+{
+ class Program
+ {
+ static void Main(string[] args)
+ {
+ var result = Parser.Default.ParseArguments<GetOptions, PutOptions>(args)
+ .WithParsed<GetOptions>((options) =>
+ {
+ Console.WriteLine($"{options.Email}, {options.Password}");
+ })
+ .WithParsed<PutOptions>((options) =>
+ {
+ Console.WriteLine($"{options.Email}, {options.Password}");
+ })
+ .WithNotParsed((errors) =>
+ {
+
+ });
+
+ Console.ReadLine();
+ }
+
+ private static int DisplayHelp<T>(ParserResult<T> result, IEnumerable<Error> errs)
+ {
+ var helpText = CommandLine.Text.HelpText.AutoBuild(result, h =>
+ {
+ h.AdditionalNewLineAfterOption = false;
+ h.AddNewLineBetweenHelpSections = true;
+ h.AddEnumValuesToHelpText = true;
+ h.AutoVersion = false;
+ h.Heading = CommandLine.Text.HeadingInfo.Empty;
+ h.MaximumDisplayWidth = 110;
+ // h.AddVerbs(typeof(SyncOptions), typeof(QueryOptions), typeof(TokenOptions));
+ return h; // only h
+ });
+ Console.WriteLine(helpText);
+ return 1;
+ }
+ }
+}
diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore.CLI/Properties/AssemblyInfo.cs b/Software/Visual_Studio/DataStore/Tango.DataStore.CLI/Properties/AssemblyInfo.cs
new file mode 100644
index 000000000..366b8e28e
--- /dev/null
+++ b/Software/Visual_Studio/DataStore/Tango.DataStore.CLI/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+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("Tango.DataStore.CLI")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Tango.DataStore.CLI")]
+[assembly: AssemblyCopyright("Copyright © 2020")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("6189b8c3-7af9-43dd-8a61-a8a05f526f62")]
+
+// 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")]
diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore.CLI/Tango.DataStore.CLI.csproj b/Software/Visual_Studio/DataStore/Tango.DataStore.CLI/Tango.DataStore.CLI.csproj
new file mode 100644
index 000000000..05e4022c4
--- /dev/null
+++ b/Software/Visual_Studio/DataStore/Tango.DataStore.CLI/Tango.DataStore.CLI.csproj
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" 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)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{6189B8C3-7AF9-43DD-8A61-A8A05F526F62}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <RootNamespace>Tango.DataStore.CLI</RootNamespace>
+ <AssemblyName>Tango.DataStore.CLI</AssemblyName>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
+ <Deterministic>true</Deterministic>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="CommandLine, Version=2.8.0.0, Culture=neutral, PublicKeyToken=5a870481e358d379, processorArchitecture=MSIL">
+ <HintPath>..\..\packages\CommandLineParser.2.8.0\lib\net461\CommandLine.dll</HintPath>
+ </Reference>
+ <Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
+ <HintPath>..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll</HintPath>
+ </Reference>
+ <Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
+ <HintPath>..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.ComponentModel.DataAnnotations" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Net.Http" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Options.cs" />
+ <Compile Include="Program.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="App.config" />
+ <None Include="packages.config" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\Tango.BL\Tango.BL.csproj">
+ <Project>{F441FEEE-322A-4943-B566-110E12FD3B72}</Project>
+ <Name>Tango.BL</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\..\Tango.Web\Tango.Web.csproj">
+ <Project>{5001990f-977b-48ff-b217-0236a5022ad8}</Project>
+ <Name>Tango.Web</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\Tango.DataStore.EF\Tango.DataStore.EF.csproj">
+ <Project>{88d9906b-8fc4-4fe0-b7eb-127a0a8fcee4}</Project>
+ <Name>Tango.DataStore.EF</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\Tango.DataStore\Tango.DataStore.csproj">
+ <Project>{e0364dfa-0721-4637-9d32-9d22aac109d6}</Project>
+ <Name>Tango.DataStore</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <ItemGroup>
+ <Folder Include="Options\" />
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+</Project> \ No newline at end of file
diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore.CLI/packages.config b/Software/Visual_Studio/DataStore/Tango.DataStore.CLI/packages.config
new file mode 100644
index 000000000..71553e4ac
--- /dev/null
+++ b/Software/Visual_Studio/DataStore/Tango.DataStore.CLI/packages.config
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="CommandLineParser" version="2.8.0" targetFramework="net461" />
+ <package id="EntityFramework" version="6.2.0" targetFramework="net461" />
+</packages> \ No newline at end of file
diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore.EF/EFDataStoreCollection.cs b/Software/Visual_Studio/DataStore/Tango.DataStore.EF/EFDataStoreCollection.cs
index 0baf5bb19..c42935368 100644
--- a/Software/Visual_Studio/DataStore/Tango.DataStore.EF/EFDataStoreCollection.cs
+++ b/Software/Visual_Studio/DataStore/Tango.DataStore.EF/EFDataStoreCollection.cs
@@ -113,11 +113,20 @@ namespace Tango.DataStore.EF
{
using (var db = ObservablesContext.CreateDefault())
{
- var items = db.DataStoreItems.Where(x => x.CollectionName == Name).ToList().Select(x => x.ToDataStoreItem()).ToList();
- var globalItems = db.GlobalDataStoreItems.Where(x => x.CollectionName == Name).ToList().Select(x => x.ToDataStoreItem()).ToList();
+ var localItems = db.DataStoreItems.Where(x => x.CollectionName == Name).ToList();
+ var globalItems = db.GlobalDataStoreItems.Where(x => x.CollectionName == Name).ToList();
+ foreach (var globalItem in globalItems.ToList())
+ {
+ var localItem = localItems.FirstOrDefault(x => x.CollectionName == globalItem.CollectionName && x.Key == globalItem.Key);
+
+ if (localItem != null)
+ {
+ globalItems.Remove(globalItem);
+ }
+ }
- return globalItems.Concat(items).ToList();
+ return localItems.Select(x => x.ToDataStoreItem()).Concat(localItems.Select(x => x.ToDataStoreItem())).ToList();
}
}
diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore/DataStoreProtoObject.cs b/Software/Visual_Studio/DataStore/Tango.DataStore/DataStoreProtoObject.cs
index 5aa7c5342..1a9dd324d 100644
--- a/Software/Visual_Studio/DataStore/Tango.DataStore/DataStoreProtoObject.cs
+++ b/Software/Visual_Studio/DataStore/Tango.DataStore/DataStoreProtoObject.cs
@@ -1,5 +1,6 @@
using Google.Protobuf;
using Newtonsoft.Json;
+using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
@@ -17,6 +18,7 @@ namespace Tango.DataStore
{
public class DataStoreProtoObject
{
+ [JsonConverter(typeof(StringEnumConverter))]
public MessageType MessageType { get; set; }
public Type Type { get; set; }
public byte[] Data { get; set; }
diff --git a/Software/Visual_Studio/Tango.sln b/Software/Visual_Studio/Tango.sln
index 3fe0dea56..9d2bb28c7 100644
--- a/Software/Visual_Studio/Tango.sln
+++ b/Software/Visual_Studio/Tango.sln
@@ -433,6 +433,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.DataStore.Remote", "D
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.DataStore.Editing", "DataStore\Tango.DataStore.Editing\Tango.DataStore.Editing.csproj", "{EE088FF7-04D1-41FB-9D6A-CEDEEE7A7B9C}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.DataStore.CLI", "DataStore\Tango.DataStore.CLI\Tango.DataStore.CLI.csproj", "{6189B8C3-7AF9-43DD-8A61-A8A05F526F62}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -4080,6 +4082,26 @@ Global
{EE088FF7-04D1-41FB-9D6A-CEDEEE7A7B9C}.Release|x64.Build.0 = Release|Any CPU
{EE088FF7-04D1-41FB-9D6A-CEDEEE7A7B9C}.Release|x86.ActiveCfg = Release|Any CPU
{EE088FF7-04D1-41FB-9D6A-CEDEEE7A7B9C}.Release|x86.Build.0 = Release|Any CPU
+ {6189B8C3-7AF9-43DD-8A61-A8A05F526F62}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {6189B8C3-7AF9-43DD-8A61-A8A05F526F62}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {6189B8C3-7AF9-43DD-8A61-A8A05F526F62}.Debug|ARM.ActiveCfg = Debug|Any CPU
+ {6189B8C3-7AF9-43DD-8A61-A8A05F526F62}.Debug|ARM.Build.0 = Debug|Any CPU
+ {6189B8C3-7AF9-43DD-8A61-A8A05F526F62}.Debug|ARM64.ActiveCfg = Debug|Any CPU
+ {6189B8C3-7AF9-43DD-8A61-A8A05F526F62}.Debug|ARM64.Build.0 = Debug|Any CPU
+ {6189B8C3-7AF9-43DD-8A61-A8A05F526F62}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {6189B8C3-7AF9-43DD-8A61-A8A05F526F62}.Debug|x64.Build.0 = Debug|Any CPU
+ {6189B8C3-7AF9-43DD-8A61-A8A05F526F62}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {6189B8C3-7AF9-43DD-8A61-A8A05F526F62}.Debug|x86.Build.0 = Debug|Any CPU
+ {6189B8C3-7AF9-43DD-8A61-A8A05F526F62}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {6189B8C3-7AF9-43DD-8A61-A8A05F526F62}.Release|Any CPU.Build.0 = Release|Any CPU
+ {6189B8C3-7AF9-43DD-8A61-A8A05F526F62}.Release|ARM.ActiveCfg = Release|Any CPU
+ {6189B8C3-7AF9-43DD-8A61-A8A05F526F62}.Release|ARM.Build.0 = Release|Any CPU
+ {6189B8C3-7AF9-43DD-8A61-A8A05F526F62}.Release|ARM64.ActiveCfg = Release|Any CPU
+ {6189B8C3-7AF9-43DD-8A61-A8A05F526F62}.Release|ARM64.Build.0 = Release|Any CPU
+ {6189B8C3-7AF9-43DD-8A61-A8A05F526F62}.Release|x64.ActiveCfg = Release|Any CPU
+ {6189B8C3-7AF9-43DD-8A61-A8A05F526F62}.Release|x64.Build.0 = Release|Any CPU
+ {6189B8C3-7AF9-43DD-8A61-A8A05F526F62}.Release|x86.ActiveCfg = Release|Any CPU
+ {6189B8C3-7AF9-43DD-8A61-A8A05F526F62}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -4229,14 +4251,15 @@ Global
{88D9906B-8FC4-4FE0-B7EB-127A0A8FCEE4} = {3F723D53-3539-42D1-8570-395BF660928D}
{29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA} = {3F723D53-3539-42D1-8570-395BF660928D}
{EE088FF7-04D1-41FB-9D6A-CEDEEE7A7B9C} = {3F723D53-3539-42D1-8570-395BF660928D}
+ {6189B8C3-7AF9-43DD-8A61-A8A05F526F62} = {3F723D53-3539-42D1-8570-395BF660928D}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
- BuildVersion_UseGlobalSettings = False
- BuildVersion_AssemblyInfoFilename = Properties\AssemblyInfo.cs
- BuildVersion_StartDate = 2000/1/1
- BuildVersion_UpdateFileVersion = False
- BuildVersion_UpdateAssemblyVersion = True
- BuildVersion_BuildVersioningStyle = None.None.Increment.DeltaBaseYearDayOfYear
SolutionGuid = {7986F7F4-A86A-4994-B1B6-0988D7F057B6}
+ BuildVersion_BuildVersioningStyle = None.None.Increment.DeltaBaseYearDayOfYear
+ BuildVersion_UpdateAssemblyVersion = True
+ BuildVersion_UpdateFileVersion = False
+ BuildVersion_StartDate = 2000/1/1
+ BuildVersion_AssemblyInfoFilename = Properties\AssemblyInfo.cs
+ BuildVersion_UseGlobalSettings = False
EndGlobalSection
EndGlobal
diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/DataStoreController.cs b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/DataStoreController.cs
new file mode 100644
index 000000000..3deab9205
--- /dev/null
+++ b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/DataStoreController.cs
@@ -0,0 +1,150 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Net.Http;
+using System.Web.Http;
+using Tango.BL.Entities;
+using Tango.DataStore;
+using Tango.DataStore.EF;
+using Tango.MachineService.DataStore;
+using Tango.Web.Helpers;
+
+namespace Tango.MachineService.Controllers
+{
+ public class DataStoreController : ApiController
+ {
+ private IDataStoreManager _manager;
+
+ public DataStoreController()
+ {
+ _manager = new EFDataStoreManager();
+ }
+
+ public List<DataStoreWebItem> Get(String sn = null, String collection = null, String key = null)
+ {
+ try
+ {
+ using (var db = ObservablesContextHelper.CreateContext())
+ {
+ if (sn != null)
+ {
+ var machineGuid = db.Machines.Where(x => x.SerialNumber == sn).Select(x => x.Guid).FirstOrDefault();
+
+ if (machineGuid == null)
+ {
+ return ThrowException<List<DataStoreWebItem>>(new KeyNotFoundException(), HttpStatusCode.NotFound, "The specified machine serial number could not be found.");
+ }
+
+ var localItems = db.DataStoreItems.Where(x => x.MachineGuid == machineGuid && (collection == null || x.CollectionName == collection) && (key == null || x.Key == key)).ToList();
+ var globalItems = db.GlobalDataStoreItems.Where(x => (collection == null || x.CollectionName == collection) && (key == null || x.Key == key)).ToList();
+
+ List<DataStoreWebItem> finalList = new List<DataStoreWebItem>();
+
+ foreach (var localItem in localItems)
+ {
+ var globalItem = globalItems.FirstOrDefault(x => x.CollectionName == localItem.CollectionName && x.Key == localItem.Key);
+ finalList.Add(localItem.ToWebItem(globalItem));
+ globalItems.Remove(globalItem);
+ }
+
+ finalList.AddRange(globalItems.Select(x => x.ToWebItem()));
+
+ return finalList;
+ }
+ else
+ {
+ var globalItems = db.GlobalDataStoreItems.Where(x => (collection == null || x.CollectionName == collection) && (key == null || x.Key == key)).ToList();
+
+ var finalList = globalItems.Select(x => x.ToWebItem()).ToList();
+
+ return finalList;
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ return ThrowException<List<DataStoreWebItem>>(ex, HttpStatusCode.InternalServerError, ex.FlattenMessage());
+ }
+ }
+
+ public void Post([FromBody]string value)
+ {
+
+ }
+
+ public void Put(int id, [FromBody]string value)
+ {
+
+ }
+
+ private T ThrowException<T>(Exception ex, HttpStatusCode code, String message = null)
+ {
+ throw new HttpResponseException(new HttpResponseMessage(code)
+ {
+ Content = new StringContent(message != null ? message : ex.Message),
+ ReasonPhrase = ex.FlattenMessage()
+ });
+ }
+ }
+
+ #region Extension Methods
+
+ public static class IDataStoreExtensions
+ {
+ public static DataStoreWebItem ToWebItem(this DataStoreItem item, GlobalDataStoreItem globalItem = null)
+ {
+ IDataStoreItem dsItem = item.ToDataStoreItem();
+ DataStoreWebItem webItem = new DataStoreWebItem();
+ webItem.Collection = item.CollectionName;
+ webItem.Type = globalItem != null ? DataStoreWebItemType.Overrides : DataStoreWebItemType.Local;
+ webItem.DataType = dsItem.Type;
+ webItem.Date = dsItem.Date;
+ webItem.Key = dsItem.Key;
+ webItem.LocalValue = dsItem.Value;
+
+ if (webItem.LocalValue is DataStoreProtoObject protoObject)
+ {
+ webItem.LocalValue = protoObject.Message;
+ webItem.ProtoMessageType = protoObject.MessageType;
+ }
+
+ if (globalItem != null)
+ {
+ var dsGlobalItem = globalItem.ToDataStoreItem();
+
+ webItem.GlobalValue = dsGlobalItem.Value;
+
+ if (webItem.GlobalValue is DataStoreProtoObject protoObjectGlobal)
+ {
+ webItem.GlobalValue = protoObjectGlobal.Message;
+ webItem.ProtoMessageType = protoObjectGlobal.MessageType;
+ }
+ }
+
+ return webItem;
+ }
+
+ public static DataStoreWebItem ToWebItem(this GlobalDataStoreItem item)
+ {
+ IDataStoreItem dsItem = item.ToDataStoreItem();
+ DataStoreWebItem webItem = new DataStoreWebItem();
+ webItem.Collection = item.CollectionName;
+ webItem.Type = DataStoreWebItemType.Global;
+ webItem.DataType = dsItem.Type;
+ webItem.Date = dsItem.Date;
+ webItem.Key = dsItem.Key;
+ webItem.GlobalValue = dsItem.Value;
+
+ if (webItem.GlobalValue is DataStoreProtoObject protoObject)
+ {
+ webItem.GlobalValue = protoObject.Message;
+ webItem.ProtoMessageType = protoObject.MessageType;
+ }
+
+ return webItem;
+ }
+ }
+
+ #endregion
+}
diff --git a/Software/Visual_Studio/Web/Tango.MachineService/DataStore/DataStoreWebItem.cs b/Software/Visual_Studio/Web/Tango.MachineService/DataStore/DataStoreWebItem.cs
new file mode 100644
index 000000000..ed8a8a385
--- /dev/null
+++ b/Software/Visual_Studio/Web/Tango.MachineService/DataStore/DataStoreWebItem.cs
@@ -0,0 +1,26 @@
+using Newtonsoft.Json;
+using Newtonsoft.Json.Converters;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+using Tango.DataStore;
+using Tango.PMR.Common;
+
+namespace Tango.MachineService.DataStore
+{
+ public class DataStoreWebItem
+ {
+ public String Collection { get; set; }
+ [JsonConverter(typeof(StringEnumConverter))]
+ public DataStoreWebItemType Type { get; set; }
+ public DateTime Date { get; set; }
+ public String Key { get; set; }
+ [JsonConverter(typeof(StringEnumConverter))]
+ public DataType DataType { get; set; }
+ [JsonConverter(typeof(StringEnumConverter))]
+ public MessageType ProtoMessageType { get; set; }
+ public Object LocalValue { get; set; }
+ public Object GlobalValue { get; set; }
+ }
+} \ No newline at end of file
diff --git a/Software/Visual_Studio/Web/Tango.MachineService/DataStore/DataStoreWebItemType.cs b/Software/Visual_Studio/Web/Tango.MachineService/DataStore/DataStoreWebItemType.cs
new file mode 100644
index 000000000..0ba8e1a5e
--- /dev/null
+++ b/Software/Visual_Studio/Web/Tango.MachineService/DataStore/DataStoreWebItemType.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace Tango.MachineService.DataStore
+{
+ public enum DataStoreWebItemType
+ {
+ Local,
+ Global,
+ Overrides
+ }
+} \ No newline at end of file
diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj b/Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj
index c662b1e87..bc60327ba 100644
--- a/Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj
+++ b/Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj
@@ -316,11 +316,14 @@
</Compile>
<Compile Include="App_Start\BundleConfig.cs" />
<Compile Include="App_Start\FilterConfig.cs" />
+ <Compile Include="Controllers\DataStoreController.cs" />
<Compile Include="Controllers\FSEAccountController.cs" />
<Compile Include="Controllers\FSEDownloadsController.cs" />
<Compile Include="Controllers\DownloadsController.cs" />
<Compile Include="Controllers\AccountController.cs" />
<Compile Include="Controllers\FSEController.cs" />
+ <Compile Include="DataStore\DataStoreWebItem.cs" />
+ <Compile Include="DataStore\DataStoreWebItemType.cs" />
<Compile Include="Filters\JwtTokenFilter.cs" />
<Compile Include="Hubs\ExternalBridgeHub.cs" />
<Compile Include="MachineServiceConfig.cs" />
@@ -402,6 +405,14 @@
</Content>
</ItemGroup>
<ItemGroup>
+ <ProjectReference Include="..\..\DataStore\Tango.DataStore.EF\Tango.DataStore.EF.csproj">
+ <Project>{88d9906b-8fc4-4fe0-b7eb-127a0a8fcee4}</Project>
+ <Name>Tango.DataStore.EF</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\..\DataStore\Tango.DataStore\Tango.DataStore.csproj">
+ <Project>{e0364dfa-0721-4637-9d32-9d22aac109d6}</Project>
+ <Name>Tango.DataStore</Name>
+ </ProjectReference>
<ProjectReference Include="..\..\FSE\Tango.FSE.Web\Tango.FSE.Web.csproj">
<Project>{d6f7d31d-7f8c-45e2-ae0a-fbbd1f5f9d5f}</Project>
<Name>Tango.FSE.Web</Name>
@@ -490,7 +501,7 @@
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
</WebProjectProperties>
</FlavorProperties>
- <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" />
+ <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" />
</VisualStudio>
</ProjectExtensions>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">