From 024eb7867d2b400212ce4ce0e4845d99bf532568 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Wed, 4 Nov 2020 13:01:49 +0200 Subject: First steps on FSE configuration module. --- .../Tango.FSE.MachineConfiguration/App.xaml | 16 ++ .../ConfigurationModule.cs | 26 +++ .../ConfigurationViewModel.cs | 14 ++ .../Images/configuration.png | Bin 0 -> 2668 bytes .../Messages/MachineLoadedMessage.cs | 14 ++ .../Navigation/ConfigurationNavigationManager.cs | 18 ++ .../Navigation/ConfigurationView.cs | 14 ++ .../Properties/AssemblyInfo.cs | 55 ++++++ .../Properties/Resources.Designer.cs | 71 +++++++ .../Properties/Resources.resx | 117 +++++++++++ .../Properties/Settings.Designer.cs | 30 +++ .../Properties/Settings.settings | 7 + .../Tango.FSE.MachineConfiguration.csproj | 216 +++++++++++++++++++++ .../ViewModelLocator.cs | 65 +++++++ .../ViewModels/ConfigurationViewVM.cs | 44 +++++ .../ViewModels/DataStoreViewVM.cs | 13 ++ .../ViewModels/MachineViewVM.cs | 60 ++++++ .../ViewModels/MainViewVM.cs | 60 ++++++ .../ViewModels/SelectionViewVM.cs | 48 +++++ .../Views/ConfigurationView.xaml | 115 +++++++++++ .../Views/ConfigurationView.xaml.cs | 28 +++ .../Views/DataStoreView.xaml | 16 ++ .../Views/DataStoreView.xaml.cs | 28 +++ .../Views/MachineView.xaml | 49 +++++ .../Views/MachineView.xaml.cs | 28 +++ .../Views/MainView.xaml | 18 ++ .../Views/MainView.xaml.cs | 31 +++ .../Views/SelectionView.xaml | 61 ++++++ .../Views/SelectionView.xaml.cs | 28 +++ .../Tango.FSE.MachineConfiguration/app.config | 85 ++++++++ .../Tango.FSE.MachineConfiguration/packages.config | 10 + .../ViewModels/OrganizationSelectionViewVM.cs | 2 +- .../FSE/Tango.FSE.Common/Resources/Styles.xaml | 80 ++++++++ .../FSE/Tango.FSE.UI/Tango.FSE.UI.csproj | 4 + .../Tango.BL/Entities/Organization.cs | 5 + Software/Visual_Studio/Tango.sln | 35 +++- 36 files changed, 1504 insertions(+), 7 deletions(-) create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/App.xaml create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ConfigurationModule.cs create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ConfigurationViewModel.cs create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Images/configuration.png create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Messages/MachineLoadedMessage.cs create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Navigation/ConfigurationNavigationManager.cs create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Navigation/ConfigurationView.cs create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Properties/AssemblyInfo.cs create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Properties/Resources.Designer.cs create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Properties/Resources.resx create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Properties/Settings.Designer.cs create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Properties/Settings.settings create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Tango.FSE.MachineConfiguration.csproj create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModelLocator.cs create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/ConfigurationViewVM.cs create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/DataStoreViewVM.cs create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/MachineViewVM.cs create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/MainViewVM.cs create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/SelectionViewVM.cs create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/ConfigurationView.xaml create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/ConfigurationView.xaml.cs create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/DataStoreView.xaml create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/DataStoreView.xaml.cs create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/MachineView.xaml create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/MachineView.xaml.cs create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/MainView.xaml create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/MainView.xaml.cs create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/SelectionView.xaml create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/SelectionView.xaml.cs create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/app.config create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/packages.config (limited to 'Software/Visual_Studio') diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/App.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/App.xaml new file mode 100644 index 000000000..28a976e78 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/App.xaml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ConfigurationModule.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ConfigurationModule.cs new file mode 100644 index 000000000..2f2c0dbb1 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ConfigurationModule.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Media.Imaging; +using Tango.BL.Enumerations; +using Tango.FSE.Common; +using Tango.FSE.MachineConfiguration.Views; + +namespace Tango.FSE.MachineConfiguration +{ + [FSEModule(index: 7)] + public class ConfigurationModule : FSEModuleBase + { + public override string Name { get; } = "Configuration"; + public override string Description { get; } = "Configuration Module"; + public override Type MainViewType { get; } = typeof(MainView); + public override Permissions Permission { get; } = Permissions.FSE_RunFSE; + + public override void Dispose() + { + + } + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ConfigurationViewModel.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ConfigurationViewModel.cs new file mode 100644 index 000000000..bfcc60bcf --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ConfigurationViewModel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.FSE.Common.Navigation; +using Tango.FSE.MachineConfiguration.Navigation; + +namespace Tango.FSE.MachineConfiguration +{ + public class ConfigurationViewModel : ModularNavigationFSEViewModel + { + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Images/configuration.png b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Images/configuration.png new file mode 100644 index 000000000..f46a49d23 Binary files /dev/null and b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Images/configuration.png differ diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Messages/MachineLoadedMessage.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Messages/MachineLoadedMessage.cs new file mode 100644 index 000000000..4a703b2a9 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Messages/MachineLoadedMessage.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; + +namespace Tango.FSE.MachineConfiguration.Messages +{ + public class MachineLoadedMessage + { + public Machine Machine { get; set; } + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Navigation/ConfigurationNavigationManager.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Navigation/ConfigurationNavigationManager.cs new file mode 100644 index 000000000..c1dfdfda7 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Navigation/ConfigurationNavigationManager.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using Tango.FSE.Common.Navigation; +using Tango.SharedUI.Controls; + +namespace Tango.FSE.MachineConfiguration.Navigation +{ + public class ConfigurationNavigationManager : ModularNavigationManager + { + public ConfigurationNavigationManager(FrameworkElement navigationControlParent) : base(navigationControlParent) + { + } + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Navigation/ConfigurationView.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Navigation/ConfigurationView.cs new file mode 100644 index 000000000..187e44ac9 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Navigation/ConfigurationView.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.FSE.MachineConfiguration.Navigation +{ + public enum ConfigurationView + { + SelectionView, + MachineView, + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Properties/AssemblyInfo.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..027dd9516 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Properties/AssemblyInfo.cs @@ -0,0 +1,55 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +// 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.FSE.MachineConfiguration")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Tango.FSE.MachineConfiguration")] +[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)] + +//In order to begin building localizable applications, set +//CultureYouAreCodingWith in your .csproj file +//inside a . For example, if you are using US english +//in your source files, set the to en-US. Then uncomment +//the NeutralResourceLanguage attribute below. Update the "en-US" in +//the line below to match the UICulture setting in the project file. + +//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] + + +// 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/FSE/Modules/Tango.FSE.MachineConfiguration/Properties/Resources.Designer.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Properties/Resources.Designer.cs new file mode 100644 index 000000000..830d15d6a --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Tango.FSE.MachineConfiguration.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Tango.FSE.MachineConfiguration.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Properties/Resources.resx b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Properties/Resources.resx new file mode 100644 index 000000000..af7dbebba --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Properties/Settings.Designer.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Properties/Settings.Designer.cs new file mode 100644 index 000000000..e41736026 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Tango.FSE.MachineConfiguration.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Properties/Settings.settings b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Properties/Settings.settings new file mode 100644 index 000000000..033d7a5e9 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Tango.FSE.MachineConfiguration.csproj b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Tango.FSE.MachineConfiguration.csproj new file mode 100644 index 000000000..e7adc1d3f --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Tango.FSE.MachineConfiguration.csproj @@ -0,0 +1,216 @@ + + + + + Debug + AnyCPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC} + library + Tango.FSE.MachineConfiguration + Tango.FSE.MachineConfiguration + v4.6.1 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + true + + + + + true + full + false + ..\..\..\Build\FSE\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + ..\..\..\Build\FSE\Release\ + TRACE + prompt + 4 + + + + ..\..\..\packages\ControlzEx.3.0.2.4\lib\net45\ControlzEx.dll + + + ..\..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll + + + ..\..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll + + + ..\..\..\packages\Google.Protobuf.3.4.1\lib\net45\Google.Protobuf.dll + + + ..\..\..\packages\MahApps.Metro.1.6.5\lib\net46\MahApps.Metro.dll + + + ..\..\..\packages\MaterialDesignColors.1.2.2\lib\net45\MaterialDesignColors.dll + + + ..\..\..\packages\MaterialDesignThemes.3.0.1\lib\net45\MaterialDesignThemes.Wpf.dll + + + ..\..\..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll + + + + + + ..\..\..\packages\ControlzEx.3.0.2.4\lib\net45\System.Windows.Interactivity.dll + + + + + + + + + 4.0 + + + + + + + + + + + + + + + + + + + ConfigurationView.xaml + + + DataStoreView.xaml + + + SelectionView.xaml + + + MachineView.xaml + + + MainView.xaml + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + {bb2abb74-ba58-4812-83aa-ec8171f42df4} + Tango.AutoComplete + + + {f441feee-322a-4943-b566-110e12fd3b72} + Tango.BL + + + {a34ee0f0-649d-41c8-8489-b6f1cc6924ee} + Tango.Core + + + {4206ac58-3b57-4699-8835-90bf6db01a61} + Tango.Integration + + + {bc932dbd-7cdb-488c-99e4-f02cf441f55e} + Tango.Logging + + + {e4927038-348d-4295-aaf4-861c58cb3943} + Tango.PMR + + + {d8f1ad85-526a-4f50-b6dc-d437af63d8d8} + Tango.Settings + + + {8491d07b-c1f6-4b62-a412-41b9fd2d6538} + Tango.SharedUI + + + {74e700b0-1156-4126-be40-ee450d3c3026} + Tango.Transport + + + {834c81c3-09b5-45d7-be12-e7d1e6655a7c} + Tango.FSE.BL + + + {bc37cccb-7392-4f78-8d1c-e9629e6e046e} + Tango.FSE.Common + + + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModelLocator.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModelLocator.cs new file mode 100644 index 000000000..187565ca4 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModelLocator.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.DI; +using Tango.FSE.MachineConfiguration.Navigation; +using Tango.FSE.MachineConfiguration.ViewModels; +using Tango.FSE.MachineConfiguration.Views; + +namespace Tango.FSE.MachineConfiguration +{ + public static class ViewModelLocator + { + static ViewModelLocator() + { + TangoIOC.Default.Register(new ConfigurationNavigationManager(MainView.Instance)); + TangoIOC.Default.Register(); + TangoIOC.Default.Register(); + TangoIOC.Default.Register(); + TangoIOC.Default.Register(); + TangoIOC.Default.Register(); + } + + public static MainViewVM MainViewVM + { + get + { + return TangoIOC.Default.GetInstance(); + } + } + + public static SelectionViewVM SelectionViewVM + { + get + { + return TangoIOC.Default.GetInstance(); + } + } + + public static MachineViewVM MachineViewVM + { + get + { + return TangoIOC.Default.GetInstance(); + } + } + + public static ConfigurationViewVM ConfigurationViewVM + { + get + { + return TangoIOC.Default.GetInstance(); + } + } + + public static DataStoreViewVM DataStoreViewVM + { + get + { + return TangoIOC.Default.GetInstance(); + } + } + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/ConfigurationViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/ConfigurationViewVM.cs new file mode 100644 index 000000000..1540a4e67 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/ConfigurationViewVM.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; +using Tango.FSE.Common; +using Tango.FSE.Common.AutoComplete; +using Tango.FSE.MachineConfiguration.Messages; + +namespace Tango.FSE.MachineConfiguration.ViewModels +{ + public class ConfigurationViewVM : FSEViewModel + { + private Machine _machine; + public Machine Machine + { + get { return _machine; } + set { _machine = value; RaisePropertyChangedAuto(); } + } + + private List _organizations; + public List Organizations + { + get { return _organizations; } + set { _organizations = value; RaisePropertyChangedAuto(); } + } + + public ConfigurationViewVM() + { + RegisterForMessage(HandleMachineLoadedMessage); + } + + private async void HandleMachineLoadedMessage(MachineLoadedMessage msg) + { + using (NotificationProvider.PushTaskItem("Loading configuration options...")) + { + Machine = msg.Machine; + Organizations = await Services.OrganizationsService.GetCurrentUserOrganizations(); + Machine.Organization = Organizations.SingleOrDefault(x => x.Guid == Machine.OrganizationGuid); + } + } + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/DataStoreViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/DataStoreViewVM.cs new file mode 100644 index 000000000..f321cd061 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/DataStoreViewVM.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.FSE.Common; + +namespace Tango.FSE.MachineConfiguration.ViewModels +{ + public class DataStoreViewVM : FSEViewModel + { + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/MachineViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/MachineViewVM.cs new file mode 100644 index 000000000..cbd6c1cf1 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/MachineViewVM.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; +using Tango.FSE.Common; +using Tango.FSE.Common.Navigation; +using Tango.FSE.MachineConfiguration.Messages; +using static Tango.FSE.MachineConfiguration.ViewModels.MachineViewVM; + +namespace Tango.FSE.MachineConfiguration.ViewModels +{ + public class MachineViewVM : ConfigurationViewModel, INavigationObjectReceiver + { + public class NavigationObject + { + public String MachineSerialNumber { get; set; } + } + + public enum NavigationView + { + ConfigurationView, + DataStoreView, + } + + private NavigationView _selectedView; + public NavigationView SelectedView + { + get { return _selectedView; } + set + { + _selectedView = value; + RaisePropertyChangedAuto(); + } + } + + private Machine _machine; + public Machine Machine + { + get { return _machine; } + set { _machine = value; RaisePropertyChangedAuto(); } + } + + public void OnNavigatedToWithObject(NavigationObject obj) + { + SelectedView = NavigationView.ConfigurationView; + LoadMachine(obj.MachineSerialNumber); + } + + private async void LoadMachine(String serialNumber) + { + using (NotificationProvider.PushTaskItem("Loading machine configuration...")) + { + Machine = await Services.MachinesService.GetMachineFull(serialNumber); + RaiseMessage(new MachineLoadedMessage() { Machine = Machine }); + } + } + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/MainViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/MainViewVM.cs new file mode 100644 index 000000000..efb2fc3cc --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/MainViewVM.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.FSE.Common; +using Tango.FSE.Common.Navigation; +using Tango.FSE.MachineConfiguration.Navigation; +using Tango.SharedUI.Helpers; + +namespace Tango.FSE.MachineConfiguration.ViewModels +{ + [ModularNavigationContainer] + public class MainViewVM : ConfigurationViewModel + { + public override void OnApplicationStarted() + { + InvokeUI(() => + { + NavigationManager.MenuItems.Add(new NavigationMenuItem(() => + { + NavigationManager.NavigateTo(); + }) + { + Name = "Configuration", + Index = 8, + Description = "Access to the organization machines configuration and settings", + Image = ResourceHelper.GetImageFromResources("Images/configuration.png"), + }); + }); + } + + public async override Task OnApplicationLogout() + { + while (ModularNavigationManager.CurrentView != ConfigurationView.SelectionView) + { + if (!await ModularNavigationManager.NavigateBack()) + { + return false; + } + } + + return await base.OnApplicationLogout(); + } + + public async override Task OnNavigateBackRequest() + { + if (ModularNavigationManager.CurrentView == ConfigurationView.SelectionView) + { + return await base.OnNavigateBackRequest(); + } + else + { + await ModularNavigationManager.NavigateBack(); + return false; + } + } + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/SelectionViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/SelectionViewVM.cs new file mode 100644 index 000000000..c62ade6fb --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/SelectionViewVM.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; +using Tango.Core.Commands; +using Tango.FSE.Common; +using Tango.FSE.MachineConfiguration.Navigation; + +namespace Tango.FSE.MachineConfiguration.ViewModels +{ + public class SelectionViewVM : ConfigurationViewModel + { + private Machine _selectedMachine; + /// + /// Gets or sets the selected machine. + /// + public Machine SelectedMachine + { + get { return _selectedMachine; } + set { _selectedMachine = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } + } + + public RelayCommand ManageMachineCommand { get; set; } + + public SelectionViewVM() + { + ManageMachineCommand = new RelayCommand(ManageSelectedMachine, () => SelectedMachine != null); + } + + private void ManageSelectedMachine() + { + if (SelectedMachine == null) + { + NotificationProvider.ShowError("No machine selected."); + return; + } + + ModularNavigationManager.NavigateTo(ConfigurationView.MachineView, new MachineViewVM.NavigationObject() + { + MachineSerialNumber = SelectedMachine.SerialNumber + }); + } + } +} + + diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/ConfigurationView.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/ConfigurationView.xaml new file mode 100644 index 000000000..8d8aa7b0e --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/ConfigurationView.xaml @@ -0,0 +1,115 @@ + + + + + + + + + + + Activate Windows License + + + + License Key + + + + + + Setup Team Viewer + + + + + Activate Disk Protection + + + + + Use Firmware Emulator (Demo Machine) + + + Device Registration + + + + + + Registered: + + + + + Device ID: + + + + + Device Name: + + + + + + + + + + + + + + + Perform Firmware Upgrade + + + + + Force Version Update + + + + + Suspend Version Update + + + + + + + + + Serial Number + + + + + Name + + + + + Organization + + + + + + + + diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/ConfigurationView.xaml.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/ConfigurationView.xaml.cs new file mode 100644 index 000000000..d25948d2c --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/ConfigurationView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.FSE.MachineConfiguration.Views +{ + /// + /// Interaction logic for MachineDataStoreView.xaml + /// + public partial class ConfigurationView : UserControl + { + public ConfigurationView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/DataStoreView.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/DataStoreView.xaml new file mode 100644 index 000000000..ac26bf445 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/DataStoreView.xaml @@ -0,0 +1,16 @@ + + + + + diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/DataStoreView.xaml.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/DataStoreView.xaml.cs new file mode 100644 index 000000000..add553b35 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/DataStoreView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.FSE.MachineConfiguration.Views +{ + /// + /// Interaction logic for MachineDataStoreView.xaml + /// + public partial class DataStoreView : UserControl + { + public DataStoreView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/MachineView.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/MachineView.xaml new file mode 100644 index 000000000..ba9418d5d --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/MachineView.xaml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/MachineView.xaml.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/MachineView.xaml.cs new file mode 100644 index 000000000..5e4d5ed7d --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/MachineView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.FSE.MachineConfiguration.Views +{ + /// + /// Interaction logic for MachineView.xaml + /// + public partial class MachineView : UserControl + { + public MachineView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/MainView.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/MainView.xaml new file mode 100644 index 000000000..a321a1bb8 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/MainView.xaml @@ -0,0 +1,18 @@ + + + + + + + + diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/MainView.xaml.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/MainView.xaml.cs new file mode 100644 index 000000000..650c297a4 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/MainView.xaml.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.FSE.MachineConfiguration.Views +{ + /// + /// Interaction logic for MainView.xaml + /// + public partial class MainView : UserControl + { + public static MainView Instance { get; set; } + + public MainView() + { + Instance = this; + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/SelectionView.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/SelectionView.xaml new file mode 100644 index 000000000..69cebf324 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/SelectionView.xaml @@ -0,0 +1,61 @@ + + + + + Machine Configuration + + The machine configuration module allows you to manage the currently connected machine configuration and other machine settings. + + Given the proper permissions, you will also be able to manage other organization machines. + + + + + + Select Machine + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/SelectionView.xaml.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/SelectionView.xaml.cs new file mode 100644 index 000000000..618ae299a --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/SelectionView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.FSE.MachineConfiguration.Views +{ + /// + /// Interaction logic for MachineSelectionView.xaml + /// + public partial class SelectionView : UserControl + { + public SelectionView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/app.config b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/app.config new file mode 100644 index 000000000..36bc04f85 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/app.config @@ -0,0 +1,85 @@ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/packages.config b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/packages.config new file mode 100644 index 000000000..dd8c723e4 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/packages.config @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.UsersAndRoles/ViewModels/OrganizationSelectionViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.UsersAndRoles/ViewModels/OrganizationSelectionViewVM.cs index 9a84cca7d..0abc285a9 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.UsersAndRoles/ViewModels/OrganizationSelectionViewVM.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.UsersAndRoles/ViewModels/OrganizationSelectionViewVM.cs @@ -63,7 +63,7 @@ namespace Tango.FSE.UsersAndRoles.ViewModels try { - return Services.OrganizationsService.GetCurrentUserOrganizations().Result.Where(x => x.Name.ToLower().StartsWith(key.ToLower())).Take(4).ToList(); + return Services.OrganizationsService.GetCurrentUserOrganizations().Result.Where(x => x.Name.ToLower().StartsWith(key.ToLower())).ToList(); } catch (Exception ex) { diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Resources/Styles.xaml b/Software/Visual_Studio/FSE/Tango.FSE.Common/Resources/Styles.xaml index 24c4e91ec..8d5e5ae0d 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.Common/Resources/Styles.xaml +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Resources/Styles.xaml @@ -3,6 +3,7 @@ xmlns:editors="clr-namespace:Tango.AutoComplete.Editors;assembly=Tango.AutoComplete" xmlns:actions="clr-namespace:Tango.FSE.Common.EventTriggerActions" xmlns:material="http://materialdesigninxaml.net/winfx/xaml/themes" + xmlns:controls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI" xmlns:wpf="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls" xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" @@ -821,4 +822,83 @@ + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/Tango.FSE.UI.csproj b/Software/Visual_Studio/FSE/Tango.FSE.UI/Tango.FSE.UI.csproj index 6c5b993b5..1434e13cd 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.UI/Tango.FSE.UI.csproj +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/Tango.FSE.UI.csproj @@ -716,6 +716,10 @@ {ac5b4be7-d607-4a38-98f8-b87aca468313} Tango.FSE.Insights + + {15bcb5bb-731e-4e2d-aa28-75485050a8dc} + Tango.FSE.MachineConfiguration + {866b916a-207c-43f0-b403-7c4a820c2e11} Tango.FSE.PPCConsole diff --git a/Software/Visual_Studio/Tango.BL/Entities/Organization.cs b/Software/Visual_Studio/Tango.BL/Entities/Organization.cs index 738c77efb..7580c6fd1 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/Organization.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/Organization.cs @@ -15,5 +15,10 @@ namespace Tango.BL.Entities { } + + public override string ToString() + { + return Name; + } } } diff --git a/Software/Visual_Studio/Tango.sln b/Software/Visual_Studio/Tango.sln index 615dc2154..893e7f945 100644 --- a/Software/Visual_Studio/Tango.sln +++ b/Software/Visual_Studio/Tango.sln @@ -427,6 +427,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.DataStore.Remote", "T EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.DataStore.EF", "Tango.DataStore.EF\Tango.DataStore.EF.csproj", "{88D9906B-8FC4-4FE0-B7EB-127A0A8FCEE4}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.FSE.MachineConfiguration", "FSE\Modules\Tango.FSE.MachineConfiguration\Tango.FSE.MachineConfiguration.csproj", "{15BCB5BB-731E-4E2D-AA28-75485050A8DC}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -4034,6 +4036,26 @@ Global {88D9906B-8FC4-4FE0-B7EB-127A0A8FCEE4}.Release|x64.Build.0 = Release|Any CPU {88D9906B-8FC4-4FE0-B7EB-127A0A8FCEE4}.Release|x86.ActiveCfg = Release|Any CPU {88D9906B-8FC4-4FE0-B7EB-127A0A8FCEE4}.Release|x86.Build.0 = Release|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Debug|ARM.ActiveCfg = Debug|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Debug|ARM.Build.0 = Debug|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Debug|ARM64.Build.0 = Debug|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Debug|x64.ActiveCfg = Debug|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Debug|x64.Build.0 = Debug|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Debug|x86.ActiveCfg = Debug|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Debug|x86.Build.0 = Debug|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Release|Any CPU.Build.0 = Release|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Release|ARM.ActiveCfg = Release|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Release|ARM.Build.0 = Release|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Release|ARM64.ActiveCfg = Release|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Release|ARM64.Build.0 = Release|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Release|x64.ActiveCfg = Release|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Release|x64.Build.0 = Release|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Release|x86.ActiveCfg = Release|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -4177,14 +4199,15 @@ Global {59643ABC-DF9A-497F-8A7C-4A131C7CF438} = {E728CBD9-1AF4-4814-A218-E4BD26E7EDEA} {69168924-9AA8-447D-AD64-F07DBF4F0909} = {5F6BBAA8-EAD0-4B18-97E5-55B4F56DD760} {EA4233F1-4B7B-4CCF-A6DE-2D17612EBA90} = {E728CBD9-1AF4-4814-A218-E4BD26E7EDEA} + {15BCB5BB-731E-4E2D-AA28-75485050A8DC} = {4EE6DBA1-71BC-49E2-8DC7-266487E61050} 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 -- cgit v1.3.1 From d6db3244c15e3937d339064da0a5c7186f32daa1 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Mon, 9 Nov 2020 07:00:47 +0200 Subject: Working on machine configuration. --- .../Messages/EditingCompositionLoadedMessage.cs | 16 ++ .../Messages/MachineLoadedMessage.cs | 14 -- .../Tango.FSE.MachineConfiguration.csproj | 2 +- .../ViewModels/ConfigurationViewVM.cs | 85 ++++++-- .../ViewModels/MachineViewVM.cs | 19 +- .../ViewModels/MainViewVM.cs | 2 +- .../ViewModels/SelectionViewVM.cs | 19 +- .../Views/ConfigurationView.xaml | 234 ++++++++++++++------- .../Views/MachineView.xaml | 4 +- .../FSE/Tango.FSE.BL/FSEServicesContainer.cs | 6 + .../Services/MachineConfigurationService.cs | 88 ++++++++ .../FSE/Tango.FSE.BL/Tango.FSE.BL.csproj | 1 + .../Connection/IMachineProvider.cs | 2 +- .../FSE/Tango.FSE.Common/Controls/MachineView.xaml | 12 +- .../FSE/Tango.FSE.Common/Resources/Styles.xaml | 197 +++++++++++++++-- .../Connection/DefaultMachineProvider.cs | 1 + .../DefaultFileAssociationProvider.cs | 5 + .../Tango.BL/Entities/HardwareVersion.cs | 11 + 18 files changed, 578 insertions(+), 140 deletions(-) create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Messages/EditingCompositionLoadedMessage.cs delete mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Messages/MachineLoadedMessage.cs create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.BL/Services/MachineConfigurationService.cs (limited to 'Software/Visual_Studio') diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Messages/EditingCompositionLoadedMessage.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Messages/EditingCompositionLoadedMessage.cs new file mode 100644 index 000000000..b858c34e0 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Messages/EditingCompositionLoadedMessage.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; +using Tango.FSE.BL.Services; +using static Tango.FSE.BL.Services.MachineConfigurationService; + +namespace Tango.FSE.MachineConfiguration.Messages +{ + public class EditingCompositionLoadedMessage + { + public MachineEditingComposition EditingComposition { get; set; } + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Messages/MachineLoadedMessage.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Messages/MachineLoadedMessage.cs deleted file mode 100644 index 4a703b2a9..000000000 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Messages/MachineLoadedMessage.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.BL.Entities; - -namespace Tango.FSE.MachineConfiguration.Messages -{ - public class MachineLoadedMessage - { - public Machine Machine { get; set; } - } -} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Tango.FSE.MachineConfiguration.csproj b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Tango.FSE.MachineConfiguration.csproj index e7adc1d3f..c5aa8c4bf 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Tango.FSE.MachineConfiguration.csproj +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Tango.FSE.MachineConfiguration.csproj @@ -79,7 +79,7 @@ - + diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/ConfigurationViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/ConfigurationViewVM.cs index 1540a4e67..63e3f22d9 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/ConfigurationViewVM.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/ConfigurationViewVM.cs @@ -4,41 +4,96 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Tango.BL.Entities; +using Tango.Core.Commands; +using Tango.Core.DI; using Tango.FSE.Common; using Tango.FSE.Common.AutoComplete; +using Tango.FSE.Common.SQL; using Tango.FSE.MachineConfiguration.Messages; +using static Tango.FSE.BL.Services.MachineConfigurationService; namespace Tango.FSE.MachineConfiguration.ViewModels { public class ConfigurationViewVM : FSEViewModel { - private Machine _machine; - public Machine Machine + [TangoInject] + private IRemoteSqlProvider RemoteSqlProvider { get; set; } + + private MachineEditingComposition _editingComposition; + public MachineEditingComposition EditingComposition { - get { return _machine; } - set { _machine = value; RaisePropertyChangedAuto(); } + get { return _editingComposition; } + set { _editingComposition = value; RaisePropertyChangedAuto(); } } - private List _organizations; - public List Organizations + public RelayCommand SaveCommand { get; set; } + public RelayCommand ResetCountersCommand { get; set; } + public RelayCommand ResetDeviceRegistrationCommand { get; set; } + + + public ConfigurationViewVM() { - get { return _organizations; } - set { _organizations = value; RaisePropertyChangedAuto(); } + RegisterForMessage(OnEditingCompositionLoaded); + SaveCommand = new RelayCommand(SaveConfiguration); + ResetCountersCommand = new RelayCommand(ResetCounters); + ResetDeviceRegistrationCommand = new RelayCommand(ResetDeviceRegistration); } - public ConfigurationViewVM() + private void OnEditingCompositionLoaded(EditingCompositionLoadedMessage msg) { - RegisterForMessage(HandleMachineLoadedMessage); + using (NotificationProvider.PushTaskItem("Loading machine configuration...")) + { + EditingComposition = msg.EditingComposition; + } } - private async void HandleMachineLoadedMessage(MachineLoadedMessage msg) + private async void SaveConfiguration() { - using (NotificationProvider.PushTaskItem("Loading configuration options...")) + using (NotificationProvider.PushTaskItem("Saving machine configuration...")) { - Machine = msg.Machine; - Organizations = await Services.OrganizationsService.GetCurrentUserOrganizations(); - Machine.Organization = Organizations.SingleOrDefault(x => x.Guid == Machine.OrganizationGuid); + EditingComposition = await Services.MachineConfigurationService.SaveMachineEditingComposition(EditingComposition); + await NotificationProvider.ShowSuccess("Machine configuration saved successfully."); } } + + private async void ResetCounters() + { + if (!MachineProvider.IsPPCAvailable) + { + await NotificationProvider.ShowError("Resetting the machine counters requires an active connection to this machine."); + return; + } + + if (!await NotificationProvider.ShowWarningQuestion("Resetting the machine counters will delete the entire job runs history. Are you sure?", "RESET COUNTERS", "CANCEL")) return; + + using (var task = NotificationProvider.PushTaskItem("Resetting machine counters...")) + { + task.UpdateProgress("Resetting local machine counters..."); + + var result = await RemoteSqlProvider.ExecuteSqlCommandAsync(new RemoteSqlCommand() + { + Mode = RemoteSqlCommandMode.Local, + Timeout = 30, + SQL = "DELETE FROM JOB_RUNS" + }); + + int localJobRuns = result.LocalAffectedRecords; + + task.UpdateProgress("Resetting global machine counters..."); + + int remoteJobRuns = await Services.MachineConfigurationService.ResetCounters(EditingComposition.Machine.Guid); + + await NotificationProvider.ShowSuccess("Machine counters deleted successfully."); + } + } + + private async void ResetDeviceRegistration() + { + if (!await NotificationProvider.ShowWarningQuestion("Resetting the machine's device registration will allow other panel PCs to perform a machine setup for this machine. Are you sure?", "RESET", "CANCEL")) return; + + EditingComposition.Machine.IsDeviceRegistered = false; + EditingComposition.Machine.DeviceId = null; + EditingComposition.Machine.DeviceName = null; + } } } diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/MachineViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/MachineViewVM.cs index cbd6c1cf1..24a0cbc42 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/MachineViewVM.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/MachineViewVM.cs @@ -7,6 +7,7 @@ using Tango.BL.Entities; using Tango.FSE.Common; using Tango.FSE.Common.Navigation; using Tango.FSE.MachineConfiguration.Messages; +using static Tango.FSE.BL.Services.MachineConfigurationService; using static Tango.FSE.MachineConfiguration.ViewModels.MachineViewVM; namespace Tango.FSE.MachineConfiguration.ViewModels @@ -15,7 +16,7 @@ namespace Tango.FSE.MachineConfiguration.ViewModels { public class NavigationObject { - public String MachineSerialNumber { get; set; } + public String MachineGuid { get; set; } } public enum NavigationView @@ -35,25 +36,25 @@ namespace Tango.FSE.MachineConfiguration.ViewModels } } - private Machine _machine; - public Machine Machine + private MachineEditingComposition _editingComposition; + public MachineEditingComposition EditingComposition { - get { return _machine; } - set { _machine = value; RaisePropertyChangedAuto(); } + get { return _editingComposition; } + set { _editingComposition = value; RaisePropertyChangedAuto(); } } public void OnNavigatedToWithObject(NavigationObject obj) { SelectedView = NavigationView.ConfigurationView; - LoadMachine(obj.MachineSerialNumber); + LoadMachine(obj.MachineGuid); } - private async void LoadMachine(String serialNumber) + private async void LoadMachine(String machineGuid) { using (NotificationProvider.PushTaskItem("Loading machine configuration...")) { - Machine = await Services.MachinesService.GetMachineFull(serialNumber); - RaiseMessage(new MachineLoadedMessage() { Machine = Machine }); + EditingComposition = await Services.MachineConfigurationService.GetMachineEditingComposition(machineGuid); + RaiseMessage(new EditingCompositionLoadedMessage() { EditingComposition = EditingComposition }); } } } diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/MainViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/MainViewVM.cs index efb2fc3cc..5b8ca21ac 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/MainViewVM.cs @@ -14,7 +14,7 @@ namespace Tango.FSE.MachineConfiguration.ViewModels [ModularNavigationContainer] public class MainViewVM : ConfigurationViewModel { - public override void OnApplicationStarted() + public override void OnApplicationReady() { InvokeUI(() => { diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/SelectionViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/SelectionViewVM.cs index c62ade6fb..b65ad7102 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/SelectionViewVM.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/SelectionViewVM.cs @@ -39,9 +39,26 @@ namespace Tango.FSE.MachineConfiguration.ViewModels ModularNavigationManager.NavigateTo(ConfigurationView.MachineView, new MachineViewVM.NavigationObject() { - MachineSerialNumber = SelectedMachine.SerialNumber + MachineGuid = SelectedMachine.Guid }); } + + public override void OnNavigatedTo() + { + base.OnNavigatedTo(); + + if (SelectedMachine == null && MachineProvider.Machine != null) + { + SelectedMachine = MachineProvider.Machine; + } + } + + public override Task OnApplicationLogout() + { + ModularNavigationManager.NavigateTo(ConfigurationView.SelectionView); + SelectedMachine = null; + return base.OnApplicationLogout(); + } } } diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/ConfigurationView.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/ConfigurationView.xaml index 8d8aa7b0e..9c8b2d878 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/ConfigurationView.xaml +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/ConfigurationView.xaml @@ -5,111 +5,191 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:Tango.FSE.MachineConfiguration.Views" xmlns:global="clr-namespace:Tango.FSE.MachineConfiguration" + xmlns:material="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:vm="clr-namespace:Tango.FSE.MachineConfiguration.ViewModels" + xmlns:enumerations="clr-namespace:Tango.BL.Enumerations;assembly=Tango.BL" xmlns:commonControls="clr-namespace:Tango.FSE.Common.Controls;assembly=Tango.FSE.Common" xmlns:resolution="clr-namespace:Tango.FSE.Common.Resolution;assembly=Tango.FSE.Common" xmlns:controls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI" xmlns:autoComplete="clr-namespace:Tango.AutoComplete.Editors;assembly=Tango.AutoComplete" mc:Ignorable="d" - d:DesignHeight="1080" d:DesignWidth="1920" d:DataContext="{d:DesignInstance Type=vm:ConfigurationViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.ConfigurationViewVM}" d:DesignStyle="{StaticResource FSE_User_Control_Designer}"> - + d:DesignHeight="2000" d:DesignWidth="1920" d:DataContext="{d:DesignInstance Type=vm:ConfigurationViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.ConfigurationViewVM}" d:DesignStyle="{StaticResource FSE_User_Control_Designer}"> - - + - - - - - Activate Windows License - + - - License Key - - + + + + + - - - Setup Team Viewer - + - - - Activate Disk Protection - + - - - Use Firmware Emulator (Demo Machine) - - - Device Registration + + + + + Activate Windows License + + + + License Key + + + + + + Setup Team Viewer + + + + + Activate Disk Protection + + + + + Use Firmware Emulator (Demo Machine) + + + + - - + Device Registration - + + + + Registered: - - + + - + Device ID: - - + + - + Device Name: - - - + + + - - - - - - - - - - - Perform Firmware Upgrade - + + + - - - Force Version Update - + - - - Suspend Version Update - - - + - - + Machine Counters - - Serial Number - - + + + + + Total Dye Time: + + - - Name - + + Total Dye Meters: + + + + + + + + + + + + + + Perform Firmware Upgrade + + + + + Force Version Update + - - Organization - + + + Suspend Version Update + - - - + + + + + + + Serial Number + + + + + Name + + + + + Organization + + + + + Site + + + + + + + + + Head Type + + + + + Hardware Version + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/MachineView.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/MachineView.xaml index ba9418d5d..9f81f82e4 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/MachineView.xaml +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/MachineView.xaml @@ -29,8 +29,8 @@ - - + + diff --git a/Software/Visual_Studio/FSE/Tango.FSE.BL/FSEServicesContainer.cs b/Software/Visual_Studio/FSE/Tango.FSE.BL/FSEServicesContainer.cs index e5487bc1e..14b74fd9c 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.BL/FSEServicesContainer.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.BL/FSEServicesContainer.cs @@ -62,6 +62,11 @@ namespace Tango.FSE.BL /// public OrganizationsService OrganizationsService { get; set; } + /// + /// Gets or sets the machine configuration service. + /// + public MachineConfigurationService MachineConfigurationService { get; set; } + /// /// Initializes a new instance of the class. /// @@ -78,6 +83,7 @@ namespace Tango.FSE.BL PublishedProcedureProjectsService = new PublishedProcedureProjectsService(); MachineEventsService = new MachineEventsService(); OrganizationsService = new OrganizationsService(); + MachineConfigurationService = new MachineConfigurationService(); } } } diff --git a/Software/Visual_Studio/FSE/Tango.FSE.BL/Services/MachineConfigurationService.cs b/Software/Visual_Studio/FSE/Tango.FSE.BL/Services/MachineConfigurationService.cs new file mode 100644 index 000000000..e6798e197 --- /dev/null +++ b/Software/Visual_Studio/FSE/Tango.FSE.BL/Services/MachineConfigurationService.cs @@ -0,0 +1,88 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL; +using Tango.BL.Entities; +using System.Data.Entity; +using Tango.BL.Builders; + +namespace Tango.FSE.BL.Services +{ + public class MachineConfigurationService : FSEServiceBase + { + public class MachineEditingComposition : IDisposable + { + public Machine Machine { get; set; } + public List Organizations { get; set; } + public List HardwareVersions { get; set; } + public String TotalDyeTime { get; set; } + public String TotalDyeMeters { get; set; } + internal ObservablesContext Context { get; set; } + + public MachineEditingComposition() + { + Organizations = new List(); + HardwareVersions = new List(); + } + + public void Dispose() + { + Context?.Dispose(); + Context = null; + } + } + + public Task GetMachineEditingComposition(String machineGuid) + { + return Task.Factory.StartNew(() => + { + ObservablesContext db = ObservablesContext.CreateDefault(); + + MachineEditingComposition composition = new MachineEditingComposition(); + + //Organizations + bool allowAll = CurrentUser.HasPermission(Tango.BL.Enumerations.Permissions.FSE_ManageAllOrganizationsUsersAndRoles); + composition.Organizations = db.Organizations.Where(x => allowAll || x.Guid == CurrentUser.OrganizationGuid).Include(x => x.Sites).ToList(); + + //Machine + composition.Machine = new MachineBuilder(db).Set(machineGuid).WithConfiguration().Build(); + + //Hardware Versions + composition.HardwareVersions = db.HardwareVersions.OrderByDescending(x => x.Version).ToList(); + + //Counters + var jobRuns = db.JobRuns.Where(x => x.MachineGuid == machineGuid).Select(x => new { x.StartDate, x.EndDate, x.EndPosition }).ToList(); + composition.TotalDyeTime = TimeSpan.FromHours(jobRuns.Select(x => x.EndDate - x.StartDate).Sum(x => x.TotalHours)).ToStringUnlimitedHours(); + int meters = (int)jobRuns.Select(x => x.EndPosition).Sum(); + composition.TotalDyeMeters = $"{meters.ToString("N0")} meters"; + + composition.Context = db; + + return composition; + }); + } + + public Task SaveMachineEditingComposition(MachineEditingComposition composition) + { + return Task.Factory.StartNew(() => + { + composition.Context.SaveChanges(); + composition.Context.Dispose(); + return GetMachineEditingComposition(composition.Machine.Guid).Result; + }); + } + + public Task ResetCounters(String machineGuid) + { + return Task.Factory.StartNew(() => + { + using (ObservablesContext db = new ObservablesContext()) + { + return db.JobRuns.Where(x => x.MachineGuid == machineGuid).DeleteFromQuery(); + } + }); + } + } +} diff --git a/Software/Visual_Studio/FSE/Tango.FSE.BL/Tango.FSE.BL.csproj b/Software/Visual_Studio/FSE/Tango.FSE.BL/Tango.FSE.BL.csproj index 39257df86..fba87644b 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.BL/Tango.FSE.BL.csproj +++ b/Software/Visual_Studio/FSE/Tango.FSE.BL/Tango.FSE.BL.csproj @@ -119,6 +119,7 @@ + diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Connection/IMachineProvider.cs b/Software/Visual_Studio/FSE/Tango.FSE.Common/Connection/IMachineProvider.cs index 9a98477b8..8c4512c41 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.Common/Connection/IMachineProvider.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Connection/IMachineProvider.cs @@ -41,7 +41,7 @@ namespace Tango.FSE.Common.Connection MachineConnectionTypes ConnectionType { get; } /// - /// Gets a value indicating whether the equals or . + /// Gets a value indicating whether the machine is connected and the equals or . /// bool IsPPCAvailable { get; } diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Controls/MachineView.xaml b/Software/Visual_Studio/FSE/Tango.FSE.Common/Controls/MachineView.xaml index c37613e3e..8d375cc6d 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.Common/Controls/MachineView.xaml +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Controls/MachineView.xaml @@ -47,11 +47,11 @@ - Hardware + 1 @@ -217,17 +217,17 @@ - Mid Tanks + - Cartridges + diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Resources/Styles.xaml b/Software/Visual_Studio/FSE/Tango.FSE.Common/Resources/Styles.xaml index 8d5e5ae0d..2b7ea3640 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.Common/Resources/Styles.xaml +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Resources/Styles.xaml @@ -9,6 +9,8 @@ xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:local="clr-namespace:Tango.FSE.Common.Resources"> + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/Connection/DefaultMachineProvider.cs b/Software/Visual_Studio/FSE/Tango.FSE.UI/Connection/DefaultMachineProvider.cs index 94b035ab5..aad63fdf9 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.UI/Connection/DefaultMachineProvider.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/Connection/DefaultMachineProvider.cs @@ -342,6 +342,7 @@ namespace Tango.FSE.UI.Connection { IsConnected = false; IsBusy = false; + Machine = null; OnMachineDisconnected(MachineOperator, null); } } diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/FileAssociation/DefaultFileAssociationProvider.cs b/Software/Visual_Studio/FSE/Tango.FSE.UI/FileAssociation/DefaultFileAssociationProvider.cs index 0d582cb11..89364cbbd 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.UI/FileAssociation/DefaultFileAssociationProvider.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/FileAssociation/DefaultFileAssociationProvider.cs @@ -19,6 +19,7 @@ namespace Tango.FSE.UI.FileAssociation { private Dictionary> _handlers; private IpcServer _ipcServer; + private bool _initialized; public const string FILE_ASSOCIATION_PREFIX = "-file"; public const int FILE_ASSOCIATION_ARGS_COUNT = 3; @@ -44,6 +45,10 @@ namespace Tango.FSE.UI.FileAssociation public async void OnApplicationReady(IFSEApplicationManager applicationManager) { + if (!_initialized) return; + + _initialized = true; + try { LogManager.Log("Starting file association IPC service..."); diff --git a/Software/Visual_Studio/Tango.BL/Entities/HardwareVersion.cs b/Software/Visual_Studio/Tango.BL/Entities/HardwareVersion.cs index 590fe9e13..bc65c33ce 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/HardwareVersion.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/HardwareVersion.cs @@ -109,5 +109,16 @@ namespace Tango.BL.Entities { } + + /// + /// Returns a that represents this instance. + /// + /// + /// A that represents this instance. + /// + public override string ToString() + { + return FullName; + } } } -- cgit v1.3.1 From 775f0015321f91aa5be3aca079e289e89d4719f5 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Tue, 10 Nov 2020 11:06:48 +0200 Subject: DataStore editing.. --- .../Converters/DataStoreValueToStringConverter.cs | 32 ++++++ .../Tango.FSE.MachineConfiguration.csproj | 17 +++ .../ViewModels/DataStoreViewVM.cs | 74 +++++++++++- .../Views/DataStoreView.xaml | 66 ++++++++++- .../FSE/Tango.FSE.BL/FSEServicesContainer.cs | 6 + .../FSE/Tango.FSE.BL/Services/DataStoreService.cs | 36 ++++++ .../FSE/Tango.FSE.BL/Tango.FSE.BL.csproj | 9 ++ .../DataStore/IDataStoreProvider.cs | 14 +++ .../DataStore/IRemoteDataStoreManager.cs | 2 +- .../FSE/Tango.FSE.Common/Tango.FSE.Common.csproj | 5 + .../DataStore/DefaultDataStoreProvider.cs | 124 +++++++++++++++++++++ .../FSE/Tango.FSE.UI/Tango.FSE.UI.csproj | 9 ++ .../FSE/Tango.FSE.UI/ViewModelLocator.cs | 2 + .../DataStore/DefaultDataStoreService.cs | 29 +++++ .../PPC/Tango.PPC.Common/Tango.PPC.Common.csproj | 2 +- .../Tango.DataStore.Editing/CustomControl1.cs | 25 +++++ .../DataStoreCollectionModel.cs | 21 ++++ .../Tango.DataStore.Editing/DataStoreItemModel.cs | 89 +++++++++++++++ .../Tango.DataStore.Editing/DataStoreModel.cs | 20 ++++ .../Properties/AssemblyInfo.cs | 55 +++++++++ .../Properties/Resources.Designer.cs | 62 +++++++++++ .../Properties/Resources.resx | 117 +++++++++++++++++++ .../Properties/Settings.Designer.cs | 30 +++++ .../Properties/Settings.settings | 7 ++ .../Tango.DataStore.Editing.csproj | 100 +++++++++++++++++ .../Tango.DataStore.Editing/Themes/Generic.xaml | 18 +++ .../RemoteDataStoreCollection.cs | 19 ++++ .../RemoteDataStoreGetAllItemsRequest.cs | 12 ++ .../RemoteDataStoreGetAllItemsResponse.cs | 18 +++ .../Tango.DataStore.Remote.csproj | 3 + .../Tango.DataStore/DataStoreHelper.cs | 4 +- Software/Visual_Studio/Tango.sln | 34 +++++- 32 files changed, 1047 insertions(+), 14 deletions(-) create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Converters/DataStoreValueToStringConverter.cs create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.BL/Services/DataStoreService.cs create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.Common/DataStore/IDataStoreProvider.cs create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.UI/DataStore/DefaultDataStoreProvider.cs create mode 100644 Software/Visual_Studio/Tango.DataStore.Editing/CustomControl1.cs create mode 100644 Software/Visual_Studio/Tango.DataStore.Editing/DataStoreCollectionModel.cs create mode 100644 Software/Visual_Studio/Tango.DataStore.Editing/DataStoreItemModel.cs create mode 100644 Software/Visual_Studio/Tango.DataStore.Editing/DataStoreModel.cs create mode 100644 Software/Visual_Studio/Tango.DataStore.Editing/Properties/AssemblyInfo.cs create mode 100644 Software/Visual_Studio/Tango.DataStore.Editing/Properties/Resources.Designer.cs create mode 100644 Software/Visual_Studio/Tango.DataStore.Editing/Properties/Resources.resx create mode 100644 Software/Visual_Studio/Tango.DataStore.Editing/Properties/Settings.Designer.cs create mode 100644 Software/Visual_Studio/Tango.DataStore.Editing/Properties/Settings.settings create mode 100644 Software/Visual_Studio/Tango.DataStore.Editing/Tango.DataStore.Editing.csproj create mode 100644 Software/Visual_Studio/Tango.DataStore.Editing/Themes/Generic.xaml create mode 100644 Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreCollection.cs create mode 100644 Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetAllItemsRequest.cs create mode 100644 Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetAllItemsResponse.cs (limited to 'Software/Visual_Studio') diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Converters/DataStoreValueToStringConverter.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Converters/DataStoreValueToStringConverter.cs new file mode 100644 index 000000000..6b3c8e28c --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Converters/DataStoreValueToStringConverter.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; +using Tango.DataStore; + +namespace Tango.FSE.MachineConfiguration.Converters +{ + public class DataStoreValueToStringConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value is IDataStoreItem item) + { + if (item != null) + { + return DataStoreHelper.FormatDataStoreItem(item); + } + } + + return value; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Tango.FSE.MachineConfiguration.csproj b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Tango.FSE.MachineConfiguration.csproj index c5aa8c4bf..af67b0d74 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Tango.FSE.MachineConfiguration.csproj +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Tango.FSE.MachineConfiguration.csproj @@ -79,6 +79,7 @@ + @@ -143,6 +144,22 @@ {a34ee0f0-649d-41c8-8489-b6f1cc6924ee} Tango.Core + + {ee088ff7-04d1-41fb-9d6a-cedeee7a7b9c} + Tango.DataStore.Editing + + + {88d9906b-8fc4-4fe0-b7eb-127a0a8fcee4} + Tango.DataStore.EF + + + {29448f3c-9b3e-4da6-8555-46a8b9a6b3aa} + Tango.DataStore.Remote + + + {e0364dfa-0721-4637-9d32-9d22aac109d6} + Tango.DataStore + {4206ac58-3b57-4699-8835-90bf6db01a61} Tango.Integration diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/DataStoreViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/DataStoreViewVM.cs index f321cd061..4a75c137b 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/DataStoreViewVM.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/DataStoreViewVM.cs @@ -3,11 +3,83 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.Core.DI; +using Tango.DataStore.Editing; using Tango.FSE.Common; +using Tango.FSE.Common.DataStore; +using Tango.FSE.MachineConfiguration.Messages; +using static Tango.SharedUI.Controls.NavigationControl; namespace Tango.FSE.MachineConfiguration.ViewModels { - public class DataStoreViewVM : FSEViewModel + public class DataStoreViewVM : FSEViewModel, INavigationViewModel { + private String machineGuid; + + [TangoInject] + private IDataStoreProvider DataStoreProvider { get; set; } + + private DataStoreModel _dataStore; + public DataStoreModel DataStore + { + get { return _dataStore; } + set { _dataStore = value; RaisePropertyChangedAuto(); } + } + + private DataStoreCollectionModel _selectedCollection; + public DataStoreCollectionModel SelectedCollection + { + get { return _selectedCollection; } + set { _selectedCollection = value; RaisePropertyChangedAuto(); } + } + + private DataStoreItemModel _selectedItem; + public DataStoreItemModel SelectedItem + { + get { return _selectedItem; } + set { _selectedItem = value; RaisePropertyChangedAuto(); } + } + + private bool _isLoading; + public bool IsLoading + { + get { return _isLoading; } + set { _isLoading = value; RaisePropertyChangedAuto(); } + } + + public DataStoreViewVM() + { + RegisterForMessage(OnEditingCompositionLoaded); + } + + private void OnEditingCompositionLoaded(EditingCompositionLoadedMessage obj) + { + DataStore = null; + machineGuid = obj.EditingComposition.Machine.Guid; + } + + public async override void OnNavigatedTo() + { + base.OnNavigatedTo(); + + if (DataStore == null) + { + try + { + IsLoading = true; + IsFree = false; + DataStore = await DataStoreProvider.GetDataStoreModel(machineGuid); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error loading data store."); + } + finally + { + IsLoading = false; + IsFree = true; + } + } + } } } diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/DataStoreView.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/DataStoreView.xaml index ac26bf445..f078efcee 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/DataStoreView.xaml +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/DataStoreView.xaml @@ -6,11 +6,71 @@ xmlns:local="clr-namespace:Tango.FSE.MachineConfiguration.Views" xmlns:global="clr-namespace:Tango.FSE.MachineConfiguration" xmlns:vm="clr-namespace:Tango.FSE.MachineConfiguration.ViewModels" + xmlns:material="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:commonControls="clr-namespace:Tango.FSE.Common.Controls;assembly=Tango.FSE.Common" xmlns:resolution="clr-namespace:Tango.FSE.Common.Resolution;assembly=Tango.FSE.Common" + xmlns:converters="clr-namespace:Tango.FSE.MachineConfiguration.Converters" mc:Ignorable="d" - d:DesignHeight="720" d:DesignWidth="1280" d:DataContext="{d:DesignInstance Type=vm:DataStoreViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.DataStoreViewVM}"> - - + d:DesignHeight="720" d:DesignWidth="1280" d:DataContext="{d:DesignInstance Type=vm:DataStoreViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.DataStoreViewVM}" d:DesignStyle="{StaticResource FSE_User_Control_Designer}"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/FSE/Tango.FSE.BL/FSEServicesContainer.cs b/Software/Visual_Studio/FSE/Tango.FSE.BL/FSEServicesContainer.cs index 14b74fd9c..c8773eccd 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.BL/FSEServicesContainer.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.BL/FSEServicesContainer.cs @@ -67,6 +67,11 @@ namespace Tango.FSE.BL /// public MachineConfigurationService MachineConfigurationService { get; set; } + /// + /// Gets or sets the data store service. + /// + public DataStoreService DataStoreService { get; set; } + /// /// Initializes a new instance of the class. /// @@ -84,6 +89,7 @@ namespace Tango.FSE.BL MachineEventsService = new MachineEventsService(); OrganizationsService = new OrganizationsService(); MachineConfigurationService = new MachineConfigurationService(); + DataStoreService = new DataStoreService(); } } } diff --git a/Software/Visual_Studio/FSE/Tango.FSE.BL/Services/DataStoreService.cs b/Software/Visual_Studio/FSE/Tango.FSE.BL/Services/DataStoreService.cs new file mode 100644 index 000000000..41ab7725b --- /dev/null +++ b/Software/Visual_Studio/FSE/Tango.FSE.BL/Services/DataStoreService.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL; +using Tango.BL.Entities; +using Tango.DataStore; + +namespace Tango.FSE.BL.Services +{ + public class DataStoreService : FSEServiceBase + { + public Task> GetGlobalDataStoreItems() + { + return Task.Factory.StartNew>(() => + { + using (ObservablesContext db = ObservablesContext.CreateDefault()) + { + return db.GlobalDataStoreItems.ToList().OrderBy(x => x.CollectionName).OrderBy(x => x.Key).ToList(); + } + }); + } + + public Task> GetMachinelDataStoreItems(String machineGuid) + { + return Task.Factory.StartNew>(() => + { + using (ObservablesContext db = ObservablesContext.CreateDefault()) + { + return db.DataStoreItems.Where(x => x.MachineGuid == machineGuid).ToList().OrderBy(x => x.CollectionName).OrderBy(x => x.Key).ToList(); + } + }); + } + } +} diff --git a/Software/Visual_Studio/FSE/Tango.FSE.BL/Tango.FSE.BL.csproj b/Software/Visual_Studio/FSE/Tango.FSE.BL/Tango.FSE.BL.csproj index fba87644b..d15611e91 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.BL/Tango.FSE.BL.csproj +++ b/Software/Visual_Studio/FSE/Tango.FSE.BL/Tango.FSE.BL.csproj @@ -119,6 +119,7 @@ + @@ -146,6 +147,14 @@ {a34ee0f0-649d-41c8-8489-b6f1cc6924ee} Tango.Core + + {88d9906b-8fc4-4fe0-b7eb-127a0a8fcee4} + Tango.DataStore.EF + + + {e0364dfa-0721-4637-9d32-9d22aac109d6} + Tango.DataStore + {bc932dbd-7cdb-488c-99e4-f02cf441f55e} Tango.Logging diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/DataStore/IDataStoreProvider.cs b/Software/Visual_Studio/FSE/Tango.FSE.Common/DataStore/IDataStoreProvider.cs new file mode 100644 index 000000000..bab513e36 --- /dev/null +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/DataStore/IDataStoreProvider.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.DataStore.Editing; + +namespace Tango.FSE.Common.DataStore +{ + public interface IDataStoreProvider + { + Task GetDataStoreModel(String machineGuid); + } +} diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/DataStore/IRemoteDataStoreManager.cs b/Software/Visual_Studio/FSE/Tango.FSE.Common/DataStore/IRemoteDataStoreManager.cs index 02cc3ac9d..162c109be 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.Common/DataStore/IRemoteDataStoreManager.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/DataStore/IRemoteDataStoreManager.cs @@ -9,6 +9,6 @@ namespace Tango.FSE.Common.DataStore { public interface IRemoteDataStoreManager : IDataStoreManager { - + } } diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Tango.FSE.Common.csproj b/Software/Visual_Studio/FSE/Tango.FSE.Common/Tango.FSE.Common.csproj index 4f0cb622b..bb44045b7 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.Common/Tango.FSE.Common.csproj +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Tango.FSE.Common.csproj @@ -188,6 +188,7 @@ + @@ -505,6 +506,10 @@ {a34ee0f0-649d-41c8-8489-b6f1cc6924ee} Tango.Core + + {ee088ff7-04d1-41fb-9d6a-cedeee7a7b9c} + Tango.DataStore.Editing + {e0364dfa-0721-4637-9d32-9d22aac109d6} Tango.DataStore diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/DataStore/DefaultDataStoreProvider.cs b/Software/Visual_Studio/FSE/Tango.FSE.UI/DataStore/DefaultDataStoreProvider.cs new file mode 100644 index 000000000..6239a33d9 --- /dev/null +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/DataStore/DefaultDataStoreProvider.cs @@ -0,0 +1,124 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; +using Tango.Core.DI; +using Tango.DataStore; +using Tango.DataStore.Editing; +using Tango.DataStore.Remote; +using Tango.FSE.BL; +using Tango.FSE.Common.Connection; +using Tango.FSE.Common.DataStore; + +namespace Tango.FSE.UI.DataStore +{ + public class DefaultDataStoreProvider : IDataStoreProvider + { + [TangoInject] + private IMachineProvider MachineProvider { get; set; } + + [TangoInject] + private FSEServicesContainer Services { get; set; } + + public Task GetDataStoreModel(String machineGuid) + { + return Task.Factory.StartNew(() => + { + DataStoreModel model = new DataStoreModel(); + + List globalItems = Services.DataStoreService.GetGlobalDataStoreItems().Result; + List localItems = Services.DataStoreService.GetMachinelDataStoreItems(machineGuid).Result; + + List itemsModels = new List(); + + //Get machine items from db. + foreach (var collection in localItems.GroupBy(x => x.CollectionName)) + { + DataStoreCollectionModel collectionModel = new DataStoreCollectionModel(); + collectionModel.Name = collection.First().CollectionName; + + foreach (var item in collection) + { + GlobalDataStoreItem globalItem = globalItems.FirstOrDefault(x => x.CollectionName == item.CollectionName && x.Key == item.Key); + + if (globalItem != null) + { + globalItems.Remove(globalItem); + } + + DataStoreItemModel itemModel = DataStoreItemModel.FromLocalDataStoreItem(item.ToDataStoreItem(), globalItem?.ToDataStoreItem()); + collectionModel.Items.Add(itemModel); + } + + model.Collections.Add(collectionModel); + } + + //Get machine items from connected machine. + if (MachineProvider.IsPPCAvailable) + { + var response = MachineProvider.MachineOperator.SendGenericRequest(new RemoteDataStoreGetAllItemsRequest(), new Transport.TransportRequestConfig() { Timeout = TimeSpan.FromSeconds(30) }).Result; + + foreach (var collection in response.Collections) + { + DataStoreCollectionModel collectionModel = model.Collections.FirstOrDefault(x => x.Name == collection.Name); + + if (collectionModel == null) + { + collectionModel = new DataStoreCollectionModel(); + collectionModel.Name = collection.Name; + model.Collections.Add(collectionModel); + } + + foreach (var remoteItem in collection.Items) + { + var localItem = collectionModel.Items.FirstOrDefault(x => x.Key == remoteItem.Key); + + if (localItem != null && remoteItem.Date > localItem.Date) + { + localItem.Value = remoteItem.Value; + localItem.Type = remoteItem.Type; + localItem.Date = remoteItem.Date; + } + else if (localItem == null) + { + GlobalDataStoreItem globalItem = globalItems.FirstOrDefault(x => x.CollectionName == collection.Name && x.Key == remoteItem.Key); + + if (globalItem != null) + { + globalItems.Remove(globalItem); + } + + DataStoreItemModel itemModel = DataStoreItemModel.FromLocalDataStoreItem(remoteItem, globalItem?.ToDataStoreItem()); + collectionModel.Items.Add(itemModel); + } + + } + } + } + + //Get global items without overrides from db. + foreach (var collection in globalItems.GroupBy(x => x.CollectionName)) + { + DataStoreCollectionModel collectionModel = model.Collections.FirstOrDefault(x => x.Name == collection.First().CollectionName); + + if (collectionModel == null) + { + collectionModel = new DataStoreCollectionModel(); + collectionModel.Name = collection.First().CollectionName; + model.Collections.Add(collectionModel); + } + + foreach (var item in collection) + { + DataStoreItemModel itemModel = DataStoreItemModel.FromGlobalDataStoreItem(item.ToDataStoreItem()); + collectionModel.Items.Add(itemModel); + } + } + + return model; + }); + } + } +} diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/Tango.FSE.UI.csproj b/Software/Visual_Studio/FSE/Tango.FSE.UI/Tango.FSE.UI.csproj index 1434e13cd..baff92208 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.UI/Tango.FSE.UI.csproj +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/Tango.FSE.UI.csproj @@ -261,6 +261,7 @@ + @@ -640,6 +641,14 @@ {38197109-8610-4d3f-92b9-16d48df94d7c} Tango.DAL.Remote + + {EE088FF7-04D1-41FB-9D6A-CEDEEE7A7B9C} + Tango.DataStore.Editing + + + {88d9906b-8fc4-4fe0-b7eb-127a0a8fcee4} + Tango.DataStore.EF + {29448f3c-9b3e-4da6-8555-46a8b9a6b3aa} Tango.DataStore.Remote diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/ViewModelLocator.cs b/Software/Visual_Studio/FSE/Tango.FSE.UI/ViewModelLocator.cs index fd514b7ac..e9d18d777 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.UI/ViewModelLocator.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/ViewModelLocator.cs @@ -117,6 +117,7 @@ namespace Tango.FSE.UI TangoIOC.Default.Unregister(); TangoIOC.Default.Unregister(); TangoIOC.Default.Unregister(); + TangoIOC.Default.Unregister(); //TangoIOC.Default.Unregister(); //TangoIOC.Default.Unregister(); //TangoIOC.Default.Unregister(); @@ -160,6 +161,7 @@ namespace Tango.FSE.UI TangoIOC.Default.Register(); TangoIOC.Default.Register(); TangoIOC.Default.Register(); + TangoIOC.Default.Register(); TangoIOC.Default.Register(); diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/DataStore/DefaultDataStoreService.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/DataStore/DefaultDataStoreService.cs index ddc0f6cdb..7c8cf4158 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/DataStore/DefaultDataStoreService.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/DataStore/DefaultDataStoreService.cs @@ -17,6 +17,7 @@ using Tango.PPC.Common.ExternalBridge; using Tango.Transport; using Tango.Core.ExtensionMethods; using Newtonsoft.Json.Linq; +using Tango.BL; namespace Tango.PPC.Common.DataStore { @@ -132,6 +133,34 @@ namespace Tango.PPC.Common.DataStore }, token); } + [ExternalBridgeRequestHandlerMethod(typeof(RemoteDataStoreGetAllItemsRequest), RequestHandlerLoggingMode.LogRequestName)] + public async Task RemoteDataStoreGetAllItemsRequest(RemoteDataStoreGetAllItemsRequest request, String token, ExternalBridgeReceiver receiver) + { + List collections = new List(); + + using (ObservablesContext db = ObservablesContext.CreateDefault()) + { + var items = db.DataStoreItems.ToList(); + + foreach (var itemsGroup in items.GroupBy(x => x.CollectionName)) + { + RemoteDataStoreCollection collection = new RemoteDataStoreCollection(); + collection.Name = itemsGroup.First().CollectionName; + collections.Add(collection); + + foreach (var item in itemsGroup) + { + collection.Items.Add(CreateRemoteItem(item.ToDataStoreItem())); + } + } + } + + await receiver.SendGenericResponse(new RemoteDataStoreGetAllItemsResponse() + { + Collections = collections + }, token); + } + private RemoteDataStoreItem CreateRemoteItem(IDataStoreItem item) { RemoteDataStoreItem remote = new RemoteDataStoreItem(); diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj index 0a6e57f5d..3d7f11809 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj @@ -511,7 +511,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.DataStore.Editing/CustomControl1.cs b/Software/Visual_Studio/Tango.DataStore.Editing/CustomControl1.cs new file mode 100644 index 000000000..fab0127e8 --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore.Editing/CustomControl1.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.DataStore.Editing +{ + public class CustomControl1 : Control + { + static CustomControl1() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(CustomControl1), new FrameworkPropertyMetadata(typeof(CustomControl1))); + } + } +} diff --git a/Software/Visual_Studio/Tango.DataStore.Editing/DataStoreCollectionModel.cs b/Software/Visual_Studio/Tango.DataStore.Editing/DataStoreCollectionModel.cs new file mode 100644 index 000000000..a5c9ba4a7 --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore.Editing/DataStoreCollectionModel.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core; + +namespace Tango.DataStore.Editing +{ + public class DataStoreCollectionModel : ExtendedObject + { + public String Name { get; set; } + public ObservableCollection Items { get; set; } + + public DataStoreCollectionModel() + { + Items = new ObservableCollection(); + } + } +} diff --git a/Software/Visual_Studio/Tango.DataStore.Editing/DataStoreItemModel.cs b/Software/Visual_Studio/Tango.DataStore.Editing/DataStoreItemModel.cs new file mode 100644 index 000000000..36dd44f22 --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore.Editing/DataStoreItemModel.cs @@ -0,0 +1,89 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core; + +namespace Tango.DataStore.Editing +{ + public class DataStoreItemModel : ExtendedObject, IDataStoreItem + { + public IDataStoreItem GlobalItem { get; set; } + + private Object _value; + public Object Value + { + get { return _value; } + set { _value = value; RaisePropertyChangedAuto(); EditingValue = value; } + } + + private Object _editingValue; + public Object EditingValue + { + get { return _editingValue; } + set { _editingValue = value; RaisePropertyChangedAuto(); RaisePropertyChanged(nameof(HasDifference)); } + } + + public bool HasDifference + { + get { return EditingValue != Value || (IsGlobal && GlobalItem.Value != Value); } + } + + public string Guid { get; set; } + public string Key { get; set; } + public DataType Type { get; set; } + public DateTime Date { get; set; } + public bool IsGlobal { get; set; } + public bool IsSynchronized { get; set; } + + public void Apply() + { + Value = EditingValue; + } + + public static DataStoreItemModel FromLocalDataStoreItem(IDataStoreItem local, IDataStoreItem globalItem) + { + DataStoreItemModel model = new DataStoreItemModel(); + + model.Value = local.Value; + model.Guid = local.Guid; + model.Key = local.Key; + model.Type = local.Type; + model.Date = local.Date; + model.IsGlobal = false; + model.IsSynchronized = local.IsSynchronized; + + model.GlobalItem = globalItem; + + return model; + } + + public static DataStoreItemModel FromGlobalDataStoreItem(IDataStoreItem global) + { + DataStoreItemModel model = new DataStoreItemModel(); + + model.GlobalItem = global; + model.Guid = global.Guid; + model.Key = global.Key; + model.Type = global.Type; + model.Date = global.Date; + model.IsGlobal = true; + model.IsSynchronized = global.IsSynchronized; + + return model; + } + + public override string ToString() + { + if (!IsGlobal) + { + return DataStoreHelper.FormatDataStoreItem(this); + } + else + { + return null; + } + } + } +} diff --git a/Software/Visual_Studio/Tango.DataStore.Editing/DataStoreModel.cs b/Software/Visual_Studio/Tango.DataStore.Editing/DataStoreModel.cs new file mode 100644 index 000000000..a68cc0af9 --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore.Editing/DataStoreModel.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core; + +namespace Tango.DataStore.Editing +{ + public class DataStoreModel : ExtendedObject + { + public ObservableCollection Collections { get; set; } + + public DataStoreModel() + { + Collections = new ObservableCollection(); + } + } +} diff --git a/Software/Visual_Studio/Tango.DataStore.Editing/Properties/AssemblyInfo.cs b/Software/Visual_Studio/Tango.DataStore.Editing/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..9f04af8ea --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore.Editing/Properties/AssemblyInfo.cs @@ -0,0 +1,55 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +// 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.Editing")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Tango.DataStore.Editing")] +[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)] + +//In order to begin building localizable applications, set +//CultureYouAreCodingWith in your .csproj file +//inside a . For example, if you are using US english +//in your source files, set the to en-US. Then uncomment +//the NeutralResourceLanguage attribute below. Update the "en-US" in +//the line below to match the UICulture setting in the project file. + +//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + +[assembly:ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] + + +// 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/Tango.DataStore.Editing/Properties/Resources.Designer.cs b/Software/Visual_Studio/Tango.DataStore.Editing/Properties/Resources.Designer.cs new file mode 100644 index 000000000..c23f8f4eb --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore.Editing/Properties/Resources.Designer.cs @@ -0,0 +1,62 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Tango.DataStore.Editing.Properties { + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if ((resourceMan == null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Tango.DataStore.Editing.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/Software/Visual_Studio/Tango.DataStore.Editing/Properties/Resources.resx b/Software/Visual_Studio/Tango.DataStore.Editing/Properties/Resources.resx new file mode 100644 index 000000000..af7dbebba --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore.Editing/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.DataStore.Editing/Properties/Settings.Designer.cs b/Software/Visual_Studio/Tango.DataStore.Editing/Properties/Settings.Designer.cs new file mode 100644 index 000000000..28f49dcd4 --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore.Editing/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Tango.DataStore.Editing.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/Software/Visual_Studio/Tango.DataStore.Editing/Properties/Settings.settings b/Software/Visual_Studio/Tango.DataStore.Editing/Properties/Settings.settings new file mode 100644 index 000000000..033d7a5e9 --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore.Editing/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.DataStore.Editing/Tango.DataStore.Editing.csproj b/Software/Visual_Studio/Tango.DataStore.Editing/Tango.DataStore.Editing.csproj new file mode 100644 index 000000000..98df18ac3 --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore.Editing/Tango.DataStore.Editing.csproj @@ -0,0 +1,100 @@ + + + + + Debug + AnyCPU + {EE088FF7-04D1-41FB-9D6A-CEDEEE7A7B9C} + library + Tango.DataStore.Editing + Tango.DataStore.Editing + v4.6.1 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + 4.0 + + + + + + + + MSBuild:Compile + Designer + + + Code + + + + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + {a34ee0f0-649d-41c8-8489-b6f1cc6924ee} + Tango.Core + + + {e0364dfa-0721-4637-9d32-9d22aac109d6} + Tango.DataStore + + + {8491d07b-c1f6-4b62-a412-41b9fd2d6538} + Tango.SharedUI + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.DataStore.Editing/Themes/Generic.xaml b/Software/Visual_Studio/Tango.DataStore.Editing/Themes/Generic.xaml new file mode 100644 index 000000000..795842292 --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore.Editing/Themes/Generic.xaml @@ -0,0 +1,18 @@ + + + diff --git a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreCollection.cs b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreCollection.cs new file mode 100644 index 000000000..e4453fafc --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreCollection.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore.Remote +{ + public class RemoteDataStoreCollection + { + public String Name { get; set; } + public List Items { get; set; } + + public RemoteDataStoreCollection() + { + Items = new List(); + } + } +} diff --git a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetAllItemsRequest.cs b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetAllItemsRequest.cs new file mode 100644 index 000000000..a285cd5c1 --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetAllItemsRequest.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore.Remote +{ + public class RemoteDataStoreGetAllItemsRequest + { + } +} diff --git a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetAllItemsResponse.cs b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetAllItemsResponse.cs new file mode 100644 index 000000000..3afb22c1e --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetAllItemsResponse.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore.Remote +{ + public class RemoteDataStoreGetAllItemsResponse + { + public List Collections { get; set; } + + public RemoteDataStoreGetAllItemsResponse() + { + Collections = new List(); + } + } +} diff --git a/Software/Visual_Studio/Tango.DataStore.Remote/Tango.DataStore.Remote.csproj b/Software/Visual_Studio/Tango.DataStore.Remote/Tango.DataStore.Remote.csproj index 4d0d04054..c01607af0 100644 --- a/Software/Visual_Studio/Tango.DataStore.Remote/Tango.DataStore.Remote.csproj +++ b/Software/Visual_Studio/Tango.DataStore.Remote/Tango.DataStore.Remote.csproj @@ -50,12 +50,15 @@ GlobalVersionInfo.cs + + + diff --git a/Software/Visual_Studio/Tango.DataStore/DataStoreHelper.cs b/Software/Visual_Studio/Tango.DataStore/DataStoreHelper.cs index 96a905120..7167648b4 100644 --- a/Software/Visual_Studio/Tango.DataStore/DataStoreHelper.cs +++ b/Software/Visual_Studio/Tango.DataStore/DataStoreHelper.cs @@ -95,11 +95,11 @@ namespace Tango.DataStore } else if (item.Type == DataType.Proto) { - return (item.Value as DataStoreProtoObject).Message.ToJsonString(); + return (item.Value as DataStoreProtoObject).Message.ToString(); } else { - return $"{item.Key}: {item.Value}"; + return item.Value.ToStringSafe(); } } } diff --git a/Software/Visual_Studio/Tango.sln b/Software/Visual_Studio/Tango.sln index 893e7f945..64f19da67 100644 --- a/Software/Visual_Studio/Tango.sln +++ b/Software/Visual_Studio/Tango.sln @@ -429,6 +429,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.DataStore.EF", "Tango EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.FSE.MachineConfiguration", "FSE\Modules\Tango.FSE.MachineConfiguration\Tango.FSE.MachineConfiguration.csproj", "{15BCB5BB-731E-4E2D-AA28-75485050A8DC}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.DataStore.Editing", "Tango.DataStore.Editing\Tango.DataStore.Editing.csproj", "{EE088FF7-04D1-41FB-9D6A-CEDEEE7A7B9C}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -4056,6 +4058,26 @@ Global {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Release|x64.Build.0 = Release|Any CPU {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Release|x86.ActiveCfg = Release|Any CPU {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Release|x86.Build.0 = Release|Any CPU + {EE088FF7-04D1-41FB-9D6A-CEDEEE7A7B9C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EE088FF7-04D1-41FB-9D6A-CEDEEE7A7B9C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EE088FF7-04D1-41FB-9D6A-CEDEEE7A7B9C}.Debug|ARM.ActiveCfg = Debug|Any CPU + {EE088FF7-04D1-41FB-9D6A-CEDEEE7A7B9C}.Debug|ARM.Build.0 = Debug|Any CPU + {EE088FF7-04D1-41FB-9D6A-CEDEEE7A7B9C}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {EE088FF7-04D1-41FB-9D6A-CEDEEE7A7B9C}.Debug|ARM64.Build.0 = Debug|Any CPU + {EE088FF7-04D1-41FB-9D6A-CEDEEE7A7B9C}.Debug|x64.ActiveCfg = Debug|Any CPU + {EE088FF7-04D1-41FB-9D6A-CEDEEE7A7B9C}.Debug|x64.Build.0 = Debug|Any CPU + {EE088FF7-04D1-41FB-9D6A-CEDEEE7A7B9C}.Debug|x86.ActiveCfg = Debug|Any CPU + {EE088FF7-04D1-41FB-9D6A-CEDEEE7A7B9C}.Debug|x86.Build.0 = Debug|Any CPU + {EE088FF7-04D1-41FB-9D6A-CEDEEE7A7B9C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EE088FF7-04D1-41FB-9D6A-CEDEEE7A7B9C}.Release|Any CPU.Build.0 = Release|Any CPU + {EE088FF7-04D1-41FB-9D6A-CEDEEE7A7B9C}.Release|ARM.ActiveCfg = Release|Any CPU + {EE088FF7-04D1-41FB-9D6A-CEDEEE7A7B9C}.Release|ARM.Build.0 = Release|Any CPU + {EE088FF7-04D1-41FB-9D6A-CEDEEE7A7B9C}.Release|ARM64.ActiveCfg = Release|Any CPU + {EE088FF7-04D1-41FB-9D6A-CEDEEE7A7B9C}.Release|ARM64.Build.0 = Release|Any CPU + {EE088FF7-04D1-41FB-9D6A-CEDEEE7A7B9C}.Release|x64.ActiveCfg = Release|Any CPU + {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 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -4202,12 +4224,12 @@ Global {15BCB5BB-731E-4E2D-AA28-75485050A8DC} = {4EE6DBA1-71BC-49E2-8DC7-266487E61050} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution - 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 + 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} EndGlobalSection EndGlobal -- cgit v1.3.1 From 14e4bd850fa6730eecd7d15bd7044f364b41c986 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Thu, 12 Nov 2020 20:38:57 +0200 Subject: Working on data store view. --- Software/PMR/Messages/Common/MessageType.proto | 2 + .../DataStore/DataStoreItemModifiedRequest.proto | 10 + .../DataStore/DataStoreItemModifiedResponse.proto | 9 + .../Tango.FSE.Firmware_0qifchtm_wpftmp.csproj | 203 ++++++++++++++++ .../Converters/DataStoreValueToStringConverter.cs | 2 +- .../Dialogs/DataStoreItemEditDialogView.xaml | 53 +++++ .../Dialogs/DataStoreItemEditDialogView.xaml.cs | 28 +++ .../Dialogs/DataStoreItemEditDialogViewVM.cs | 173 ++++++++++++++ .../Images/data_collection.png | Bin 0 -> 1963 bytes .../Tango.FSE.MachineConfiguration.csproj | 11 + .../ViewModels/ConfigurationViewVM.cs | 2 + .../ViewModels/DataStoreViewVM.cs | 216 +++++++++++++++-- .../Views/ConfigurationView.xaml | 10 +- .../Views/DataStoreView.xaml | 258 ++++++++++++++++----- .../Views/MachineView.xaml | 6 +- .../Tango.FSE.Procedures/Themes/Generic.xaml | 1 - .../FSE/Tango.FSE.BL/Services/DataStoreService.cs | 2 +- .../Services/MachineConfigurationService.cs | 2 + .../FSE/Tango.FSE.BL/Services/MachinesService.cs | 28 ++- .../DataStore/IDataStoreProvider.cs | 1 + .../Notifications/INotificationProvider.cs | 2 +- .../Tango.FSE.Common/Notifications/InputBoxVM.cs | 38 ++- .../FSE/Tango.FSE.Common/Resources/Styles.xaml | 2 +- .../Controls/NotificationsControl.xaml | 12 +- .../DataStore/DefaultDataStoreProvider.cs | 140 +++++++++++ .../Notifications/DefaultNotificationProvider.cs | 4 +- .../DataStore/DefaultDataStoreService.cs | 75 +++++- .../PPC/Tango.PPC.Common/Tango.PPC.Common.csproj | 6 +- .../Connectivity/DefaultConnectivityProvider.cs | 2 +- .../Tango.BL/DTO/DataStoreItemDTOBase.cs | 8 + .../Tango.BL/Entities/DataStoreItemBase.cs | 38 +++ .../ExtensionMethods/StringExtensions.cs | 5 + .../Tango.DAL.Remote/DB/DATA_STORE_ITEMS.cs | 1 + .../Tango.DAL.Remote/DB/RemoteADO.edmx | 3 + .../Tango.DAL.Remote/DB/RemoteADO.edmx.diagram | 146 ++++++------ .../DataStoreCollectionModel.cs | 1 + .../Tango.DataStore.Editing/DataStoreItemModel.cs | 53 ++++- .../Tango.DataStore.Editing.csproj | 6 + .../UpdateDataStoreRequest.cs | 21 ++ .../UpdateDataStoreResponse.cs | 13 ++ .../Tango.DataStore/DataStoreHelper.cs | 72 +++++- .../Tango.DataStore/DataStoreProtoObject.cs | 6 + .../Visual_Studio/Tango.PMR/Common/MessageType.cs | 9 +- .../DataStore/DataStoreItemModifiedRequest.cs | 188 +++++++++++++++ .../DataStore/DataStoreItemModifiedResponse.cs | 131 +++++++++++ Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj | 4 +- .../Tango.SharedUI/Controls/SearchComboBox.cs | 24 +- .../Converters/EnumToItemsSourceConverter.cs | 13 +- .../Controllers/PPCController.cs | 11 +- .../Properties/AssemblyInfo.cs | 2 +- 50 files changed, 1852 insertions(+), 201 deletions(-) create mode 100644 Software/PMR/Messages/DataStore/DataStoreItemModifiedRequest.proto create mode 100644 Software/PMR/Messages/DataStore/DataStoreItemModifiedResponse.proto create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.Firmware/Tango.FSE.Firmware_0qifchtm_wpftmp.csproj create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Dialogs/DataStoreItemEditDialogView.xaml create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Dialogs/DataStoreItemEditDialogView.xaml.cs create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Dialogs/DataStoreItemEditDialogViewVM.cs create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Images/data_collection.png create mode 100644 Software/Visual_Studio/Tango.DataStore.Editing/UpdateDataStoreRequest.cs create mode 100644 Software/Visual_Studio/Tango.DataStore.Editing/UpdateDataStoreResponse.cs create mode 100644 Software/Visual_Studio/Tango.PMR/DataStore/DataStoreItemModifiedRequest.cs create mode 100644 Software/Visual_Studio/Tango.PMR/DataStore/DataStoreItemModifiedResponse.cs (limited to 'Software/Visual_Studio') diff --git a/Software/PMR/Messages/Common/MessageType.proto b/Software/PMR/Messages/Common/MessageType.proto index e8ad94156..4fe8a5e6f 100644 --- a/Software/PMR/Messages/Common/MessageType.proto +++ b/Software/PMR/Messages/Common/MessageType.proto @@ -313,4 +313,6 @@ enum MessageType PutDataStoreItemResponse = 13001; GetDataStoreItemRequest = 13002; GetDataStoreItemResponse = 13003; + DataStoreItemModifiedRequest = 13004; + DataStoreItemModifiedResponse = 13005; } diff --git a/Software/PMR/Messages/DataStore/DataStoreItemModifiedRequest.proto b/Software/PMR/Messages/DataStore/DataStoreItemModifiedRequest.proto new file mode 100644 index 000000000..c86d9e016 --- /dev/null +++ b/Software/PMR/Messages/DataStore/DataStoreItemModifiedRequest.proto @@ -0,0 +1,10 @@ +syntax = "proto3"; + +package Tango.PMR.DataStore; +option java_package = "com.twine.tango.pmr.datastore"; + +message DataStoreItemModifiedRequest +{ + string Collection = 1; + string Key = 2; +} \ No newline at end of file diff --git a/Software/PMR/Messages/DataStore/DataStoreItemModifiedResponse.proto b/Software/PMR/Messages/DataStore/DataStoreItemModifiedResponse.proto new file mode 100644 index 000000000..d6a597fb5 --- /dev/null +++ b/Software/PMR/Messages/DataStore/DataStoreItemModifiedResponse.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; + +package Tango.PMR.DataStore; +option java_package = "com.twine.tango.pmr.datastore"; + +message DataStoreItemModifiedResponse +{ + +} \ No newline at end of file diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Firmware/Tango.FSE.Firmware_0qifchtm_wpftmp.csproj b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Firmware/Tango.FSE.Firmware_0qifchtm_wpftmp.csproj new file mode 100644 index 000000000..8708fb9b0 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Firmware/Tango.FSE.Firmware_0qifchtm_wpftmp.csproj @@ -0,0 +1,203 @@ + + + + + Debug + AnyCPU + {7CB96D74-8B71-4A81-B4E1-6DE7BFCA6174} + library + Tango.FSE.Firmware + Tango.FSE.Firmware + v4.6.1 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + true + + + + + true + full + false + ..\..\..\Build\FSE\Debug\ + DEBUG;TRACE + prompt + 4 + Off + + + pdbonly + true + ..\..\..\Build\FSE\Release\ + TRACE + prompt + 4 + + + + + + + FirmwareUpdateView.xaml + + + + + + + + + + + FileSystemView.xaml + + + LogsView.xaml + + + MainView.xaml + + + UpdatesView.xaml + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + {208C8BD8-72C6-4E3C-ACAA-351091A2ACC7} + Tango.PPC.Shared + + + {bb2abb74-ba58-4812-83aa-ec8171f42df4} + Tango.AutoComplete + + + {f441feee-322a-4943-b566-110e12fd3b72} + Tango.BL + + + {a34ee0f0-649d-41c8-8489-b6f1cc6924ee} + Tango.Core + + + {c6ebbbbe-2123-44dc-aef7-a0d47d736ac0} + Tango.FileSystem + + + {4206ac58-3b57-4699-8835-90bf6db01a61} + Tango.Integration + + + {bc932dbd-7cdb-488c-99e4-f02cf441f55e} + Tango.Logging + + + {e4927038-348d-4295-aaf4-861c58cb3943} + Tango.PMR + + + {d8f1ad85-526a-4f50-b6dc-d437af63d8d8} + Tango.Settings + + + {8491d07b-c1f6-4b62-a412-41b9fd2d6538} + Tango.SharedUI + + + {74e700b0-1156-4126-be40-ee450d3c3026} + Tango.Transport + + + {834c81c3-09b5-45d7-be12-e7d1e6655a7c} + Tango.FSE.BL + + + {bc37cccb-7392-4f78-8d1c-e9629e6e046e} + Tango.FSE.Common + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Converters/DataStoreValueToStringConverter.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Converters/DataStoreValueToStringConverter.cs index 6b3c8e28c..4acf7fd8e 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Converters/DataStoreValueToStringConverter.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Converters/DataStoreValueToStringConverter.cs @@ -17,7 +17,7 @@ namespace Tango.FSE.MachineConfiguration.Converters { if (item != null) { - return DataStoreHelper.FormatDataStoreItem(item); + return DataStoreHelper.FormatDataStoreItem(item).ToOneLine().Ellipsis(100); } } diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Dialogs/DataStoreItemEditDialogView.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Dialogs/DataStoreItemEditDialogView.xaml new file mode 100644 index 000000000..2fd3b9cdf --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Dialogs/DataStoreItemEditDialogView.xaml @@ -0,0 +1,53 @@ + + + + + + + + + + + + Data Type + + + + + + + + + Message Type + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Dialogs/DataStoreItemEditDialogView.xaml.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Dialogs/DataStoreItemEditDialogView.xaml.cs new file mode 100644 index 000000000..b0f741759 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Dialogs/DataStoreItemEditDialogView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.FSE.MachineConfiguration.Dialogs +{ + /// + /// Interaction logic for DataStoreItemEditDialogView.xaml + /// + public partial class DataStoreItemEditDialogView : UserControl + { + public DataStoreItemEditDialogView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Dialogs/DataStoreItemEditDialogViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Dialogs/DataStoreItemEditDialogViewVM.cs new file mode 100644 index 000000000..29ec03942 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Dialogs/DataStoreItemEditDialogViewVM.cs @@ -0,0 +1,173 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.Commands; +using Tango.Core.DI; +using Tango.Core.ExtensionMethods; +using Tango.Core.Helpers; +using Tango.DataStore; +using Tango.DataStore.Editing; +using Tango.FSE.Common; +using Tango.FSE.Common.Storage; +using Tango.PMR; +using Tango.PMR.Common; + +namespace Tango.FSE.MachineConfiguration.Dialogs +{ + public class DataStoreItemEditDialogViewVM : FSEDialogViewVM + { + private const int MAX_FILE_SIZE_KB = 100; + + [TangoInject] + private IStorageProvider StorageProvider { get; set; } + + [TangoInject] + private Common.Notifications.INotificationProvider NotificationProvider { get; set; } + + private DataStoreItemModel _item; + public DataStoreItemModel Item + { + get { return _item; } + set + { + _item = value; + RaisePropertyChangedAuto(); + + if (_item.IsGlobal) + { + Value = _item.GlobalItem.Value; + } + else + { + Value = _item.Value; + } + + Type = _item.Type; + + if (Type == DataType.Proto) + { + ProtoMessageType = (Value as DataStoreProtoObject).MessageType; + } + + if (_item.IsGlobal) + { + EditingValue = _item.GlobalItem.ToString(); + } + else + { + EditingValue = _item.ToString(); + } + } + } + + public bool EnableTypeChange { get; set; } + + private Object _value; + public Object Value + { + get { return _value; } + set { _value = value; RaisePropertyChangedAuto(); } + } + + private DataType _type; + public DataType Type + { + get { return _type; } + set { _type = value; RaisePropertyChangedAuto(); OnEditingValueChanged(); } + } + + private MessageType _protoMessageType; + public MessageType ProtoMessageType + { + get { return _protoMessageType; } + set { _protoMessageType = value; RaisePropertyChangedAuto(); OnEditingValueChanged(); } + } + + private String _editingValue; + public String EditingValue + { + get { return _editingValue; } + set { _editingValue = value; RaisePropertyChangedAuto(); OnEditingValueChanged(); } + } + + private String _error; + public String Error + { + get { return _error; } + set { _error = value; RaisePropertyChangedAuto(); RaisePropertyChanged(nameof(HasError)); InvalidateRelayCommands(); } + } + + public bool HasError + { + get { return Error != null; } + } + + public RelayCommand LoadFileCommand { get; set; } + + public RelayCommand InitProtoCommand { get; set; } + + public DataStoreItemEditDialogViewVM() + { + EnableTypeChange = true; + LoadFileCommand = new RelayCommand(LoadFile); + InitProtoCommand = new RelayCommand(InitProto); + TangoIOC.Default.Inject(this); + } + + private void InitProto() + { + if (Type == DataType.Proto) + { + var type = MessageFactory.GetPMRTypeFromMessageType(ProtoMessageType); + var instance = Activator.CreateInstance(type); + EditingValue = instance.ToJsonString(); + } + } + + private async void LoadFile() + { + if (Type == DataType.Bytes) + { + var result = await StorageProvider.OpenFile("Load a file"); + if (result) + { + if ((new FileInfo(result.SelectedItem).Length / 1024) > MAX_FILE_SIZE_KB) + { + await NotificationProvider.ShowError($"The selected file size exceeds the maximum {MAX_FILE_SIZE_KB}kb allowed."); + return; + } + + var bytes = File.ReadAllBytes(result.SelectedItem); + Value = bytes; + _editingValue = DataStoreHelper.GetByteArrayHexString(bytes); + RaisePropertyChanged(nameof(EditingValue)); + } + } + } + + private void OnEditingValueChanged() + { + if (EditingValue != null) + { + try + { + Value = DataStoreHelper.ParseDataStoreValue(Type, EditingValue, ProtoMessageType); + Error = null; + } + catch (Exception ex) + { + Error = ex.Message; + } + } + } + + protected override bool CanOK() + { + return base.CanOK() && !HasError; + } + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Images/data_collection.png b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Images/data_collection.png new file mode 100644 index 000000000..95163a226 Binary files /dev/null and b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Images/data_collection.png differ diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Tango.FSE.MachineConfiguration.csproj b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Tango.FSE.MachineConfiguration.csproj index af67b0d74..2e876db16 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Tango.FSE.MachineConfiguration.csproj +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Tango.FSE.MachineConfiguration.csproj @@ -80,6 +80,10 @@ + + DataStoreItemEditDialogView.xaml + + @@ -198,6 +202,10 @@ MSBuild:Compile Designer + + Designer + MSBuild:Compile + MSBuild:Compile Designer @@ -222,6 +230,9 @@ + + + diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/ConfigurationViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/ConfigurationViewVM.cs index 63e3f22d9..61eef2bdc 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/ConfigurationViewVM.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/ConfigurationViewVM.cs @@ -44,6 +44,8 @@ namespace Tango.FSE.MachineConfiguration.ViewModels using (NotificationProvider.PushTaskItem("Loading machine configuration...")) { EditingComposition = msg.EditingComposition; + EditingComposition.Machine.ForceVersionUpdateChanged += (x, value) => { if (value) EditingComposition.Machine.SuspendVersionUpdate = false; }; + EditingComposition.Machine.SuspendVersionUpdateChanged += (x, value) => { if (value) EditingComposition.Machine.ForceVersionUpdate = false; }; } } diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/DataStoreViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/DataStoreViewVM.cs index 4a75c137b..76aee9cde 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/DataStoreViewVM.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/DataStoreViewVM.cs @@ -1,12 +1,17 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Windows.Data; +using Tango.Core.Commands; using Tango.Core.DI; +using Tango.DataStore; using Tango.DataStore.Editing; using Tango.FSE.Common; using Tango.FSE.Common.DataStore; +using Tango.FSE.MachineConfiguration.Dialogs; using Tango.FSE.MachineConfiguration.Messages; using static Tango.SharedUI.Controls.NavigationControl; @@ -15,6 +20,8 @@ namespace Tango.FSE.MachineConfiguration.ViewModels public class DataStoreViewVM : FSEViewModel, INavigationViewModel { private String machineGuid; + private ICollectionView _selectedCollectionView; + private ICollectionView _collectionsView; [TangoInject] private IDataStoreProvider DataStoreProvider { get; set; } @@ -30,7 +37,7 @@ namespace Tango.FSE.MachineConfiguration.ViewModels public DataStoreCollectionModel SelectedCollection { get { return _selectedCollection; } - set { _selectedCollection = value; RaisePropertyChangedAuto(); } + set { _selectedCollection = value; RaisePropertyChangedAuto(); OnSelectedCollectionChanged(); } } private DataStoreItemModel _selectedItem; @@ -40,16 +47,134 @@ namespace Tango.FSE.MachineConfiguration.ViewModels set { _selectedItem = value; RaisePropertyChangedAuto(); } } - private bool _isLoading; - public bool IsLoading + private String _filter; + public String Filter { - get { return _isLoading; } - set { _isLoading = value; RaisePropertyChangedAuto(); } + get { return _filter; } + set { _filter = value; RaisePropertyChangedAuto(); _selectedCollectionView?.Refresh(); } } + public RelayCommand RemoveItemCommand { get; set; } + public RelayCommand RemoveCollectionCommand { get; set; } + public RelayCommand AddItemCommand { get; set; } + public RelayCommand AddCollectionCommand { get; set; } + public RelayCommand EditItemCommand { get; set; } + public RelayCommand SaveCommand { get; set; } + public RelayCommand ReloadCommand { get; set; } + public DataStoreViewVM() { RegisterForMessage(OnEditingCompositionLoaded); + RemoveItemCommand = new RelayCommand(RemoveItem); + RemoveCollectionCommand = new RelayCommand(RemoveCollection); + AddItemCommand = new RelayCommand(AddItem); + AddCollectionCommand = new RelayCommand(AddCollection); + EditItemCommand = new RelayCommand(EditItem); + SaveCommand = new RelayCommand(SaveModel); + ReloadCommand = new RelayCommand(ReloadDataStore); + } + + private async void ReloadDataStore() + { + if (DataStore != null) + { + if (DataStore.Collections.SelectMany(x => x.Items).Any(x => x.HasDifference)) + { + if (!await NotificationProvider.ShowWarningQuestion("Reloading the data store will discard all the current changes. Are you sure?", "RELOAD")) + { + return; + } + } + } + + await LoadDataStore(); + } + + private async void EditItem(DataStoreItemModel item) + { + var vm = await NotificationProvider.ShowDialog(new DataStoreItemEditDialogViewVM() { Item = item, EnableTypeChange = !item.IsGlobal }); + + if (vm.DialogResult) + { + item.IsDeleted = false; + item.IsGlobal = false; + item.Type = vm.Type; + item.Value = vm.Value; + } + } + + private async void AddCollection() + { + var result = await NotificationProvider.ShowInputBox("Add Collection", "Please enter the collection name", MaterialDesignThemes.Wpf.PackIconKind.Collection, null, null, 20, null, null, (input) => + { + if (DataStore.Collections.ToList().Exists(x => x.Name.ToLower() == input.ToLower())) + { + return "The specified collection already exists."; + } + + return null; + }); + + if (result.Confirmed) + { + if (DataStore.Collections.ToList().Exists(x => x.Name.ToLower() == result.Input.ToLower())) + { + await NotificationProvider.ShowError("The specified collection already exists."); + AddCollection(); + return; + } + + DataStore.Collections.Add(new DataStoreCollectionModel() + { + Name = result.Input + }); + + SelectedCollection = DataStore.Collections.Last(); + } + } + + private async void AddItem() + { + var result = await NotificationProvider.ShowInputBox("Add Item", "Please enter the item key", MaterialDesignThemes.Wpf.PackIconKind.KeyAdd, null, null, 20, null, null, (input) => + { + if (SelectedCollection.Items.ToList().Exists(x => x.Key.ToLower() == input.ToLower())) + { + return "The specified key already exists in the collection."; + } + + return null; + }); + + if (result.Confirmed) + { + if (SelectedCollection.Items.ToList().Exists(x => x.Key == result.Input)) + { + await NotificationProvider.ShowError("The specified key already exists in the collection."); + AddItem(); + return; + } + + SelectedCollection.Items.Add(new DataStoreItemModel() + { + Date = DateTime.UtcNow, + Guid = Guid.NewGuid().ToString(), + Key = result.Input, + Type = DataType.Int32, + Value = 10 + }); + } + } + + private void RemoveCollection(DataStoreCollectionModel collection) + { + collection.IsDeleted = true; + _collectionsView?.Refresh(); + } + + private void RemoveItem(DataStoreItemModel item) + { + item.IsDeleted = true; + _selectedCollectionView.Refresh(); } private void OnEditingCompositionLoaded(EditingCompositionLoadedMessage obj) @@ -58,28 +183,87 @@ namespace Tango.FSE.MachineConfiguration.ViewModels machineGuid = obj.EditingComposition.Machine.Guid; } - public async override void OnNavigatedTo() + private void OnSelectedCollectionChanged() { - base.OnNavigatedTo(); + if (SelectedCollection != null) + { + _selectedCollectionView = CollectionViewSource.GetDefaultView(SelectedCollection.Items); + _selectedCollectionView.Filter = (x) => FilterItems(x as DataStoreItemModel); + _selectedCollectionView.Refresh(); + } + } - if (DataStore == null) + private bool FilterItems(DataStoreItemModel itemModel) + { + return (!itemModel.IsDeleted || itemModel.GlobalItem != null) && (String.IsNullOrWhiteSpace(Filter) || itemModel.Key.ToLower().Contains(Filter.ToLower())); + } + + private async void SaveModel() + { + try { - try + using (NotificationProvider.PushTaskItem("Updating data store...")) { - IsLoading = true; - IsFree = false; - DataStore = await DataStoreProvider.GetDataStoreModel(machineGuid); + await DataStoreProvider.UpdateDataStoreModel(DataStore, machineGuid); } - catch (Exception ex) + + if (MachineProvider.IsPPCAvailable) { - LogManager.Log(ex, "Error loading data store."); + await NotificationProvider.ShowSuccess("The connected machine is now synchronized with the data store."); } - finally + else { - IsLoading = false; + await NotificationProvider.ShowInfo("Data store save successfully.\nThe machine will be updated on the next synchronization pass."); + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Error saving data store."); + await NotificationProvider.ShowError($"Error occurred while trying to save the data store.\n{ex.FlattenMessage()}"); + return; + } + + await LoadDataStore(); + } + + private async Task LoadDataStore() + { + try + { + using (NotificationProvider.PushTaskItem("Loading data store...")) + { + IsFree = false; + var dataStore = await DataStoreProvider.GetDataStoreModel(machineGuid); + + _collectionsView = CollectionViewSource.GetDefaultView(dataStore.Collections); + _collectionsView.Filter = (x) => { return !(x as DataStoreCollectionModel).IsDeleted; }; + _collectionsView.Refresh(); + + DataStore = dataStore; + SelectedCollection = DataStore.Collections.FirstOrDefault(); + IsFree = true; } } + catch (Exception ex) + { + LogManager.Log(ex, "Error loading data store."); + if (await NotificationProvider.ShowWarningQuestion($"Error occurred while trying to load the data store.\n{ex.FlattenMessage()}", "RETRY", "CANCEL")) + { + await LoadDataStore(); + return; + } + } + } + + public async override void OnNavigatedTo() + { + base.OnNavigatedTo(); + + if (DataStore == null) + { + await LoadDataStore(); + } } } } diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/ConfigurationView.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/ConfigurationView.xaml index 9c8b2d878..ed24c3a67 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/ConfigurationView.xaml +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/ConfigurationView.xaml @@ -114,18 +114,18 @@ - - - Perform Firmware Upgrade + + + Disable Firmware Upgrade - + Force Version Update - + Suspend Version Update diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/DataStoreView.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/DataStoreView.xaml index f078efcee..f4029e30c 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/DataStoreView.xaml +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/DataStoreView.xaml @@ -4,7 +4,9 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:Tango.FSE.MachineConfiguration.Views" + xmlns:helpers="clr-namespace:Tango.SharedUI.Helpers;assembly=Tango.SharedUI" xmlns:global="clr-namespace:Tango.FSE.MachineConfiguration" + xmlns:controls="clr-namespace:Tango.FSE.Common.Controls;assembly=Tango.FSE.Common" xmlns:vm="clr-namespace:Tango.FSE.MachineConfiguration.ViewModels" xmlns:material="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:commonControls="clr-namespace:Tango.FSE.Common.Controls;assembly=Tango.FSE.Common" @@ -16,61 +18,213 @@ - - - - - - + + + + + + + + + The data store contains global and local (machine) configuration and calibration parameters. + + Updating the data store parameters will take effect on the next machine cloud synchronization pass. + + If this is the currently connected machine, updating the data store will take effect immediately. + + + + + + + + + + + + Machine is connected, updating the data store will be take effect immediately. + + + + + + + + + + + + + + + + + + + + + + + + + ADD ITEM + + + + + + + + + + + ADD COLLECTION + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/MachineView.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/MachineView.xaml index 9f81f82e4..ca6470db3 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/MachineView.xaml +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/MachineView.xaml @@ -12,14 +12,14 @@ d:DesignHeight="1080" d:DesignWidth="1920" d:DataContext="{d:DesignInstance Type=vm:MachineViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MachineViewVM}" d:DesignStyle="{StaticResource FSE_User_Control_Designer}"> - + diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/Themes/Generic.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/Themes/Generic.xaml index 3917368f2..0e055d730 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/Themes/Generic.xaml +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/Themes/Generic.xaml @@ -635,7 +635,6 @@ - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Dialogs/ExportDialogView.xaml.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Dialogs/ExportDialogView.xaml.cs new file mode 100644 index 000000000..4ee37908c --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Dialogs/ExportDialogView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.FSE.MachineConfiguration.Dialogs +{ + /// + /// Interaction logic for ImportDialogView.xaml + /// + public partial class ExportDialogView : UserControl + { + public ExportDialogView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Dialogs/ExportDialogViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Dialogs/ExportDialogViewVM.cs new file mode 100644 index 000000000..9f605c79e --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Dialogs/ExportDialogViewVM.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.DataStore.Editing; +using Tango.FSE.Common; + +namespace Tango.FSE.MachineConfiguration.Dialogs +{ + public class ExportDialogViewVM : FSEDialogViewVM + { + public DataStoreModel DataStore { get; set; } + + public ExportDialogViewVM() + { + OKText = "EXPORT"; + } + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Dialogs/ImportDialogView.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Dialogs/ImportDialogView.xaml new file mode 100644 index 000000000..5d9653eb4 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Dialogs/ImportDialogView.xaml @@ -0,0 +1,113 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Dialogs/ImportDialogView.xaml.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Dialogs/ImportDialogView.xaml.cs new file mode 100644 index 000000000..bc729601f --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Dialogs/ImportDialogView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.FSE.MachineConfiguration.Dialogs +{ + /// + /// Interaction logic for ImportDialogView.xaml + /// + public partial class ImportDialogView : UserControl + { + public ImportDialogView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Dialogs/ImportDialogViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Dialogs/ImportDialogViewVM.cs new file mode 100644 index 000000000..a4e53e85b --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Dialogs/ImportDialogViewVM.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.DataStore.Editing; +using Tango.FSE.Common; + +namespace Tango.FSE.MachineConfiguration.Dialogs +{ + public class ImportDialogViewVM : FSEDialogViewVM + { + public DataStoreModel DataStore { get; set; } + + public ImportDialogViewVM() + { + OKText = "IMPORT"; + } + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Models/CsvModel.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Models/CsvModel.cs new file mode 100644 index 000000000..1e12fda4b --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Models/CsvModel.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.FSE.MachineConfiguration.Models +{ + public class CsvModel + { + public String Date { get; set; } + public String Collection { get; set; } + public String Key { get; set; } + public String Type { get; set; } + public String MessageType { get; set; } + public String Value { get; set; } + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Tango.FSE.MachineConfiguration.csproj b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Tango.FSE.MachineConfiguration.csproj index 2e876db16..db7b7d12d 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Tango.FSE.MachineConfiguration.csproj +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Tango.FSE.MachineConfiguration.csproj @@ -84,7 +84,16 @@ DataStoreItemEditDialogView.xaml + + ExportDialogView.xaml + + + ImportDialogView.xaml + + + + @@ -148,6 +157,10 @@ {a34ee0f0-649d-41c8-8489-b6f1cc6924ee} Tango.Core + + {58e8825f-0c96-449c-b320-1e82b0aa876b} + Tango.CSV + {ee088ff7-04d1-41fb-9d6a-cedeee7a7b9c} Tango.DataStore.Editing @@ -206,6 +219,14 @@ Designer MSBuild:Compile + + MSBuild:Compile + Designer + + + Designer + MSBuild:Compile + MSBuild:Compile Designer @@ -233,6 +254,7 @@ + diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/DataStoreViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/DataStoreViewVM.cs index 76aee9cde..198f1bd9b 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/DataStoreViewVM.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/DataStoreViewVM.cs @@ -7,24 +7,30 @@ using System.Threading.Tasks; using System.Windows.Data; using Tango.Core.Commands; using Tango.Core.DI; +using Tango.CSV; using Tango.DataStore; using Tango.DataStore.Editing; using Tango.FSE.Common; +using Tango.FSE.Common.Connection; using Tango.FSE.Common.DataStore; +using Tango.FSE.Common.Notifications; using Tango.FSE.MachineConfiguration.Dialogs; using Tango.FSE.MachineConfiguration.Messages; +using Tango.FSE.MachineConfiguration.Models; +using static Tango.FSE.BL.Services.MachineConfigurationService; using static Tango.SharedUI.Controls.NavigationControl; namespace Tango.FSE.MachineConfiguration.ViewModels { public class DataStoreViewVM : FSEViewModel, INavigationViewModel { - private String machineGuid; + private String _machineGuid; + private MachineEditingComposition _editingComposition; private ICollectionView _selectedCollectionView; private ICollectionView _collectionsView; [TangoInject] - private IDataStoreProvider DataStoreProvider { get; set; } + public IDataStoreProvider DataStoreProvider { get; set; } private DataStoreModel _dataStore; public DataStoreModel DataStore @@ -54,6 +60,11 @@ namespace Tango.FSE.MachineConfiguration.ViewModels set { _filter = value; RaisePropertyChangedAuto(); _selectedCollectionView?.Refresh(); } } + public bool CanSync + { + get { return MachineProvider.IsPPCAvailable && MachineProvider.Machine != null && _machineGuid == MachineProvider.Machine.Guid; } + } + public RelayCommand RemoveItemCommand { get; set; } public RelayCommand RemoveCollectionCommand { get; set; } public RelayCommand AddItemCommand { get; set; } @@ -61,6 +72,8 @@ namespace Tango.FSE.MachineConfiguration.ViewModels public RelayCommand EditItemCommand { get; set; } public RelayCommand SaveCommand { get; set; } public RelayCommand ReloadCommand { get; set; } + public RelayCommand ImportCommand { get; set; } + public RelayCommand ExportCommand { get; set; } public DataStoreViewVM() { @@ -72,6 +85,15 @@ namespace Tango.FSE.MachineConfiguration.ViewModels EditItemCommand = new RelayCommand(EditItem); SaveCommand = new RelayCommand(SaveModel); ReloadCommand = new RelayCommand(ReloadDataStore); + ExportCommand = new RelayCommand(ExportDataStore); + ImportCommand = new RelayCommand(ImportDataStore); + } + + [TangoInject] + public DataStoreViewVM(IMachineProvider machineProvider) : this() + { + machineProvider.MachineConnected += (_, __) => RaisePropertyChanged(nameof(CanSync)); + machineProvider.MachineDisconnected += (_, __) => RaisePropertyChanged(nameof(CanSync)); } private async void ReloadDataStore() @@ -180,7 +202,8 @@ namespace Tango.FSE.MachineConfiguration.ViewModels private void OnEditingCompositionLoaded(EditingCompositionLoadedMessage obj) { DataStore = null; - machineGuid = obj.EditingComposition.Machine.Guid; + _editingComposition = obj.EditingComposition; + _machineGuid = obj.EditingComposition.Machine.Guid; } private void OnSelectedCollectionChanged() @@ -204,7 +227,7 @@ namespace Tango.FSE.MachineConfiguration.ViewModels { using (NotificationProvider.PushTaskItem("Updating data store...")) { - await DataStoreProvider.UpdateDataStoreModel(DataStore, machineGuid); + await DataStoreProvider.UpdateDataStoreModel(DataStore, _machineGuid); } if (MachineProvider.IsPPCAvailable) @@ -213,7 +236,7 @@ namespace Tango.FSE.MachineConfiguration.ViewModels } else { - await NotificationProvider.ShowInfo("Data store save successfully.\nThe machine will be updated on the next synchronization pass."); + await NotificationProvider.ShowSuccess("Data store saved successfully.\nThe machine will be updated on the next synchronization pass."); } } catch (Exception ex) @@ -233,7 +256,9 @@ namespace Tango.FSE.MachineConfiguration.ViewModels using (NotificationProvider.PushTaskItem("Loading data store...")) { IsFree = false; - var dataStore = await DataStoreProvider.GetDataStoreModel(machineGuid); + RaisePropertyChanged(nameof(CanSync)); + + var dataStore = await DataStoreProvider.GetDataStoreModel(_machineGuid); _collectionsView = CollectionViewSource.GetDefaultView(dataStore.Collections); _collectionsView.Filter = (x) => { return !(x as DataStoreCollectionModel).IsDeleted; }; @@ -265,5 +290,176 @@ namespace Tango.FSE.MachineConfiguration.ViewModels await LoadDataStore(); } } + + private async void ImportDataStore() + { + var result = await StorageProvider.OpenFile("Import data store", "CSV Files|*.csv"); + + if (result) + { + try + { + DataStoreModel model = new DataStoreModel(); + + using (NotificationProvider.PushTaskItem("Analyzing file...")) + { + await Task.Delay(1000); + + await Task.Factory.StartNew(() => + { + var items = CsvFile.Read(new CsvSource(result.SelectedItem)).ToList(); + + foreach (var collection in items.GroupBy(x => x.Collection)) + { + DataStoreCollectionModel collectionModel = new DataStoreCollectionModel(); + + collectionModel = new DataStoreCollectionModel(); + collectionModel.Name = collection.First().Collection; + collectionModel.IsSelected = true; + model.Collections.Add(collectionModel); + + foreach (var item in collection) + { + DataStoreItemModel itemModel = new DataStoreItemModel(); + itemModel.Guid = Guid.NewGuid().ToString(); + itemModel.Key = item.Key; + itemModel.Date = DateTime.Parse(item.Date); + itemModel.IsSelected = true; + + DataType type = (DataType)Enum.Parse(typeof(DataType), item.Type); + itemModel.OriginalType = type; + itemModel.Type = type; + + PMR.Common.MessageType? messageType = null; + if (type == DataType.Proto && item.MessageType.IsNotNullOrEmpty()) + { + messageType = (PMR.Common.MessageType)Enum.Parse(typeof(PMR.Common.MessageType), item.MessageType); + } + + itemModel.OriginalValue = DataStoreHelper.ParseDataStoreValue(type, item.Value, messageType); + itemModel.Value = itemModel.OriginalValue; + + collectionModel.Items.Add(itemModel); + } + } + }); + } + + var vm = await NotificationProvider.ShowDialog(new ImportDialogViewVM() { DataStore = model }); + + if (vm.DialogResult) + { + if (!vm.DataStore.Collections.SelectMany(x => x.Items).Any(x => x.IsSelected)) + { + await NotificationProvider.ShowInfo("No items selected to import."); + return; + } + + foreach (var collection in vm.DataStore.Collections.Where(x => x.Items.Any(y => y.IsSelected))) + { + var collectionModel = DataStore.Collections.FirstOrDefault(x => x.Name == collection.Name); + + if (collectionModel == null) + { + DataStore.Collections.Add(collection); + } + else + { + foreach (var item in collection.Items.Where(x => x.IsSelected)) + { + var itemModel = collectionModel.Items.FirstOrDefault(x => x.Key == item.Key); + + if (itemModel == null) + { + itemModel = new DataStoreItemModel(); + itemModel.Guid = item.Guid; + itemModel.Key = item.Key; + collectionModel.Items.Add(itemModel); + } + + itemModel.Date = DateTime.UtcNow; + itemModel.IsDeleted = false; + itemModel.IsGlobal = false; + itemModel.Type = item.Type; + itemModel.Value = item.Value; + } + } + } + + await NotificationProvider.ShowSuccess("Data store imported successfully."); + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Error importing data store."); + await NotificationProvider.ShowError($"Error importing the data store.\n{ex.FlattenMessage()}"); + } + } + } + + private async void ExportDataStore() + { + var vm = await NotificationProvider.ShowDialog(new ExportDialogViewVM() { DataStore = DataStore }); + + if (vm.DialogResult) + { + if (!vm.DataStore.Collections.SelectMany(x => x.Items).Any(x => x.IsSelected)) + { + await NotificationProvider.ShowInfo("No items selected to export."); + return; + } + + var result = await StorageProvider.SaveFile("Export data store", "CSV Files|*.csv", $"{_editingComposition.Machine.SerialNumber}_datastore_{DateTime.Now.ToFileName()}.csv", ".csv"); + + if (result) + { + try + { + using (NotificationProvider.PushTaskItem("Exporting data store...")) + { + await Task.Delay(1000); + + await Task.Factory.StartNew(() => + { + using (DynamicCsvFile csvFile = new DynamicCsvFile(result.SelectedItem)) + { + csvFile.Columns.Add(new DynamicCsvFileColumn() { Name = "Date" }); + csvFile.Columns.Add(new DynamicCsvFileColumn() { Name = "Collection" }); + csvFile.Columns.Add(new DynamicCsvFileColumn() { Name = "Key" }); + csvFile.Columns.Add(new DynamicCsvFileColumn() { Name = "Type" }); + csvFile.Columns.Add(new DynamicCsvFileColumn() { Name = "MessageType" }); + csvFile.Columns.Add(new DynamicCsvFileColumn() { Name = "Value" }); + + foreach (var collection in DataStore.Collections) + { + foreach (var item in collection.Items.Where(x => x.IsSelected && !x.IsGlobal && x.Value != null)) + { + PMR.Common.MessageType? messageType = null; + + if (item.Type == DataType.Proto) + { + messageType = (item.Value as DataStoreProtoObject).MessageType; + } + + csvFile.Append(item.Date, $"\"{collection.Name}\"", $"\"{item.Key}\"", item.Type, messageType.ToStringSafe(), $"\"{item.FormattedValue.Replace("\"", "\"\"")}\""); + } + } + } + }); + } + + NotificationProvider.PushSnackbarItem(MessageType.Success, "Export Data Store", true, "Data store exported successfully.", TimeSpan.FromSeconds(8), null, () => + { + StorageProvider.ShowInExplorer(result.SelectedItem); + }); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error exporting data store."); + await NotificationProvider.ShowError($"Error exporting the data store.\n{ex.FlattenMessage()}"); + } + } + } + } } } diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/DataStoreView.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/DataStoreView.xaml index f4029e30c..52a140c81 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/DataStoreView.xaml +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/DataStoreView.xaml @@ -22,7 +22,7 @@ - + @@ -34,13 +34,22 @@ + + + + Accept Real-Time Firmware Updates + + + + + - + Machine is connected, updating the data store will be take effect immediately. @@ -67,7 +76,7 @@ + diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore.Editing/UpdateDataStoreRequest.cs b/Software/Visual_Studio/DataStore/Tango.DataStore.Editing/UpdateDataStoreRequest.cs new file mode 100644 index 000000000..dc95ea6ae --- /dev/null +++ b/Software/Visual_Studio/DataStore/Tango.DataStore.Editing/UpdateDataStoreRequest.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.DTO; + +namespace Tango.DataStore.Editing +{ + public class UpdateDataStoreRequest + { + public List ToDelete { get; set; } + public List ToUpsert { get; set; } + + public UpdateDataStoreRequest() + { + ToDelete = new List(); + ToUpsert = new List(); + } + } +} diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore.Editing/UpdateDataStoreResponse.cs b/Software/Visual_Studio/DataStore/Tango.DataStore.Editing/UpdateDataStoreResponse.cs new file mode 100644 index 000000000..697ae341d --- /dev/null +++ b/Software/Visual_Studio/DataStore/Tango.DataStore.Editing/UpdateDataStoreResponse.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore.Editing +{ + public class UpdateDataStoreResponse + { + + } +} diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore.LiteDB/LiteDBDataStoreCollection.cs b/Software/Visual_Studio/DataStore/Tango.DataStore.LiteDB/LiteDBDataStoreCollection.cs new file mode 100644 index 000000000..c76a3b6d9 --- /dev/null +++ b/Software/Visual_Studio/DataStore/Tango.DataStore.LiteDB/LiteDBDataStoreCollection.cs @@ -0,0 +1,113 @@ +using LiteDB; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore.Lite +{ + public class LiteDBDataStoreCollection : IDataStoreCollection + { + private ILiteCollection _collection; + + public string Name { get; private set; } + + public LiteDBDataStoreCollection(ILiteCollection collection) + { + _collection = collection; + } + + public void Put(string key, T value) + { + Put(key, (object)value); + } + + public void Put(string key, object value) + { + Put(key, DataStoreHelper.GetDataType(value), value); + } + + public void Put(string key, DataType type, object value) + { + _collection.Upsert(new LiteDBDataStoreItem() + { + Key = key, + Date = DateTime.UtcNow, + Type = type, + Value = value, + IsSynchronized = false, + }); + } + + public T Get(string key) + { + return (T)Convert.ChangeType(Get(key), typeof(T)); + } + + public T Get(string key, T defaultValue) + { + return (T)Convert.ChangeType(Get(key, defaultValue), typeof(T)); + } + + public object Get(string key) + { + return Get(key, null); + } + + public object Get(string key, object defaultValue) + { + return GetItem(key, defaultValue).Value; + } + + public IDataStoreItem GetItem(string key) + { + return GetItem(key, null); + } + + public IDataStoreItem GetItem(string key, object defaultValue) + { + var item = _collection.FindById(key); + + if (item == null) + { + if (defaultValue == null) + { + throw new KeyNotFoundException("The specified key was not found on the data store."); + } + else + { + Put(key, defaultValue); + return GetItem(key); + } + } + + return item; + } + + public List GetAll() + { + return _collection.FindAll().ToList(); + } + + public void Delete(string key) + { + _collection.Delete(key); + } + + public void DeleteAll() + { + _collection.DeleteMany(x => true); + } + + public int Count() + { + return _collection.Count(); + } + + public List GetUnsynchronized() + { + return _collection.Find(x => !x.IsSynchronized).ToList(); + } + } +} diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore.LiteDB/LiteDBDataStoreItem.cs b/Software/Visual_Studio/DataStore/Tango.DataStore.LiteDB/LiteDBDataStoreItem.cs new file mode 100644 index 000000000..ba2e5748e --- /dev/null +++ b/Software/Visual_Studio/DataStore/Tango.DataStore.LiteDB/LiteDBDataStoreItem.cs @@ -0,0 +1,30 @@ +using LiteDB; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore.Lite +{ + public class LiteDBDataStoreItem : IDataStoreItem + { + public String Guid { get; set; } + [BsonId] + public string Key { get; set; } + public DataType Type { get; set; } + public object Value { get; set; } + public DateTime Date { get; set; } + public bool IsSynchronized { get; set; } + + public LiteDBDataStoreItem() + { + Guid = System.Guid.NewGuid().ToString(); + } + + public override string ToString() + { + return DataStoreHelper.FormatDataStoreItem(this); + } + } +} diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore.LiteDB/LiteDBDataStoreManager.cs b/Software/Visual_Studio/DataStore/Tango.DataStore.LiteDB/LiteDBDataStoreManager.cs new file mode 100644 index 000000000..25abd91ab --- /dev/null +++ b/Software/Visual_Studio/DataStore/Tango.DataStore.LiteDB/LiteDBDataStoreManager.cs @@ -0,0 +1,47 @@ +using LiteDB; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore.Lite +{ + public class LiteDBDataStoreManager : IDataStoreManager + { + private bool _disposed; + private LiteDatabase _database; + + public String DatabasePath { get; private set; } + + public LiteDBDataStoreManager(String databasePath) + { + DatabasePath = databasePath; + Directory.CreateDirectory(Path.GetDirectoryName(DatabasePath)); + _database = new LiteDatabase($"Filename={DatabasePath}"); + _database.Pragma("TIMEOUT", 10); //Read Timeout + _database.Pragma("UTC_DATE", true); //Keep time as UTC when getting data + _database.Commit(); + } + + public IDataStoreCollection GetCollection(string name) + { + return new LiteDBDataStoreCollection(_database.GetCollection(name)); + } + + public List GetCollectionNames() + { + return _database.GetCollectionNames().ToList(); + } + + public void Dispose() + { + if (!_disposed) + { + _disposed = true; + _database.Dispose(); + } + } + } +} diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore.LiteDB/Properties/AssemblyInfo.cs b/Software/Visual_Studio/DataStore/Tango.DataStore.LiteDB/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..f1b35f107 --- /dev/null +++ b/Software/Visual_Studio/DataStore/Tango.DataStore.LiteDB/Properties/AssemblyInfo.cs @@ -0,0 +1,7 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("Tango - Data Store LiteDB Implementation")] +[assembly: AssemblyVersion("2.0.4.1608")] +[assembly: ComVisible(false)] \ No newline at end of file diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore.LiteDB/Tango.DataStore.Lite.csproj b/Software/Visual_Studio/DataStore/Tango.DataStore.LiteDB/Tango.DataStore.Lite.csproj new file mode 100644 index 000000000..65ba97520 --- /dev/null +++ b/Software/Visual_Studio/DataStore/Tango.DataStore.LiteDB/Tango.DataStore.Lite.csproj @@ -0,0 +1,66 @@ + + + + + Debug + AnyCPU + {FA96BC0C-4055-475C-9DCC-70A5A9436B10} + Library + Properties + Tango.DataStore.Lite + Tango.DataStore.Lite + v4.6.1 + 512 + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\LiteDB.5.0.4\lib\net45\LiteDB.dll + + + + + + + + + + + + + + GlobalVersionInfo.cs + + + + + + + + + {e0364dfa-0721-4637-9d32-9d22aac109d6} + Tango.DataStore + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore.LiteDB/packages.config b/Software/Visual_Studio/DataStore/Tango.DataStore.LiteDB/packages.config new file mode 100644 index 000000000..9dcac7837 --- /dev/null +++ b/Software/Visual_Studio/DataStore/Tango.DataStore.LiteDB/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/Properties/AssemblyInfo.cs b/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..808b25d41 --- /dev/null +++ b/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/Properties/AssemblyInfo.cs @@ -0,0 +1,7 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("Tango - Data Store Remote Messages")] +[assembly: AssemblyVersion("2.0.4.1608")] +[assembly: ComVisible(false)] \ No newline at end of file diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreCollection.cs b/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreCollection.cs new file mode 100644 index 000000000..e4453fafc --- /dev/null +++ b/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreCollection.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore.Remote +{ + public class RemoteDataStoreCollection + { + public String Name { get; set; } + public List Items { get; set; } + + public RemoteDataStoreCollection() + { + Items = new List(); + } + } +} diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreCountRequest.cs b/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreCountRequest.cs new file mode 100644 index 000000000..84ba279fb --- /dev/null +++ b/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreCountRequest.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore.Remote +{ + public class RemoteDataStoreCountRequest + { + public String Collection { get; set; } + } +} diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreCountResponse.cs b/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreCountResponse.cs new file mode 100644 index 000000000..71d4e13b2 --- /dev/null +++ b/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreCountResponse.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore.Remote +{ + public class RemoteDataStoreCountResponse + { + public int Count { get; set; } + } +} diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreDeleteAllRequest.cs b/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreDeleteAllRequest.cs new file mode 100644 index 000000000..ab5406611 --- /dev/null +++ b/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreDeleteAllRequest.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore.Remote +{ + public class RemoteDataStoreDeleteAllRequest + { + public String Collection { get; set; } + } +} diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreDeleteAllResponse.cs b/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreDeleteAllResponse.cs new file mode 100644 index 000000000..b5ddc0b64 --- /dev/null +++ b/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreDeleteAllResponse.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore.Remote +{ + public class RemoteDataStoreDeleteAllResponse + { + + } +} diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreDeleteRequest.cs b/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreDeleteRequest.cs new file mode 100644 index 000000000..13d400154 --- /dev/null +++ b/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreDeleteRequest.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore.Remote +{ + public class RemoteDataStoreDeleteRequest + { + public String Collection { get; set; } + public String Key { get; set; } + } +} diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreDeleteResponse.cs b/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreDeleteResponse.cs new file mode 100644 index 000000000..07bb40a8b --- /dev/null +++ b/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreDeleteResponse.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore.Remote +{ + public class RemoteDataStoreDeleteResponse + { + } +} diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreGetAllItemsRequest.cs b/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreGetAllItemsRequest.cs new file mode 100644 index 000000000..a285cd5c1 --- /dev/null +++ b/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreGetAllItemsRequest.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore.Remote +{ + public class RemoteDataStoreGetAllItemsRequest + { + } +} diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreGetAllItemsResponse.cs b/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreGetAllItemsResponse.cs new file mode 100644 index 000000000..3afb22c1e --- /dev/null +++ b/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreGetAllItemsResponse.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore.Remote +{ + public class RemoteDataStoreGetAllItemsResponse + { + public List Collections { get; set; } + + public RemoteDataStoreGetAllItemsResponse() + { + Collections = new List(); + } + } +} diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreGetAllRequest.cs b/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreGetAllRequest.cs new file mode 100644 index 000000000..747a5cb2f --- /dev/null +++ b/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreGetAllRequest.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore.Remote +{ + public class RemoteDataStoreGetAllRequest + { + public String Collection { get; set; } + } +} diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreGetAllResponse.cs b/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreGetAllResponse.cs new file mode 100644 index 000000000..2d9e0f527 --- /dev/null +++ b/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreGetAllResponse.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore.Remote +{ + public class RemoteDataStoreGetAllResponse + { + public List Items { get; set; } + + public RemoteDataStoreGetAllResponse() + { + Items = new List(); + } + } +} diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreGetCollectionNamesRequest.cs b/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreGetCollectionNamesRequest.cs new file mode 100644 index 000000000..6299f7512 --- /dev/null +++ b/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreGetCollectionNamesRequest.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore.Remote +{ + public class RemoteDataStoreGetCollectionNamesRequest + { + } +} diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreGetCollectionNamesResponse.cs b/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreGetCollectionNamesResponse.cs new file mode 100644 index 000000000..fe98b73fc --- /dev/null +++ b/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreGetCollectionNamesResponse.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore.Remote +{ + public class RemoteDataStoreGetCollectionNamesResponse + { + public List Names { get; set; } + + public RemoteDataStoreGetCollectionNamesResponse() + { + Names = new List(); + } + } +} diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreGetItemRequest.cs b/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreGetItemRequest.cs new file mode 100644 index 000000000..7d16a0f38 --- /dev/null +++ b/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreGetItemRequest.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore.Remote +{ + public class RemoteDataStoreGetItemRequest + { + public String Collection { get; set; } + public String Key { get; set; } + public Object DefaultValue { get; set; } + } +} diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreGetItemResponse.cs b/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreGetItemResponse.cs new file mode 100644 index 000000000..82393a786 --- /dev/null +++ b/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreGetItemResponse.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore.Remote +{ + public class RemoteDataStoreGetItemResponse + { + public RemoteDataStoreItem Item { get; set; } + } +} diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreGetRequest.cs b/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreGetRequest.cs new file mode 100644 index 000000000..4b8e9ee47 --- /dev/null +++ b/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreGetRequest.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore.Remote +{ + public class RemoteDataStoreGetRequest + { + public String Collection { get; set; } + public String Key { get; set; } + public Object DefaultValue { get; set; } + } +} diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreGetResponse.cs b/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreGetResponse.cs new file mode 100644 index 000000000..cc3b157e8 --- /dev/null +++ b/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreGetResponse.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore.Remote +{ + public class RemoteDataStoreGetResponse + { + public DataType DataType { get; set; } + + private Object _value; + public Object Value + { + get + { + return DataType == DataType.Proto ? ProtoObject : _value; + } + set + { + if (value is DataStoreProtoObject protoValue) + { + ProtoObject = protoValue; + } + else + { + _value = value; + } + } + } + + public DataStoreProtoObject ProtoObject { get; set; } + } +} diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreItem.cs b/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreItem.cs new file mode 100644 index 000000000..4327a0bd6 --- /dev/null +++ b/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreItem.cs @@ -0,0 +1,47 @@ +using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore.Remote +{ + public class RemoteDataStoreItem : IDataStoreItem + { + public string Guid { get; set; } + public string Key { get; set; } + public DataType Type { get; set; } + + private object _value; + public object Value + { + get + { + if (_value is JObject jObject) + { + return (jObject.ToObject()); + } + else + { + return _value; + } + } + set { _value = value; } + } + + public DateTime Date { get; set; } + public bool IsSynchronized { get; set; } + + public RemoteDataStoreItem() + { + Guid = System.Guid.NewGuid().ToString(); + Date = DateTime.UtcNow; + } + + public override string ToString() + { + return DataStoreHelper.FormatDataStoreItem(this); + } + } +} diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStorePutRequest.cs b/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStorePutRequest.cs new file mode 100644 index 000000000..77aa5e41f --- /dev/null +++ b/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStorePutRequest.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore.Remote +{ + public class RemoteDataStorePutRequest + { + public String Collection { get; set; } + public DataType DataType { get; set; } + public String Key { get; set; } + + private Object _value; + public Object Value + { + get + { + return DataType == DataType.Proto ? ProtoObject : _value; + } + set + { + if (value is DataStoreProtoObject protoValue) + { + ProtoObject = protoValue; + } + else + { + _value = value; + } + } + } + + public DataStoreProtoObject ProtoObject { get; set; } + } +} diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStorePutResponse.cs b/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStorePutResponse.cs new file mode 100644 index 000000000..7dd92490a --- /dev/null +++ b/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStorePutResponse.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore.Remote +{ + public class RemoteDataStorePutResponse + { + } +} diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreStartListenRequest.cs b/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreStartListenRequest.cs new file mode 100644 index 000000000..b8da17012 --- /dev/null +++ b/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreStartListenRequest.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore.Remote +{ + public class RemoteDataStoreStartListenRequest + { + } +} diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreStartListenResponse.cs b/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreStartListenResponse.cs new file mode 100644 index 000000000..c2a6c24a6 --- /dev/null +++ b/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/RemoteDataStoreStartListenResponse.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore.Remote +{ + public enum RemoteDataStoreChangeType + { + None, + Modified + } + + public class RemoteDataStoreStartListenResponse + { + public RemoteDataStoreChangeType ChangeType { get; set; } + public String CollectionName { get; set; } + public RemoteDataStoreItem Item { get; set; } + } +} diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/Tango.DataStore.Remote.csproj b/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/Tango.DataStore.Remote.csproj new file mode 100644 index 000000000..49fa37dc1 --- /dev/null +++ b/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/Tango.DataStore.Remote.csproj @@ -0,0 +1,87 @@ + + + + + Debug + AnyCPU + {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA} + Library + Properties + Tango.DataStore.Remote + Tango.DataStore.Remote + v4.6.1 + 512 + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\Google.Protobuf.3.4.1\lib\net45\Google.Protobuf.dll + + + ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll + + + + + + + + + + + + + GlobalVersionInfo.cs + + + + + + + + + + + + + + + + + + + + + + + + + + + + {e0364dfa-0721-4637-9d32-9d22aac109d6} + Tango.DataStore + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/packages.config b/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/packages.config new file mode 100644 index 000000000..026e719c3 --- /dev/null +++ b/Software/Visual_Studio/DataStore/Tango.DataStore.Remote/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore/DataStoreHelper.cs b/Software/Visual_Studio/DataStore/Tango.DataStore/DataStoreHelper.cs new file mode 100644 index 000000000..0ca8e484e --- /dev/null +++ b/Software/Visual_Studio/DataStore/Tango.DataStore/DataStoreHelper.cs @@ -0,0 +1,160 @@ +using Google.Protobuf; +using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.ExtensionMethods; +using Tango.PMR; +using Tango.PMR.Common; + +namespace Tango.DataStore +{ + /// + /// Contains data store helper methods. + /// + public static class DataStoreHelper + { + /// + /// Gets the data store data type by the specified object type. + /// + /// The value. + /// + public static DataType GetDataType(Object value) + { + return GetDataType(value.GetType()); + } + + /// + /// Gets data store data type by the specified .net type. + /// + /// The type. + /// + /// + public static DataType GetDataType(Type type) + { + if (type == typeof(int)) + { + return DataType.Int32; + } + else if (type == typeof(Int64)) + { + return DataType.Int32; + } + else if (type == typeof(float)) + { + return DataType.Float; + } + else if (type == typeof(double)) + { + return DataType.Double; + } + else if (type == typeof(String)) + { + return DataType.String; + } + else if (type == typeof(bool)) + { + return DataType.Boolean; + } + else if (type == typeof(byte[])) + { + return DataType.Bytes; + } + else if (type == typeof(DataStoreProtoObject)) + { + return DataType.Proto; + } + else if (typeof(IMessage).IsAssignableFrom(type)) + { + return DataType.Proto; + } + + throw new NotSupportedException($"The specified type '{type.Name}' is not supported by the data store."); + } + + /// + /// Formats the data store item as a string. + /// + /// The item. + /// + public static String FormatDataStoreItem(IDataStoreItem item) + { + if (item.Type == DataType.Bytes) + { + return GetByteArrayHexString((byte[])item.Value); + } + else if (item.Type == DataType.Proto) + { + return (item.Value as DataStoreProtoObject).Message.ToJsonString(); + } + else + { + return item.Value.ToStringSafe(); + } + } + + /// + /// Returns a byte array string representation in hex format. + /// + /// The data. + /// + public static String GetByteArrayHexString(byte[] data) + { + StringBuilder hex = new StringBuilder(); + foreach (byte b in data) + { + hex.Append(b.ToString("X2") + " "); + } + return hex.ToString(); + } + + /// + /// Parses a data store value from a string. + /// + /// The type. + /// The string. + /// Type of the proto message (if type is Proto). + /// + /// No PMR message type specified. + /// The specified data store type is not supported. + public static Object ParseDataStoreValue(DataType type, String text, MessageType? protoMessageType = null) + { + switch (type) + { + case DataType.String: + return text; + case DataType.Int32: + return int.Parse(text); + case DataType.Float: + return float.Parse(text); + case DataType.Double: + return double.Parse(text); + case DataType.Boolean: + return bool.Parse(text); + case DataType.Proto: + if (protoMessageType == null) throw new ArgumentNullException("No PMR message type specified."); + var messageType = MessageFactory.GetPMRTypeFromMessageType(protoMessageType.Value); + var instance = Activator.CreateInstance(messageType) as IMessage; + instance = instance.GetParser().ParseJson(text); + return DataStoreProtoObject.FromMessage(instance); + case DataType.Bytes: + string[] hexValuesSplit = text.Split(' '); + List bytes = new List(); + foreach (string hex in hexValuesSplit) + { + if (hex.IsNotNullOrEmpty()) + { + byte b = (byte)Convert.ToInt32(hex.Trim(), 16); + bytes.Add(b); + } + } + return bytes.ToArray(); + } + + throw new NotSupportedException("The specified data store type is not supported."); + } + } +} diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore/DataStoreProtoObject.cs b/Software/Visual_Studio/DataStore/Tango.DataStore/DataStoreProtoObject.cs new file mode 100644 index 000000000..5aa7c5342 --- /dev/null +++ b/Software/Visual_Studio/DataStore/Tango.DataStore/DataStoreProtoObject.cs @@ -0,0 +1,83 @@ +using Google.Protobuf; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.Bson; +using Tango.Core.ExtensionMethods; +using Tango.PMR; +using Tango.PMR.Common; +using Tango.PMR.DataStore; + +namespace Tango.DataStore +{ + public class DataStoreProtoObject + { + public MessageType MessageType { get; set; } + public Type Type { get; set; } + public byte[] Data { get; set; } + + + private IMessage _message; + [JsonIgnore] + public IMessage Message + { + get + { + if (_message == null) + { + _message = MessageFactory.ParseProtoMessage(Data, Type); + } + + return _message; + } + private set { _message = value; } + } + + public byte[] ToBytes() + { + return BsonConvert.Serialize(this); + } + + public static DataStoreProtoObject FromBytes(byte[] data) + { + var instance = BsonConvert.Deserialize(data); + instance.Message = MessageFactory.ParseProtoMessage(instance.Data, instance.Type); + + return instance; + } + + public static DataStoreProtoObject FromMessage(IMessage message) + { + DataStoreProtoObject proto = new DataStoreProtoObject(); + proto.Type = message.GetType(); + proto.MessageType = MessageFactory.ParseMessageType(proto.Type.Name); + proto.Data = message.ToByteArray(); + proto.Message = message; + return proto; + } + + public static DataStoreProtoObject FromJObject(JObject obj) + { + return (obj.ToObject()); + } + + public static DataStoreProtoObject FromPMRDataStoreItem(DataStoreItem item) + { + DataStoreProtoObject proto = new DataStoreProtoObject(); + proto.MessageType = item.ProtoType; + proto.Type = MessageFactory.GetPMRTypeFromMessageType(item.ProtoType); + proto.Data = item.BytesValue.ToByteArray(); + return proto; + } + + public override string ToString() + { + return Message?.ToJsonString(); + } + } +} diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore/DataType.cs b/Software/Visual_Studio/DataStore/Tango.DataStore/DataType.cs new file mode 100644 index 000000000..132bff28e --- /dev/null +++ b/Software/Visual_Studio/DataStore/Tango.DataStore/DataType.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore +{ + /// + /// Represents a data store item type. + /// + public enum DataType + { + Int32, + Float, + Double, + Boolean, + String, + Bytes, + Proto + } +} diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore/ExtensionMethods.cs b/Software/Visual_Studio/DataStore/Tango.DataStore/ExtensionMethods.cs new file mode 100644 index 000000000..acc381a61 --- /dev/null +++ b/Software/Visual_Studio/DataStore/Tango.DataStore/ExtensionMethods.cs @@ -0,0 +1,16 @@ +using Google.Protobuf; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.DataStore; + +public static class ExtensionMethods +{ + public static DataStoreProtoObject ToDataStoreProtoObject(IMessage message) + { + return DataStoreProtoObject.FromMessage(message); + } +} + diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore/IDataStoreCollection.cs b/Software/Visual_Studio/DataStore/Tango.DataStore/IDataStoreCollection.cs new file mode 100644 index 000000000..baca95c67 --- /dev/null +++ b/Software/Visual_Studio/DataStore/Tango.DataStore/IDataStoreCollection.cs @@ -0,0 +1,119 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore +{ + /// + /// Represents a data store collection. + /// + public interface IDataStoreCollection + { + /// + /// Gets the collection name. + /// + String Name { get; } + + /// + /// Upserts the specified key and value. + /// + /// The key. + /// The value. + void Put(String key, Object value); + + /// + /// Upserts the specified key and value of type T. + /// + /// + /// The key. + /// The value. + void Put(String key, T value); + + /// + /// Upserts the specified key and value. + /// The value must be of the specified DataType. + /// + /// The key. + /// The type. + /// The value. + void Put(String key, DataType type, Object value); + + /// + /// Gets the value by the specified key + /// + /// The key. + /// + Object Get(String key); + + /// + /// Gets the value by the specified key + /// + /// The key. + /// Will execute put when the key was not found. + /// + Object Get(String key, Object defaultValue); + + /// + /// Gets the value of type T by the specified key + /// + /// + /// The key. + /// + T Get(String key); + + /// + /// Gets the value of type T by the specified key + /// + /// + /// The key. + /// Will execute put when the key was not found. + /// + T Get(String key, T defaultValue); + + /// + /// Gets the full data store item by the specified key. + /// + /// The key. + /// + IDataStoreItem GetItem(String key); + + /// + /// Gets the full data store item by the specified key. + /// + /// The key. + /// Will execute put when the key was not found. + /// + IDataStoreItem GetItem(String key, Object defaultValue); + + /// + /// Gets all the data store items in the collection. + /// + /// + List GetAll(); + + /// + /// Gets all the data store unsynchronized items in the collection. + /// + /// + List GetUnsynchronized(); + + /// + /// Deleted an item by the specified key. + /// + /// The key. + void Delete(String key); + + /// + /// Deletes all items in the collection. + /// + void DeleteAll(); + + /// + /// Returns the number of items in the collection. + /// + /// + int Count(); + } +} diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore/IDataStoreItem.cs b/Software/Visual_Studio/DataStore/Tango.DataStore/IDataStoreItem.cs new file mode 100644 index 000000000..9c03f40ee --- /dev/null +++ b/Software/Visual_Studio/DataStore/Tango.DataStore/IDataStoreItem.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore +{ + /// + /// Represents a data store item. + /// + public interface IDataStoreItem + { + /// + /// Gets or sets the unique identifier (Use only for synchronization). + /// + String Guid { get; set; } + + /// + /// Gets or sets item id. + /// + String Key { get; set; } + + /// + /// Gets or sets the item type. + /// + DataType Type { get; set; } + + /// + /// Gets or sets the item value. + /// + Object Value { get; set; } + + /// + /// Gets or sets the item update UTC date. + /// + DateTime Date { get; set; } + + /// + /// Gets or sets a value indicating whether this item is synchronized with the remote service. + /// + bool IsSynchronized { get; set; } + } +} diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore/IDataStoreManager.cs b/Software/Visual_Studio/DataStore/Tango.DataStore/IDataStoreManager.cs new file mode 100644 index 000000000..5443f12e2 --- /dev/null +++ b/Software/Visual_Studio/DataStore/Tango.DataStore/IDataStoreManager.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore +{ + /// + /// Represents a key/value data store manager. + /// + /// + public interface IDataStoreManager : IDisposable + { + /// + /// Gets the data store collection by name. + /// + /// The name. + /// + IDataStoreCollection GetCollection(String name); + + /// + /// Gets all the collection names. + /// + /// + List GetCollectionNames(); + } +} diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore/Properties/AssemblyInfo.cs b/Software/Visual_Studio/DataStore/Tango.DataStore/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..8e9365e03 --- /dev/null +++ b/Software/Visual_Studio/DataStore/Tango.DataStore/Properties/AssemblyInfo.cs @@ -0,0 +1,7 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("Tango - Data Store Library")] +[assembly: AssemblyVersion("2.0.4.1608")] +[assembly: ComVisible(false)] \ No newline at end of file diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore/Tango.DataStore.csproj b/Software/Visual_Studio/DataStore/Tango.DataStore/Tango.DataStore.csproj new file mode 100644 index 000000000..d75d39963 --- /dev/null +++ b/Software/Visual_Studio/DataStore/Tango.DataStore/Tango.DataStore.csproj @@ -0,0 +1,78 @@ + + + + + Debug + AnyCPU + {E0364DFA-0721-4637-9D32-9D22AAC109D6} + Library + Properties + Tango.DataStore + Tango.DataStore + v4.6.1 + 512 + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + bin\Debug\Tango.DataStore.xml + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + bin\Release\Tango.DataStore.xml + + + + ..\packages\Google.Protobuf.3.4.1\lib\net45\Google.Protobuf.dll + + + ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll + + + + + + + + + + + + + GlobalVersionInfo.cs + + + + + + + + + + + + + + + + {A34EE0F0-649D-41C8-8489-B6F1CC6924EE} + Tango.Core + + + {e4927038-348d-4295-aaf4-861c58cb3943} + Tango.PMR + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore/packages.config b/Software/Visual_Studio/DataStore/Tango.DataStore/packages.config new file mode 100644 index 000000000..026e719c3 --- /dev/null +++ b/Software/Visual_Studio/DataStore/Tango.DataStore/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Tango.FSE.MachineConfiguration.csproj b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Tango.FSE.MachineConfiguration.csproj index db7b7d12d..1a820ae3c 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Tango.FSE.MachineConfiguration.csproj +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Tango.FSE.MachineConfiguration.csproj @@ -161,19 +161,19 @@ {58e8825f-0c96-449c-b320-1e82b0aa876b} Tango.CSV - + {ee088ff7-04d1-41fb-9d6a-cedeee7a7b9c} Tango.DataStore.Editing - + {88d9906b-8fc4-4fe0-b7eb-127a0a8fcee4} Tango.DataStore.EF - + {29448f3c-9b3e-4da6-8555-46a8b9a6b3aa} Tango.DataStore.Remote - + {e0364dfa-0721-4637-9d32-9d22aac109d6} Tango.DataStore diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures.Documentation/Help/proc-doc.chm b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures.Documentation/Help/proc-doc.chm index dd4a2d6c4..8777b5768 100644 Binary files a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures.Documentation/Help/proc-doc.chm and b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures.Documentation/Help/proc-doc.chm differ diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures.Documentation/Tango.FSE.Procedures.Documentation.shfbproj b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures.Documentation/Tango.FSE.Procedures.Documentation.shfbproj index dc353ec12..10bf82219 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures.Documentation/Tango.FSE.Procedures.Documentation.shfbproj +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures.Documentation/Tango.FSE.Procedures.Documentation.shfbproj @@ -34,7 +34,7 @@ - + HtmlHelp1 C# @@ -57,106 +57,107 @@ InheritedMembers, InheritedFrameworkMembers, ProtectedInternalAsProtected, NonBrowsable - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This is the global summery for the help file. This is the global summery for the help file. @@ -211,10 +212,10 @@ - + Tango.DataStore {e0364dfa-0721-4637-9d32-9d22aac109d6} - True + False Tango.FSE.Common diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/Tango.FSE.Procedures.csproj b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/Tango.FSE.Procedures.csproj index 32a333579..72b3dadd1 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/Tango.FSE.Procedures.csproj +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/Tango.FSE.Procedures.csproj @@ -288,7 +288,7 @@ {58e8825f-0c96-449c-b320-1e82b0aa876b} Tango.CSV - + {e0364dfa-0721-4637-9d32-9d22aac109d6} Tango.DataStore diff --git a/Software/Visual_Studio/FSE/Tango.FSE.BL/Tango.FSE.BL.csproj b/Software/Visual_Studio/FSE/Tango.FSE.BL/Tango.FSE.BL.csproj index d15611e91..c361f1d3f 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.BL/Tango.FSE.BL.csproj +++ b/Software/Visual_Studio/FSE/Tango.FSE.BL/Tango.FSE.BL.csproj @@ -147,11 +147,11 @@ {a34ee0f0-649d-41c8-8489-b6f1cc6924ee} Tango.Core - + {88d9906b-8fc4-4fe0-b7eb-127a0a8fcee4} Tango.DataStore.EF - + {e0364dfa-0721-4637-9d32-9d22aac109d6} Tango.DataStore diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Tango.FSE.Common.csproj b/Software/Visual_Studio/FSE/Tango.FSE.Common/Tango.FSE.Common.csproj index bb44045b7..9a43bb5fb 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.Common/Tango.FSE.Common.csproj +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Tango.FSE.Common.csproj @@ -506,11 +506,11 @@ {a34ee0f0-649d-41c8-8489-b6f1cc6924ee} Tango.Core - + {ee088ff7-04d1-41fb-9d6a-cedeee7a7b9c} Tango.DataStore.Editing - + {e0364dfa-0721-4637-9d32-9d22aac109d6} Tango.DataStore diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/Tango.FSE.UI.csproj b/Software/Visual_Studio/FSE/Tango.FSE.UI/Tango.FSE.UI.csproj index baff92208..4b4d46a78 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.UI/Tango.FSE.UI.csproj +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/Tango.FSE.UI.csproj @@ -641,19 +641,19 @@ {38197109-8610-4d3f-92b9-16d48df94d7c} Tango.DAL.Remote - + {EE088FF7-04D1-41FB-9D6A-CEDEEE7A7B9C} Tango.DataStore.Editing - + {88d9906b-8fc4-4fe0-b7eb-127a0a8fcee4} Tango.DataStore.EF - + {29448f3c-9b3e-4da6-8555-46a8b9a6b3aa} Tango.DataStore.Remote - + {E0364DFA-0721-4637-9D32-9D22AAC109D6} Tango.DataStore diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj index 1b073ee6f..9d39c96d9 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj @@ -364,6 +364,26 @@ + + {ee088ff7-04d1-41fb-9d6a-cedeee7a7b9c} + Tango.DataStore.Editing + + + {88d9906b-8fc4-4fe0-b7eb-127a0a8fcee4} + Tango.DataStore.EF + + + {fa96bc0c-4055-475c-9dcc-70a5a9436b10} + Tango.DataStore.Lite + + + {29448f3c-9b3e-4da6-8555-46a8b9a6b3aa} + Tango.DataStore.Remote + + + {e0364dfa-0721-4637-9d32-9d22aac109d6} + Tango.DataStore + {c5df1816-34e5-4700-824c-29623a1baa22} Tango.AdvancedInstaller @@ -388,26 +408,6 @@ {58e8825f-0c96-449c-b320-1e82b0aa876b} Tango.CSV - - {ee088ff7-04d1-41fb-9d6a-cedeee7a7b9c} - Tango.DataStore.Editing - - - {88d9906b-8fc4-4fe0-b7eb-127a0a8fcee4} - Tango.DataStore.EF - - - {fa96bc0c-4055-475c-9dcc-70a5a9436b10} - Tango.DataStore.Lite - - - {29448f3c-9b3e-4da6-8555-46a8b9a6b3aa} - Tango.DataStore.Remote - - - {e0364dfa-0721-4637-9d32-9d22aac109d6} - Tango.DataStore - {63561e19-ff5a-414b-a5ef-e30711543e1d} Tango.Emulations @@ -520,7 +520,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.DataStore.EF/EFDataStoreCollection.cs b/Software/Visual_Studio/Tango.DataStore.EF/EFDataStoreCollection.cs deleted file mode 100644 index 0baf5bb19..000000000 --- a/Software/Visual_Studio/Tango.DataStore.EF/EFDataStoreCollection.cs +++ /dev/null @@ -1,156 +0,0 @@ -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.BL; -using Tango.BL.Entities; -using Tango.Core.ExtensionMethods; - -namespace Tango.DataStore.EF -{ - public class EFDataStoreCollection : IDataStoreCollection - { - public string Name { get; } - - public EFDataStoreCollection(String name) - { - Name = name; - } - - public void Put(string key, T value) - { - Put(key, (object)value); - } - - public void Put(string key, object value) - { - Put(key, DataStoreHelper.GetDataType(value), value); - } - - public void Put(string key, DataType type, object value) - { - using (var db = ObservablesContext.CreateDefault()) - { - DataStoreItem item = db.DataStoreItems.SingleOrDefault(x => x.CollectionName == Name && x.Key == key); - - if (item == null) - { - item = new DataStoreItem(); - db.DataStoreItems.Add(item); - } - - item.CollectionName = Name; - item.Key = key; - item.DataType = (int)type; - item.Value = EFDataStoreHelper.CreateBytes(type, value); - item.IsSynchronized = false; - item.LastUpdated = DateTime.UtcNow; - - db.SaveChanges(); - } - } - - public T Get(string key) - { - return (T)Get(key, null); - } - - public T Get(string key, T defaultValue) - { - return (T)Get(key, (object)defaultValue); - } - - public object Get(string key) - { - return Get(key, null); - } - - public object Get(string key, object defaultValue) - { - return GetItem(key, defaultValue).Value; - } - - public IDataStoreItem GetItem(string key) - { - return GetItem(key, null); - } - - public IDataStoreItem GetItem(string key, object defaultValue) - { - using (var db = ObservablesContext.CreateDefault()) - { - var item = db.DataStoreItems.SingleOrDefault(x => x.CollectionName == Name && x.Key == key); - - if (item == null) - { - var globalItem = db.GlobalDataStoreItems.SingleOrDefault(x => x.CollectionName == Name && x.Key == key); - - if (globalItem == null) - { - if (defaultValue == null) - { - throw new KeyNotFoundException("The specified data store key was not found."); - } - else - { - Put(key, defaultValue); - return GetItem(key); - } - } - else - { - return globalItem.ToDataStoreItem(); - } - } - - return item.ToDataStoreItem(); - } - } - - public List GetAll() - { - 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(); - - - return globalItems.Concat(items).ToList(); - } - } - - public List GetUnsynchronized() - { - using (var db = ObservablesContext.CreateDefault()) - { - return db.DataStoreItems.Where(x => x.CollectionName == Name && !x.IsSynchronized).ToList().Select(x => x.ToDataStoreItem()).ToList(); - } - } - - public void Delete(string key) - { - using (var db = ObservablesContext.CreateDefault()) - { - db.Database.ExecuteSqlCommand($"DELETE FROM DATA_STORE_ITEMS WHERE COLLECTION_NAME = '{Name}' AND [KEY] = '{key}'"); - } - } - - public void DeleteAll() - { - using (var db = ObservablesContext.CreateDefault()) - { - db.Database.ExecuteSqlCommand($"DELETE FROM DATA_STORE_ITEMS WHERE COLLECTION_NAME = '{Name}'"); - } - } - - public int Count() - { - using (var db = ObservablesContext.CreateDefault()) - { - return db.DataStoreItems.Count(x => x.CollectionName == Name); - } - } - } -} diff --git a/Software/Visual_Studio/Tango.DataStore.EF/EFDataStoreHelper.cs b/Software/Visual_Studio/Tango.DataStore.EF/EFDataStoreHelper.cs deleted file mode 100644 index 85b3b6731..000000000 --- a/Software/Visual_Studio/Tango.DataStore.EF/EFDataStoreHelper.cs +++ /dev/null @@ -1,105 +0,0 @@ -using Google.Protobuf; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.BL.Entities; - -namespace Tango.DataStore.EF -{ - public static class EFDataStoreHelper - { - public static byte[] CreateBytes(DataType type, Object obj) - { - switch (type) - { - case DataType.Int32: - return BitConverter.GetBytes((int)obj); - case DataType.Float: - return BitConverter.GetBytes((float)obj); - case DataType.Double: - return BitConverter.GetBytes((double)obj); - case DataType.Boolean: - return BitConverter.GetBytes((bool)obj); - case DataType.String: - return Encoding.Default.GetBytes(obj.ToString()); - case DataType.Bytes: - return (byte[])obj; - case DataType.Proto: - if (obj is DataStoreProtoObject protoMessage) - { - return protoMessage.ToBytes(); - } - else - { - throw new NotSupportedException($"Data type is 'Proto' but object is not of type '{nameof(DataStoreProtoObject)}'."); - } - } - - throw new NotSupportedException("The specified type is not supported."); - } - - public static Object CreateObject(DataType type, byte[] bytes) - { - switch (type) - { - case DataType.Int32: - return BitConverter.ToInt32(bytes, 0); - case DataType.Float: - return BitConverter.ToSingle(bytes, 0); - case DataType.Double: - return BitConverter.ToDouble(bytes, 0); - case DataType.Boolean: - return BitConverter.ToBoolean(bytes, 0); - case DataType.String: - return Encoding.Default.GetString(bytes); - case DataType.Bytes: - return bytes; - case DataType.Proto: - return DataStoreProtoObject.FromBytes(bytes); - } - - throw new NotSupportedException("The specified type is not supported."); - } - - public static IDataStoreItem CreateDataStoreItem(DataStoreItem item) - { - return new EFDataStoreItem() - { - Guid = item.Guid, - Date = item.LastUpdated, - IsSynchronized = item.IsSynchronized, - Key = item.Key, - Type = (DataType)item.DataType, - Value = CreateObject((DataType)item.DataType, item.Value) - }; - } - - public static IDataStoreItem CreateDataStoreItem(GlobalDataStoreItem item) - { - return new EFDataStoreItem() - { - Guid = item.Guid, - Date = item.LastUpdated, - IsSynchronized = true, - Key = item.Key, - Type = (DataType)item.DataType, - Value = CreateObject((DataType)item.DataType, item.Value) - }; - } - - public static DataStoreItem CreateDbDataStoreItem(IDataStoreItem item) - { - return new DataStoreItem() - { - Guid = item.Guid, - LastUpdated = item.Date, - IsSynchronized = item.IsSynchronized, - Key = item.Key, - DataType = (int)item.Type, - Value = CreateBytes(item.Type, item.Value) - }; - } - } -} diff --git a/Software/Visual_Studio/Tango.DataStore.EF/EFDataStoreItem.cs b/Software/Visual_Studio/Tango.DataStore.EF/EFDataStoreItem.cs deleted file mode 100644 index 6bcb97d17..000000000 --- a/Software/Visual_Studio/Tango.DataStore.EF/EFDataStoreItem.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.DataStore.EF -{ - public class EFDataStoreItem : IDataStoreItem - { - public string Guid { get; set; } - public string Key { get; set; } - public DataType Type { get; set; } - public object Value { get; set; } - public DateTime Date { get; set; } - public bool IsSynchronized { get; set; } - - public EFDataStoreItem() - { - Guid = System.Guid.NewGuid().ToString(); - } - - public override string ToString() - { - return DataStoreHelper.FormatDataStoreItem(this); - } - } -} diff --git a/Software/Visual_Studio/Tango.DataStore.EF/EFDataStoreManager.cs b/Software/Visual_Studio/Tango.DataStore.EF/EFDataStoreManager.cs deleted file mode 100644 index 4314a25f9..000000000 --- a/Software/Visual_Studio/Tango.DataStore.EF/EFDataStoreManager.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.BL; - -namespace Tango.DataStore.EF -{ - public class EFDataStoreManager : IDataStoreManager - { - public IDataStoreCollection GetCollection(string name) - { - using (var db = ObservablesContext.CreateDefault()) - { - return new EFDataStoreCollection(name); - } - } - - public List GetCollectionNames() - { - using (var db = ObservablesContext.CreateDefault()) - { - return db.DataStoreItems.Select(x => x.CollectionName).Distinct().ToList(); - } - } - - public void Dispose() - { - //DO Nothing. - } - } -} diff --git a/Software/Visual_Studio/Tango.DataStore.EF/ExtensionMethods.cs b/Software/Visual_Studio/Tango.DataStore.EF/ExtensionMethods.cs deleted file mode 100644 index 9f09ae658..000000000 --- a/Software/Visual_Studio/Tango.DataStore.EF/ExtensionMethods.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.BL.Entities; -using Tango.DataStore; -using Tango.DataStore.EF; - -public static class ExtensionMethods -{ - public static IDataStoreItem ToDataStoreItem(this DataStoreItem item) - { - return EFDataStoreHelper.CreateDataStoreItem(item); - } - - public static IDataStoreItem ToDataStoreItem(this GlobalDataStoreItem item) - { - return EFDataStoreHelper.CreateDataStoreItem(item); - } - - public static DataStoreItem ToDbDataStoreItem(this IDataStoreItem item) - { - return EFDataStoreHelper.CreateDbDataStoreItem(item); - } -} - diff --git a/Software/Visual_Studio/Tango.DataStore.EF/Properties/AssemblyInfo.cs b/Software/Visual_Studio/Tango.DataStore.EF/Properties/AssemblyInfo.cs deleted file mode 100644 index c59e45461..000000000 --- a/Software/Visual_Studio/Tango.DataStore.EF/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,7 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -[assembly: AssemblyTitle("Tango - Data Store Entity Framework Implementation")] -[assembly: AssemblyVersion("2.0.4.1608")] -[assembly: ComVisible(false)] \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.DataStore.EF/Tango.DataStore.EF.csproj b/Software/Visual_Studio/Tango.DataStore.EF/Tango.DataStore.EF.csproj deleted file mode 100644 index 96ecb5ad1..000000000 --- a/Software/Visual_Studio/Tango.DataStore.EF/Tango.DataStore.EF.csproj +++ /dev/null @@ -1,89 +0,0 @@ - - - - - Debug - AnyCPU - {88D9906B-8FC4-4FE0-B7EB-127A0A8FCEE4} - Library - Properties - Tango.DataStore.EF - Tango.DataStore.EF - v4.6.1 - 512 - true - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll - - - ..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll - - - ..\packages\Google.Protobuf.3.4.1\lib\net45\Google.Protobuf.dll - - - ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll - - - - - - - - - - - - - - GlobalVersionInfo.cs - - - - - - - - - - - - - - {f441feee-322a-4943-b566-110e12fd3b72} - Tango.BL - - - {a34ee0f0-649d-41c8-8489-b6f1cc6924ee} - Tango.Core - - - {e0364dfa-0721-4637-9d32-9d22aac109d6} - Tango.DataStore - - - {e4927038-348d-4295-aaf4-861c58cb3943} - Tango.PMR - - - - \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.DataStore.EF/packages.config b/Software/Visual_Studio/Tango.DataStore.EF/packages.config deleted file mode 100644 index 13be55da1..000000000 --- a/Software/Visual_Studio/Tango.DataStore.EF/packages.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.DataStore.Editing/CustomControl1.cs b/Software/Visual_Studio/Tango.DataStore.Editing/CustomControl1.cs deleted file mode 100644 index fab0127e8..000000000 --- a/Software/Visual_Studio/Tango.DataStore.Editing/CustomControl1.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; - -namespace Tango.DataStore.Editing -{ - public class CustomControl1 : Control - { - static CustomControl1() - { - DefaultStyleKeyProperty.OverrideMetadata(typeof(CustomControl1), new FrameworkPropertyMetadata(typeof(CustomControl1))); - } - } -} diff --git a/Software/Visual_Studio/Tango.DataStore.Editing/DataStoreCollectionModel.cs b/Software/Visual_Studio/Tango.DataStore.Editing/DataStoreCollectionModel.cs deleted file mode 100644 index 3e58aa4b1..000000000 --- a/Software/Visual_Studio/Tango.DataStore.Editing/DataStoreCollectionModel.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.Core; - -namespace Tango.DataStore.Editing -{ - public class DataStoreCollectionModel : ExtendedObject - { - public String Name { get; set; } - public ObservableCollection Items { get; set; } - public bool IsDeleted { get; set; } - - private bool _isSelected; - public bool IsSelected - { - get { return _isSelected; } - set { _isSelected = value; RaisePropertyChangedAuto(); Items.ToList().ForEach(x => x.IsSelected = value); } - } - - public DataStoreCollectionModel() - { - Items = new ObservableCollection(); - } - } -} diff --git a/Software/Visual_Studio/Tango.DataStore.Editing/DataStoreItemModel.cs b/Software/Visual_Studio/Tango.DataStore.Editing/DataStoreItemModel.cs deleted file mode 100644 index 3b1741395..000000000 --- a/Software/Visual_Studio/Tango.DataStore.Editing/DataStoreItemModel.cs +++ /dev/null @@ -1,140 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.Core; - -namespace Tango.DataStore.Editing -{ - public class DataStoreItemModel : ExtendedObject, IDataStoreItem - { - public IDataStoreItem GlobalItem { get; set; } - - public DataType OriginalType { get; set; } - public Object OriginalValue { get; set; } - - private Object _value; - public Object Value - { - get { return _value; } - set { _value = value; RaisePropertyChangedAuto(); RaisePropertyChanged(nameof(HasDifference)); RaisePropertyChanged(nameof(FormattedValue)); } - } - - private bool _isSelected; - public bool IsSelected - { - get { return _isSelected; } - set { _isSelected = value; RaisePropertyChangedAuto(); } - } - - public bool HasDifference - { - get - { - if (OriginalType != Type) - { - return true; - } - - if (OriginalType == DataType.Bytes && Type == DataType.Bytes) - { - if (OriginalValue != null && Value != null) - { - return !Enumerable.SequenceEqual(OriginalValue as byte[], Value as byte[]); - } - } - - if (Value == null && OriginalValue == null) return false; - - return !OriginalValue.ToStringSafe().Equals(Value.ToStringSafe()) || (IsGlobal && GlobalItem.Value != Value); - } - } - - public String FormattedValue - { - get { return this.ToString().ToOneLine(); } - } - - public string Guid { get; set; } - public string Key { get; set; } - - private DataType _type; - public DataType Type - { - get { return _type; } - set { _type = value; RaisePropertyChangedAuto(); } - } - - private DateTime _date; - public DateTime Date - { - get { return _date; } - set { _date = value; RaisePropertyChangedAuto(); } - } - - public bool IsSynchronized { get; set; } - public bool ExistsOnMachine { get; set; } - - private bool _isGlobal; - public bool IsGlobal - { - get { return _isGlobal; } - set { _isGlobal = value; RaisePropertyChangedAuto(); } - } - - private bool _isDeleted; - public bool IsDeleted - { - get { return _isDeleted; } - set { _isDeleted = value; RaisePropertyChangedAuto(); } - } - - public static DataStoreItemModel FromLocalDataStoreItem(IDataStoreItem local, IDataStoreItem globalItem) - { - DataStoreItemModel model = new DataStoreItemModel(); - - model.OriginalValue = local.Value; - model.Value = local.Value; - model.Guid = local.Guid; - model.Key = local.Key; - model.OriginalType = local.Type; - model.Type = local.Type; - model.Date = local.Date; - model.IsGlobal = false; - model.IsSynchronized = local.IsSynchronized; - - model.GlobalItem = globalItem; - - return model; - } - - public static DataStoreItemModel FromGlobalDataStoreItem(IDataStoreItem global) - { - DataStoreItemModel model = new DataStoreItemModel(); - - model.GlobalItem = global; - model.Guid = global.Guid; - model.Key = global.Key; - model.Type = global.Type; - model.OriginalType = global.Type; - model.Date = global.Date; - model.IsGlobal = true; - model.IsSynchronized = global.IsSynchronized; - - return model; - } - - public override string ToString() - { - if (this.Value != null) - { - return DataStoreHelper.FormatDataStoreItem(this); - } - else - { - return null; - } - } - } -} diff --git a/Software/Visual_Studio/Tango.DataStore.Editing/DataStoreModel.cs b/Software/Visual_Studio/Tango.DataStore.Editing/DataStoreModel.cs deleted file mode 100644 index a68cc0af9..000000000 --- a/Software/Visual_Studio/Tango.DataStore.Editing/DataStoreModel.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.Core; - -namespace Tango.DataStore.Editing -{ - public class DataStoreModel : ExtendedObject - { - public ObservableCollection Collections { get; set; } - - public DataStoreModel() - { - Collections = new ObservableCollection(); - } - } -} diff --git a/Software/Visual_Studio/Tango.DataStore.Editing/Properties/AssemblyInfo.cs b/Software/Visual_Studio/Tango.DataStore.Editing/Properties/AssemblyInfo.cs deleted file mode 100644 index 9f04af8ea..000000000 --- a/Software/Visual_Studio/Tango.DataStore.Editing/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System.Reflection; -using System.Resources; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Windows; - -// 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.Editing")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Tango.DataStore.Editing")] -[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)] - -//In order to begin building localizable applications, set -//CultureYouAreCodingWith in your .csproj file -//inside a . For example, if you are using US english -//in your source files, set the to en-US. Then uncomment -//the NeutralResourceLanguage attribute below. Update the "en-US" in -//the line below to match the UICulture setting in the project file. - -//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] - - -[assembly:ThemeInfo( - ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located - //(used if a resource is not found in the page, - // or application resource dictionaries) - ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located - //(used if a resource is not found in the page, - // app, or any theme specific resource dictionaries) -)] - - -// 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/Tango.DataStore.Editing/Properties/Resources.Designer.cs b/Software/Visual_Studio/Tango.DataStore.Editing/Properties/Resources.Designer.cs deleted file mode 100644 index c23f8f4eb..000000000 --- a/Software/Visual_Studio/Tango.DataStore.Editing/Properties/Resources.Designer.cs +++ /dev/null @@ -1,62 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Tango.DataStore.Editing.Properties { - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if ((resourceMan == null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Tango.DataStore.Editing.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - } -} diff --git a/Software/Visual_Studio/Tango.DataStore.Editing/Properties/Resources.resx b/Software/Visual_Studio/Tango.DataStore.Editing/Properties/Resources.resx deleted file mode 100644 index af7dbebba..000000000 --- a/Software/Visual_Studio/Tango.DataStore.Editing/Properties/Resources.resx +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.DataStore.Editing/Properties/Settings.Designer.cs b/Software/Visual_Studio/Tango.DataStore.Editing/Properties/Settings.Designer.cs deleted file mode 100644 index 28f49dcd4..000000000 --- a/Software/Visual_Studio/Tango.DataStore.Editing/Properties/Settings.Designer.cs +++ /dev/null @@ -1,30 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Tango.DataStore.Editing.Properties -{ - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase - { - - private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default - { - get - { - return defaultInstance; - } - } - } -} diff --git a/Software/Visual_Studio/Tango.DataStore.Editing/Properties/Settings.settings b/Software/Visual_Studio/Tango.DataStore.Editing/Properties/Settings.settings deleted file mode 100644 index 033d7a5e9..000000000 --- a/Software/Visual_Studio/Tango.DataStore.Editing/Properties/Settings.settings +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.DataStore.Editing/Tango.DataStore.Editing.csproj b/Software/Visual_Studio/Tango.DataStore.Editing/Tango.DataStore.Editing.csproj deleted file mode 100644 index 4707dca0b..000000000 --- a/Software/Visual_Studio/Tango.DataStore.Editing/Tango.DataStore.Editing.csproj +++ /dev/null @@ -1,106 +0,0 @@ - - - - - Debug - AnyCPU - {EE088FF7-04D1-41FB-9D6A-CEDEEE7A7B9C} - library - Tango.DataStore.Editing - Tango.DataStore.Editing - v4.6.1 - 512 - {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 4 - true - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - 4.0 - - - - - - - - - - MSBuild:Compile - Designer - - - Code - - - - - - - - Code - - - True - True - Resources.resx - - - True - Settings.settings - True - - - ResXFileCodeGenerator - Resources.Designer.cs - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - - - {f441feee-322a-4943-b566-110e12fd3b72} - Tango.BL - - - {a34ee0f0-649d-41c8-8489-b6f1cc6924ee} - Tango.Core - - - {e0364dfa-0721-4637-9d32-9d22aac109d6} - Tango.DataStore - - - {8491d07b-c1f6-4b62-a412-41b9fd2d6538} - Tango.SharedUI - - - - \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.DataStore.Editing/Themes/Generic.xaml b/Software/Visual_Studio/Tango.DataStore.Editing/Themes/Generic.xaml deleted file mode 100644 index 795842292..000000000 --- a/Software/Visual_Studio/Tango.DataStore.Editing/Themes/Generic.xaml +++ /dev/null @@ -1,18 +0,0 @@ - - - diff --git a/Software/Visual_Studio/Tango.DataStore.Editing/UpdateDataStoreRequest.cs b/Software/Visual_Studio/Tango.DataStore.Editing/UpdateDataStoreRequest.cs deleted file mode 100644 index dc95ea6ae..000000000 --- a/Software/Visual_Studio/Tango.DataStore.Editing/UpdateDataStoreRequest.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.BL.DTO; - -namespace Tango.DataStore.Editing -{ - public class UpdateDataStoreRequest - { - public List ToDelete { get; set; } - public List ToUpsert { get; set; } - - public UpdateDataStoreRequest() - { - ToDelete = new List(); - ToUpsert = new List(); - } - } -} diff --git a/Software/Visual_Studio/Tango.DataStore.Editing/UpdateDataStoreResponse.cs b/Software/Visual_Studio/Tango.DataStore.Editing/UpdateDataStoreResponse.cs deleted file mode 100644 index 697ae341d..000000000 --- a/Software/Visual_Studio/Tango.DataStore.Editing/UpdateDataStoreResponse.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.DataStore.Editing -{ - public class UpdateDataStoreResponse - { - - } -} diff --git a/Software/Visual_Studio/Tango.DataStore.LiteDB/LiteDBDataStoreCollection.cs b/Software/Visual_Studio/Tango.DataStore.LiteDB/LiteDBDataStoreCollection.cs deleted file mode 100644 index c76a3b6d9..000000000 --- a/Software/Visual_Studio/Tango.DataStore.LiteDB/LiteDBDataStoreCollection.cs +++ /dev/null @@ -1,113 +0,0 @@ -using LiteDB; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.DataStore.Lite -{ - public class LiteDBDataStoreCollection : IDataStoreCollection - { - private ILiteCollection _collection; - - public string Name { get; private set; } - - public LiteDBDataStoreCollection(ILiteCollection collection) - { - _collection = collection; - } - - public void Put(string key, T value) - { - Put(key, (object)value); - } - - public void Put(string key, object value) - { - Put(key, DataStoreHelper.GetDataType(value), value); - } - - public void Put(string key, DataType type, object value) - { - _collection.Upsert(new LiteDBDataStoreItem() - { - Key = key, - Date = DateTime.UtcNow, - Type = type, - Value = value, - IsSynchronized = false, - }); - } - - public T Get(string key) - { - return (T)Convert.ChangeType(Get(key), typeof(T)); - } - - public T Get(string key, T defaultValue) - { - return (T)Convert.ChangeType(Get(key, defaultValue), typeof(T)); - } - - public object Get(string key) - { - return Get(key, null); - } - - public object Get(string key, object defaultValue) - { - return GetItem(key, defaultValue).Value; - } - - public IDataStoreItem GetItem(string key) - { - return GetItem(key, null); - } - - public IDataStoreItem GetItem(string key, object defaultValue) - { - var item = _collection.FindById(key); - - if (item == null) - { - if (defaultValue == null) - { - throw new KeyNotFoundException("The specified key was not found on the data store."); - } - else - { - Put(key, defaultValue); - return GetItem(key); - } - } - - return item; - } - - public List GetAll() - { - return _collection.FindAll().ToList(); - } - - public void Delete(string key) - { - _collection.Delete(key); - } - - public void DeleteAll() - { - _collection.DeleteMany(x => true); - } - - public int Count() - { - return _collection.Count(); - } - - public List GetUnsynchronized() - { - return _collection.Find(x => !x.IsSynchronized).ToList(); - } - } -} diff --git a/Software/Visual_Studio/Tango.DataStore.LiteDB/LiteDBDataStoreItem.cs b/Software/Visual_Studio/Tango.DataStore.LiteDB/LiteDBDataStoreItem.cs deleted file mode 100644 index ba2e5748e..000000000 --- a/Software/Visual_Studio/Tango.DataStore.LiteDB/LiteDBDataStoreItem.cs +++ /dev/null @@ -1,30 +0,0 @@ -using LiteDB; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.DataStore.Lite -{ - public class LiteDBDataStoreItem : IDataStoreItem - { - public String Guid { get; set; } - [BsonId] - public string Key { get; set; } - public DataType Type { get; set; } - public object Value { get; set; } - public DateTime Date { get; set; } - public bool IsSynchronized { get; set; } - - public LiteDBDataStoreItem() - { - Guid = System.Guid.NewGuid().ToString(); - } - - public override string ToString() - { - return DataStoreHelper.FormatDataStoreItem(this); - } - } -} diff --git a/Software/Visual_Studio/Tango.DataStore.LiteDB/LiteDBDataStoreManager.cs b/Software/Visual_Studio/Tango.DataStore.LiteDB/LiteDBDataStoreManager.cs deleted file mode 100644 index 25abd91ab..000000000 --- a/Software/Visual_Studio/Tango.DataStore.LiteDB/LiteDBDataStoreManager.cs +++ /dev/null @@ -1,47 +0,0 @@ -using LiteDB; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.DataStore.Lite -{ - public class LiteDBDataStoreManager : IDataStoreManager - { - private bool _disposed; - private LiteDatabase _database; - - public String DatabasePath { get; private set; } - - public LiteDBDataStoreManager(String databasePath) - { - DatabasePath = databasePath; - Directory.CreateDirectory(Path.GetDirectoryName(DatabasePath)); - _database = new LiteDatabase($"Filename={DatabasePath}"); - _database.Pragma("TIMEOUT", 10); //Read Timeout - _database.Pragma("UTC_DATE", true); //Keep time as UTC when getting data - _database.Commit(); - } - - public IDataStoreCollection GetCollection(string name) - { - return new LiteDBDataStoreCollection(_database.GetCollection(name)); - } - - public List GetCollectionNames() - { - return _database.GetCollectionNames().ToList(); - } - - public void Dispose() - { - if (!_disposed) - { - _disposed = true; - _database.Dispose(); - } - } - } -} diff --git a/Software/Visual_Studio/Tango.DataStore.LiteDB/Properties/AssemblyInfo.cs b/Software/Visual_Studio/Tango.DataStore.LiteDB/Properties/AssemblyInfo.cs deleted file mode 100644 index f1b35f107..000000000 --- a/Software/Visual_Studio/Tango.DataStore.LiteDB/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,7 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -[assembly: AssemblyTitle("Tango - Data Store LiteDB Implementation")] -[assembly: AssemblyVersion("2.0.4.1608")] -[assembly: ComVisible(false)] \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.DataStore.LiteDB/Tango.DataStore.Lite.csproj b/Software/Visual_Studio/Tango.DataStore.LiteDB/Tango.DataStore.Lite.csproj deleted file mode 100644 index 2bf561432..000000000 --- a/Software/Visual_Studio/Tango.DataStore.LiteDB/Tango.DataStore.Lite.csproj +++ /dev/null @@ -1,66 +0,0 @@ - - - - - Debug - AnyCPU - {FA96BC0C-4055-475C-9DCC-70A5A9436B10} - Library - Properties - Tango.DataStore.Lite - Tango.DataStore.Lite - v4.6.1 - 512 - true - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\packages\LiteDB.5.0.4\lib\net45\LiteDB.dll - - - - - - - - - - - - - - GlobalVersionInfo.cs - - - - - - - - - {e0364dfa-0721-4637-9d32-9d22aac109d6} - Tango.DataStore - - - - - - - \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.DataStore.LiteDB/packages.config b/Software/Visual_Studio/Tango.DataStore.LiteDB/packages.config deleted file mode 100644 index 9dcac7837..000000000 --- a/Software/Visual_Studio/Tango.DataStore.LiteDB/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.DataStore.Remote/Properties/AssemblyInfo.cs b/Software/Visual_Studio/Tango.DataStore.Remote/Properties/AssemblyInfo.cs deleted file mode 100644 index 808b25d41..000000000 --- a/Software/Visual_Studio/Tango.DataStore.Remote/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,7 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -[assembly: AssemblyTitle("Tango - Data Store Remote Messages")] -[assembly: AssemblyVersion("2.0.4.1608")] -[assembly: ComVisible(false)] \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreCollection.cs b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreCollection.cs deleted file mode 100644 index e4453fafc..000000000 --- a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreCollection.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.DataStore.Remote -{ - public class RemoteDataStoreCollection - { - public String Name { get; set; } - public List Items { get; set; } - - public RemoteDataStoreCollection() - { - Items = new List(); - } - } -} diff --git a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreCountRequest.cs b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreCountRequest.cs deleted file mode 100644 index 84ba279fb..000000000 --- a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreCountRequest.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.DataStore.Remote -{ - public class RemoteDataStoreCountRequest - { - public String Collection { get; set; } - } -} diff --git a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreCountResponse.cs b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreCountResponse.cs deleted file mode 100644 index 71d4e13b2..000000000 --- a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreCountResponse.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.DataStore.Remote -{ - public class RemoteDataStoreCountResponse - { - public int Count { get; set; } - } -} diff --git a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreDeleteAllRequest.cs b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreDeleteAllRequest.cs deleted file mode 100644 index ab5406611..000000000 --- a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreDeleteAllRequest.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.DataStore.Remote -{ - public class RemoteDataStoreDeleteAllRequest - { - public String Collection { get; set; } - } -} diff --git a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreDeleteAllResponse.cs b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreDeleteAllResponse.cs deleted file mode 100644 index b5ddc0b64..000000000 --- a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreDeleteAllResponse.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.DataStore.Remote -{ - public class RemoteDataStoreDeleteAllResponse - { - - } -} diff --git a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreDeleteRequest.cs b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreDeleteRequest.cs deleted file mode 100644 index 13d400154..000000000 --- a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreDeleteRequest.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.DataStore.Remote -{ - public class RemoteDataStoreDeleteRequest - { - public String Collection { get; set; } - public String Key { get; set; } - } -} diff --git a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreDeleteResponse.cs b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreDeleteResponse.cs deleted file mode 100644 index 07bb40a8b..000000000 --- a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreDeleteResponse.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.DataStore.Remote -{ - public class RemoteDataStoreDeleteResponse - { - } -} diff --git a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetAllItemsRequest.cs b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetAllItemsRequest.cs deleted file mode 100644 index a285cd5c1..000000000 --- a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetAllItemsRequest.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.DataStore.Remote -{ - public class RemoteDataStoreGetAllItemsRequest - { - } -} diff --git a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetAllItemsResponse.cs b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetAllItemsResponse.cs deleted file mode 100644 index 3afb22c1e..000000000 --- a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetAllItemsResponse.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.DataStore.Remote -{ - public class RemoteDataStoreGetAllItemsResponse - { - public List Collections { get; set; } - - public RemoteDataStoreGetAllItemsResponse() - { - Collections = new List(); - } - } -} diff --git a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetAllRequest.cs b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetAllRequest.cs deleted file mode 100644 index 747a5cb2f..000000000 --- a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetAllRequest.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.DataStore.Remote -{ - public class RemoteDataStoreGetAllRequest - { - public String Collection { get; set; } - } -} diff --git a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetAllResponse.cs b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetAllResponse.cs deleted file mode 100644 index 2d9e0f527..000000000 --- a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetAllResponse.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.DataStore.Remote -{ - public class RemoteDataStoreGetAllResponse - { - public List Items { get; set; } - - public RemoteDataStoreGetAllResponse() - { - Items = new List(); - } - } -} diff --git a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetCollectionNamesRequest.cs b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetCollectionNamesRequest.cs deleted file mode 100644 index 6299f7512..000000000 --- a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetCollectionNamesRequest.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.DataStore.Remote -{ - public class RemoteDataStoreGetCollectionNamesRequest - { - } -} diff --git a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetCollectionNamesResponse.cs b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetCollectionNamesResponse.cs deleted file mode 100644 index fe98b73fc..000000000 --- a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetCollectionNamesResponse.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.DataStore.Remote -{ - public class RemoteDataStoreGetCollectionNamesResponse - { - public List Names { get; set; } - - public RemoteDataStoreGetCollectionNamesResponse() - { - Names = new List(); - } - } -} diff --git a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetItemRequest.cs b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetItemRequest.cs deleted file mode 100644 index 7d16a0f38..000000000 --- a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetItemRequest.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.DataStore.Remote -{ - public class RemoteDataStoreGetItemRequest - { - public String Collection { get; set; } - public String Key { get; set; } - public Object DefaultValue { get; set; } - } -} diff --git a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetItemResponse.cs b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetItemResponse.cs deleted file mode 100644 index 82393a786..000000000 --- a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetItemResponse.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.DataStore.Remote -{ - public class RemoteDataStoreGetItemResponse - { - public RemoteDataStoreItem Item { get; set; } - } -} diff --git a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetRequest.cs b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetRequest.cs deleted file mode 100644 index 4b8e9ee47..000000000 --- a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetRequest.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.DataStore.Remote -{ - public class RemoteDataStoreGetRequest - { - public String Collection { get; set; } - public String Key { get; set; } - public Object DefaultValue { get; set; } - } -} diff --git a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetResponse.cs b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetResponse.cs deleted file mode 100644 index cc3b157e8..000000000 --- a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetResponse.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.DataStore.Remote -{ - public class RemoteDataStoreGetResponse - { - public DataType DataType { get; set; } - - private Object _value; - public Object Value - { - get - { - return DataType == DataType.Proto ? ProtoObject : _value; - } - set - { - if (value is DataStoreProtoObject protoValue) - { - ProtoObject = protoValue; - } - else - { - _value = value; - } - } - } - - public DataStoreProtoObject ProtoObject { get; set; } - } -} diff --git a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreItem.cs b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreItem.cs deleted file mode 100644 index 4327a0bd6..000000000 --- a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreItem.cs +++ /dev/null @@ -1,47 +0,0 @@ -using Newtonsoft.Json.Linq; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.DataStore.Remote -{ - public class RemoteDataStoreItem : IDataStoreItem - { - public string Guid { get; set; } - public string Key { get; set; } - public DataType Type { get; set; } - - private object _value; - public object Value - { - get - { - if (_value is JObject jObject) - { - return (jObject.ToObject()); - } - else - { - return _value; - } - } - set { _value = value; } - } - - public DateTime Date { get; set; } - public bool IsSynchronized { get; set; } - - public RemoteDataStoreItem() - { - Guid = System.Guid.NewGuid().ToString(); - Date = DateTime.UtcNow; - } - - public override string ToString() - { - return DataStoreHelper.FormatDataStoreItem(this); - } - } -} diff --git a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStorePutRequest.cs b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStorePutRequest.cs deleted file mode 100644 index 77aa5e41f..000000000 --- a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStorePutRequest.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.DataStore.Remote -{ - public class RemoteDataStorePutRequest - { - public String Collection { get; set; } - public DataType DataType { get; set; } - public String Key { get; set; } - - private Object _value; - public Object Value - { - get - { - return DataType == DataType.Proto ? ProtoObject : _value; - } - set - { - if (value is DataStoreProtoObject protoValue) - { - ProtoObject = protoValue; - } - else - { - _value = value; - } - } - } - - public DataStoreProtoObject ProtoObject { get; set; } - } -} diff --git a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStorePutResponse.cs b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStorePutResponse.cs deleted file mode 100644 index 7dd92490a..000000000 --- a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStorePutResponse.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.DataStore.Remote -{ - public class RemoteDataStorePutResponse - { - } -} diff --git a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreStartListenRequest.cs b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreStartListenRequest.cs deleted file mode 100644 index b8da17012..000000000 --- a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreStartListenRequest.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.DataStore.Remote -{ - public class RemoteDataStoreStartListenRequest - { - } -} diff --git a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreStartListenResponse.cs b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreStartListenResponse.cs deleted file mode 100644 index c2a6c24a6..000000000 --- a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreStartListenResponse.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.DataStore.Remote -{ - public enum RemoteDataStoreChangeType - { - None, - Modified - } - - public class RemoteDataStoreStartListenResponse - { - public RemoteDataStoreChangeType ChangeType { get; set; } - public String CollectionName { get; set; } - public RemoteDataStoreItem Item { get; set; } - } -} diff --git a/Software/Visual_Studio/Tango.DataStore.Remote/Tango.DataStore.Remote.csproj b/Software/Visual_Studio/Tango.DataStore.Remote/Tango.DataStore.Remote.csproj deleted file mode 100644 index 8618affdd..000000000 --- a/Software/Visual_Studio/Tango.DataStore.Remote/Tango.DataStore.Remote.csproj +++ /dev/null @@ -1,87 +0,0 @@ - - - - - Debug - AnyCPU - {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA} - Library - Properties - Tango.DataStore.Remote - Tango.DataStore.Remote - v4.6.1 - 512 - true - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\packages\Google.Protobuf.3.4.1\lib\net45\Google.Protobuf.dll - - - ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll - - - - - - - - - - - - - GlobalVersionInfo.cs - - - - - - - - - - - - - - - - - - - - - - - - - - - - {e0364dfa-0721-4637-9d32-9d22aac109d6} - Tango.DataStore - - - - - - - \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.DataStore.Remote/packages.config b/Software/Visual_Studio/Tango.DataStore.Remote/packages.config deleted file mode 100644 index 026e719c3..000000000 --- a/Software/Visual_Studio/Tango.DataStore.Remote/packages.config +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.DataStore/DataStoreHelper.cs b/Software/Visual_Studio/Tango.DataStore/DataStoreHelper.cs deleted file mode 100644 index 0ca8e484e..000000000 --- a/Software/Visual_Studio/Tango.DataStore/DataStoreHelper.cs +++ /dev/null @@ -1,160 +0,0 @@ -using Google.Protobuf; -using Newtonsoft.Json.Linq; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.Core.ExtensionMethods; -using Tango.PMR; -using Tango.PMR.Common; - -namespace Tango.DataStore -{ - /// - /// Contains data store helper methods. - /// - public static class DataStoreHelper - { - /// - /// Gets the data store data type by the specified object type. - /// - /// The value. - /// - public static DataType GetDataType(Object value) - { - return GetDataType(value.GetType()); - } - - /// - /// Gets data store data type by the specified .net type. - /// - /// The type. - /// - /// - public static DataType GetDataType(Type type) - { - if (type == typeof(int)) - { - return DataType.Int32; - } - else if (type == typeof(Int64)) - { - return DataType.Int32; - } - else if (type == typeof(float)) - { - return DataType.Float; - } - else if (type == typeof(double)) - { - return DataType.Double; - } - else if (type == typeof(String)) - { - return DataType.String; - } - else if (type == typeof(bool)) - { - return DataType.Boolean; - } - else if (type == typeof(byte[])) - { - return DataType.Bytes; - } - else if (type == typeof(DataStoreProtoObject)) - { - return DataType.Proto; - } - else if (typeof(IMessage).IsAssignableFrom(type)) - { - return DataType.Proto; - } - - throw new NotSupportedException($"The specified type '{type.Name}' is not supported by the data store."); - } - - /// - /// Formats the data store item as a string. - /// - /// The item. - /// - public static String FormatDataStoreItem(IDataStoreItem item) - { - if (item.Type == DataType.Bytes) - { - return GetByteArrayHexString((byte[])item.Value); - } - else if (item.Type == DataType.Proto) - { - return (item.Value as DataStoreProtoObject).Message.ToJsonString(); - } - else - { - return item.Value.ToStringSafe(); - } - } - - /// - /// Returns a byte array string representation in hex format. - /// - /// The data. - /// - public static String GetByteArrayHexString(byte[] data) - { - StringBuilder hex = new StringBuilder(); - foreach (byte b in data) - { - hex.Append(b.ToString("X2") + " "); - } - return hex.ToString(); - } - - /// - /// Parses a data store value from a string. - /// - /// The type. - /// The string. - /// Type of the proto message (if type is Proto). - /// - /// No PMR message type specified. - /// The specified data store type is not supported. - public static Object ParseDataStoreValue(DataType type, String text, MessageType? protoMessageType = null) - { - switch (type) - { - case DataType.String: - return text; - case DataType.Int32: - return int.Parse(text); - case DataType.Float: - return float.Parse(text); - case DataType.Double: - return double.Parse(text); - case DataType.Boolean: - return bool.Parse(text); - case DataType.Proto: - if (protoMessageType == null) throw new ArgumentNullException("No PMR message type specified."); - var messageType = MessageFactory.GetPMRTypeFromMessageType(protoMessageType.Value); - var instance = Activator.CreateInstance(messageType) as IMessage; - instance = instance.GetParser().ParseJson(text); - return DataStoreProtoObject.FromMessage(instance); - case DataType.Bytes: - string[] hexValuesSplit = text.Split(' '); - List bytes = new List(); - foreach (string hex in hexValuesSplit) - { - if (hex.IsNotNullOrEmpty()) - { - byte b = (byte)Convert.ToInt32(hex.Trim(), 16); - bytes.Add(b); - } - } - return bytes.ToArray(); - } - - throw new NotSupportedException("The specified data store type is not supported."); - } - } -} diff --git a/Software/Visual_Studio/Tango.DataStore/DataStoreProtoObject.cs b/Software/Visual_Studio/Tango.DataStore/DataStoreProtoObject.cs deleted file mode 100644 index 5aa7c5342..000000000 --- a/Software/Visual_Studio/Tango.DataStore/DataStoreProtoObject.cs +++ /dev/null @@ -1,83 +0,0 @@ -using Google.Protobuf; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.Core.Bson; -using Tango.Core.ExtensionMethods; -using Tango.PMR; -using Tango.PMR.Common; -using Tango.PMR.DataStore; - -namespace Tango.DataStore -{ - public class DataStoreProtoObject - { - public MessageType MessageType { get; set; } - public Type Type { get; set; } - public byte[] Data { get; set; } - - - private IMessage _message; - [JsonIgnore] - public IMessage Message - { - get - { - if (_message == null) - { - _message = MessageFactory.ParseProtoMessage(Data, Type); - } - - return _message; - } - private set { _message = value; } - } - - public byte[] ToBytes() - { - return BsonConvert.Serialize(this); - } - - public static DataStoreProtoObject FromBytes(byte[] data) - { - var instance = BsonConvert.Deserialize(data); - instance.Message = MessageFactory.ParseProtoMessage(instance.Data, instance.Type); - - return instance; - } - - public static DataStoreProtoObject FromMessage(IMessage message) - { - DataStoreProtoObject proto = new DataStoreProtoObject(); - proto.Type = message.GetType(); - proto.MessageType = MessageFactory.ParseMessageType(proto.Type.Name); - proto.Data = message.ToByteArray(); - proto.Message = message; - return proto; - } - - public static DataStoreProtoObject FromJObject(JObject obj) - { - return (obj.ToObject()); - } - - public static DataStoreProtoObject FromPMRDataStoreItem(DataStoreItem item) - { - DataStoreProtoObject proto = new DataStoreProtoObject(); - proto.MessageType = item.ProtoType; - proto.Type = MessageFactory.GetPMRTypeFromMessageType(item.ProtoType); - proto.Data = item.BytesValue.ToByteArray(); - return proto; - } - - public override string ToString() - { - return Message?.ToJsonString(); - } - } -} diff --git a/Software/Visual_Studio/Tango.DataStore/DataType.cs b/Software/Visual_Studio/Tango.DataStore/DataType.cs deleted file mode 100644 index 132bff28e..000000000 --- a/Software/Visual_Studio/Tango.DataStore/DataType.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.DataStore -{ - /// - /// Represents a data store item type. - /// - public enum DataType - { - Int32, - Float, - Double, - Boolean, - String, - Bytes, - Proto - } -} diff --git a/Software/Visual_Studio/Tango.DataStore/ExtensionMethods.cs b/Software/Visual_Studio/Tango.DataStore/ExtensionMethods.cs deleted file mode 100644 index acc381a61..000000000 --- a/Software/Visual_Studio/Tango.DataStore/ExtensionMethods.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Google.Protobuf; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.DataStore; - -public static class ExtensionMethods -{ - public static DataStoreProtoObject ToDataStoreProtoObject(IMessage message) - { - return DataStoreProtoObject.FromMessage(message); - } -} - diff --git a/Software/Visual_Studio/Tango.DataStore/IDataStoreCollection.cs b/Software/Visual_Studio/Tango.DataStore/IDataStoreCollection.cs deleted file mode 100644 index baca95c67..000000000 --- a/Software/Visual_Studio/Tango.DataStore/IDataStoreCollection.cs +++ /dev/null @@ -1,119 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.DataStore -{ - /// - /// Represents a data store collection. - /// - public interface IDataStoreCollection - { - /// - /// Gets the collection name. - /// - String Name { get; } - - /// - /// Upserts the specified key and value. - /// - /// The key. - /// The value. - void Put(String key, Object value); - - /// - /// Upserts the specified key and value of type T. - /// - /// - /// The key. - /// The value. - void Put(String key, T value); - - /// - /// Upserts the specified key and value. - /// The value must be of the specified DataType. - /// - /// The key. - /// The type. - /// The value. - void Put(String key, DataType type, Object value); - - /// - /// Gets the value by the specified key - /// - /// The key. - /// - Object Get(String key); - - /// - /// Gets the value by the specified key - /// - /// The key. - /// Will execute put when the key was not found. - /// - Object Get(String key, Object defaultValue); - - /// - /// Gets the value of type T by the specified key - /// - /// - /// The key. - /// - T Get(String key); - - /// - /// Gets the value of type T by the specified key - /// - /// - /// The key. - /// Will execute put when the key was not found. - /// - T Get(String key, T defaultValue); - - /// - /// Gets the full data store item by the specified key. - /// - /// The key. - /// - IDataStoreItem GetItem(String key); - - /// - /// Gets the full data store item by the specified key. - /// - /// The key. - /// Will execute put when the key was not found. - /// - IDataStoreItem GetItem(String key, Object defaultValue); - - /// - /// Gets all the data store items in the collection. - /// - /// - List GetAll(); - - /// - /// Gets all the data store unsynchronized items in the collection. - /// - /// - List GetUnsynchronized(); - - /// - /// Deleted an item by the specified key. - /// - /// The key. - void Delete(String key); - - /// - /// Deletes all items in the collection. - /// - void DeleteAll(); - - /// - /// Returns the number of items in the collection. - /// - /// - int Count(); - } -} diff --git a/Software/Visual_Studio/Tango.DataStore/IDataStoreItem.cs b/Software/Visual_Studio/Tango.DataStore/IDataStoreItem.cs deleted file mode 100644 index 9c03f40ee..000000000 --- a/Software/Visual_Studio/Tango.DataStore/IDataStoreItem.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.DataStore -{ - /// - /// Represents a data store item. - /// - public interface IDataStoreItem - { - /// - /// Gets or sets the unique identifier (Use only for synchronization). - /// - String Guid { get; set; } - - /// - /// Gets or sets item id. - /// - String Key { get; set; } - - /// - /// Gets or sets the item type. - /// - DataType Type { get; set; } - - /// - /// Gets or sets the item value. - /// - Object Value { get; set; } - - /// - /// Gets or sets the item update UTC date. - /// - DateTime Date { get; set; } - - /// - /// Gets or sets a value indicating whether this item is synchronized with the remote service. - /// - bool IsSynchronized { get; set; } - } -} diff --git a/Software/Visual_Studio/Tango.DataStore/IDataStoreManager.cs b/Software/Visual_Studio/Tango.DataStore/IDataStoreManager.cs deleted file mode 100644 index 5443f12e2..000000000 --- a/Software/Visual_Studio/Tango.DataStore/IDataStoreManager.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.DataStore -{ - /// - /// Represents a key/value data store manager. - /// - /// - public interface IDataStoreManager : IDisposable - { - /// - /// Gets the data store collection by name. - /// - /// The name. - /// - IDataStoreCollection GetCollection(String name); - - /// - /// Gets all the collection names. - /// - /// - List GetCollectionNames(); - } -} diff --git a/Software/Visual_Studio/Tango.DataStore/Properties/AssemblyInfo.cs b/Software/Visual_Studio/Tango.DataStore/Properties/AssemblyInfo.cs deleted file mode 100644 index 8e9365e03..000000000 --- a/Software/Visual_Studio/Tango.DataStore/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,7 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -[assembly: AssemblyTitle("Tango - Data Store Library")] -[assembly: AssemblyVersion("2.0.4.1608")] -[assembly: ComVisible(false)] \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.DataStore/Tango.DataStore.csproj b/Software/Visual_Studio/Tango.DataStore/Tango.DataStore.csproj deleted file mode 100644 index c12abe9e8..000000000 --- a/Software/Visual_Studio/Tango.DataStore/Tango.DataStore.csproj +++ /dev/null @@ -1,78 +0,0 @@ - - - - - Debug - AnyCPU - {E0364DFA-0721-4637-9D32-9D22AAC109D6} - Library - Properties - Tango.DataStore - Tango.DataStore - v4.6.1 - 512 - true - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - bin\Debug\Tango.DataStore.xml - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - bin\Release\Tango.DataStore.xml - - - - ..\packages\Google.Protobuf.3.4.1\lib\net45\Google.Protobuf.dll - - - ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll - - - - - - - - - - - - - GlobalVersionInfo.cs - - - - - - - - - - - - - - - - {A34EE0F0-649D-41C8-8489-B6F1CC6924EE} - Tango.Core - - - {e4927038-348d-4295-aaf4-861c58cb3943} - Tango.PMR - - - - \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.DataStore/packages.config b/Software/Visual_Studio/Tango.DataStore/packages.config deleted file mode 100644 index 026e719c3..000000000 --- a/Software/Visual_Studio/Tango.DataStore/packages.config +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj b/Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj index b24079da0..4d76daabc 100644 --- a/Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj +++ b/Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj @@ -173,6 +173,22 @@ + + {88d9906b-8fc4-4fe0-b7eb-127a0a8fcee4} + Tango.DataStore.EF + + + {fa96bc0c-4055-475c-9dcc-70a5a9436b10} + Tango.DataStore.Lite + + + {29448f3c-9b3e-4da6-8555-46a8b9a6b3aa} + Tango.DataStore.Remote + + + {e0364dfa-0721-4637-9d32-9d22aac109d6} + Tango.DataStore + {1674f726-0e66-414f-b9fd-c6f20d7f07c7} Tango.MachineStudio.Logging @@ -213,22 +229,6 @@ {38197109-8610-4d3f-92b9-16d48df94d7c} Tango.DAL.Remote - - {88d9906b-8fc4-4fe0-b7eb-127a0a8fcee4} - Tango.DataStore.EF - - - {fa96bc0c-4055-475c-9dcc-70a5a9436b10} - Tango.DataStore.Lite - - - {29448f3c-9b3e-4da6-8555-46a8b9a6b3aa} - Tango.DataStore.Remote - - - {e0364dfa-0721-4637-9d32-9d22aac109d6} - Tango.DataStore - {ca87a608-7b17-4c98-88f2-42abee10f4c1} Tango.Documents @@ -323,7 +323,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.sln b/Software/Visual_Studio/Tango.sln index 64f19da67..3fe0dea56 100644 --- a/Software/Visual_Studio/Tango.sln +++ b/Software/Visual_Studio/Tango.sln @@ -419,17 +419,19 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.Git", "Tango.Git\Tang EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.PPC.Packages.Auth2", "PPC\UpdatePackages\Tango.PPC.Packages.Auth2\Tango.PPC.Packages.Auth2.csproj", "{EA4233F1-4B7B-4CCF-A6DE-2D17612EBA90}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.DataStore", "Tango.DataStore\Tango.DataStore.csproj", "{E0364DFA-0721-4637-9D32-9D22AAC109D6}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.FSE.MachineConfiguration", "FSE\Modules\Tango.FSE.MachineConfiguration\Tango.FSE.MachineConfiguration.csproj", "{15BCB5BB-731E-4E2D-AA28-75485050A8DC}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.DataStore.Lite", "Tango.DataStore.LiteDB\Tango.DataStore.Lite.csproj", "{FA96BC0C-4055-475C-9DCC-70A5A9436B10}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DataStore", "DataStore", "{3F723D53-3539-42D1-8570-395BF660928D}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.DataStore.Remote", "Tango.DataStore.Remote\Tango.DataStore.Remote.csproj", "{29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.DataStore", "DataStore\Tango.DataStore\Tango.DataStore.csproj", "{E0364DFA-0721-4637-9D32-9D22AAC109D6}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.DataStore.EF", "Tango.DataStore.EF\Tango.DataStore.EF.csproj", "{88D9906B-8FC4-4FE0-B7EB-127A0A8FCEE4}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.DataStore.Lite", "DataStore\Tango.DataStore.LiteDB\Tango.DataStore.Lite.csproj", "{FA96BC0C-4055-475C-9DCC-70A5A9436B10}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.FSE.MachineConfiguration", "FSE\Modules\Tango.FSE.MachineConfiguration\Tango.FSE.MachineConfiguration.csproj", "{15BCB5BB-731E-4E2D-AA28-75485050A8DC}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.DataStore.EF", "DataStore\Tango.DataStore.EF\Tango.DataStore.EF.csproj", "{88D9906B-8FC4-4FE0-B7EB-127A0A8FCEE4}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.DataStore.Remote", "DataStore\Tango.DataStore.Remote\Tango.DataStore.Remote.csproj", "{29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.DataStore.Editing", "Tango.DataStore.Editing\Tango.DataStore.Editing.csproj", "{EE088FF7-04D1-41FB-9D6A-CEDEEE7A7B9C}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.DataStore.Editing", "DataStore\Tango.DataStore.Editing\Tango.DataStore.Editing.csproj", "{EE088FF7-04D1-41FB-9D6A-CEDEEE7A7B9C}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -3958,6 +3960,26 @@ Global {EA4233F1-4B7B-4CCF-A6DE-2D17612EBA90}.Release|x64.Build.0 = Release|Any CPU {EA4233F1-4B7B-4CCF-A6DE-2D17612EBA90}.Release|x86.ActiveCfg = Release|Any CPU {EA4233F1-4B7B-4CCF-A6DE-2D17612EBA90}.Release|x86.Build.0 = Release|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Debug|ARM.ActiveCfg = Debug|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Debug|ARM.Build.0 = Debug|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Debug|ARM64.Build.0 = Debug|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Debug|x64.ActiveCfg = Debug|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Debug|x64.Build.0 = Debug|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Debug|x86.ActiveCfg = Debug|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Debug|x86.Build.0 = Debug|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Release|Any CPU.Build.0 = Release|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Release|ARM.ActiveCfg = Release|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Release|ARM.Build.0 = Release|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Release|ARM64.ActiveCfg = Release|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Release|ARM64.Build.0 = Release|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Release|x64.ActiveCfg = Release|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Release|x64.Build.0 = Release|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Release|x86.ActiveCfg = Release|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Release|x86.Build.0 = Release|Any CPU {E0364DFA-0721-4637-9D32-9D22AAC109D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {E0364DFA-0721-4637-9D32-9D22AAC109D6}.Debug|Any CPU.Build.0 = Debug|Any CPU {E0364DFA-0721-4637-9D32-9D22AAC109D6}.Debug|ARM.ActiveCfg = Debug|Any CPU @@ -3998,26 +4020,6 @@ Global {FA96BC0C-4055-475C-9DCC-70A5A9436B10}.Release|x64.Build.0 = Release|Any CPU {FA96BC0C-4055-475C-9DCC-70A5A9436B10}.Release|x86.ActiveCfg = Release|Any CPU {FA96BC0C-4055-475C-9DCC-70A5A9436B10}.Release|x86.Build.0 = Release|Any CPU - {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Debug|ARM.ActiveCfg = Debug|Any CPU - {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Debug|ARM.Build.0 = Debug|Any CPU - {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Debug|ARM64.ActiveCfg = Debug|Any CPU - {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Debug|ARM64.Build.0 = Debug|Any CPU - {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Debug|x64.ActiveCfg = Debug|Any CPU - {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Debug|x64.Build.0 = Debug|Any CPU - {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Debug|x86.ActiveCfg = Debug|Any CPU - {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Debug|x86.Build.0 = Debug|Any CPU - {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Release|Any CPU.Build.0 = Release|Any CPU - {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Release|ARM.ActiveCfg = Release|Any CPU - {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Release|ARM.Build.0 = Release|Any CPU - {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Release|ARM64.ActiveCfg = Release|Any CPU - {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Release|ARM64.Build.0 = Release|Any CPU - {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Release|x64.ActiveCfg = Release|Any CPU - {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Release|x64.Build.0 = Release|Any CPU - {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Release|x86.ActiveCfg = Release|Any CPU - {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Release|x86.Build.0 = Release|Any CPU {88D9906B-8FC4-4FE0-B7EB-127A0A8FCEE4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {88D9906B-8FC4-4FE0-B7EB-127A0A8FCEE4}.Debug|Any CPU.Build.0 = Debug|Any CPU {88D9906B-8FC4-4FE0-B7EB-127A0A8FCEE4}.Debug|ARM.ActiveCfg = Debug|Any CPU @@ -4038,26 +4040,26 @@ Global {88D9906B-8FC4-4FE0-B7EB-127A0A8FCEE4}.Release|x64.Build.0 = Release|Any CPU {88D9906B-8FC4-4FE0-B7EB-127A0A8FCEE4}.Release|x86.ActiveCfg = Release|Any CPU {88D9906B-8FC4-4FE0-B7EB-127A0A8FCEE4}.Release|x86.Build.0 = Release|Any CPU - {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Debug|ARM.ActiveCfg = Debug|Any CPU - {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Debug|ARM.Build.0 = Debug|Any CPU - {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Debug|ARM64.ActiveCfg = Debug|Any CPU - {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Debug|ARM64.Build.0 = Debug|Any CPU - {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Debug|x64.ActiveCfg = Debug|Any CPU - {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Debug|x64.Build.0 = Debug|Any CPU - {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Debug|x86.ActiveCfg = Debug|Any CPU - {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Debug|x86.Build.0 = Debug|Any CPU - {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Release|Any CPU.ActiveCfg = Release|Any CPU - {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Release|Any CPU.Build.0 = Release|Any CPU - {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Release|ARM.ActiveCfg = Release|Any CPU - {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Release|ARM.Build.0 = Release|Any CPU - {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Release|ARM64.ActiveCfg = Release|Any CPU - {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Release|ARM64.Build.0 = Release|Any CPU - {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Release|x64.ActiveCfg = Release|Any CPU - {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Release|x64.Build.0 = Release|Any CPU - {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Release|x86.ActiveCfg = Release|Any CPU - {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Release|x86.Build.0 = Release|Any CPU + {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Debug|ARM.ActiveCfg = Debug|Any CPU + {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Debug|ARM.Build.0 = Debug|Any CPU + {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Debug|ARM64.Build.0 = Debug|Any CPU + {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Debug|x64.ActiveCfg = Debug|Any CPU + {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Debug|x64.Build.0 = Debug|Any CPU + {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Debug|x86.ActiveCfg = Debug|Any CPU + {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Debug|x86.Build.0 = Debug|Any CPU + {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Release|Any CPU.Build.0 = Release|Any CPU + {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Release|ARM.ActiveCfg = Release|Any CPU + {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Release|ARM.Build.0 = Release|Any CPU + {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Release|ARM64.ActiveCfg = Release|Any CPU + {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Release|ARM64.Build.0 = Release|Any CPU + {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Release|x64.ActiveCfg = Release|Any CPU + {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Release|x64.Build.0 = Release|Any CPU + {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Release|x86.ActiveCfg = Release|Any CPU + {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Release|x86.Build.0 = Release|Any CPU {EE088FF7-04D1-41FB-9D6A-CEDEEE7A7B9C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {EE088FF7-04D1-41FB-9D6A-CEDEEE7A7B9C}.Debug|Any CPU.Build.0 = Debug|Any CPU {EE088FF7-04D1-41FB-9D6A-CEDEEE7A7B9C}.Debug|ARM.ActiveCfg = Debug|Any CPU @@ -4222,6 +4224,11 @@ Global {69168924-9AA8-447D-AD64-F07DBF4F0909} = {5F6BBAA8-EAD0-4B18-97E5-55B4F56DD760} {EA4233F1-4B7B-4CCF-A6DE-2D17612EBA90} = {E728CBD9-1AF4-4814-A218-E4BD26E7EDEA} {15BCB5BB-731E-4E2D-AA28-75485050A8DC} = {4EE6DBA1-71BC-49E2-8DC7-266487E61050} + {E0364DFA-0721-4637-9D32-9D22AAC109D6} = {3F723D53-3539-42D1-8570-395BF660928D} + {FA96BC0C-4055-475C-9DCC-70A5A9436B10} = {3F723D53-3539-42D1-8570-395BF660928D} + {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} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution BuildVersion_UseGlobalSettings = False -- cgit v1.3.1 From 0ee81ef847af3702b3b37f94cc62e835f9294e55 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Mon, 16 Nov 2020 14:35:19 +0200 Subject: Working on DataStore WebAPI & CLI. --- .../DataStore/Tango.DataStore.CLI/App.config | 28 ++++ .../DataStore/Tango.DataStore.CLI/Options.cs | 51 +++++++ .../DataStore/Tango.DataStore.CLI/Program.cs | 49 +++++++ .../Tango.DataStore.CLI/Properties/AssemblyInfo.cs | 36 +++++ .../Tango.DataStore.CLI/Tango.DataStore.CLI.csproj | 86 ++++++++++++ .../DataStore/Tango.DataStore.CLI/packages.config | 5 + .../Tango.DataStore.EF/EFDataStoreCollection.cs | 15 ++- .../Tango.DataStore/DataStoreProtoObject.cs | 2 + Software/Visual_Studio/Tango.sln | 35 ++++- .../Controllers/DataStoreController.cs | 150 +++++++++++++++++++++ .../DataStore/DataStoreWebItem.cs | 26 ++++ .../DataStore/DataStoreWebItemType.cs | 14 ++ .../Tango.MachineService.csproj | 13 +- 13 files changed, 500 insertions(+), 10 deletions(-) create mode 100644 Software/Visual_Studio/DataStore/Tango.DataStore.CLI/App.config create mode 100644 Software/Visual_Studio/DataStore/Tango.DataStore.CLI/Options.cs create mode 100644 Software/Visual_Studio/DataStore/Tango.DataStore.CLI/Program.cs create mode 100644 Software/Visual_Studio/DataStore/Tango.DataStore.CLI/Properties/AssemblyInfo.cs create mode 100644 Software/Visual_Studio/DataStore/Tango.DataStore.CLI/Tango.DataStore.CLI.csproj create mode 100644 Software/Visual_Studio/DataStore/Tango.DataStore.CLI/packages.config create mode 100644 Software/Visual_Studio/Web/Tango.MachineService/Controllers/DataStoreController.cs create mode 100644 Software/Visual_Studio/Web/Tango.MachineService/DataStore/DataStoreWebItem.cs create mode 100644 Software/Visual_Studio/Web/Tango.MachineService/DataStore/DataStoreWebItemType.cs (limited to 'Software/Visual_Studio') 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 @@ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + \ 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(args) + .WithParsed((options) => + { + Console.WriteLine($"{options.Email}, {options.Password}"); + }) + .WithParsed((options) => + { + Console.WriteLine($"{options.Email}, {options.Password}"); + }) + .WithNotParsed((errors) => + { + + }); + + Console.ReadLine(); + } + + private static int DisplayHelp(ParserResult result, IEnumerable 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 @@ + + + + + Debug + AnyCPU + {6189B8C3-7AF9-43DD-8A61-A8A05F526F62} + Exe + Tango.DataStore.CLI + Tango.DataStore.CLI + v4.6.1 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\..\packages\CommandLineParser.2.8.0\lib\net461\CommandLine.dll + + + ..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll + + + ..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll + + + + + + + + + + + + + + + + + + + + + + + {F441FEEE-322A-4943-B566-110E12FD3B72} + Tango.BL + + + {5001990f-977b-48ff-b217-0236a5022ad8} + Tango.Web + + + {88d9906b-8fc4-4fe0-b7eb-127a0a8fcee4} + Tango.DataStore.EF + + + {e0364dfa-0721-4637-9d32-9d22aac109d6} + Tango.DataStore + + + + + + + \ 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 @@ + + + + + \ 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 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>(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 finalList = new List(); + + 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>(ex, HttpStatusCode.InternalServerError, ex.FlattenMessage()); + } + } + + public void Post([FromBody]string value) + { + + } + + public void Put(int id, [FromBody]string value) + { + + } + + private T ThrowException(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 @@ + + + @@ -402,6 +405,14 @@ + + {88d9906b-8fc4-4fe0-b7eb-127a0a8fcee4} + Tango.DataStore.EF + + + {e0364dfa-0721-4637-9d32-9d22aac109d6} + Tango.DataStore + {d6f7d31d-7f8c-45e2-ae0a-fbbd1f5f9d5f} Tango.FSE.Web @@ -490,7 +501,7 @@ False - + -- cgit v1.3.1 From e45861e0422aba9e92a38b117b09c09d9cae0284 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Mon, 16 Nov 2020 14:35:46 +0200 Subject: Redundant. --- .../Visual_Studio/Web/Tango.MachineService/Properties/AssemblyInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Software/Visual_Studio') diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Properties/AssemblyInfo.cs b/Software/Visual_Studio/Web/Tango.MachineService/Properties/AssemblyInfo.cs index 601098814..e4f5879f5 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/Properties/AssemblyInfo.cs +++ b/Software/Visual_Studio/Web/Tango.MachineService/Properties/AssemblyInfo.cs @@ -24,4 +24,4 @@ using System.Runtime.InteropServices; // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("3.0.7.0")] +[assembly: AssemblyVersion("3.0.8.0")] -- cgit v1.3.1 From c39d31f1095bda6bda2755100f9f8df3da1eb93d Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Mon, 16 Nov 2020 16:13:30 +0200 Subject: Implemented workaround for none twine users testing on FSE login. --- .../FSE/Tango.FSE.UI/ViewModels/LoginViewVM.cs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'Software/Visual_Studio') diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/ViewModels/LoginViewVM.cs b/Software/Visual_Studio/FSE/Tango.FSE.UI/ViewModels/LoginViewVM.cs index 70a68918a..67b8a1145 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.UI/ViewModels/LoginViewVM.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/ViewModels/LoginViewVM.cs @@ -69,6 +69,11 @@ namespace Tango.FSE.UI.ViewModels set { _email = value; RaisePropertyChangedAuto(); RaisePropertyChanged(nameof(DisplayEnvironment)); InvalidateRelayCommands(); } } + public String ProcessedEmail + { + get { return Email.ToStringOrEmpty().EndsWith("TEST") ? Email.Replace("TEST", "") : Email; } + } + private String _password; /// /// Gets or sets the user password. @@ -158,7 +163,7 @@ namespace Tango.FSE.UI.ViewModels /// public bool DisplayEnvironment { - get { return Email.IsNotNullOrEmpty() && Email.ToLower().EndsWith("@twine-s.com"); } + get { return Email.IsNotNullOrEmpty() && (Email.ToLower().EndsWith("@twine-s.com") || Email.EndsWith("TEST")); } } #endregion @@ -288,7 +293,7 @@ namespace Tango.FSE.UI.ViewModels { try { - LogManager.Log($"Logging in user '{Email}'..."); + LogManager.Log($"Logging in user '{ProcessedEmail}'..."); if (!Validate()) { @@ -303,7 +308,7 @@ namespace Tango.FSE.UI.ViewModels } SelectedView = LoginViews.Logging; - var result = await AuthenticationProvider.Login(Email, Password, SelectedEnvironment, (status) => Status = status); + var result = await AuthenticationProvider.Login(ProcessedEmail, Password, SelectedEnvironment, (status) => Status = status); if (result.Response.PasswordChangeRequired) { @@ -327,7 +332,7 @@ namespace Tango.FSE.UI.ViewModels } catch (Exception ex) { - LogManager.Log(ex, $"Error occurred while trying to login user '{Email}'."); + LogManager.Log(ex, $"Error occurred while trying to login user '{ProcessedEmail}'."); IsFree = true; SelectedView = LoginViews.Login; await NotificationProvider.ShowError(GetErrorMessage(ex)); @@ -379,7 +384,7 @@ namespace Tango.FSE.UI.ViewModels IsFree = false; SelectedView = LoginViews.ChangingPassword; await Task.Delay(1000); - await AuthenticationProvider.ChangePassword(Email, CurrentPassword, NewPassword); + await AuthenticationProvider.ChangePassword(ProcessedEmail, CurrentPassword, NewPassword); Password = null; SelectedView = LoginViews.Login; Status = "Password changed..."; @@ -387,7 +392,7 @@ namespace Tango.FSE.UI.ViewModels } catch (Exception ex) { - LogManager.Log(ex, $"Error updating password for user '{Email}'."); + LogManager.Log(ex, $"Error updating password for user '{ProcessedEmail}'."); await NotificationProvider.ShowError($"Error updating your password.\n{ex.FlattenMessage()}"); SelectedView = LoginViews.ChangePassword; } @@ -428,7 +433,7 @@ namespace Tango.FSE.UI.ViewModels { IsFree = false; SelectedView = LoginViews.SendingForgotPasswordEmail; - await Services.AuthenticationService.SendForgotPasswordEmail(Email, SelectedEnvironment); + await Services.AuthenticationService.SendForgotPasswordEmail(ProcessedEmail, SelectedEnvironment); SelectedView = LoginViews.Login; await NotificationProvider.ShowSuccess("The email was delivered successfully!\nPlease check your email account."); } -- cgit v1.3.1 From 6f0f2a7908884deab8aca33ec967d03c5e564060 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Mon, 16 Nov 2020 18:32:04 +0200 Subject: Working on DataStore WebAPI. Modified data store bytes parsing to Base64. --- .../Tango.DataStore.EF/EFDataStoreHelper.cs | 16 +++- .../Tango.DataStore.EF/ExtensionMethods.cs | 9 ++- .../Tango.DataStore.Web/DataStoreWebHelper.cs | 16 ++++ .../Tango.DataStore.Web/DataStoreWebItem.cs | 26 +++++++ .../Tango.DataStore.Web/DataStoreWebItemType.cs | 14 ++++ .../Tango.DataStore.Web/DataStoreWebPutItem.cs | 28 +++++++ .../Tango.DataStore.Web/ExtensionMethods.cs | 12 +++ .../Tango.DataStore.Web/Properties/AssemblyInfo.cs | 36 +++++++++ .../Tango.DataStore.Web/Tango.DataStore.Web.csproj | 71 ++++++++++++++++++ .../DataStore/Tango.DataStore.Web/packages.config | 5 ++ .../DataStore/Tango.DataStore/DataStoreHelper.cs | 41 ++++------- .../Dialogs/DataStoreItemEditDialogViewVM.cs | 2 +- .../ViewModels/DataStoreViewVM.cs | 24 ++++-- .../ViewModels/SelectionViewVM.cs | 17 ++++- .../Views/SelectionView.xaml | 2 +- .../DataStore/DefaultDataStoreProvider.cs | 27 ++++++- .../DataStore/DefaultDataStoreService.cs | 33 +++++++++ Software/Visual_Studio/Tango.sln | 23 ++++++ .../Controllers/DataStoreController.cs | 85 ++++++++++++++++++++-- .../DataStore/DataStoreWebItem.cs | 26 ------- .../DataStore/DataStoreWebItemType.cs | 14 ---- .../Tango.MachineService.csproj | 6 +- 22 files changed, 441 insertions(+), 92 deletions(-) create mode 100644 Software/Visual_Studio/DataStore/Tango.DataStore.Web/DataStoreWebHelper.cs create mode 100644 Software/Visual_Studio/DataStore/Tango.DataStore.Web/DataStoreWebItem.cs create mode 100644 Software/Visual_Studio/DataStore/Tango.DataStore.Web/DataStoreWebItemType.cs create mode 100644 Software/Visual_Studio/DataStore/Tango.DataStore.Web/DataStoreWebPutItem.cs create mode 100644 Software/Visual_Studio/DataStore/Tango.DataStore.Web/ExtensionMethods.cs create mode 100644 Software/Visual_Studio/DataStore/Tango.DataStore.Web/Properties/AssemblyInfo.cs create mode 100644 Software/Visual_Studio/DataStore/Tango.DataStore.Web/Tango.DataStore.Web.csproj create mode 100644 Software/Visual_Studio/DataStore/Tango.DataStore.Web/packages.config delete mode 100644 Software/Visual_Studio/Web/Tango.MachineService/DataStore/DataStoreWebItem.cs delete mode 100644 Software/Visual_Studio/Web/Tango.MachineService/DataStore/DataStoreWebItemType.cs (limited to 'Software/Visual_Studio') diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore.EF/EFDataStoreHelper.cs b/Software/Visual_Studio/DataStore/Tango.DataStore.EF/EFDataStoreHelper.cs index 85b3b6731..5e885458b 100644 --- a/Software/Visual_Studio/DataStore/Tango.DataStore.EF/EFDataStoreHelper.cs +++ b/Software/Visual_Studio/DataStore/Tango.DataStore.EF/EFDataStoreHelper.cs @@ -89,11 +89,12 @@ namespace Tango.DataStore.EF }; } - public static DataStoreItem CreateDbDataStoreItem(IDataStoreItem item) + public static DataStoreItem CreateLocalDbDataStoreItem(IDataStoreItem item, String collection) { return new DataStoreItem() { Guid = item.Guid, + CollectionName = collection, LastUpdated = item.Date, IsSynchronized = item.IsSynchronized, Key = item.Key, @@ -101,5 +102,18 @@ namespace Tango.DataStore.EF Value = CreateBytes(item.Type, item.Value) }; } + + public static GlobalDataStoreItem CreateGlobalDbDataStoreItem(IDataStoreItem item, String collection) + { + return new GlobalDataStoreItem() + { + Guid = item.Guid, + CollectionName = collection, + LastUpdated = item.Date, + Key = item.Key, + DataType = (int)item.Type, + Value = CreateBytes(item.Type, item.Value) + }; + } } } diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore.EF/ExtensionMethods.cs b/Software/Visual_Studio/DataStore/Tango.DataStore.EF/ExtensionMethods.cs index 9f09ae658..6d45a69e7 100644 --- a/Software/Visual_Studio/DataStore/Tango.DataStore.EF/ExtensionMethods.cs +++ b/Software/Visual_Studio/DataStore/Tango.DataStore.EF/ExtensionMethods.cs @@ -19,9 +19,14 @@ public static class ExtensionMethods return EFDataStoreHelper.CreateDataStoreItem(item); } - public static DataStoreItem ToDbDataStoreItem(this IDataStoreItem item) + public static DataStoreItem ToLocalDbDataStoreItem(this IDataStoreItem item, String collection) { - return EFDataStoreHelper.CreateDbDataStoreItem(item); + return EFDataStoreHelper.CreateLocalDbDataStoreItem(item, collection); + } + + public static GlobalDataStoreItem ToGlobalDbDataStoreItem(this IDataStoreItem item, String collection) + { + return EFDataStoreHelper.CreateGlobalDbDataStoreItem(item, collection); } } diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore.Web/DataStoreWebHelper.cs b/Software/Visual_Studio/DataStore/Tango.DataStore.Web/DataStoreWebHelper.cs new file mode 100644 index 000000000..2353a70fe --- /dev/null +++ b/Software/Visual_Studio/DataStore/Tango.DataStore.Web/DataStoreWebHelper.cs @@ -0,0 +1,16 @@ +using Google.Protobuf; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.PMR; +using Tango.PMR.Common; + +namespace Tango.DataStore.Web +{ + public static class DataStoreWebHelper + { + + } +} diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore.Web/DataStoreWebItem.cs b/Software/Visual_Studio/DataStore/Tango.DataStore.Web/DataStoreWebItem.cs new file mode 100644 index 000000000..a847517b1 --- /dev/null +++ b/Software/Visual_Studio/DataStore/Tango.DataStore.Web/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.DataStore.Web +{ + 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/DataStore/Tango.DataStore.Web/DataStoreWebItemType.cs b/Software/Visual_Studio/DataStore/Tango.DataStore.Web/DataStoreWebItemType.cs new file mode 100644 index 000000000..684997bf4 --- /dev/null +++ b/Software/Visual_Studio/DataStore/Tango.DataStore.Web/DataStoreWebItemType.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace Tango.DataStore.Web +{ + public enum DataStoreWebItemType + { + Local, + Global, + Overrides + } +} \ No newline at end of file diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore.Web/DataStoreWebPutItem.cs b/Software/Visual_Studio/DataStore/Tango.DataStore.Web/DataStoreWebPutItem.cs new file mode 100644 index 000000000..6b897c82a --- /dev/null +++ b/Software/Visual_Studio/DataStore/Tango.DataStore.Web/DataStoreWebPutItem.cs @@ -0,0 +1,28 @@ +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.PMR.Common; + +namespace Tango.DataStore.Web +{ + public class DataStoreWebPutItem + { + public String MachineSerialNumber { get; set; } + + public String Collection { 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 Value { get; set; } + } +} diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore.Web/ExtensionMethods.cs b/Software/Visual_Studio/DataStore/Tango.DataStore.Web/ExtensionMethods.cs new file mode 100644 index 000000000..a0959ae27 --- /dev/null +++ b/Software/Visual_Studio/DataStore/Tango.DataStore.Web/ExtensionMethods.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore.Web +{ + public class ExtensionMethods + { + } +} diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore.Web/Properties/AssemblyInfo.cs b/Software/Visual_Studio/DataStore/Tango.DataStore.Web/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..27f57a100 --- /dev/null +++ b/Software/Visual_Studio/DataStore/Tango.DataStore.Web/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.Web")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Tango.DataStore.Web")] +[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("a9828548-af43-4ce4-8b13-50e99f9c9cf7")] + +// 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.Web/Tango.DataStore.Web.csproj b/Software/Visual_Studio/DataStore/Tango.DataStore.Web/Tango.DataStore.Web.csproj new file mode 100644 index 000000000..ac4e4a6f8 --- /dev/null +++ b/Software/Visual_Studio/DataStore/Tango.DataStore.Web/Tango.DataStore.Web.csproj @@ -0,0 +1,71 @@ + + + + + Debug + AnyCPU + {A9828548-AF43-4CE4-8B13-50E99F9C9CF7} + Library + Properties + Tango.DataStore.Web + Tango.DataStore.Web + v4.6.1 + 512 + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\..\packages\Google.Protobuf.3.4.1\lib\net45\Google.Protobuf.dll + + + ..\..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll + + + + + + + + + + + + + + + + + + + + + {e4927038-348d-4295-aaf4-861c58cb3943} + Tango.PMR + + + {e0364dfa-0721-4637-9d32-9d22aac109d6} + Tango.DataStore + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore.Web/packages.config b/Software/Visual_Studio/DataStore/Tango.DataStore.Web/packages.config new file mode 100644 index 000000000..026e719c3 --- /dev/null +++ b/Software/Visual_Studio/DataStore/Tango.DataStore.Web/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore/DataStoreHelper.cs b/Software/Visual_Studio/DataStore/Tango.DataStore/DataStoreHelper.cs index 0ca8e484e..0ceecd81b 100644 --- a/Software/Visual_Studio/DataStore/Tango.DataStore/DataStoreHelper.cs +++ b/Software/Visual_Studio/DataStore/Tango.DataStore/DataStoreHelper.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; +using System.Text.RegularExpressions; using System.Threading.Tasks; using Tango.Core.ExtensionMethods; using Tango.PMR; @@ -84,7 +85,7 @@ namespace Tango.DataStore { if (item.Type == DataType.Bytes) { - return GetByteArrayHexString((byte[])item.Value); + return Convert.ToBase64String((byte[])item.Value); } else if (item.Type == DataType.Proto) { @@ -96,21 +97,6 @@ namespace Tango.DataStore } } - /// - /// Returns a byte array string representation in hex format. - /// - /// The data. - /// - public static String GetByteArrayHexString(byte[] data) - { - StringBuilder hex = new StringBuilder(); - foreach (byte b in data) - { - hex.Append(b.ToString("X2") + " "); - } - return hex.ToString(); - } - /// /// Parses a data store value from a string. /// @@ -141,20 +127,21 @@ namespace Tango.DataStore instance = instance.GetParser().ParseJson(text); return DataStoreProtoObject.FromMessage(instance); case DataType.Bytes: - string[] hexValuesSplit = text.Split(' '); - List bytes = new List(); - foreach (string hex in hexValuesSplit) - { - if (hex.IsNotNullOrEmpty()) - { - byte b = (byte)Convert.ToInt32(hex.Trim(), 16); - bytes.Add(b); - } - } - return bytes.ToArray(); + return Convert.FromBase64String(text); } throw new NotSupportedException("The specified data store type is not supported."); } + + /// + /// Validates the name of the collection or key. + /// + /// The name. + /// + public static bool ValidateCollectionOrKeyName(String name) + { + var regexItem = new Regex("^[a-zA-Z0-9_-]*$"); + return regexItem.IsMatch(name); + } } } diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Dialogs/DataStoreItemEditDialogViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Dialogs/DataStoreItemEditDialogViewVM.cs index 29ec03942..9cde14c6f 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Dialogs/DataStoreItemEditDialogViewVM.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Dialogs/DataStoreItemEditDialogViewVM.cs @@ -143,7 +143,7 @@ namespace Tango.FSE.MachineConfiguration.Dialogs var bytes = File.ReadAllBytes(result.SelectedItem); Value = bytes; - _editingValue = DataStoreHelper.GetByteArrayHexString(bytes); + _editingValue = Convert.ToBase64String(bytes); RaisePropertyChanged(nameof(EditingValue)); } } diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/DataStoreViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/DataStoreViewVM.cs index 7c1fae7ac..ef708afd3 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/DataStoreViewVM.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/DataStoreViewVM.cs @@ -146,6 +146,11 @@ namespace Tango.FSE.MachineConfiguration.ViewModels return "The specified collection already exists."; } + if (!DataStoreHelper.ValidateCollectionOrKeyName(input)) + { + return "Collection name contains invalid characters."; + } + return null; }); @@ -176,14 +181,19 @@ namespace Tango.FSE.MachineConfiguration.ViewModels } var result = await NotificationProvider.ShowInputBox("Add Item", "Please enter the item key", MaterialDesignThemes.Wpf.PackIconKind.KeyAdd, null, null, 20, null, null, (input) => - { - if (SelectedCollection.Items.ToList().Exists(x => x.Key.ToLower() == input.ToLower())) - { - return "The specified key already exists in the collection."; - } + { + if (SelectedCollection.Items.ToList().Exists(x => x.Key.ToLower() == input.ToLower())) + { + return "The specified key already exists in the collection."; + } - return null; - }); + if (!DataStoreHelper.ValidateCollectionOrKeyName(input)) + { + return "Key name contains invalid characters."; + } + + return null; + }); if (result.Confirmed) { diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/SelectionViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/SelectionViewVM.cs index b65ad7102..39772a4cf 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/SelectionViewVM.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/SelectionViewVM.cs @@ -19,7 +19,13 @@ namespace Tango.FSE.MachineConfiguration.ViewModels public Machine SelectedMachine { get { return _selectedMachine; } - set { _selectedMachine = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } + set + { + _selectedMachine = value; + RaisePropertyChangedAuto(); + InvalidateRelayCommands(); + OnSelectedMachineChanged(); + } } public RelayCommand ManageMachineCommand { get; set; } @@ -29,6 +35,15 @@ namespace Tango.FSE.MachineConfiguration.ViewModels ManageMachineCommand = new RelayCommand(ManageSelectedMachine, () => SelectedMachine != null); } + private async void OnSelectedMachineChanged() + { + if (SelectedMachine != null) + { + await Task.Delay(100); + this.SetFocus(() => ManageMachineCommand); + } + } + private void ManageSelectedMachine() { if (SelectedMachine == null) diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/SelectionView.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/SelectionView.xaml index 69cebf324..51039ca89 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/SelectionView.xaml +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/SelectionView.xaml @@ -49,7 +49,7 @@ -