From 5e68543fd93e441e1e76acc3f439594f66c4412a Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Thu, 18 Jan 2018 16:20:02 +0200 Subject: Removed Deleted from most of DB Tables !!!!!!!!!!! --- .../Views/MachineVersionDialog.xaml | 80 ++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineVersionDialog.xaml (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineVersionDialog.xaml') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineVersionDialog.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineVersionDialog.xaml new file mode 100644 index 000000000..60aebef7f --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineVersionDialog.xaml @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Version + + + + , + + + + + + + Name + + + + + + + + + + + + + + + + + + -- cgit v1.3.1 From bc2d3eb5ec8c7176627dcb8f5c02cc085b2db584 Mon Sep 17 00:00:00 2001 From: Roy Date: Sat, 20 Jan 2018 21:30:53 +0200 Subject: Implemented new CATS. Implemented Process Parameters View on DB Module. Implemented RML Process Parameters View on DB Module. Modified DB Module table initials letter casing. Moved observables generator to CLI. --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 8388608 -> 8388608 bytes .../Controls/DbTableView.xaml | 2 +- .../ProcessParametersRmlsToStringConverter.cs | 40 --- .../Managers/RegisteredView.cs | 12 + .../Tango.MachineStudio.DB.csproj | 16 +- .../Tango.MachineStudio.DB/ViewModelLocator.cs | 9 + .../ViewModels/CatsViewVM.cs | 1 + .../RmlsProcessParametersTablesViewVM.cs | 18 ++ .../Views/DBViews/CatView.xaml | 7 +- .../Views/DBViews/CatsView.xaml | 3 +- .../Views/DBViews/ProcessParametersTableView.xaml | 2 +- .../DBViews/RmlsProcessParametersTableView.xaml | 31 +++ .../DBViews/RmlsProcessParametersTableView.xaml.cs | 28 +++ .../DBViews/RmlsProcessParametersTablesView.xaml | 26 ++ .../RmlsProcessParametersTablesView.xaml.cs | 30 +++ .../Views/MainDBView.xaml.cs | 2 +- .../ViewModels/MachineVersionDialogVM.cs | 10 +- .../Views/MachineVersionDialog.xaml | 13 +- .../Tango.DAL.Observables/Entities/Cat.cs | 43 +++- .../Tango.DAL.Observables/Entities/Machine.cs | 21 -- .../Entities/ProcessParametersTable.cs | 14 +- .../Tango.DAL.Observables/Entities/Rml.cs | 35 ++- .../Entities/RmlsProcessParameter.cs | 114 --------- .../Entities/RmlsProcessParametersTable.cs | 133 ++++++++++ .../ObservablesEntitiesAdapter.cs | 2 + .../ObservablesEntitiesAdapterExtension.cs | 22 +- .../Tango.DAL.Observables/ObservablesGenerator.cs | 270 -------------------- .../Tango.DAL.Observables.csproj | 9 +- Software/Visual_Studio/Tango.DAL.Remote/DB/CAT.cs | 5 +- .../Visual_Studio/Tango.DAL.Remote/DB/MACHINE.cs | 3 - .../DB/PROCESS_PARAMETERS_TABLES.cs | 4 +- Software/Visual_Studio/Tango.DAL.Remote/DB/RML.cs | 7 +- .../Tango.DAL.Remote/DB/RMLS_PROCESS_PARAMETERS.cs | 26 -- .../DB/RMLS_PROCESS_PARAMETERS_TABLES.cs | 27 ++ .../Tango.DAL.Remote/DB/RemoteADO.Context.cs | 2 +- .../Tango.DAL.Remote/DB/RemoteADO.edmx | 112 ++++----- .../Tango.DAL.Remote/DB/RemoteADO.edmx.diagram | 88 +++---- .../Tango.DAL.Remote/Tango.DAL.Remote.csproj | 2 +- .../Remote/RemoteDBComparer.cs | 14 +- .../Tango.UnitTesting/CodeGeneration_TST.cs | 1 + .../Tango.UnitTesting/Tango.UnitTesting.csproj | 4 + .../ObservablesGenerator.cs | 271 +++++++++++++++++++++ .../Tango.DBObservablesGenerator.CLI/Program.cs | 1 - .../Tango.DBObservablesGenerator.CLI.csproj | 16 ++ .../packages.config | 42 ++++ 46 files changed, 881 insertions(+), 657 deletions(-) delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Converters/ProcessParametersRmlsToStringConverter.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/RmlsProcessParametersTablesViewVM.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/RmlsProcessParametersTableView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/RmlsProcessParametersTableView.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/RmlsProcessParametersTablesView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/RmlsProcessParametersTablesView.xaml.cs delete mode 100644 Software/Visual_Studio/Tango.DAL.Observables/Entities/RmlsProcessParameter.cs create mode 100644 Software/Visual_Studio/Tango.DAL.Observables/Entities/RmlsProcessParametersTable.cs delete mode 100644 Software/Visual_Studio/Tango.DAL.Observables/ObservablesGenerator.cs delete mode 100644 Software/Visual_Studio/Tango.DAL.Remote/DB/RMLS_PROCESS_PARAMETERS.cs create mode 100644 Software/Visual_Studio/Tango.DAL.Remote/DB/RMLS_PROCESS_PARAMETERS_TABLES.cs create mode 100644 Software/Visual_Studio/Utilities/Tango.DBObservablesGenerator.CLI/ObservablesGenerator.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineVersionDialog.xaml') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 0d278796c..dedfe10f7 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 ad3b1ba73..579e80a02 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/Controls/DbTableView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Controls/DbTableView.xaml index d1c62ed7e..f3e13e338 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Controls/DbTableView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Controls/DbTableView.xaml @@ -5,7 +5,7 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" mc:Ignorable="d" - d:DesignHeight="720" d:DesignWidth="1280"> + d:DesignHeight="720" d:DesignWidth="1000" MaxWidth="1000"> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Converters/ProcessParametersRmlsToStringConverter.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Converters/ProcessParametersRmlsToStringConverter.cs deleted file mode 100644 index 359467e2d..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Converters/ProcessParametersRmlsToStringConverter.cs +++ /dev/null @@ -1,40 +0,0 @@ -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.DAL.Observables; -using Tango.MachineStudio.DB.ViewModels; - -namespace Tango.MachineStudio.DB.Converters -{ - /// - /// Converts a liquid type RML to string. - /// - /// - public class ProcessParametersRmlsToStringConverter : IValueConverter - { - public object Convert(object value, Type targetType, object parameter, CultureInfo culture) - { - if (value == null) return ""; - - if (value is IEnumerable) - { - IEnumerable liquidRmls = value as IEnumerable; - return String.Join(", ", liquidRmls.Select(x => x.Rml.Name)); - } - else - { - IEnumerable> rmls = value as IEnumerable>; - return String.Join(", ", rmls.Where(x => x.IsSelected).Select(x => x.Entity.Name)); - } - } - - public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) - { - throw new NotImplementedException(); - } - } -} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Managers/RegisteredView.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Managers/RegisteredView.cs index cdd32eaa5..cd53ff8d8 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Managers/RegisteredView.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Managers/RegisteredView.cs @@ -33,7 +33,14 @@ namespace Tango.MachineStudio.DB.Managers { Location = new Point(rnd.Next(30, 200), rnd.Next(30, 200)); Icon = PackIconKind.Table; + + if (header.Length < 5) + { + header = header.ToUpper(); + } + Header = header; + View = view; if (action != null) @@ -64,6 +71,11 @@ namespace Tango.MachineStudio.DB.Managers /// The view. public RegisteredView(String header, FrameworkElement view) : this(header, view, null) { + if (header.Length < 5) + { + header = header.ToUpper(); + } + Header = header; View = view; } 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 42bcb5eac..bb3084207 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 @@ -89,7 +89,6 @@ - @@ -130,6 +129,7 @@ + @@ -142,6 +142,12 @@ ActionTypeView.xaml + + RmlsProcessParametersTablesView.xaml + + + RmlsProcessParametersTableView.xaml + ProcessParametersTablesView.xaml @@ -372,6 +378,14 @@ 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 350bebcc0..5fe386749 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModelLocator.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModelLocator.cs @@ -60,6 +60,7 @@ namespace Tango.MachineStudio.DB SimpleIoc.Default.Register(); SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); } public static MainViewVM MainViewVM @@ -349,5 +350,13 @@ namespace Tango.MachineStudio.DB return ServiceLocator.Current.GetInstance(); } } + + public static RmlsProcessParametersTablesViewVM RmlsProcessParametersTablesViewVM + { + 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 index 74a7e29eb..a768b3c7c 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/CatsViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/CatsViewVM.cs @@ -16,6 +16,7 @@ namespace Tango.MachineStudio.DB.ViewModels public CatsViewVM(INotificationProvider notification) : base(notification) { SelectDataFileCommand = new RelayCommand(SelectDataFile); + } public RelayCommand SelectDataFileCommand { get; set; } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/RmlsProcessParametersTablesViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/RmlsProcessParametersTablesViewVM.cs new file mode 100644 index 000000000..4ae1f063f --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/RmlsProcessParametersTablesViewVM.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.DAL.Observables; +using Tango.MachineStudio.Common.Notifications; + +namespace Tango.MachineStudio.DB.ViewModels +{ + public class RmlsProcessParametersTablesViewVM : DbTableViewModel + { + public RmlsProcessParametersTablesViewVM(INotificationProvider notification) : base(notification) + { + + } + } +} 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 index 442f77ae3..9cd01cfc4 100644 --- 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 @@ -28,6 +28,9 @@ + + + @@ -44,8 +47,8 @@ - - + + 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 index d88a2a142..e72146525 100644 --- 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 @@ -22,6 +22,7 @@ + @@ -34,7 +35,7 @@ - + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/ProcessParametersTableView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/ProcessParametersTableView.xaml index 06442196e..e9b7c31af 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/ProcessParametersTableView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/ProcessParametersTableView.xaml @@ -56,7 +56,7 @@ - + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/RmlsProcessParametersTableView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/RmlsProcessParametersTableView.xaml new file mode 100644 index 000000000..767b39f29 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/RmlsProcessParametersTableView.xaml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/RmlsProcessParametersTableView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/RmlsProcessParametersTableView.xaml.cs new file mode 100644 index 000000000..713a46204 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/RmlsProcessParametersTableView.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 UserView.xaml + /// + public partial class RmlsProcessParametersTableView : UserControl + { + public RmlsProcessParametersTableView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/RmlsProcessParametersTablesView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/RmlsProcessParametersTablesView.xaml new file mode 100644 index 000000000..d599c64a3 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/RmlsProcessParametersTablesView.xaml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/RmlsProcessParametersTablesView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/RmlsProcessParametersTablesView.xaml.cs new file mode 100644 index 000000000..c4ee7e66d --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/RmlsProcessParametersTablesView.xaml.cs @@ -0,0 +1,30 @@ +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; + +namespace Tango.MachineStudio.DB.Views.DBViews +{ + /// + /// Interaction logic for UsersView.xaml + /// + [DBView] + public partial class RmlsProcessParametersTablesView : UserControl + { + public RmlsProcessParametersTablesView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/MainDBView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/MainDBView.xaml.cs index 1ffdf7eb0..b769b9bfd 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/MainDBView.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/MainDBView.xaml.cs @@ -58,7 +58,7 @@ namespace Tango.MachineStudio.DB.Views grid.DataContext = message.Context; presenter.Content = view; icon.Kind = (message.DialogOpenMode == DialogOpenMode.Editing ? PackIconKind.TableEdit : PackIconKind.Plus); - txtTitle.Text = (message.DialogOpenMode == DialogOpenMode.Editing ? "Edit " : "Add New ") + message.EntityType.Name.ToTitle(); + txtTitle.Text = (message.DialogOpenMode == DialogOpenMode.Editing ? "Edit " : "Add New ") + (message.EntityType.Name.Length < 5 ? message.EntityType.Name.ToUpper() : message.EntityType.Name).ToTitle(); IsEditViewOpen = true; } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MachineVersionDialogVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MachineVersionDialogVM.cs index 6854472f1..3776a5e91 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MachineVersionDialogVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MachineVersionDialogVM.cs @@ -12,7 +12,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels { public class MachineVersionDialogVM : DialogViewVM { - public MachineVersionsProvider VersionsProvider { get; set; } + public ObservablesEntitiesAdapter Adapter { get; set; } public double Version { get; set; } @@ -44,16 +44,10 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels public MachineVersionDialogVM() { - VersionsProvider = new MachineVersionsProvider(); + Adapter = ObservablesEntitiesAdapter.Instance; AcceptCommand = new RelayCommand(() => { - if (SelectedVersion == null) - { - Version = double.Parse(VersionsProvider.Text); - } - Accept(); - }); CancelCommand = new RelayCommand(Cancel); } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineVersionDialog.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineVersionDialog.xaml index 60aebef7f..f6c39a6cd 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineVersionDialog.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineVersionDialog.xaml @@ -36,18 +36,9 @@ - + Version - - - - , - - - - - - + Name diff --git a/Software/Visual_Studio/Tango.DAL.Observables/Entities/Cat.cs b/Software/Visual_Studio/Tango.DAL.Observables/Entities/Cat.cs index 447332aeb..0b1128e51 100644 --- a/Software/Visual_Studio/Tango.DAL.Observables/Entities/Cat.cs +++ b/Software/Visual_Studio/Tango.DAL.Observables/Entities/Cat.cs @@ -10,6 +10,25 @@ namespace Tango.DAL.Observables public partial class Cat : ObservableEntity { + private String _name; + /// + /// Gets or sets the cat name. + /// + [EntityFieldName("NAME")] + public String Name + { + get + { + return _name; + } + + set + { + _name = value; RaisePropertyChanged(nameof(Name)); + } + + } + private String _liquidtypeguid; /// /// Gets or sets the cat liquid type guid. @@ -29,21 +48,21 @@ namespace Tango.DAL.Observables } - private String _machineguid; + private String _rmlguid; /// - /// Gets or sets the cat machine guid. + /// Gets or sets the cat rml guid. /// - [EntityFieldName("MACHINE_GUID")] - public String MachineGuid + [EntityFieldName("RML_GUID")] + public String RmlGuid { get { - return _machineguid; + return _rmlguid; } set { - _machineguid = value; RaisePropertyChanged(nameof(MachineGuid)); + _rmlguid = value; RaisePropertyChanged(nameof(RmlGuid)); } } @@ -86,21 +105,21 @@ namespace Tango.DAL.Observables } - private Machine _machine; + private Rml _rml; /// - /// Gets or sets the cat machine. + /// Gets or sets the cat rml. /// - [EntityFieldName("MACHINE")] - public Machine Machine + [EntityFieldName("RML")] + public Rml Rml { get { - return _machine; + return _rml; } set { - _machine = value; RaisePropertyChanged(nameof(Machine)); + _rml = value; RaisePropertyChanged(nameof(Rml)); } } diff --git a/Software/Visual_Studio/Tango.DAL.Observables/Entities/Machine.cs b/Software/Visual_Studio/Tango.DAL.Observables/Entities/Machine.cs index 44bb84ee4..2f2c8ded4 100644 --- a/Software/Visual_Studio/Tango.DAL.Observables/Entities/Machine.cs +++ b/Software/Visual_Studio/Tango.DAL.Observables/Entities/Machine.cs @@ -124,25 +124,6 @@ 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. @@ -262,8 +243,6 @@ 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/ProcessParametersTable.cs b/Software/Visual_Studio/Tango.DAL.Observables/Entities/ProcessParametersTable.cs index 8bc2cff3b..410ad7b8e 100644 --- a/Software/Visual_Studio/Tango.DAL.Observables/Entities/ProcessParametersTable.cs +++ b/Software/Visual_Studio/Tango.DAL.Observables/Entities/ProcessParametersTable.cs @@ -352,21 +352,21 @@ namespace Tango.DAL.Observables } - private ObservableCollection _rmlsprocessparameters; + private ObservableCollection _rmlsprocessparameterstables; /// - /// Gets or sets the processparameterstable rmls process parameters. + /// Gets or sets the processparameterstable rmls process parameters tables. /// - [EntityFieldName("RMLS_PROCESS_PARAMETERS")] - public ObservableCollection RmlsProcessParameters + [EntityFieldName("RMLS_PROCESS_PARAMETERS_TABLES")] + public ObservableCollection RmlsProcessParametersTables { get { - return _rmlsprocessparameters; + return _rmlsprocessparameterstables; } set { - _rmlsprocessparameters = value; RaisePropertyChanged(nameof(RmlsProcessParameters)); + _rmlsprocessparameterstables = value; RaisePropertyChanged(nameof(RmlsProcessParametersTables)); } } @@ -395,7 +395,7 @@ namespace Tango.DAL.Observables private void Init() { - RmlsProcessParameters = new ObservableCollection(); + RmlsProcessParametersTables = 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 ab62b578d..8c97df116 100644 --- a/Software/Visual_Studio/Tango.DAL.Observables/Entities/Rml.cs +++ b/Software/Visual_Studio/Tango.DAL.Observables/Entities/Rml.cs @@ -390,6 +390,25 @@ namespace Tango.DAL.Observables } + private ObservableCollection _cats; + /// + /// Gets or sets the rml cats. + /// + [EntityFieldName("CATS")] + public ObservableCollection Cats + { + get + { + return _cats; + } + + set + { + _cats = value; RaisePropertyChanged(nameof(Cats)); + } + + } + private ObservableCollection _ccts; /// /// Gets or sets the rml ccts. @@ -561,21 +580,21 @@ namespace Tango.DAL.Observables } - private ObservableCollection _rmlsprocessparameters; + private ObservableCollection _rmlsprocessparameterstables; /// - /// Gets or sets the rml rmls process parameters. + /// Gets or sets the rml rmls process parameters tables. /// - [EntityFieldName("RMLS_PROCESS_PARAMETERS")] - public ObservableCollection RmlsProcessParameters + [EntityFieldName("RMLS_PROCESS_PARAMETERS_TABLES")] + public ObservableCollection RmlsProcessParametersTables { get { - return _rmlsprocessparameters; + return _rmlsprocessparameterstables; } set { - _rmlsprocessparameters = value; RaisePropertyChanged(nameof(RmlsProcessParameters)); + _rmlsprocessparameterstables = value; RaisePropertyChanged(nameof(RmlsProcessParametersTables)); } } @@ -604,11 +623,13 @@ namespace Tango.DAL.Observables private void Init() { + Cats = new ObservableCollection(); + Ccts = new ObservableCollection(); LiquidTypesRmls = new ObservableCollection(); - RmlsProcessParameters = new ObservableCollection(); + RmlsProcessParametersTables = new ObservableCollection(); } } diff --git a/Software/Visual_Studio/Tango.DAL.Observables/Entities/RmlsProcessParameter.cs b/Software/Visual_Studio/Tango.DAL.Observables/Entities/RmlsProcessParameter.cs deleted file mode 100644 index 4dc3a23b4..000000000 --- a/Software/Visual_Studio/Tango.DAL.Observables/Entities/RmlsProcessParameter.cs +++ /dev/null @@ -1,114 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using Tango.DAL.Remote.DB; - -namespace Tango.DAL.Observables -{ - [EntityFieldName("RMLS_PROCESS_PARAMETERS")] - public partial class RmlsProcessParameter : ObservableEntity - { - - private String _rmlguid; - /// - /// Gets or sets the rmlsprocessparameter rml guid. - /// - [EntityFieldName("RML_GUID")] - public String RmlGuid - { - get - { - return _rmlguid; - } - - set - { - _rmlguid = value; RaisePropertyChanged(nameof(RmlGuid)); - } - - } - - private String _processparametersguid; - /// - /// Gets or sets the rmlsprocessparameter process parameters guid. - /// - [EntityFieldName("PROCESS_PARAMETERS_GUID")] - public String ProcessParametersGuid - { - get - { - return _processparametersguid; - } - - set - { - _processparametersguid = value; RaisePropertyChanged(nameof(ProcessParametersGuid)); - } - - } - - private ProcessParametersTable _processparameterstables; - /// - /// Gets or sets the rmlsprocessparameter process parameters tables. - /// - [EntityFieldName("PROCESS_PARAMETERS_TABLES")] - public ProcessParametersTable ProcessParametersTables - { - get - { - return _processparameterstables; - } - - set - { - _processparameterstables = value; RaisePropertyChanged(nameof(ProcessParametersTables)); - } - - } - - private Rml _rml; - /// - /// Gets or sets the rmlsprocessparameter rml. - /// - [EntityFieldName("RML")] - public Rml Rml - { - get - { - return _rml; - } - - set - { - _rml = value; RaisePropertyChanged(nameof(Rml)); - } - - } - - /// - /// Initializes a new instance of the class. - /// - public RmlsProcessParameter() : base() - { - Init(); - } - - /// - /// Initializes a new instance of the class. - /// - /// The entity. - public RmlsProcessParameter(RMLS_PROCESS_PARAMETERS entity) : base(entity) - { - Init(); - MapEntityToObservable(entity, this); - } - - /// - /// Initialize complex types. - /// - private void Init() - { - } - } -} diff --git a/Software/Visual_Studio/Tango.DAL.Observables/Entities/RmlsProcessParametersTable.cs b/Software/Visual_Studio/Tango.DAL.Observables/Entities/RmlsProcessParametersTable.cs new file mode 100644 index 000000000..5c912f3f0 --- /dev/null +++ b/Software/Visual_Studio/Tango.DAL.Observables/Entities/RmlsProcessParametersTable.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("RMLS_PROCESS_PARAMETERS_TABLES")] + public partial class RmlsProcessParametersTable : ObservableEntity + { + + private String _rmlguid; + /// + /// Gets or sets the rmlsprocessparameterstable rml guid. + /// + [EntityFieldName("RML_GUID")] + public String RmlGuid + { + get + { + return _rmlguid; + } + + set + { + _rmlguid = value; RaisePropertyChanged(nameof(RmlGuid)); + } + + } + + private String _processparameterstableguid; + /// + /// Gets or sets the rmlsprocessparameterstable process parameters table guid. + /// + [EntityFieldName("PROCESS_PARAMETERS_TABLE_GUID")] + public String ProcessParametersTableGuid + { + get + { + return _processparameterstableguid; + } + + set + { + _processparameterstableguid = value; RaisePropertyChanged(nameof(ProcessParametersTableGuid)); + } + + } + + private Int32 _tableindex; + /// + /// Gets or sets the rmlsprocessparameterstable table index. + /// + [EntityFieldName("TABLE_INDEX")] + public Int32 TableIndex + { + get + { + return _tableindex; + } + + set + { + _tableindex = value; RaisePropertyChanged(nameof(TableIndex)); + } + + } + + private ProcessParametersTable _processparameterstables; + /// + /// Gets or sets the rmlsprocessparameterstable process parameters tables. + /// + [EntityFieldName("PROCESS_PARAMETERS_TABLES")] + public ProcessParametersTable ProcessParametersTables + { + get + { + return _processparameterstables; + } + + set + { + _processparameterstables = value; RaisePropertyChanged(nameof(ProcessParametersTables)); + } + + } + + private Rml _rml; + /// + /// Gets or sets the rmlsprocessparameterstable rml. + /// + [EntityFieldName("RML")] + public Rml Rml + { + get + { + return _rml; + } + + set + { + _rml = value; RaisePropertyChanged(nameof(Rml)); + } + + } + + /// + /// Initializes a new instance of the class. + /// + public RmlsProcessParametersTable() : base() + { + Init(); + } + + /// + /// Initializes a new instance of the class. + /// + /// The entity. + public RmlsProcessParametersTable(RMLS_PROCESS_PARAMETERS_TABLES entity) : base(entity) + { + Init(); + MapEntityToObservable(entity, this); + } + + /// + /// Initialize complex types. + /// + private void Init() + { + } + } +} diff --git a/Software/Visual_Studio/Tango.DAL.Observables/ObservablesEntitiesAdapter.cs b/Software/Visual_Studio/Tango.DAL.Observables/ObservablesEntitiesAdapter.cs index b24640c79..b78ebcdbc 100644 --- a/Software/Visual_Studio/Tango.DAL.Observables/ObservablesEntitiesAdapter.cs +++ b/Software/Visual_Studio/Tango.DAL.Observables/ObservablesEntitiesAdapter.cs @@ -249,6 +249,8 @@ namespace Tango.DAL.Observables ProcessParametersTables = Context.PROCESS_PARAMETERS_TABLES.ToList().Select(x => ObservableEntity.CreateObservableFromEntity(x)).ToObservableCollection(); + RmlsProcessParametersTables = Context.RMLS_PROCESS_PARAMETERS_TABLES.ToList().Select(x => ObservableEntity.CreateObservableFromEntity(x)).ToObservableCollection(); + InitCollectionSources(); //BindingOperations.EnableCollectionSynchronization(Machines, _syncLock); diff --git a/Software/Visual_Studio/Tango.DAL.Observables/ObservablesEntitiesAdapterExtension.cs b/Software/Visual_Studio/Tango.DAL.Observables/ObservablesEntitiesAdapterExtension.cs index 279d170d8..180ac394a 100644 --- a/Software/Visual_Studio/Tango.DAL.Observables/ObservablesEntitiesAdapterExtension.cs +++ b/Software/Visual_Studio/Tango.DAL.Observables/ObservablesEntitiesAdapterExtension.cs @@ -1302,38 +1302,38 @@ namespace Tango.DAL.Observables } - private ObservableCollection _rmlsprocessparameters; + private ObservableCollection _rmlsprocessparameterstables; /// - /// Gets or sets the RmlsProcessParameters. + /// Gets or sets the RmlsProcessParametersTables. /// - public ObservableCollection RmlsProcessParameters + public ObservableCollection RmlsProcessParametersTables { get { - return _rmlsprocessparameters; + return _rmlsprocessparameterstables; } set { - _rmlsprocessparameters = value; RaisePropertyChanged(nameof(RmlsProcessParameters)); + _rmlsprocessparameterstables = value; RaisePropertyChanged(nameof(RmlsProcessParametersTables)); } } - private ICollectionView _rmlsprocessparametersViewSource; + private ICollectionView _rmlsprocessparameterstablesViewSource; /// - /// Gets or sets the RmlsProcessParameters View Source. + /// Gets or sets the RmlsProcessParametersTables View Source. /// - public ICollectionView RmlsProcessParametersViewSource + public ICollectionView RmlsProcessParametersTablesViewSource { get { - return _rmlsprocessparametersViewSource; + return _rmlsprocessparameterstablesViewSource; } set { - _rmlsprocessparametersViewSource = value; RaisePropertyChanged(nameof(RmlsProcessParametersViewSource)); + _rmlsprocessparameterstablesViewSource = value; RaisePropertyChanged(nameof(RmlsProcessParametersTablesViewSource)); } } @@ -1596,7 +1596,7 @@ namespace Tango.DAL.Observables RmlsViewSource = CreateCollectionView(Rmls); - RmlsProcessParametersViewSource = CreateCollectionView(RmlsProcessParameters); + RmlsProcessParametersTablesViewSource = CreateCollectionView(RmlsProcessParametersTables); RolesViewSource = CreateCollectionView(Roles); diff --git a/Software/Visual_Studio/Tango.DAL.Observables/ObservablesGenerator.cs b/Software/Visual_Studio/Tango.DAL.Observables/ObservablesGenerator.cs deleted file mode 100644 index 53f27c9ba..000000000 --- a/Software/Visual_Studio/Tango.DAL.Observables/ObservablesGenerator.cs +++ /dev/null @@ -1,270 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Data.Entity; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; -using Tango.CodeGeneration; -using Tango.DAL.Remote.DB; -using Tango.Settings; -using Humanizer; - -namespace Tango.DAL.Observables -{ - /// - /// Generates observable entities code files. - /// - public class ObservablesGenerator - { - /// - /// Generates C# code files. - /// - /// The target path. - public void GenerateCSharp(String targetPath) - { - //Generate Entities... - foreach (var table in typeof(RemoteDB).GetProperties().Where(x => typeof(IEnumerable).IsAssignableFrom(x.PropertyType))) - { - EntityCodeFile codeFile = new EntityCodeFile(ObservableEntity.DalNameToStandardName(table.Name).SingularizeMVC()) - { - EntityName = table.Name.SingularizeMVC(), - TableName = table.Name, - }; - - foreach (var field in table.PropertyType.GenericTypeArguments.First().GetProperties().Skip(3)) - { - EntityCodeFileField codeField = new EntityCodeFileField(); - codeField.FieldName = field.Name; - codeField.Name = ObservableEntity.DalNameToStandardName(field.Name); - codeField.Description = field.Name.Replace("_", " ").ToLower(); - - - if (field.PropertyType.IsGenericType) - { - codeField.Type = String.Format("ObservableCollection<{0}>", ObservableEntity.DalNameToStandardName(field.PropertyType.GenericTypeArguments.Single().Name).SingularizeMVC()); - codeField.Construct = true; - } - else - { - if (field.PropertyType.IsClass && field.PropertyType != typeof(String)) - { - codeField.Type = ObservableEntity.DalNameToStandardName(field.PropertyType.Name).SingularizeMVC(); - } - else - { - codeField.Type = field.PropertyType.Name; - } - } - codeFile.Fields.Add(codeField); - } - - String code = codeFile.GenerateCode(); - - String entitiesPath = Path.Combine(targetPath, "Entities"); - Directory.CreateDirectory(entitiesPath); - File.WriteAllText(Path.Combine(entitiesPath, codeFile.Name + ".cs"), code); - } - //Generate Entities... - - //Generate Enumerations... - using (RemoteDB db = new RemoteDB(SettingsManager.Default.DataBase.SQLServerAddress, false)) - { - foreach (var tableProp in db.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(x => x.PropertyType.IsGenericType)) - { - try - { - var a = tableProp.PropertyType.GenericTypeArguments.FirstOrDefault(); - var codeProp = tableProp.PropertyType.GenericTypeArguments.First().GetProperty("CODE"); - var nameProp = tableProp.PropertyType.GenericTypeArguments.First().GetProperty("NAME"); - var descriptionProp = tableProp.PropertyType.GenericTypeArguments.First().GetProperty("DESCRIPTION"); - - if (codeProp != null && nameProp != null) - { - EnumerationFile enumFile = new EnumerationFile(); - enumFile.Name = ObservableEntity.DalNameToStandardName(tableProp.Name); - - foreach (var row in tableProp.GetValue(db) as IEnumerable) - { - EnumerationField field = new EnumerationField(); - field.Name = nameProp.GetValue(row).ToString().Replace(" ", ""); - field.Value = (int)codeProp.GetValue(row); - - if (descriptionProp != null) - { - field.Description = descriptionProp.GetValue(row).ToString(); - } - else - { - field.Description = nameProp.GetValue(row).ToString(); - } - enumFile.Fields.Add(field); - } - - String enumerationsPath = Path.Combine(targetPath, "Enumerations"); - Directory.CreateDirectory(enumerationsPath); - String code = enumFile.GenerateCode(); - File.WriteAllText(Path.Combine(enumerationsPath, enumFile.Name + ".cs"), code); - } - } - catch { } - } - } - //Generate Enumerations... - - //Generate Observables Adapter Extensions... - ObservablesAdapterFile adapterFile = new ObservablesAdapterFile(); - adapterFile.Name = nameof(ObservablesEntitiesAdapter); - - foreach (var table in typeof(RemoteDB).GetProperties().Where(x => typeof(IEnumerable).IsAssignableFrom(x.PropertyType))) - { - adapterFile.Properties.Add(new Property() - { - Name = ObservableEntity.DalNameToStandardName(table.Name), - Type = String.Format("ObservableCollection<{0}>", ObservableEntity.DalNameToStandardName(table.PropertyType.GenericTypeArguments.Single().Name).SingularizeMVC()), - }); - } - - String adapterCode = adapterFile.GenerateCode(); - File.WriteAllText(Path.Combine(targetPath, "ObservablesEntitiesAdapterExtension.cs"), adapterCode); - //Generate Observables Adapter Extensions... - } - - /// - /// Generates Java code files. - /// - /// The target path. - public void GenerateJava(String targetPath) - { - //Generate Entities... - foreach (var table in typeof(RemoteDB).GetProperties().Where(x => typeof(IEnumerable).IsAssignableFrom(x.PropertyType))) - { - EntityCodeFileJava codeFile = new EntityCodeFileJava(ObservableEntity.DalNameToStandardName(table.Name).Singularize(false)) - { - EntityName = table.Name.Singularize(false), - TableName = table.Name, - }; - - - - foreach (var field in table.PropertyType.GenericTypeArguments.First().GetProperties().Skip(3).Where(x => !x.Name.Contains("GUID"))) - { - EntityCodeFileField codeField = new EntityCodeFileField(); - codeField.FieldName = field.Name; - codeField.Name = ObservableEntity.DalNameToStandardName(field.Name); - codeField.Description = FirstCharacterToLower(ObservableEntity.DalNameToStandardName(field.Name)); - - - if (field.PropertyType.IsGenericType) - { - continue; - } - else - { - if (field.PropertyType.IsClass && field.PropertyType != typeof(String) && field.PropertyType != typeof(Byte[])) - { - codeField.Type = ObservableEntity.DalNameToStandardName(field.PropertyType.Name).Singularize(false); - codeField.Construct = true; - } - else if (field.PropertyType == typeof(Byte[])) - { - codeField.Type = field.PropertyType.Name.ToLower(); - } - else - { - codeField.Type = field.PropertyType.Name == "Int32" ? "int" : field.PropertyType.Name; - } - } - codeFile.Fields.Add(codeField); - } - - codeFile.IndentResult = false; - String code = codeFile.GenerateCode(); - - String entitiesPath = Path.Combine(targetPath, "entities"); - Directory.CreateDirectory(entitiesPath); - File.WriteAllText(Path.Combine(entitiesPath, codeFile.Name + ".java"), code); - } - //Generate Entities... - - //Generate Enumerations... - using (RemoteDB db = new RemoteDB(SettingsManager.Default.DataBase.SQLServerAddress, false)) - { - foreach (var tableProp in db.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(x => x.PropertyType.IsGenericType)) - { - try - { - var a = tableProp.PropertyType.GenericTypeArguments.FirstOrDefault(); - var codeProp = tableProp.PropertyType.GenericTypeArguments.First().GetProperty("CODE"); - var nameProp = tableProp.PropertyType.GenericTypeArguments.First().GetProperty("NAME"); - var descriptionProp = tableProp.PropertyType.GenericTypeArguments.First().GetProperty("DESCRIPTION"); - - if (codeProp != null && nameProp != null) - { - EnumerationFileJava enumFile = new EnumerationFileJava(); - enumFile.Name = ObservableEntity.DalNameToStandardName(tableProp.Name); - - foreach (var row in tableProp.GetValue(db) as IEnumerable) - { - EnumerationField field = new EnumerationField(); - field.Name = nameProp.GetValue(row).ToString().Replace(" ", ""); - field.Value = (int)codeProp.GetValue(row); - - if (descriptionProp != null) - { - field.Description = descriptionProp.GetValue(row).ToString(); - } - else - { - field.Description = nameProp.GetValue(row).ToString(); - } - enumFile.Fields.Add(field); - } - - String enumerationsPath = Path.Combine(targetPath, "enumerations"); - Directory.CreateDirectory(enumerationsPath); - String code = enumFile.GenerateCode(); - File.WriteAllText(Path.Combine(enumerationsPath, enumFile.Name + ".java"), code); - } - } - catch { } - } - } - //Generate Enumerations... - - //Generate DAO... - TangoDAOJavaFile daoFile = new TangoDAOJavaFile(); - daoFile.Name = "TangoDAO"; - - foreach (var table in typeof(RemoteDB).GetProperties().Where(x => typeof(IEnumerable).IsAssignableFrom(x.PropertyType))) - { - daoFile.Entities.Add(new TangoDAOJavaFile.TangoDAOEntity() - { - Name = ObservableEntity.DalNameToStandardName(table.Name).Singularize(false), - TableName = ObservableEntity.DalNameToStandardName(table.Name), - }); - } - - String daoCode = daoFile.GenerateCode(); - String daoFolder = Path.Combine(targetPath, "dao"); - Directory.CreateDirectory(daoFolder); - File.WriteAllText(Path.Combine(daoFolder, "TangoDAO.java"), daoCode); - //Generate DAO... - } - - /// - /// Lower case the first character of a string. - /// - /// The string. - /// - private static string FirstCharacterToLower(string str) - { - if (String.IsNullOrEmpty(str) || Char.IsLower(str, 0)) - return str; - - return Char.ToLowerInvariant(str[0]) + str.Substring(1); - } - } -} 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 40730e3a1..1918f8551 100644 --- a/Software/Visual_Studio/Tango.DAL.Observables/Tango.DAL.Observables.csproj +++ b/Software/Visual_Studio/Tango.DAL.Observables/Tango.DAL.Observables.csproj @@ -69,7 +69,7 @@ - + @@ -93,7 +93,6 @@ - @@ -154,10 +153,10 @@ - - + "$(TargetDir)dbobgen.exe" "$(SolutionDir)Tango.DAL.Observables" -csharp - "$(TargetDir)dbobgen.exe" "$(SolutionDir)Tango.DAL.Observables" -csharp + + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/CAT.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/CAT.cs index a9dafc33a..f016853a4 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/CAT.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/CAT.cs @@ -17,11 +17,12 @@ namespace Tango.DAL.Remote.DB public int ID { get; set; } public string GUID { get; set; } public System.DateTime LAST_UPDATED { get; set; } + public string NAME { get; set; } public string LIQUID_TYPE_GUID { get; set; } - public string MACHINE_GUID { get; set; } + public string RML_GUID { get; set; } public byte[] DATA { get; set; } public virtual LIQUID_TYPES LIQUID_TYPES { get; set; } - public virtual MACHINE MACHINE { get; set; } + public virtual RML RML { get; set; } } } diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/MACHINE.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/MACHINE.cs index 8963261a1..367005cf4 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/MACHINE.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/MACHINE.cs @@ -17,7 +17,6 @@ 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,8 +31,6 @@ 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/PROCESS_PARAMETERS_TABLES.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/PROCESS_PARAMETERS_TABLES.cs index 92c11111b..edd04034f 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/PROCESS_PARAMETERS_TABLES.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/PROCESS_PARAMETERS_TABLES.cs @@ -17,7 +17,7 @@ namespace Tango.DAL.Remote.DB [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] public PROCESS_PARAMETERS_TABLES() { - this.RMLS_PROCESS_PARAMETERS = new HashSet(); + this.RMLS_PROCESS_PARAMETERS_TABLES = new HashSet(); } public int ID { get; set; } @@ -43,6 +43,6 @@ namespace Tango.DAL.Remote.DB public double LUBRICATION_NL_PER_CM { get; set; } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] - public virtual ICollection RMLS_PROCESS_PARAMETERS { get; set; } + public virtual ICollection RMLS_PROCESS_PARAMETERS_TABLES { get; set; } } } diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RML.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/RML.cs index 1fd04214b..253270c8c 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RML.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RML.cs @@ -17,9 +17,10 @@ namespace Tango.DAL.Remote.DB [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] public RML() { + this.CATS = new HashSet(); this.CCTS = new HashSet(); this.LIQUID_TYPES_RMLS = new HashSet(); - this.RMLS_PROCESS_PARAMETERS = new HashSet(); + this.RMLS_PROCESS_PARAMETERS_TABLES = new HashSet(); } public int ID { get; set; } @@ -46,6 +47,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 CATS { get; set; } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] public virtual ICollection CCTS { get; set; } public virtual FIBER_SHAPES FIBER_SHAPES { get; set; } @@ -58,6 +61,6 @@ namespace Tango.DAL.Remote.DB public virtual MEDIA_MATERIALS MEDIA_MATERIALS { get; set; } public virtual MEDIA_PURPOSES MEDIA_PURPOSES { get; set; } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] - public virtual ICollection RMLS_PROCESS_PARAMETERS { get; set; } + public virtual ICollection RMLS_PROCESS_PARAMETERS_TABLES { get; set; } } } diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RMLS_PROCESS_PARAMETERS.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/RMLS_PROCESS_PARAMETERS.cs deleted file mode 100644 index cfab486af..000000000 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RMLS_PROCESS_PARAMETERS.cs +++ /dev/null @@ -1,26 +0,0 @@ -//------------------------------------------------------------------------------ -// -// 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 RMLS_PROCESS_PARAMETERS - { - public int ID { get; set; } - public string GUID { get; set; } - public System.DateTime LAST_UPDATED { get; set; } - public string RML_GUID { get; set; } - public string PROCESS_PARAMETERS_GUID { get; set; } - - public virtual PROCESS_PARAMETERS_TABLES PROCESS_PARAMETERS_TABLES { get; set; } - public virtual RML RML { get; set; } - } -} diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RMLS_PROCESS_PARAMETERS_TABLES.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/RMLS_PROCESS_PARAMETERS_TABLES.cs new file mode 100644 index 000000000..a6582b7f8 --- /dev/null +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RMLS_PROCESS_PARAMETERS_TABLES.cs @@ -0,0 +1,27 @@ +//------------------------------------------------------------------------------ +// +// 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 RMLS_PROCESS_PARAMETERS_TABLES + { + public int ID { get; set; } + public string GUID { get; set; } + public System.DateTime LAST_UPDATED { get; set; } + public string RML_GUID { get; set; } + public string PROCESS_PARAMETERS_TABLE_GUID { get; set; } + public int TABLE_INDEX { get; set; } + + public virtual PROCESS_PARAMETERS_TABLES PROCESS_PARAMETERS_TABLES { get; set; } + public virtual RML RML { 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 767f7020b..4ba24207f 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.Context.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.Context.cs @@ -61,7 +61,7 @@ namespace Tango.DAL.Remote.DB public virtual DbSet PERMISSIONS { get; set; } public virtual DbSet PROCESS_PARAMETERS_TABLES { get; set; } public virtual DbSet RMLS { get; set; } - public virtual DbSet RMLS_PROCESS_PARAMETERS { get; set; } + public virtual DbSet RMLS_PROCESS_PARAMETERS_TABLES { get; set; } public virtual DbSet ROLES { get; set; } public virtual DbSet ROLES_PERMISSIONS { get; set; } public virtual DbSet SYNC_CONFIGURATIONS { 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 714147555..8b17998d2 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx @@ -89,8 +89,9 @@ + - + @@ -446,7 +447,7 @@ - + @@ -454,7 +455,8 @@ - + + @@ -510,7 +512,7 @@ - + @@ -522,17 +524,15 @@ - - - - + + - + - + @@ -974,13 +974,13 @@ - + - - + + @@ -988,12 +988,12 @@ - + - + @@ -1121,18 +1121,18 @@ - + - + - - + + @@ -1277,11 +1277,11 @@ - + - + @@ -1353,7 +1353,7 @@ - + @@ -1391,12 +1391,12 @@ - + - - + + @@ -1525,11 +1525,11 @@ - + - + @@ -1636,11 +1636,12 @@ + - + - - + + @@ -1839,7 +1840,7 @@ - + @@ -1882,7 +1883,6 @@ - @@ -2024,7 +2024,7 @@ - + @@ -2053,6 +2053,7 @@ + @@ -2062,9 +2063,9 @@ - + - + @@ -2072,9 +2073,10 @@ - - - + + + + @@ -2239,7 +2241,7 @@ - + @@ -2251,17 +2253,15 @@ - - - - + + - + - + @@ -2655,13 +2655,13 @@ - + - - + + @@ -2669,12 +2669,12 @@ - + - + @@ -2809,8 +2809,9 @@ - + + @@ -3198,10 +3199,11 @@ - - - - + + + + + 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 50edc44ea..5b12d9aa8 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram @@ -5,48 +5,48 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -55,8 +55,8 @@ - - + + 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 3ff95ff97..8470d72a4 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/Tango.DAL.Remote.csproj +++ b/Software/Visual_Studio/Tango.DAL.Remote/Tango.DAL.Remote.csproj @@ -188,7 +188,7 @@ RemoteADO.tt - + RemoteADO.tt diff --git a/Software/Visual_Studio/Tango.Synchronization/Remote/RemoteDBComparer.cs b/Software/Visual_Studio/Tango.Synchronization/Remote/RemoteDBComparer.cs index 0b4731ddf..af10f9637 100644 --- a/Software/Visual_Studio/Tango.Synchronization/Remote/RemoteDBComparer.cs +++ b/Software/Visual_Studio/Tango.Synchronization/Remote/RemoteDBComparer.cs @@ -68,8 +68,8 @@ namespace Tango.Synchronization.Remote var local_users = _localDB.USERS.ToList(); LogManager.Log("Querying all local users roles..."); var local_users_roles = _localDB.USERS_ROLES.ToList(); - LogManager.Log("Querying all CATS..."); - var local_cats = _localDB.CATS.ToList(); + //LogManager.Log("Querying all CATS..."); + //var local_cats = _localDB.CATS.ToList(); LogManager.Log("Loading SQL Server database to memory..."); @@ -125,9 +125,9 @@ namespace Tango.Synchronization.Remote guids = remote_ids_packs.Select(x => x.CARTRIDGE_TYPE_GUID).ToList(); var remote_cartridges_types = _remoteDB.CARTRIDGE_TYPES.Where(x => guids.Contains(x.GUID)).ToList(); - LogManager.Log("Querying all remote CATS..."); - guids = remote_machines.Select(x => x.GUID).ToList(); - var remote_cats = _remoteDB.CATS.Where(x => guids.Contains(x.MACHINE_GUID)).ToList(); + //LogManager.Log("Querying all remote CATS..."); + //guids = remote_machines.Select(x => x.GUID).ToList(); + //var remote_cats = _remoteDB.CATS.Where(x => guids.Contains(x.MACHINE_GUID)).ToList(); foreach (var config in _remoteDB.SYNC_CONFIGURATIONS.Where(x => (SyncConfiguration)x.SYNC_TYPE == SyncConfiguration.OverwriteLocal)) @@ -166,8 +166,8 @@ namespace Tango.Synchronization.Remote LogManager.Log("Comparing users roles"); CompareCollections(remote_users_roles, local_users_roles, _remoteDB.USERS_ROLES, _localDB.USERS_ROLES); - LogManager.Log("Comparing cats"); - CompareCollections(remote_cats, local_cats, _remoteDB.CATS, _localDB.CATS); + //LogManager.Log("Comparing cats"); + //CompareCollections(remote_cats, local_cats, _remoteDB.CATS, _localDB.CATS); LogManager.Log("Comparison done!"); diff --git a/Software/Visual_Studio/Tango.UnitTesting/CodeGeneration_TST.cs b/Software/Visual_Studio/Tango.UnitTesting/CodeGeneration_TST.cs index a5f62b4a4..159fbc930 100644 --- a/Software/Visual_Studio/Tango.UnitTesting/CodeGeneration_TST.cs +++ b/Software/Visual_Studio/Tango.UnitTesting/CodeGeneration_TST.cs @@ -5,6 +5,7 @@ using Tango.DAL.Observables; using Tango.Settings; using System.Linq; using System.Collections.Generic; +using Tango.DBObservablesGenerator.CLI; namespace Tango.UnitTesting { diff --git a/Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj b/Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj index a8274bc5f..0130e3811 100644 --- a/Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj +++ b/Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj @@ -130,6 +130,10 @@ {7ada4e86-cad7-4968-a210-3a8a9e5153ab} Tango.Synchronization + + {ebb7cb9f-6af2-456b-a5dd-1b136b605d90} + Tango.DBObservablesGenerator.CLI + diff --git a/Software/Visual_Studio/Utilities/Tango.DBObservablesGenerator.CLI/ObservablesGenerator.cs b/Software/Visual_Studio/Utilities/Tango.DBObservablesGenerator.CLI/ObservablesGenerator.cs new file mode 100644 index 000000000..33f2d81ff --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.DBObservablesGenerator.CLI/ObservablesGenerator.cs @@ -0,0 +1,271 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Data.Entity; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using Tango.CodeGeneration; +using Tango.DAL.Remote.DB; +using Tango.Settings; +using Humanizer; +using Tango.DAL.Observables; + +namespace Tango.DBObservablesGenerator.CLI +{ + /// + /// Generates observable entities code files. + /// + public class ObservablesGenerator + { + /// + /// Generates C# code files. + /// + /// The target path. + public void GenerateCSharp(String targetPath) + { + //Generate Entities... + foreach (var table in typeof(RemoteDB).GetProperties().Where(x => typeof(IEnumerable).IsAssignableFrom(x.PropertyType))) + { + EntityCodeFile codeFile = new EntityCodeFile(ObservableEntity.DalNameToStandardName(table.Name).SingularizeMVC()) + { + EntityName = table.Name.SingularizeMVC(), + TableName = table.Name, + }; + + foreach (var field in table.PropertyType.GenericTypeArguments.First().GetProperties().Skip(3)) + { + EntityCodeFileField codeField = new EntityCodeFileField(); + codeField.FieldName = field.Name; + codeField.Name = ObservableEntity.DalNameToStandardName(field.Name); + codeField.Description = field.Name.Replace("_", " ").ToLower(); + + + if (field.PropertyType.IsGenericType) + { + codeField.Type = String.Format("ObservableCollection<{0}>", ObservableEntity.DalNameToStandardName(field.PropertyType.GenericTypeArguments.Single().Name).SingularizeMVC()); + codeField.Construct = true; + } + else + { + if (field.PropertyType.IsClass && field.PropertyType != typeof(String)) + { + codeField.Type = ObservableEntity.DalNameToStandardName(field.PropertyType.Name).SingularizeMVC(); + } + else + { + codeField.Type = field.PropertyType.Name; + } + } + codeFile.Fields.Add(codeField); + } + + String code = codeFile.GenerateCode(); + + String entitiesPath = Path.Combine(targetPath, "Entities"); + Directory.CreateDirectory(entitiesPath); + File.WriteAllText(Path.Combine(entitiesPath, codeFile.Name + ".cs"), code); + } + //Generate Entities... + + //Generate Enumerations... + using (RemoteDB db = new RemoteDB(SettingsManager.Default.DataBase.SQLServerAddress, false)) + { + foreach (var tableProp in db.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(x => x.PropertyType.IsGenericType)) + { + try + { + var a = tableProp.PropertyType.GenericTypeArguments.FirstOrDefault(); + var codeProp = tableProp.PropertyType.GenericTypeArguments.First().GetProperty("CODE"); + var nameProp = tableProp.PropertyType.GenericTypeArguments.First().GetProperty("NAME"); + var descriptionProp = tableProp.PropertyType.GenericTypeArguments.First().GetProperty("DESCRIPTION"); + + if (codeProp != null && nameProp != null) + { + EnumerationFile enumFile = new EnumerationFile(); + enumFile.Name = ObservableEntity.DalNameToStandardName(tableProp.Name); + + foreach (var row in tableProp.GetValue(db) as IEnumerable) + { + EnumerationField field = new EnumerationField(); + field.Name = nameProp.GetValue(row).ToString().Replace(" ", ""); + field.Value = (int)codeProp.GetValue(row); + + if (descriptionProp != null) + { + field.Description = descriptionProp.GetValue(row).ToString(); + } + else + { + field.Description = nameProp.GetValue(row).ToString(); + } + enumFile.Fields.Add(field); + } + + String enumerationsPath = Path.Combine(targetPath, "Enumerations"); + Directory.CreateDirectory(enumerationsPath); + String code = enumFile.GenerateCode(); + File.WriteAllText(Path.Combine(enumerationsPath, enumFile.Name + ".cs"), code); + } + } + catch { } + } + } + //Generate Enumerations... + + //Generate Observables Adapter Extensions... + ObservablesAdapterFile adapterFile = new ObservablesAdapterFile(); + adapterFile.Name = nameof(ObservablesEntitiesAdapter); + + foreach (var table in typeof(RemoteDB).GetProperties().Where(x => typeof(IEnumerable).IsAssignableFrom(x.PropertyType))) + { + adapterFile.Properties.Add(new Property() + { + Name = ObservableEntity.DalNameToStandardName(table.Name), + Type = String.Format("ObservableCollection<{0}>", ObservableEntity.DalNameToStandardName(table.PropertyType.GenericTypeArguments.Single().Name).SingularizeMVC()), + }); + } + + String adapterCode = adapterFile.GenerateCode(); + File.WriteAllText(Path.Combine(targetPath, "ObservablesEntitiesAdapterExtension.cs"), adapterCode); + //Generate Observables Adapter Extensions... + } + + /// + /// Generates Java code files. + /// + /// The target path. + public void GenerateJava(String targetPath) + { + //Generate Entities... + foreach (var table in typeof(RemoteDB).GetProperties().Where(x => typeof(IEnumerable).IsAssignableFrom(x.PropertyType))) + { + EntityCodeFileJava codeFile = new EntityCodeFileJava(ObservableEntity.DalNameToStandardName(table.Name).Singularize(false)) + { + EntityName = table.Name.Singularize(false), + TableName = table.Name, + }; + + + + foreach (var field in table.PropertyType.GenericTypeArguments.First().GetProperties().Skip(3).Where(x => !x.Name.Contains("GUID"))) + { + EntityCodeFileField codeField = new EntityCodeFileField(); + codeField.FieldName = field.Name; + codeField.Name = ObservableEntity.DalNameToStandardName(field.Name); + codeField.Description = FirstCharacterToLower(ObservableEntity.DalNameToStandardName(field.Name)); + + + if (field.PropertyType.IsGenericType) + { + continue; + } + else + { + if (field.PropertyType.IsClass && field.PropertyType != typeof(String) && field.PropertyType != typeof(Byte[])) + { + codeField.Type = ObservableEntity.DalNameToStandardName(field.PropertyType.Name).Singularize(false); + codeField.Construct = true; + } + else if (field.PropertyType == typeof(Byte[])) + { + codeField.Type = field.PropertyType.Name.ToLower(); + } + else + { + codeField.Type = field.PropertyType.Name == "Int32" ? "int" : field.PropertyType.Name; + } + } + codeFile.Fields.Add(codeField); + } + + codeFile.IndentResult = false; + String code = codeFile.GenerateCode(); + + String entitiesPath = Path.Combine(targetPath, "entities"); + Directory.CreateDirectory(entitiesPath); + File.WriteAllText(Path.Combine(entitiesPath, codeFile.Name + ".java"), code); + } + //Generate Entities... + + //Generate Enumerations... + using (RemoteDB db = new RemoteDB(SettingsManager.Default.DataBase.SQLServerAddress, false)) + { + foreach (var tableProp in db.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(x => x.PropertyType.IsGenericType)) + { + try + { + var a = tableProp.PropertyType.GenericTypeArguments.FirstOrDefault(); + var codeProp = tableProp.PropertyType.GenericTypeArguments.First().GetProperty("CODE"); + var nameProp = tableProp.PropertyType.GenericTypeArguments.First().GetProperty("NAME"); + var descriptionProp = tableProp.PropertyType.GenericTypeArguments.First().GetProperty("DESCRIPTION"); + + if (codeProp != null && nameProp != null) + { + EnumerationFileJava enumFile = new EnumerationFileJava(); + enumFile.Name = ObservableEntity.DalNameToStandardName(tableProp.Name); + + foreach (var row in tableProp.GetValue(db) as IEnumerable) + { + EnumerationField field = new EnumerationField(); + field.Name = nameProp.GetValue(row).ToString().Replace(" ", ""); + field.Value = (int)codeProp.GetValue(row); + + if (descriptionProp != null) + { + field.Description = descriptionProp.GetValue(row).ToString(); + } + else + { + field.Description = nameProp.GetValue(row).ToString(); + } + enumFile.Fields.Add(field); + } + + String enumerationsPath = Path.Combine(targetPath, "enumerations"); + Directory.CreateDirectory(enumerationsPath); + String code = enumFile.GenerateCode(); + File.WriteAllText(Path.Combine(enumerationsPath, enumFile.Name + ".java"), code); + } + } + catch { } + } + } + //Generate Enumerations... + + //Generate DAO... + TangoDAOJavaFile daoFile = new TangoDAOJavaFile(); + daoFile.Name = "TangoDAO"; + + foreach (var table in typeof(RemoteDB).GetProperties().Where(x => typeof(IEnumerable).IsAssignableFrom(x.PropertyType))) + { + daoFile.Entities.Add(new TangoDAOJavaFile.TangoDAOEntity() + { + Name = ObservableEntity.DalNameToStandardName(table.Name).Singularize(false), + TableName = ObservableEntity.DalNameToStandardName(table.Name), + }); + } + + String daoCode = daoFile.GenerateCode(); + String daoFolder = Path.Combine(targetPath, "dao"); + Directory.CreateDirectory(daoFolder); + File.WriteAllText(Path.Combine(daoFolder, "TangoDAO.java"), daoCode); + //Generate DAO... + } + + /// + /// Lower case the first character of a string. + /// + /// The string. + /// + private static string FirstCharacterToLower(string str) + { + if (String.IsNullOrEmpty(str) || Char.IsLower(str, 0)) + return str; + + return Char.ToLowerInvariant(str[0]) + str.Substring(1); + } + } +} diff --git a/Software/Visual_Studio/Utilities/Tango.DBObservablesGenerator.CLI/Program.cs b/Software/Visual_Studio/Utilities/Tango.DBObservablesGenerator.CLI/Program.cs index 1b9b4c96a..3ec883692 100644 --- a/Software/Visual_Studio/Utilities/Tango.DBObservablesGenerator.CLI/Program.cs +++ b/Software/Visual_Studio/Utilities/Tango.DBObservablesGenerator.CLI/Program.cs @@ -5,7 +5,6 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Tango.Core.Helpers; -using Tango.DAL.Observables; namespace Tango.DBObservablesGenerator.CLI { diff --git a/Software/Visual_Studio/Utilities/Tango.DBObservablesGenerator.CLI/Tango.DBObservablesGenerator.CLI.csproj b/Software/Visual_Studio/Utilities/Tango.DBObservablesGenerator.CLI/Tango.DBObservablesGenerator.CLI.csproj index f996d017d..fa573208b 100644 --- a/Software/Visual_Studio/Utilities/Tango.DBObservablesGenerator.CLI/Tango.DBObservablesGenerator.CLI.csproj +++ b/Software/Visual_Studio/Utilities/Tango.DBObservablesGenerator.CLI/Tango.DBObservablesGenerator.CLI.csproj @@ -38,6 +38,9 @@ ..\..\packages\EntityFramework.6.0.0\lib\net45\EntityFramework.SqlServer.dll + + ..\..\packages\Humanizer.Core.2.2.0\lib\netstandard1.0\Humanizer.dll + @@ -52,6 +55,7 @@ GlobalVersionInfo.cs + @@ -60,6 +64,10 @@ + + {caedae94-11ed-473c-888a-268a6d38cd20} + Tango.CodeGeneration + {a34ee0f0-649d-41c8-8489-b6f1cc6924ee} Tango.Core @@ -68,6 +76,14 @@ {0ecd6da8-7aa6-48d9-8b65-279d176ad9af} Tango.DAL.Observables + + {38197109-8610-4d3f-92b9-16d48df94d7c} + Tango.DAL.Remote + + + {d8f1ad85-526a-4f50-b6dc-d437af63d8d8} + Tango.Settings + \ No newline at end of file diff --git a/Software/Visual_Studio/Utilities/Tango.DBObservablesGenerator.CLI/packages.config b/Software/Visual_Studio/Utilities/Tango.DBObservablesGenerator.CLI/packages.config index 9256e1591..5148e8474 100644 --- a/Software/Visual_Studio/Utilities/Tango.DBObservablesGenerator.CLI/packages.config +++ b/Software/Visual_Studio/Utilities/Tango.DBObservablesGenerator.CLI/packages.config @@ -1,4 +1,46 @@  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file -- cgit v1.3.1