diff options
| author | Roy <roy.mail.net@gmail.com> | 2018-01-27 22:57:48 +0200 |
|---|---|---|
| committer | Roy <roy.mail.net@gmail.com> | 2018-01-27 22:57:48 +0200 |
| commit | bfc6aeabda4b320f9365f5eef4c8f1bcab9b24af (patch) | |
| tree | 9dc44c02e8f4128232f0c4c4ae87115221131605 /Software/Visual_Studio/Utilities | |
| parent | 20482140c124fd1d5caaffcc9b0dfe853b30dd6f (diff) | |
| download | Tango-bfc6aeabda4b320f9365f5eef4c8f1bcab9b24af.tar.gz Tango-bfc6aeabda4b320f9365f5eef4c8f1bcab9b24af.zip | |
Added IDS_PACK_FORMULA.
Added necessary login to machine designer & db module.
Started working on job segments.
Diffstat (limited to 'Software/Visual_Studio/Utilities')
2 files changed, 39 insertions, 23 deletions
diff --git a/Software/Visual_Studio/Utilities/Tango.DBObservablesGenerator.CLI/ObservablesGenerator.cs b/Software/Visual_Studio/Utilities/Tango.DBObservablesGenerator.CLI/ObservablesGenerator.cs index af0e1a08d..3973e8ad5 100644 --- a/Software/Visual_Studio/Utilities/Tango.DBObservablesGenerator.CLI/ObservablesGenerator.cs +++ b/Software/Visual_Studio/Utilities/Tango.DBObservablesGenerator.CLI/ObservablesGenerator.cs @@ -11,7 +11,7 @@ using Tango.CodeGeneration; using Tango.DAL.Remote.DB; using Tango.Settings; using Humanizer; -using Tango.DAL.Observables; +using System.Globalization; namespace Tango.DBObservablesGenerator.CLI { @@ -29,32 +29,32 @@ namespace Tango.DBObservablesGenerator.CLI //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()) + EntityCodeFile codeFile = new EntityCodeFile(DalNameToStandardName(table.Name).SingularizeMVC()) { EntityName = table.Name.SingularizeMVC(), TableName = table.Name, }; - List<String> foreignKeys = table.PropertyType.GenericTypeArguments.First().GetProperties().Skip(3).Where(x => x.PropertyType == typeof(String)).Where(x => x.Name.ToLower().Contains("guid")).Select(x => ObservableEntity.DalNameToStandardName(x.Name).SingularizeMVC().Replace("Guid", "")).ToList(); + List<String> foreignKeys = table.PropertyType.GenericTypeArguments.First().GetProperties().Skip(3).Where(x => x.PropertyType == typeof(String)).Where(x => x.Name.ToLower().Contains("guid")).Select(x => DalNameToStandardName(x.Name).SingularizeMVC().Replace("Guid", "")).ToList(); 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.Name = 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.Type = String.Format("ObservableCollection<{0}>", DalNameToStandardName(field.PropertyType.GenericTypeArguments.Single().Name).SingularizeMVC()); codeField.Construct = true; } else { if (field.PropertyType.IsClass && field.PropertyType != typeof(String) && field.PropertyType != typeof(byte[])) { - codeField.Type = ObservableEntity.DalNameToStandardName(field.PropertyType.Name).SingularizeMVC(); + codeField.Type = DalNameToStandardName(field.PropertyType.Name).SingularizeMVC(); codeField.Name = codeField.Type; var fk = foreignKeys.SingleOrDefault(x => x.Contains(codeField.Name)); @@ -103,7 +103,7 @@ namespace Tango.DBObservablesGenerator.CLI if (codeProp != null && nameProp != null) { EnumerationFile enumFile = new EnumerationFile(); - enumFile.Name = ObservableEntity.DalNameToStandardName(tableProp.Name); + enumFile.Name = DalNameToStandardName(tableProp.Name); foreach (var row in tableProp.GetValue(db) as IEnumerable) { @@ -135,14 +135,14 @@ namespace Tango.DBObservablesGenerator.CLI //Generate Observables Adapter Extensions... ObservablesAdapterFile adapterFile = new ObservablesAdapterFile(); - adapterFile.Name = nameof(ObservablesEntitiesAdapter); + adapterFile.Name = "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()), + Name = DalNameToStandardName(table.Name), + Type = String.Format("ObservableCollection<{0}>", DalNameToStandardName(table.PropertyType.GenericTypeArguments.Single().Name).SingularizeMVC()), }); } @@ -158,8 +158,8 @@ namespace Tango.DBObservablesGenerator.CLI { contextFile.Properties.Add(new Property() { - Name = ObservableEntity.DalNameToStandardName(table.Name), - Type = String.Format("DbSet<{0}>", ObservableEntity.DalNameToStandardName(table.PropertyType.GenericTypeArguments.Single().Name).SingularizeMVC()), + Name = DalNameToStandardName(table.Name), + Type = String.Format("DbSet<{0}>", DalNameToStandardName(table.PropertyType.GenericTypeArguments.Single().Name).SingularizeMVC()), }); } String contextCode = contextFile.GenerateCode(); @@ -176,7 +176,7 @@ namespace Tango.DBObservablesGenerator.CLI //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)) + EntityCodeFileJava codeFile = new EntityCodeFileJava(DalNameToStandardName(table.Name).Singularize(false)) { EntityName = table.Name.Singularize(false), TableName = table.Name, @@ -188,8 +188,8 @@ namespace Tango.DBObservablesGenerator.CLI { EntityCodeFileField codeField = new EntityCodeFileField(); codeField.FieldName = field.Name; - codeField.Name = ObservableEntity.DalNameToStandardName(field.Name); - codeField.Description = FirstCharacterToLower(ObservableEntity.DalNameToStandardName(field.Name)); + codeField.Name = DalNameToStandardName(field.Name); + codeField.Description = FirstCharacterToLower(DalNameToStandardName(field.Name)); if (field.PropertyType.IsGenericType) @@ -200,7 +200,7 @@ namespace Tango.DBObservablesGenerator.CLI { if (field.PropertyType.IsClass && field.PropertyType != typeof(String) && field.PropertyType != typeof(Byte[])) { - codeField.Type = ObservableEntity.DalNameToStandardName(field.PropertyType.Name).Singularize(false); + codeField.Type = DalNameToStandardName(field.PropertyType.Name).Singularize(false); codeField.Construct = true; } else if (field.PropertyType == typeof(Byte[])) @@ -239,7 +239,7 @@ namespace Tango.DBObservablesGenerator.CLI if (codeProp != null && nameProp != null) { EnumerationFileJava enumFile = new EnumerationFileJava(); - enumFile.Name = ObservableEntity.DalNameToStandardName(tableProp.Name); + enumFile.Name = DalNameToStandardName(tableProp.Name); foreach (var row in tableProp.GetValue(db) as IEnumerable) { @@ -277,8 +277,8 @@ namespace Tango.DBObservablesGenerator.CLI { daoFile.Entities.Add(new TangoDAOJavaFile.TangoDAOEntity() { - Name = ObservableEntity.DalNameToStandardName(table.Name).Singularize(false), - TableName = ObservableEntity.DalNameToStandardName(table.Name), + Name = DalNameToStandardName(table.Name).Singularize(false), + TableName = DalNameToStandardName(table.Name), }); } @@ -301,5 +301,25 @@ namespace Tango.DBObservablesGenerator.CLI return Char.ToLowerInvariant(str[0]) + str.Substring(1); } + + /// <summary> + /// Converts the specified database conventional name to the observables conventional name. + /// </summary> + /// <param name="dalName">DAL name.</param> + /// <returns></returns> + private static String DalNameToStandardName(String dalName) + { + return String.Join("", dalName.Split('_').Select(x => ToTitleCase(x))); + } + + /// <summary> + /// Converts the specified text to title case. + /// </summary> + /// <param name="text">The text.</param> + /// <returns></returns> + private static string ToTitleCase(string text) + { + return CultureInfo.CurrentCulture.TextInfo.ToTitleCase(text.ToLower()); + } } } 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 fa573208b..87baf3a3f 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 @@ -72,10 +72,6 @@ <Project>{a34ee0f0-649d-41c8-8489-b6f1cc6924ee}</Project> <Name>Tango.Core</Name> </ProjectReference> - <ProjectReference Include="..\..\Tango.DAL.Observables\Tango.DAL.Observables.csproj"> - <Project>{0ecd6da8-7aa6-48d9-8b65-279d176ad9af}</Project> - <Name>Tango.DAL.Observables</Name> - </ProjectReference> <ProjectReference Include="..\..\Tango.DAL.Remote\Tango.DAL.Remote.csproj"> <Project>{38197109-8610-4d3f-92b9-16d48df94d7c}</Project> <Name>Tango.DAL.Remote</Name> |
