From 2ea2bb5bcd96045f1bd6cb4c3d8b8416dbaa05dc Mon Sep 17 00:00:00 2001 From: Roy Date: Tue, 26 Dec 2017 21:16:15 +0200 Subject: MERGE --- .../ViewModels/MainViewVM.cs | 525 +++++++++++++++++++++ 1 file changed, 525 insertions(+) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/ViewModels/MainViewVM.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/ViewModels/MainViewVM.cs') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/ViewModels/MainViewVM.cs new file mode 100644 index 000000000..d7e641735 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/ViewModels/MainViewVM.cs @@ -0,0 +1,525 @@ +using Microsoft.Win32; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using Tango.Core.Commands; +using Tango.MachineStudio.Common.Notifications; +using Tango.MachineStudio.Common.StudioApplication; +using Tango.Scripting; +using Tango.Settings; +using Tango.SharedUI; +using Tango.Stubs; +using Tango.Transport; +using Tango.Transport.Adapters; + +namespace Tango.MachineStudio.Stubs.ViewModels +{ + /// + /// Represents the script execution utility main view model. + /// + /// + public class MainViewVM : ViewModel + { + private UsbTransportAdapter _adapter; //Holds the USB transport adapter. + private StubManager _stubManager; + private INotificationProvider _notification; + + #region Properties + + public IStudioApplicationManager ApplicationManager { get; set; } + + private bool _useConnectedMachine; + /// + /// Gets or sets a value indicating whether [use connected machine]. + /// + public bool UseConnectedMachine + { + get { return _useConnectedMachine; } + set { _useConnectedMachine = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } + } + + /// + /// Gets or sets the code tabs. + /// + public ObservableCollection CodeTabs { get; set; } + + /// + /// Gets or sets the additional highlight C# types. + /// + public ObservableCollection> HighlightTypes { get; set; } + + /// + /// Gets or sets the collection of stub snippets. + /// + public ObservableCollection StubSnippets { get; set; } + + private StubSnippetVM _selectedStubSnippet; + /// + /// Gets or sets the selected stub snippet. + /// + public StubSnippetVM SelectedStubSnippet + { + get { return _selectedStubSnippet; } + set { _selectedStubSnippet = value; RaisePropertyChanged(nameof(SelectedStubSnippet)); } + } + + private String _log; + /// + /// Gets or sets the current response log. + /// + public String Log + { + get { return _log; } + set { _log = value; RaisePropertyChanged(nameof(Log)); } + } + + private CodeTabVM _selectedCodeTab; + /// + /// Gets or sets the selected code tab. + /// + public CodeTabVM SelectedCodeTab + { + get { return _selectedCodeTab; } + set { _selectedCodeTab = value; RaisePropertyChanged(nameof(SelectedCodeTab)); InvalidateRelayCommands(); } + } + + private bool _isConnected; + /// + /// Gets or sets a value indicating whether the USB adapter is connected. + /// + public bool IsConnected + { + get { return _isConnected; } + set { _isConnected = value; RaisePropertyChanged(nameof(IsConnected)); InvalidateRelayCommands(); } + } + + private List _ports; + /// + /// Gets or sets the available USB ports. + /// + public List Ports + { + get { return _ports; } + set { _ports = value; RaisePropertyChanged(nameof(Ports)); } + } + + private String _selectedPort; + /// + /// Gets or sets the selected USB port. + /// + public String SelectedPort + { + get { return _selectedPort; } + set { _selectedPort = value; RaisePropertyChanged(nameof(SelectedPort)); InvalidateRelayCommands(); } + } + + private String _status; + /// + /// Gets or sets the current status bar text. + /// + public String Status + { + get { return _status; } + set { _status = value; RaisePropertyChanged(nameof(Status)); } + } + + private bool _isRunning; + /// + /// Gets or sets a value indicating whether a stub is currently running. + /// + public bool IsRunning + { + get { return _isRunning; } + set { _isRunning = value; RaisePropertyChanged(nameof(IsRunning)); InvalidateRelayCommands(); } + } + + #endregion + + #region Commands + + /// + /// Gets or sets the new command. + /// + public RelayCommand NewCommand { get; set; } + + /// + /// Gets or sets the close tab command. + /// + public RelayCommand CloseTabCommand { get; set; } + + /// + /// Gets or sets the run command. + /// + public RelayCommand RunCommand { get; set; } + + /// + /// Gets or sets the stop command. + /// + public RelayCommand StopCommand { get; set; } + + /// + /// Gets or sets the toggle connection command. + /// + public RelayCommand ToggleConnectionCommand { get; set; } + + /// + /// Gets or sets the open command. + /// + public RelayCommand OpenCommand { get; set; } + + /// + /// Gets or sets the save command. + /// + public RelayCommand SaveCommand { get; set; } + + /// + /// Gets or sets the save as command. + /// + public RelayCommand SaveAsCommand { get; set; } + + /// + /// Gets or sets the stub snippet selected command. + /// + public RelayCommand StubSnippetSelectedCommand { get; set; } + + /// + /// Gets or sets the insert snippet command. + /// + public RelayCommand InsertSnippetCommand { get; set; } + + /// + /// Gets or sets the exit command. + /// + public RelayCommand ExitCommand { get; set; } + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + public MainViewVM(IStudioApplicationManager applicationManager, INotificationProvider notification) + { + ApplicationManager = applicationManager; + _notification = notification; + + CodeTabs = new ObservableCollection(); + + NewCommand = new RelayCommand(CreateNewTab); + CloseTabCommand = new RelayCommand(OnTabClosing); + RunCommand = new RelayCommand(RunTab, (x) => (IsConnected || UseConnectedMachine) && !IsRunning && SelectedCodeTab != null); + StopCommand = new RelayCommand(StopTab, (x) => (IsConnected || UseConnectedMachine) && IsRunning && SelectedCodeTab != null); + InsertSnippetCommand = new RelayCommand((x) => { }); + + HighlightTypes = new ObservableCollection>(); + HighlightTypes.Add(new KeyValuePair("stubManager", typeof(StubManager))); + + StubSnippets = new ObservableCollection(); + + foreach (var stubType in StubBase.GetAvailableRequestStubs()) + { + StubSnippetVM snippet = new StubSnippetVM(); + snippet.Name = stubType.Name.Replace("Stub_", ""); + snippet.Code = String.Format("stubManager.Run(\"{0}\" ,{1});", stubType.Name, String.Join(", ", stubType.GetProperties(BindingFlags.Public | BindingFlags.Instance).Select(x => x.PropertyType.Name == "string" ? "\"string\"" : x.PropertyType.Name))); + StubSnippets.Add(snippet); + } + + ToggleConnectionCommand = new RelayCommand(ToggleConnection, (x) => !IsRunning); + OpenCommand = new RelayCommand(OpenFile); + SaveCommand = new RelayCommand(SaveFile); + SaveAsCommand = new RelayCommand(SaveAsFile); + StubSnippetSelectedCommand = new RelayCommand(OnStubSnippetSelected); + ExitCommand = new RelayCommand(() => Application.Current.Shutdown()); + + Ports = new List() + { + "COM1", + "COM2", + "COM3", + "COM4", + "COM5", + "COM6", + "COM7", + "COM8", + "COM9", + }; + + SelectedPort = SettingsManager.Default.StubsUI.SelectedPort != null ? SettingsManager.Default.StubsUI.SelectedPort : Ports.First(); + + Status = "Ready"; + + if (SettingsManager.Default.StubsUI.LastTabs.Count > 0) + { + foreach (var file in SettingsManager.Default.StubsUI.LastTabs) + { + if (File.Exists(file)) + { + OpenFile(file); + } + } + } + else + { + CreateNewTab(); + } + + Application.Current.Exit += Current_Exit; + } + + #endregion + + #region Virtual Methods + + /// + /// Called when a stub snippet is double clicked. + /// + protected virtual void OnStubSnippetSelected() + { + if (SelectedStubSnippet != null) + { + if (InsertSnippetCommand != null) + { + InsertSnippetCommand.Execute(SelectedStubSnippet.Code); + } + } + } + + /// + /// Called when user closes a script tab. + /// + /// The code tab. + protected virtual void OnTabClosing(CodeTabVM codeTab) + { + CodeTabs.Remove(codeTab); + } + + #endregion + + #region Private Methods + + /// + /// Saves the selected script file. + /// + private void SaveFile() + { + if (SelectedCodeTab != null) + { + if (SelectedCodeTab.File == null) + { + SaveAsFile(); + } + else + { + File.WriteAllText(SelectedCodeTab.File, SelectedCodeTab.Code); + } + } + } + + /// + /// Saves the selected script file. + /// + private void SaveAsFile() + { + if (SelectedCodeTab != null) + { + SaveFileDialog dlg = new SaveFileDialog(); + dlg.Filter = "C# Script Files|*.cs"; + dlg.DefaultExt = ".cs"; + if (dlg.ShowDialog().Value) + { + File.WriteAllText(dlg.FileName, SelectedCodeTab.Code); + SelectedCodeTab.File = dlg.FileName; + } + } + } + + /// + /// Opens a script from HD. + /// + private void OpenFile() + { + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "C# Script Files|*.cs"; + dlg.Multiselect = true; + if (dlg.ShowDialog().Value) + { + foreach (var file in dlg.FileNames) + { + OpenFile(file); + } + } + } + + /// + /// Opens the file. + /// + /// The file. + private void OpenFile(String file) + { + var newTab = new CodeTabVM(); + newTab.File = file; + newTab.Code = File.ReadAllText(file); + CodeTabs.Add(newTab); + SelectedCodeTab = newTab; + } + + /// + /// Toggles the USB adapter connection. + /// + private void ToggleConnection() + { + try + { + if (!IsConnected) + { + _adapter = new UsbTransportAdapter(SelectedPort); + _adapter.Connect().Wait(); + IsConnected = true; + } + else + { + _adapter.Disconnect().Wait(); + IsConnected = false; + } + } + catch (Exception ex) + { + MessageBox.Show(ex.ToString(), "Tango"); + } + } + + /// + /// Creates a new script tab. + /// + private void CreateNewTab() + { + var newTab = new CodeTabVM(); + CodeTabs.Add(newTab); + SelectedCodeTab = newTab; + } + + /// + /// Runs the selected script tab. + /// + private async void RunTab() + { + if (UseConnectedMachine && !ApplicationManager.IsMachineConnected) + { + _notification.ShowError("Cannot execute stub while 'Connected Machine' is set but not machine connected."); + return; + } + + IsRunning = true; + SelectedCodeTab.IsRunning = true; + Log = (DateTime.Now.ToTimeString() + ": ") + "Executing script '" + SelectedCodeTab.Title + "'..." + Environment.NewLine; + + await Task.Factory.StartNew(async () => + { + try + { + ITransportAdapter adapter = _adapter; + + if (ApplicationManager.IsMachineConnected && UseConnectedMachine) + { + adapter = ApplicationManager.ConnectedMachine.Adapters.First(); + } + + _stubManager = new StubManager(adapter); + var thisStubManager = _stubManager; + _stubManager.Completed += Manager_Completed; + _stubManager.Failed += Manager_Failed; + _stubManager.Executed += Manager_Executed; + + ScriptEngine engine = new ScriptEngine(new StubOnExecuteParameters(_stubManager)); + + engine.ReferencedAssemblies.Add(this.GetType()); + await engine.Run(SelectedCodeTab.Code); + + if (!thisStubManager.Aborted) + { + IsRunning = false; + SelectedCodeTab.IsRunning = false; + } + } + catch (Exception ex) + { + IsRunning = false; + SelectedCodeTab.IsRunning = false; + MessageBox.Show(ex.Message, "Tango"); + } + }); + } + + /// + /// Stops the currently current script. + /// + private void StopTab() + { + if (_stubManager != null) + { + _stubManager.Abort(); + IsRunning = false; + SelectedCodeTab.IsRunning = false; + Status = "Stopped!"; + Log += (DateTime.Now.ToTimeString() + ": ") + "Stopped!" + Environment.NewLine; + } + } + + #endregion + + #region Event Handlers + + /// + /// Handled the Executed event. + /// + /// The sender. + /// Name of the stub. + private void Manager_Executed(object sender, string stubName) + { + Log += (DateTime.Now.ToTimeString() + ": ") + "Executing '" + stubName + "'..." + Environment.NewLine; + Status = "Executing " + stubName + "..."; + } + + /// + /// Handled the Failed event. + /// + /// The sender. + /// The exception. + private void Manager_Failed(object sender, Exception ex) + { + if (IsRunning) + { + Log += (DateTime.Now.ToTimeString() + ": ") + ex.Message + Environment.NewLine; + Status = "Failed!"; + } + } + + /// + /// Handled the Completed event. + /// + /// The sender. + /// The response. + private void Manager_Completed(object sender, string response) + { + Log += (DateTime.Now.ToTimeString() + ": ") + "Response Received:" + Environment.NewLine; + Log += (DateTime.Now.ToTimeString() + ": ") + response + Environment.NewLine; + Status = "Completed"; + } + + private void Current_Exit(object sender, ExitEventArgs e) + { + SettingsManager.Default.MachineStudio.StubsModule.SelectedPort = SelectedPort; + SettingsManager.Default.MachineStudio.StubsModule.LastTabs = CodeTabs.Select(x => x.File).ToList(); + SettingsManager.SaveDefaultSettings(); + } + + #endregion + } +} -- cgit v1.3.1 From 9d12fd0ba222619dd5b42816ed004c7b762809dd Mon Sep 17 00:00:00 2001 From: Roy Date: Tue, 26 Dec 2017 23:55:41 +0200 Subject: Added CCT & CAT to DB Module ! Implemented "deep filtering" on db module search. --- Software/DB/Tango.db | Bin 602112 -> 602112 bytes Software/DB/Tango.mdf | Bin 8388608 -> 8388608 bytes Software/DB/Tango_log.ldf | Bin 8388608 -> 8388608 bytes .../Converters/ByteArrayToFileSizeConverter.cs | 34 ++++ .../Tango.MachineStudio.DB.csproj | 31 +++ .../Tango.MachineStudio.DB/ViewModelLocator.cs | 19 ++ .../ViewModels/CatsViewVM.cs | 41 ++++ .../ViewModels/CctsViewVM.cs | 75 ++++++++ .../ViewModels/DbTableViewModel.cs | 50 +++-- .../Views/DBViews/CatView.xaml | 62 ++++++ .../Views/DBViews/CatView.xaml.cs | 28 +++ .../Views/DBViews/CatsView.xaml | 43 +++++ .../Views/DBViews/CatsView.xaml.cs | 32 ++++ .../Views/DBViews/CctView.xaml | 58 ++++++ .../Views/DBViews/CctView.xaml.cs | 28 +++ .../Views/DBViews/CctsView.xaml | 36 ++++ .../Views/DBViews/CctsView.xaml.cs | 32 ++++ .../ViewModels/MainViewVM.cs | 2 +- Software/Visual_Studio/Tango.DAL.Local/DB/CAT.cs | 25 +++ Software/Visual_Studio/Tango.DAL.Local/DB/CCT.cs | 30 +++ .../Visual_Studio/Tango.DAL.Local/DB/DISPENSER.cs | 1 + .../Tango.DAL.Local/DB/LocalADO.Context.cs | 2 + .../Visual_Studio/Tango.DAL.Local/DB/LocalADO.edmx | 96 ++++++++++ .../Tango.DAL.Local/DB/LocalADO.edmx.diagram | 64 ++++--- .../Tango.DAL.Local/Tango.DAL.Local.csproj | 6 + .../Tango.DAL.Observables/Entities/Cat.cs | 133 +++++++++++++ .../Tango.DAL.Observables/Entities/Cct.cs | 209 +++++++++++++++++++++ .../Tango.DAL.Observables/Entities/LiquidType.cs | 21 +++ .../Tango.DAL.Observables/Entities/Machine.cs | 21 +++ .../Tango.DAL.Observables/Entities/Rml.cs | 21 +++ .../Tango.DAL.Observables/ObservableEntity.cs | 6 +- .../ObservablesEntitiesAdapter.cs | 4 + .../ObservablesEntitiesAdapterExtension.cs | 76 ++++++++ .../Tango.DAL.Observables.csproj | 2 + Software/Visual_Studio/Tango.DAL.Remote/DB/CAT.cs | 28 +++ Software/Visual_Studio/Tango.DAL.Remote/DB/CCT.cs | 32 ++++ .../Tango.DAL.Remote/DB/LIQUID_TYPES.cs | 3 + .../Visual_Studio/Tango.DAL.Remote/DB/MACHINE.cs | 3 + Software/Visual_Studio/Tango.DAL.Remote/DB/RML.cs | 3 + .../Tango.DAL.Remote/DB/RemoteADO.Context.cs | 2 + .../Tango.DAL.Remote/DB/RemoteADO.edmx | 195 +++++++++++++++++++ .../Tango.DAL.Remote/DB/RemoteADO.edmx.diagram | 83 ++++---- .../Tango.DAL.Remote/Tango.DAL.Remote.csproj | 6 + 43 files changed, 1557 insertions(+), 86 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Converters/ByteArrayToFileSizeConverter.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/CatsViewVM.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/CctsViewVM.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/CatView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/CatView.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/CatsView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/CatsView.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/CctView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/CctView.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/CctsView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/CctsView.xaml.cs create mode 100644 Software/Visual_Studio/Tango.DAL.Local/DB/CAT.cs create mode 100644 Software/Visual_Studio/Tango.DAL.Local/DB/CCT.cs create mode 100644 Software/Visual_Studio/Tango.DAL.Observables/Entities/Cat.cs create mode 100644 Software/Visual_Studio/Tango.DAL.Observables/Entities/Cct.cs create mode 100644 Software/Visual_Studio/Tango.DAL.Remote/DB/CAT.cs create mode 100644 Software/Visual_Studio/Tango.DAL.Remote/DB/CCT.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/ViewModels/MainViewVM.cs') diff --git a/Software/DB/Tango.db b/Software/DB/Tango.db index 0d057922b..a9e15d59e 100644 Binary files a/Software/DB/Tango.db and b/Software/DB/Tango.db differ diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 8c68d77f1..0537c561f 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index d80e67e97..370c5a60f 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Converters/ByteArrayToFileSizeConverter.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Converters/ByteArrayToFileSizeConverter.cs new file mode 100644 index 000000000..8a690450c --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Converters/ByteArrayToFileSizeConverter.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; + +namespace Tango.MachineStudio.DB.Converters +{ + public class ByteArrayToFileSizeConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + return BytesToString((int)value); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + + static String BytesToString(long byteCount) + { + string[] suf = { "B", "KB", "MB", "GB", "TB", "PB", "EB" }; //Longs run out around EB + if (byteCount == 0) + return "0" + suf[0]; + long bytes = Math.Abs(byteCount); + int place = System.Convert.ToInt32(Math.Floor(Math.Log(bytes, 1024))); + double num = Math.Round(bytes / Math.Pow(1024, place), 1); + return (Math.Sign(byteCount) * num).ToString() + suf[place]; + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Tango.MachineStudio.DB.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Tango.MachineStudio.DB.csproj index 12af196bc..01cd9d1a9 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Tango.MachineStudio.DB.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Tango.MachineStudio.DB.csproj @@ -87,6 +87,7 @@ + @@ -101,6 +102,8 @@ + + @@ -137,6 +140,18 @@ ActionTypeView.xaml + + CatsView.xaml + + + CctsView.xaml + + + CatView.xaml + + + CctView.xaml + RmlView.xaml @@ -352,6 +367,22 @@ MSBuild:Compile Designer + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + MSBuild:Compile Designer diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModelLocator.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModelLocator.cs index fa4139389..857f0d3cf 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModelLocator.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModelLocator.cs @@ -55,6 +55,9 @@ namespace Tango.MachineStudio.DB SimpleIoc.Default.Register(); SimpleIoc.Default.Register(); SimpleIoc.Default.Register(); + + SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); } public static MainViewVM MainViewVM @@ -320,5 +323,21 @@ namespace Tango.MachineStudio.DB return ServiceLocator.Current.GetInstance(); } } + + public static CctsViewVM CctsViewVM + { + get + { + return ServiceLocator.Current.GetInstance(); + } + } + + public static CatsViewVM CatsViewVM + { + get + { + return ServiceLocator.Current.GetInstance(); + } + } } } \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/CatsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/CatsViewVM.cs new file mode 100644 index 000000000..74a7e29eb --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/CatsViewVM.cs @@ -0,0 +1,41 @@ +using Microsoft.Win32; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.Commands; +using Tango.DAL.Observables; +using Tango.MachineStudio.Common.Notifications; + +namespace Tango.MachineStudio.DB.ViewModels +{ + public class CatsViewVM : DbTableViewModel + { + public CatsViewVM(INotificationProvider notification) : base(notification) + { + SelectDataFileCommand = new RelayCommand(SelectDataFile); + } + + public RelayCommand SelectDataFileCommand { get; set; } + + private void SelectDataFile() + { + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "Color Adjustment Files|*.CAT"; + dlg.Title = "Select Color Adjustment File"; + if (dlg.ShowDialog().Value) + { + try + { + EditEntity.Data = File.ReadAllBytes(dlg.FileName); + } + catch (Exception ex) + { + _notification.ShowError(ex.Message); + } + } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/CctsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/CctsViewVM.cs new file mode 100644 index 000000000..02d7c351d --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/CctsViewVM.cs @@ -0,0 +1,75 @@ +using Microsoft.Win32; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.Commands; +using Tango.DAL.Observables; +using Tango.MachineStudio.Common.Notifications; + +namespace Tango.MachineStudio.DB.ViewModels +{ + public class CctsViewVM : DbTableViewModel + { + public CctsViewVM(INotificationProvider notification) : base(notification) + { + SelectForwardFileCommand = new RelayCommand(SelectForwardFile); + SelectInverseFileCommand = new RelayCommand(SelectInverseFile); + } + + public RelayCommand SelectForwardFileCommand { get; set; } + + public RelayCommand SelectInverseFileCommand { get; set; } + + private void SelectInverseFile() + { + String file = SelectFile(); + if (file != null) + { + try + { + EditEntity.InverseData = File.ReadAllBytes(file); + EditEntity.InverseFileName = Path.GetFileName(file); + } + catch (Exception ex) + { + _notification.ShowError(ex.Message); + } + } + } + + private void SelectForwardFile() + { + String file = SelectFile(); + if (file != null) + { + try + { + EditEntity.ForwardData = File.ReadAllBytes(file); + EditEntity.ForwardFileName = Path.GetFileName(file); + } + catch (Exception ex) + { + _notification.ShowError(ex.Message); + } + } + } + + private String SelectFile() + { + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "Color Conversion Files|*.CCT"; + dlg.Title = "Select Color Conversion File"; + if (dlg.ShowDialog().Value) + { + return dlg.FileName; + } + else + { + return null; + } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/DbTableViewModel.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/DbTableViewModel.cs index e472e312a..bc8d54ce9 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/DbTableViewModel.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/DbTableViewModel.cs @@ -20,7 +20,7 @@ namespace Tango.MachineStudio.DB.ViewModels { public abstract class DbTableViewModel : ViewModel, IShutdownRequestBlocker where T : class, IObservableEntity { - private INotificationProvider _notification; + protected INotificationProvider _notification; /// /// Initializes a new instance of the class. @@ -156,11 +156,11 @@ namespace Tango.MachineStudio.DB.ViewModels { using (_notification.PushTaskItem("Saving changes to database...")) { - var dependenctEntities = SelectedEntity.GetDependentEntitiesNameAndGuid(); + var dependenctEntities = SelectedEntity.GetDependentEntitiesNameAndGuid(); if (dependenctEntities.Count > 0) { - _notification.ShowError("The selected entity is being used by " + dependenctEntities.Count + " other entities." + Environment.NewLine + "Please delete any dependencies and try again." + Environment.NewLine + Environment.NewLine + String.Join(Environment.NewLine,dependenctEntities.Select(x => x.Key + ", ID: " + x.Value))); + _notification.ShowError("The selected entity is being used by " + dependenctEntities.Count + " other entities." + Environment.NewLine + "Please delete any dependencies and try again." + Environment.NewLine + Environment.NewLine + String.Join(Environment.NewLine, dependenctEntities.Select(x => x.Key + ", ID: " + x.Value))); return; } @@ -293,18 +293,44 @@ namespace Tango.MachineStudio.DB.ViewModels collectionView.Filter = (entity) => { - return - entity. - GetType(). - GetProperties(BindingFlags.Public | BindingFlags.Instance). - Where(x => x.Name != "Deleted" && x.Name != "ID" && x.Name != "LastUpdated"). - Where(x => !x.PropertyType.IsGenericType && (x.PropertyType.IsClass || x.PropertyType == typeof(String))). - Select(prop => prop.GetValue(entity).ToString()). - ToList(). - Any(x => x.ToLower().Contains(filter.ToLower())); + return FilterEntity((T)entity, filter); }; } + private bool FilterEntity(T entity, String filter) + { + foreach (var prop in entity.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(x => x.PropertyType.IsClass && x.PropertyType != typeof(String) && x.PropertyType != typeof(byte[]) && !x.PropertyType.IsGenericType)) + { + object obj = prop.GetValue(entity); + + if (obj != null) + { + foreach (var innerProp in obj.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(x => x.Name != "Deleted" && x.Name != "ID" && x.Name != "LastUpdated").Where(x => !x.PropertyType.IsGenericType && (x.PropertyType.IsClass || x.PropertyType == typeof(String)))) + { + object value = innerProp.GetValue(obj); + + if (value != null) + { + if (value.ToString().ToLower().Contains(filter.ToLower())) + { + return true; + } + } + } + } + } + + return + entity. + GetType(). + GetProperties(BindingFlags.Public | BindingFlags.Instance). + Where(x => x.Name != "Deleted" && x.Name != "ID" && x.Name != "LastUpdated"). + Where(x => !x.PropertyType.IsGenericType && (x.PropertyType.IsClass || x.PropertyType == typeof(String))). + Select(prop => prop.GetValue(entity).ToString()). + ToList(). + Any(x => x.ToLower().Contains(filter.ToLower())); + } + protected virtual void InitializeEntity(T entity) { diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/CatView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/CatView.xaml new file mode 100644 index 000000000..442f77ae3 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/CatView.xaml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/CatView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/CatView.xaml.cs new file mode 100644 index 000000000..9e389feb3 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/CatView.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.MachineStudio.DB.Views.DBViews +{ + /// + /// Interaction logic for MachineView.xaml + /// + public partial class CatView : UserControl + { + public CatView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/CatsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/CatsView.xaml new file mode 100644 index 000000000..d88a2a142 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/CatsView.xaml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/CatsView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/CatsView.xaml.cs new file mode 100644 index 000000000..ec9dae44f --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/CatsView.xaml.cs @@ -0,0 +1,32 @@ +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; +using Tango.MachineStudio.DB.CustomAttributes; +using Tango.MachineStudio.DB.Managers; +using Tango.SharedUI.Controls; + +namespace Tango.MachineStudio.DB.Views.DBViews +{ + /// + /// Interaction logic for MachinesView.xaml + /// + [DBView] + public partial class CatsView : UserControl + { + public CatsView() : base() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/CctView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/CctView.xaml new file mode 100644 index 000000000..a5bfc2f14 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/CctView.xaml @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/CctView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/CctView.xaml.cs new file mode 100644 index 000000000..1a6ee6da7 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/CctView.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.MachineStudio.DB.Views.DBViews +{ + /// + /// Interaction logic for MachineView.xaml + /// + public partial class CctView : UserControl + { + public CctView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/CctsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/CctsView.xaml new file mode 100644 index 000000000..09962447c --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/CctsView.xaml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/CctsView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/CctsView.xaml.cs new file mode 100644 index 000000000..fa4d80bd2 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/CctsView.xaml.cs @@ -0,0 +1,32 @@ +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; +using Tango.MachineStudio.DB.CustomAttributes; +using Tango.MachineStudio.DB.Managers; +using Tango.SharedUI.Controls; + +namespace Tango.MachineStudio.DB.Views.DBViews +{ + /// + /// Interaction logic for MachinesView.xaml + /// + [DBView] + public partial class CctsView : UserControl + { + public CctsView() : base() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/ViewModels/MainViewVM.cs index d7e641735..43b57bef3 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/ViewModels/MainViewVM.cs @@ -412,7 +412,7 @@ namespace Tango.MachineStudio.Stubs.ViewModels { if (UseConnectedMachine && !ApplicationManager.IsMachineConnected) { - _notification.ShowError("Cannot execute stub while 'Connected Machine' is set but not machine connected."); + _notification.ShowError("Cannot execute stub while 'Connected Machine' is set but no machine connected."); return; } diff --git a/Software/Visual_Studio/Tango.DAL.Local/DB/CAT.cs b/Software/Visual_Studio/Tango.DAL.Local/DB/CAT.cs new file mode 100644 index 000000000..c46de78a5 --- /dev/null +++ b/Software/Visual_Studio/Tango.DAL.Local/DB/CAT.cs @@ -0,0 +1,25 @@ +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Tango.DAL.Local.DB +{ + using System; + using System.Collections.Generic; + + public partial class CAT + { + public long ID { get; set; } + public string GUID { get; set; } + public System.DateTime LAST_UPDATED { get; set; } + public bool DELETED { get; set; } + public string LIQUID_TYPE_GUID { get; set; } + public string MACHINE_GUID { get; set; } + public byte[] DATA { get; set; } + } +} diff --git a/Software/Visual_Studio/Tango.DAL.Local/DB/CCT.cs b/Software/Visual_Studio/Tango.DAL.Local/DB/CCT.cs new file mode 100644 index 000000000..fc71ebf27 --- /dev/null +++ b/Software/Visual_Studio/Tango.DAL.Local/DB/CCT.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Tango.DAL.Local.DB +{ + using System; + using System.Collections.Generic; + + public partial class CCT + { + public long ID { get; set; } + public string GUID { get; set; } + public System.DateTime LAST_UPDATED { get; set; } + public bool DELETED { get; set; } + public string NAME { get; set; } + public string DESCRIPTION { get; set; } + public string FORWARD_FILE_NAME { get; set; } + public string INVERSE_FILE_NAME { get; set; } + public byte[] FORWARD_DATA { get; set; } + public byte[] INVERSE_DATA { get; set; } + public double VERSION { get; set; } + public string RML_GUID { get; set; } + } +} diff --git a/Software/Visual_Studio/Tango.DAL.Local/DB/DISPENSER.cs b/Software/Visual_Studio/Tango.DAL.Local/DB/DISPENSER.cs index 41fedc263..dc77b198b 100644 --- a/Software/Visual_Studio/Tango.DAL.Local/DB/DISPENSER.cs +++ b/Software/Visual_Studio/Tango.DAL.Local/DB/DISPENSER.cs @@ -18,6 +18,7 @@ namespace Tango.DAL.Local.DB public string GUID { get; set; } public System.DateTime LAST_UPDATED { get; set; } public bool DELETED { get; set; } + public string SERIAL_NUMBER { get; set; } public string DISPENSER_TYPE_GUID { get; set; } } } diff --git a/Software/Visual_Studio/Tango.DAL.Local/DB/LocalADO.Context.cs b/Software/Visual_Studio/Tango.DAL.Local/DB/LocalADO.Context.cs index 24df1c1ce..5577ba99f 100644 --- a/Software/Visual_Studio/Tango.DAL.Local/DB/LocalADO.Context.cs +++ b/Software/Visual_Studio/Tango.DAL.Local/DB/LocalADO.Context.cs @@ -33,6 +33,8 @@ namespace Tango.DAL.Local.DB public virtual DbSet APPLICATION_VERSIONS { get; set; } public virtual DbSet CARTRIDGE_TYPES { get; set; } public virtual DbSet CARTRIDGES { get; set; } + public virtual DbSet CATS { get; set; } + public virtual DbSet CCTS { get; set; } public virtual DbSet CONFIGURATIONS { get; set; } public virtual DbSet CONTACTS { get; set; } public virtual DbSet DISPENSER_TYPES { get; set; } diff --git a/Software/Visual_Studio/Tango.DAL.Local/DB/LocalADO.edmx b/Software/Visual_Studio/Tango.DAL.Local/DB/LocalADO.edmx index 4bd90ccea..444822fe1 100644 --- a/Software/Visual_Studio/Tango.DAL.Local/DB/LocalADO.edmx +++ b/Software/Visual_Studio/Tango.DAL.Local/DB/LocalADO.edmx @@ -98,6 +98,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -150,6 +179,7 @@ + @@ -478,6 +508,8 @@ + + @@ -523,6 +555,8 @@ + + @@ -648,6 +682,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -700,6 +763,7 @@ + @@ -1126,6 +1190,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1177,6 +1272,7 @@ + diff --git a/Software/Visual_Studio/Tango.DAL.Local/DB/LocalADO.edmx.diagram b/Software/Visual_Studio/Tango.DAL.Local/DB/LocalADO.edmx.diagram index f36a25560..f9884e5ba 100644 --- a/Software/Visual_Studio/Tango.DAL.Local/DB/LocalADO.edmx.diagram +++ b/Software/Visual_Studio/Tango.DAL.Local/DB/LocalADO.edmx.diagram @@ -13,37 +13,39 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/Tango.DAL.Local/Tango.DAL.Local.csproj b/Software/Visual_Studio/Tango.DAL.Local/Tango.DAL.Local.csproj index b37074e7f..16e1101a7 100644 --- a/Software/Visual_Studio/Tango.DAL.Local/Tango.DAL.Local.csproj +++ b/Software/Visual_Studio/Tango.DAL.Local/Tango.DAL.Local.csproj @@ -89,6 +89,12 @@ LocalADO.tt + + LocalADO.tt + + + LocalADO.tt + LocalADO.tt diff --git a/Software/Visual_Studio/Tango.DAL.Observables/Entities/Cat.cs b/Software/Visual_Studio/Tango.DAL.Observables/Entities/Cat.cs new file mode 100644 index 000000000..c179af8f3 --- /dev/null +++ b/Software/Visual_Studio/Tango.DAL.Observables/Entities/Cat.cs @@ -0,0 +1,133 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using Tango.DAL.Remote.DB; + +namespace Tango.DAL.Observables +{ + [EntityFieldName("CATS")] + public class Cat : ObservableEntity + { + + private String _liquidtypeguid; + /// + /// Gets or sets the cat liquid type guid. + /// + [EntityFieldName("LIQUID_TYPE_GUID")] + public String LiquidTypeGuid + { + get + { + return _liquidtypeguid; + } + + set + { + _liquidtypeguid = value; RaisePropertyChanged(nameof(LiquidTypeGuid)); + } + + } + + private String _machineguid; + /// + /// Gets or sets the cat machine guid. + /// + [EntityFieldName("MACHINE_GUID")] + public String MachineGuid + { + get + { + return _machineguid; + } + + set + { + _machineguid = value; RaisePropertyChanged(nameof(MachineGuid)); + } + + } + + private Byte[] _data; + /// + /// Gets or sets the cat data. + /// + [EntityFieldName("DATA")] + public Byte[] Data + { + get + { + return _data; + } + + set + { + _data = value; RaisePropertyChanged(nameof(Data)); + } + + } + + private LiquidType _liquidtypes; + /// + /// Gets or sets the cat liquid types. + /// + [EntityFieldName("LIQUID_TYPES")] + public LiquidType LiquidTypes + { + get + { + return _liquidtypes; + } + + set + { + _liquidtypes = value; RaisePropertyChanged(nameof(LiquidTypes)); + } + + } + + private Machine _machine; + /// + /// Gets or sets the cat machine. + /// + [EntityFieldName("MACHINE")] + public Machine Machine + { + get + { + return _machine; + } + + set + { + _machine = value; RaisePropertyChanged(nameof(Machine)); + } + + } + + /// + /// Initializes a new instance of the class. + /// + public Cat() : base() + { + Init(); + } + + /// + /// Initializes a new instance of the class. + /// + /// The entity. + public Cat(CAT entity) : base(entity) + { + Init(); + MapEntityToObservable(entity, this); + } + + /// + /// Initialize complex types. + /// + private void Init() + { + } + } +} diff --git a/Software/Visual_Studio/Tango.DAL.Observables/Entities/Cct.cs b/Software/Visual_Studio/Tango.DAL.Observables/Entities/Cct.cs new file mode 100644 index 000000000..412cbbb1c --- /dev/null +++ b/Software/Visual_Studio/Tango.DAL.Observables/Entities/Cct.cs @@ -0,0 +1,209 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using Tango.DAL.Remote.DB; + +namespace Tango.DAL.Observables +{ + [EntityFieldName("CCTS")] + public class Cct : ObservableEntity + { + + private String _name; + /// + /// Gets or sets the cct name. + /// + [EntityFieldName("NAME")] + public String Name + { + get + { + return _name; + } + + set + { + _name = value; RaisePropertyChanged(nameof(Name)); + } + + } + + private String _description; + /// + /// Gets or sets the cct description. + /// + [EntityFieldName("DESCRIPTION")] + public String Description + { + get + { + return _description; + } + + set + { + _description = value; RaisePropertyChanged(nameof(Description)); + } + + } + + private String _forwardfilename; + /// + /// Gets or sets the cct forward file name. + /// + [EntityFieldName("FORWARD_FILE_NAME")] + public String ForwardFileName + { + get + { + return _forwardfilename; + } + + set + { + _forwardfilename = value; RaisePropertyChanged(nameof(ForwardFileName)); + } + + } + + private String _inversefilename; + /// + /// Gets or sets the cct inverse file name. + /// + [EntityFieldName("INVERSE_FILE_NAME")] + public String InverseFileName + { + get + { + return _inversefilename; + } + + set + { + _inversefilename = value; RaisePropertyChanged(nameof(InverseFileName)); + } + + } + + private Byte[] _forwarddata; + /// + /// Gets or sets the cct forward data. + /// + [EntityFieldName("FORWARD_DATA")] + public Byte[] ForwardData + { + get + { + return _forwarddata; + } + + set + { + _forwarddata = value; RaisePropertyChanged(nameof(ForwardData)); + } + + } + + private Byte[] _inversedata; + /// + /// Gets or sets the cct inverse data. + /// + [EntityFieldName("INVERSE_DATA")] + public Byte[] InverseData + { + get + { + return _inversedata; + } + + set + { + _inversedata = value; RaisePropertyChanged(nameof(InverseData)); + } + + } + + private Double _version; + /// + /// Gets or sets the cct version. + /// + [EntityFieldName("VERSION")] + public Double Version + { + get + { + return _version; + } + + set + { + _version = value; RaisePropertyChanged(nameof(Version)); + } + + } + + private String _rmlguid; + /// + /// Gets or sets the cct rml guid. + /// + [EntityFieldName("RML_GUID")] + public String RmlGuid + { + get + { + return _rmlguid; + } + + set + { + _rmlguid = value; RaisePropertyChanged(nameof(RmlGuid)); + } + + } + + private Rml _rml; + /// + /// Gets or sets the cct rml. + /// + [EntityFieldName("RML")] + public Rml Rml + { + get + { + return _rml; + } + + set + { + _rml = value; RaisePropertyChanged(nameof(Rml)); + } + + } + + /// + /// Initializes a new instance of the class. + /// + public Cct() : base() + { + Init(); + } + + /// + /// Initializes a new instance of the class. + /// + /// The entity. + public Cct(CCT entity) : base(entity) + { + Init(); + MapEntityToObservable(entity, this); + } + + /// + /// Initialize complex types. + /// + private void Init() + { + } + } +} diff --git a/Software/Visual_Studio/Tango.DAL.Observables/Entities/LiquidType.cs b/Software/Visual_Studio/Tango.DAL.Observables/Entities/LiquidType.cs index 613d6a739..c558e227d 100644 --- a/Software/Visual_Studio/Tango.DAL.Observables/Entities/LiquidType.cs +++ b/Software/Visual_Studio/Tango.DAL.Observables/Entities/LiquidType.cs @@ -86,6 +86,25 @@ namespace Tango.DAL.Observables } + private ObservableCollection _cats; + /// + /// Gets or sets the liquidtype cats. + /// + [EntityFieldName("CATS")] + public ObservableCollection Cats + { + get + { + return _cats; + } + + set + { + _cats = value; RaisePropertyChanged(nameof(Cats)); + } + + } + private ObservableCollection _idspacks; /// /// Gets or sets the liquidtype ids packs. @@ -148,6 +167,8 @@ namespace Tango.DAL.Observables private void Init() { + Cats = new ObservableCollection(); + IdsPacks = new ObservableCollection(); LiquidTypesRmls = new ObservableCollection(); diff --git a/Software/Visual_Studio/Tango.DAL.Observables/Entities/Machine.cs b/Software/Visual_Studio/Tango.DAL.Observables/Entities/Machine.cs index ec946a15a..40d191c67 100644 --- a/Software/Visual_Studio/Tango.DAL.Observables/Entities/Machine.cs +++ b/Software/Visual_Studio/Tango.DAL.Observables/Entities/Machine.cs @@ -124,6 +124,25 @@ namespace Tango.DAL.Observables } + private ObservableCollection _cats; + /// + /// Gets or sets the machine cats. + /// + [EntityFieldName("CATS")] + public ObservableCollection Cats + { + get + { + return _cats; + } + + set + { + _cats = value; RaisePropertyChanged(nameof(Cats)); + } + + } + private Configuration _configuration; /// /// Gets or sets the machine configuration. @@ -243,6 +262,8 @@ namespace Tango.DAL.Observables private void Init() { + Cats = new ObservableCollection(); + MachinesConfigurations = new ObservableCollection(); MachinesEvents = new ObservableCollection(); diff --git a/Software/Visual_Studio/Tango.DAL.Observables/Entities/Rml.cs b/Software/Visual_Studio/Tango.DAL.Observables/Entities/Rml.cs index b0f85c1ab..e1811d5e4 100644 --- a/Software/Visual_Studio/Tango.DAL.Observables/Entities/Rml.cs +++ b/Software/Visual_Studio/Tango.DAL.Observables/Entities/Rml.cs @@ -371,6 +371,25 @@ namespace Tango.DAL.Observables } + private ObservableCollection _ccts; + /// + /// Gets or sets the rml ccts. + /// + [EntityFieldName("CCTS")] + public ObservableCollection Ccts + { + get + { + return _ccts; + } + + set + { + _ccts = value; RaisePropertyChanged(nameof(Ccts)); + } + + } + private FiberShape _fibershapes; /// /// Gets or sets the rml fiber shapes. @@ -547,6 +566,8 @@ namespace Tango.DAL.Observables private void Init() { + Ccts = new ObservableCollection(); + LiquidTypesRmls = new ObservableCollection(); } diff --git a/Software/Visual_Studio/Tango.DAL.Observables/ObservableEntity.cs b/Software/Visual_Studio/Tango.DAL.Observables/ObservableEntity.cs index 74bcfbb83..56455246f 100644 --- a/Software/Visual_Studio/Tango.DAL.Observables/ObservableEntity.cs +++ b/Software/Visual_Studio/Tango.DAL.Observables/ObservableEntity.cs @@ -70,7 +70,7 @@ namespace Tango.DAL.Observables } } } - else if (prop.PropertyType.IsClass && prop.PropertyType != typeof(String) && prop.PropertyType != typeof(DateTime)) + else if (prop.PropertyType.IsClass && prop.PropertyType != typeof(String) && prop.PropertyType != typeof(DateTime) && prop.PropertyType != typeof(byte[])) { Type propType = observable.GetType().GetProperty(name).PropertyType; @@ -244,7 +244,7 @@ namespace Tango.DAL.Observables //Match guids.. - foreach (var prop in this.GetType().GetProperties().Where(x => !x.PropertyType.IsGenericType && x.PropertyType.IsClass && x.PropertyType != typeof(String) && x.PropertyType != typeof(DateTime))) + foreach (var prop in this.GetType().GetProperties().Where(x => !x.PropertyType.IsGenericType && x.PropertyType.IsClass && x.PropertyType != typeof(String) && x.PropertyType != typeof(DateTime) && x.PropertyType != typeof(byte[]))) { IObservableEntity propObservable = prop.GetValue(this) as IObservableEntity; @@ -286,7 +286,7 @@ namespace Tango.DAL.Observables } } } - else if (prop.PropertyType.IsClass && prop.PropertyType != typeof(String) && prop.PropertyType != typeof(DateTime)) + else if (prop.PropertyType.IsClass && prop.PropertyType != typeof(String) && prop.PropertyType != typeof(DateTime) && prop.PropertyType != typeof(byte[])) { var item = (prop.GetValue(this) as ObservableEntity); if (!savedEntities.Contains(item)) diff --git a/Software/Visual_Studio/Tango.DAL.Observables/ObservablesEntitiesAdapter.cs b/Software/Visual_Studio/Tango.DAL.Observables/ObservablesEntitiesAdapter.cs index 63fdce62a..e4baa31c9 100644 --- a/Software/Visual_Studio/Tango.DAL.Observables/ObservablesEntitiesAdapter.cs +++ b/Software/Visual_Studio/Tango.DAL.Observables/ObservablesEntitiesAdapter.cs @@ -145,6 +145,10 @@ namespace Tango.DAL.Observables Rmls = Context.RMLS.Where(x => !x.DELETED).ToList().Select(x => ObservableEntity.CreateObservableFromEntity(x)).ToObservableCollection(); + Ccts = Context.CCTS.Where(x => !x.DELETED).ToList().Select(x => ObservableEntity.CreateObservableFromEntity(x)).ToObservableCollection(); + + Cats = Context.CATS.Where(x => !x.DELETED).ToList().Select(x => ObservableEntity.CreateObservableFromEntity(x)).ToObservableCollection(); + InitCollectionSources(); } diff --git a/Software/Visual_Studio/Tango.DAL.Observables/ObservablesEntitiesAdapterExtension.cs b/Software/Visual_Studio/Tango.DAL.Observables/ObservablesEntitiesAdapterExtension.cs index 8b17c1182..d5d687d46 100644 --- a/Software/Visual_Studio/Tango.DAL.Observables/ObservablesEntitiesAdapterExtension.cs +++ b/Software/Visual_Studio/Tango.DAL.Observables/ObservablesEntitiesAdapterExtension.cs @@ -294,6 +294,78 @@ namespace Tango.DAL.Observables } + private ObservableCollection _cats; + /// + /// Gets or sets the Cats. + /// + public ObservableCollection Cats + { + get + { + return _cats; + } + + set + { + _cats = value; RaisePropertyChanged(nameof(Cats)); + } + + } + + private ICollectionView _catsViewSource; + /// + /// Gets or sets the Cats View Source. + /// + public ICollectionView CatsViewSource + { + get + { + return _catsViewSource; + } + + set + { + _catsViewSource = value; RaisePropertyChanged(nameof(CatsViewSource)); + } + + } + + private ObservableCollection _ccts; + /// + /// Gets or sets the Ccts. + /// + public ObservableCollection Ccts + { + get + { + return _ccts; + } + + set + { + _ccts = value; RaisePropertyChanged(nameof(Ccts)); + } + + } + + private ICollectionView _cctsViewSource; + /// + /// Gets or sets the Ccts View Source. + /// + public ICollectionView CctsViewSource + { + get + { + return _cctsViewSource; + } + + set + { + _cctsViewSource = value; RaisePropertyChanged(nameof(CctsViewSource)); + } + + } + private ObservableCollection _configurations; /// /// Gets or sets the Configurations. @@ -1432,6 +1504,10 @@ namespace Tango.DAL.Observables CartridgesViewSource = CreateCollectionView(Cartridges); + CatsViewSource = CreateCollectionView(Cats); + + CctsViewSource = CreateCollectionView(Ccts); + ConfigurationsViewSource = CreateCollectionView(Configurations); ContactsViewSource = CreateCollectionView(Contacts); diff --git a/Software/Visual_Studio/Tango.DAL.Observables/Tango.DAL.Observables.csproj b/Software/Visual_Studio/Tango.DAL.Observables/Tango.DAL.Observables.csproj index 096b12d91..5912b99ea 100644 --- a/Software/Visual_Studio/Tango.DAL.Observables/Tango.DAL.Observables.csproj +++ b/Software/Visual_Studio/Tango.DAL.Observables/Tango.DAL.Observables.csproj @@ -57,6 +57,8 @@ GlobalVersionInfo.cs + + diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/CAT.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/CAT.cs new file mode 100644 index 000000000..162c39209 --- /dev/null +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/CAT.cs @@ -0,0 +1,28 @@ +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Tango.DAL.Remote.DB +{ + using System; + using System.Collections.Generic; + + public partial class CAT + { + public int ID { get; set; } + public string GUID { get; set; } + public System.DateTime LAST_UPDATED { get; set; } + public bool DELETED { get; set; } + public string LIQUID_TYPE_GUID { get; set; } + public string MACHINE_GUID { get; set; } + public byte[] DATA { get; set; } + + public virtual LIQUID_TYPES LIQUID_TYPES { get; set; } + public virtual MACHINE MACHINE { get; set; } + } +} diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/CCT.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/CCT.cs new file mode 100644 index 000000000..9a420020b --- /dev/null +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/CCT.cs @@ -0,0 +1,32 @@ +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Tango.DAL.Remote.DB +{ + using System; + using System.Collections.Generic; + + public partial class CCT + { + public int ID { get; set; } + public string GUID { get; set; } + public System.DateTime LAST_UPDATED { get; set; } + public bool DELETED { get; set; } + public string NAME { get; set; } + public string DESCRIPTION { get; set; } + public string FORWARD_FILE_NAME { get; set; } + public string INVERSE_FILE_NAME { get; set; } + public byte[] FORWARD_DATA { get; set; } + public byte[] INVERSE_DATA { get; set; } + public double VERSION { get; set; } + public string RML_GUID { get; set; } + + public virtual RML RML { get; set; } + } +} diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/LIQUID_TYPES.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/LIQUID_TYPES.cs index 13821ad8d..71f55585b 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/LIQUID_TYPES.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/LIQUID_TYPES.cs @@ -17,6 +17,7 @@ namespace Tango.DAL.Remote.DB [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] public LIQUID_TYPES() { + this.CATS = new HashSet(); this.IDS_PACKS = new HashSet(); this.LIQUID_TYPES_RMLS = new HashSet(); } @@ -30,6 +31,8 @@ namespace Tango.DAL.Remote.DB public double VERSION { get; set; } public int COLOR { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection CATS { get; set; } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] public virtual ICollection IDS_PACKS { get; set; } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/MACHINE.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/MACHINE.cs index 927397513..bd54bbf4a 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/MACHINE.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/MACHINE.cs @@ -17,6 +17,7 @@ namespace Tango.DAL.Remote.DB [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] public MACHINE() { + this.CATS = new HashSet(); this.MACHINES_CONFIGURATIONS = new HashSet(); this.MACHINES_EVENTS = new HashSet(); } @@ -32,6 +33,8 @@ namespace Tango.DAL.Remote.DB public string MACHINE_VERSION_GUID { get; set; } public string CONFIGURATION_GUID { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection CATS { get; set; } public virtual CONFIGURATION CONFIGURATION { get; set; } public virtual MACHINE_VERSIONS MACHINE_VERSIONS { get; set; } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RML.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/RML.cs index 6c681437f..ab1189e95 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RML.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RML.cs @@ -17,6 +17,7 @@ namespace Tango.DAL.Remote.DB [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] public RML() { + this.CCTS = new HashSet(); this.LIQUID_TYPES_RMLS = new HashSet(); } @@ -44,6 +45,8 @@ namespace Tango.DAL.Remote.DB public double ELONGATION_AT_BREAK_PERCENTAGE { get; set; } public double ESTIMATED_THREAD_DIAMETER { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection CCTS { get; set; } public virtual FIBER_SHAPES FIBER_SHAPES { get; set; } public virtual FIBER_SYNTHS FIBER_SYNTHS { get; set; } public virtual LINEAR_MASS_DENSITY_UNITS LINEAR_MASS_DENSITY_UNITS { get; set; } diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.Context.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.Context.cs index 7af957ce4..a04261d6a 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.Context.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.Context.cs @@ -33,6 +33,8 @@ namespace Tango.DAL.Remote.DB public virtual DbSet APPLICATION_VERSIONS { get; set; } public virtual DbSet CARTRIDGE_TYPES { get; set; } public virtual DbSet CARTRIDGES { get; set; } + public virtual DbSet CATS { get; set; } + public virtual DbSet CCTS { get; set; } public virtual DbSet CONFIGURATIONS { get; set; } public virtual DbSet CONTACTS { get; set; } public virtual DbSet DISPENSER_TYPES { get; set; } diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx index 4cc5f3b22..7e82dbbe3 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx @@ -99,6 +99,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -496,6 +525,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1007,6 +1072,8 @@ + + @@ -1042,6 +1109,18 @@ + + + + + + + + + + + + @@ -1220,6 +1299,8 @@ + + @@ -1287,6 +1368,18 @@ + + + + + + + + + + + + @@ -1524,6 +1617,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1724,6 +1849,7 @@ + @@ -1768,6 +1894,7 @@ + @@ -1907,6 +2034,7 @@ + @@ -2093,6 +2221,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -2605,6 +2769,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram index 4448347e9..1bf8a6a7b 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram @@ -5,45 +5,47 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -53,6 +55,9 @@ + + + diff --git a/Software/Visual_Studio/Tango.DAL.Remote/Tango.DAL.Remote.csproj b/Software/Visual_Studio/Tango.DAL.Remote/Tango.DAL.Remote.csproj index 24b595544..0159a5727 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/Tango.DAL.Remote.csproj +++ b/Software/Visual_Studio/Tango.DAL.Remote/Tango.DAL.Remote.csproj @@ -89,6 +89,12 @@ RemoteADO.tt + + RemoteADO.tt + + + RemoteADO.tt + RemoteADO.tt -- cgit v1.3.1