diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-12-28 00:55:44 +0200 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-12-28 00:55:44 +0200 |
| commit | c2064e58fd1923bf820e14afcd014036299336b9 (patch) | |
| tree | 69bb017eeccaac56954754870ff7eb62169a95b5 /Software/Visual_Studio | |
| parent | 7a0aa322afe6599f25d356c7f31403ef96cddde1 (diff) | |
| parent | 78e2602610d1712bf7dfac08d082a8467bcd0210 (diff) | |
| download | Tango-c2064e58fd1923bf820e14afcd014036299336b9.tar.gz Tango-c2064e58fd1923bf820e14afcd014036299336b9.zip | |
Merged csv to job importer branch.
Diffstat (limited to 'Software/Visual_Studio')
9 files changed, 668 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Tango.BL/Helpers/SegmentsCsvHelper.cs b/Software/Visual_Studio/Tango.BL/Helpers/SegmentsCsvHelper.cs new file mode 100644 index 000000000..636f84fdf --- /dev/null +++ b/Software/Visual_Studio/Tango.BL/Helpers/SegmentsCsvHelper.cs @@ -0,0 +1,444 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Builders; +using Tango.BL.DTO; +using Tango.BL.Entities; +using Tango.BL.Enumerations; +using Tango.CSV; +using Tango.PMR.Exports; + +namespace Tango.BL.Helpers +{ + public static class SegmentsCsvHelper + { + public class SegmentCsvModel + { + + public String Index { get; set; } + + public String ColorSpace { get; set; } + + public String Length { get; set; } + + public String CatalogName1 { get; set; } + public String CatalogItem1 { get; set; } + + public String Red1 { get; set; } + public String Green1 { get; set; } + public String Blue1 { get; set; } + + public String L1 { get; set; } + public String A1 { get; set; } + public String B1 { get; set; } + + + + public String Cyan1 { get; set; } + public String Magenta1 { get; set; } + public String Yellow1 { get; set; } + public String Black1 { get; set; } + + public String CatalogName2 { get; set; } + public String CatalogItem2 { get; set; } + + public String Red2 { get; set; } + public String Green2 { get; set; } + public String Blue2 { get; set; } + + public String L2 { get; set; } + public String A2 { get; set; } + public String B2 { get; set; } + + + public String Cyan2{ get; set; } + public String Magenta2 { get; set; } + public String Yellow2 { get; set; } + public String Black2 { get; set; } + + public bool IsRgb2NullOrEqual() + { + if (String.IsNullOrWhiteSpace(Red2) || String.IsNullOrWhiteSpace(Green2) || String.IsNullOrWhiteSpace(Blue2)) return true; + if (Red1 == Red2 && Green1 == Green2 && Blue1 == Blue2) return true; + return false; + } + + internal bool IsVolumeNullOrEqual() + { + if (String.IsNullOrWhiteSpace(Cyan2) || String.IsNullOrWhiteSpace(Magenta2 ) || String.IsNullOrWhiteSpace(Yellow2) || String.IsNullOrWhiteSpace(Black2)) return true; + if (Cyan1 == Cyan2 && Magenta1 == Magenta2 && Yellow1 == Yellow2 && Black1 == Black2) return true; + return false; + } + + internal bool IsCatalogNameNullOrEqual() + { + if (String.IsNullOrWhiteSpace(CatalogName2) || String.IsNullOrEmpty(CatalogItem2)) return true; + if (CatalogName1 == CatalogName2 && CatalogItem1 == CatalogItem2) return true; + return false; + } + + internal bool IsLab2NullOrEqual() + { + if (String.IsNullOrWhiteSpace(L2) || String.IsNullOrWhiteSpace(A2) || String.IsNullOrWhiteSpace(B2)) return true; + if (L1 == L2 && A1 == A2 && B1 == B2) return true; + return false; + } + } + + public static Task<List<Segment>> FromFile(String filePath, Machine machine, ObservablesContext context) + { + return Task.Factory.StartNew(() => + { + List<SegmentCsvModel> rows = CsvFile.Read<SegmentCsvModel>(new CsvSource(filePath)).ToList(); + + List<Segment> segments = new List<Segment>(); + + var catalogs = new CatalogsCollectionBuilder(context).SetAll().WithGroups().WithItems().BuildList(); + var colorSpaces = context.ColorSpaces.ToList(); + + if (machine.Configuration == null || machine.Configuration.IdsPacks == null || machine.Configuration.IdsPacks.Count == 0) + { + machine = new MachineBuilder(context).Set(machine.Guid).WithConfiguration().Build(); + } + + var idsPacks = machine.Configuration.NoneEmptyIdsPacks.ToList(); + + var cyanIdsPack = idsPacks.FirstOrDefault(x => x.LiquidType.Type == LiquidTypes.Cyan); + var magentaIdsPack = idsPacks.FirstOrDefault(x => x.LiquidType.Type == LiquidTypes.Magenta); + var yellowIdsPack = idsPacks.FirstOrDefault(x => x.LiquidType.Type == LiquidTypes.Yellow); + var blackIdsPack = idsPacks.FirstOrDefault(x => x.LiquidType.Type == LiquidTypes.Black); + + int lineCount = 0; + + foreach (var row in rows) + { + lineCount++; + + try + { + Segment segment = new Segment(); + segment.Length = double.Parse(row.Length); + segment.SegmentIndex = int.Parse(row.Index); + + ColorSpace colorSpace = colorSpaces.SingleOrDefault(x => x.Name == row.ColorSpace); + + if (colorSpace == null) throw new InvalidOperationException($"Color space '{row.ColorSpace}' not found on line '{lineCount}'."); + + BrushStop stop1 = new BrushStop(); + stop1.ColorSpace = colorSpace; + stop1.OffsetPercent = 0; + segment.BrushStops.Add(stop1); + + if (colorSpace.Space == ColorSpaces.RGB) + { + int red1; + if(!int.TryParse(row.Red1, out red1)) + { + throw new InvalidOperationException($"Value Red1 '{row.Red1}' should be a number on line'{lineCount}'."); + } + stop1.Red = red1; + if (stop1.Red < 0 || stop1.Red > 255) throw new InvalidOperationException($"Value red1 '{row.Red1}' is out of range on line '{lineCount}'."); + + int green1; + if (!int.TryParse(row.Green1, out green1)) + { + throw new InvalidOperationException($"Value Green1 '{row.Green1}' should be a number on line'{lineCount}'."); + } + stop1.Green = green1; + if (stop1.Green < 0 || stop1.Green > 255) throw new InvalidOperationException($"Value green1 '{row.Green1}' is out of range on line '{lineCount}'."); + + int blue1; + if (!int.TryParse(row.Blue1, out blue1)) + { + throw new InvalidOperationException($"Value Blue1 '{row.Blue1}' should be a number on line'{lineCount}'."); + } + stop1.Blue = blue1; + if (stop1.Blue < 0 || stop1.Blue > 255) throw new InvalidOperationException($"Value blue1 '{row.Blue1}' is out of range on line '{lineCount}'."); + + if (!row.IsRgb2NullOrEqual()) + { + BrushStop stop2 = new BrushStop(); + stop2.ColorSpace = stop1.ColorSpace; + stop2.OffsetPercent = 100; + + int red2; + if (!int.TryParse(row.Red2, out red2)) + { + throw new InvalidOperationException($"Value Red2 '{row.Red2}' should be a number on line'{lineCount}'."); + } + stop2.Red = red2; + if (stop2.Red < 0 || stop2.Red > 255) throw new InvalidOperationException($"Value red2 '{row.Red2}' is out of range on line '{lineCount}'."); + + int green2; + if (!int.TryParse(row.Green2, out green2)) + { + throw new InvalidOperationException($"Value Green2 '{row.Green2}' should be a number on line'{lineCount}'."); + } + stop2.Green = green2; + if (stop2.Green < 0 || stop2.Green > 255) throw new InvalidOperationException($"Value green2 '{row.Green2}' is out of range on line '{lineCount}'."); + + int blue2; + if (!int.TryParse(row.Blue2, out blue2)) + { + throw new InvalidOperationException($"Value Blue2 '{row.Blue2}' should be a number on line'{lineCount}'."); + } + stop2.Blue = blue2; + if (stop2.Blue < 0 || stop2.Blue > 255) throw new InvalidOperationException($"Value blue2 '{row.Blue2}' is out of range on line '{lineCount}'."); + + segment.BrushStops.Add(stop2); + } + } + else if (colorSpace.Space == ColorSpaces.Volume) + { + double cyan1; + if (!double.TryParse(row.Cyan1, out cyan1)) + { + throw new InvalidOperationException($"Value Cyan1 '{row.Cyan1}' should be a number on line'{lineCount}.'!"); + } + if (cyan1 < 0 || cyan1 > 100) throw new InvalidOperationException($"Value Cyan1 '{row.Cyan1}' is out of range on line '{lineCount}.'!"); + stop1.SetVolume(cyanIdsPack.PackIndex, cyan1); + + double magenta1; + if (!double.TryParse(row.Magenta1, out magenta1)) + { + throw new InvalidOperationException($"Value Magenta1 '{row.Magenta1}' should be a number on line'{lineCount}.'!"); + } + if (magenta1 < 0 || magenta1 > 100) throw new InvalidOperationException($"Value Magenta1 '{row.Magenta1}' is out of range on line '{lineCount}.'!"); + + stop1.SetVolume(magentaIdsPack.PackIndex, magenta1); + + double yellow1 = double.Parse(row.Yellow1); + if (!double.TryParse(row.Yellow1, out yellow1)) + { + throw new InvalidOperationException($"Value Yellow1 '{row.Yellow1}' should be a number on line'{lineCount}.'!"); + } + if (yellow1 < 0 || yellow1 > 100) throw new InvalidOperationException($"Value Yellow1 '{row.Yellow1}' is out of range on line '{lineCount}.'!"); + + stop1.SetVolume(yellowIdsPack.PackIndex, yellow1); + + double black1 = double.Parse(row.Black1); + if (!double.TryParse(row.Black1, out black1)) + { + throw new InvalidOperationException($"Value Black1 '{row.Black1}' should be a number on line'{lineCount}.'!"); + } + if (black1 < 0 || black1 > 100) throw new InvalidOperationException($"Value Black1 '{row.Black1}' is out of range on line '{lineCount}.'!"); + + stop1.SetVolume(blackIdsPack.PackIndex, black1); + + if (!row.IsVolumeNullOrEqual()) + { + BrushStop stop2 = new BrushStop(); + stop2.ColorSpace = stop1.ColorSpace; + stop2.OffsetPercent = 100; + + double cyan2; + if (!double.TryParse(row.Cyan2, out cyan2)) + { + throw new InvalidOperationException($"Value Cyan2 '{row.Cyan2}' should be a number on line'{lineCount}.'!"); + } + if (cyan2 < 0 || cyan2 > 100) throw new InvalidOperationException($"Value Cyan2 '{row.Cyan2}' is out of range on line '{lineCount}.'!"); + stop2.SetVolume(cyanIdsPack.PackIndex, cyan2); + + double magenta2; + if (!double.TryParse(row.Magenta2, out magenta2)) + { + throw new InvalidOperationException($"Value Magenta2 '{row.Magenta2}' should be a number on line'{lineCount}.'!"); + } + if (magenta2 < 0 || magenta2 > 100) throw new InvalidOperationException($"Value Magenta2 '{row.Magenta2}' is out of range on line '{lineCount}.'!"); + + stop2.SetVolume(magentaIdsPack.PackIndex, magenta2); + + double yellow2 = double.Parse(row.Yellow2); + if (!double.TryParse(row.Yellow2, out yellow2)) + { + throw new InvalidOperationException($"Value Yellow2 '{row.Yellow2}' should be a number on line'{lineCount}.'!"); + } + if (yellow2 < 0 || yellow2 > 100) throw new InvalidOperationException($"Value Yellow2 '{row.Yellow2}' is out of range on line '{lineCount}.'!"); + + stop2.SetVolume(yellowIdsPack.PackIndex, yellow2); + + double black2 = double.Parse(row.Black2); + if (!double.TryParse(row.Black2, out black2)) + { + throw new InvalidOperationException($"Value Black2 '{row.Black2}' should be a number on line'{lineCount}.'!"); + } + if (black2 < 0 || black2 > 100) throw new InvalidOperationException($"Value Black2 '{row.Black2}' is out of range on line '{lineCount}.'!"); + + stop2.SetVolume(blackIdsPack.PackIndex, black2); + + segment.BrushStops.Add(stop2); + } + } + else if (colorSpace.Space == ColorSpaces.Catalog) + { + var catalog = catalogs.FirstOrDefault(x => x.Name == row.CatalogName1); + if (catalog == null) + { + throw new InvalidOperationException($"Catalog '{row.CatalogName1}' not found on line '{lineCount}'."); + } + + var item = catalog.ColorCatalogsGroups.SelectMany(x => x.ColorCatalogsItems).FirstOrDefault(x => x.Name == row.CatalogItem1); + if (item == null) + { + throw new InvalidOperationException($"Catalog item '{row.CatalogItem1}' not found on catalog '{catalog.Name}' on line '{lineCount}'."); + } + + stop1.ColorCatalog = catalog; + stop1.ColorCatalogsItem = item; + if (!row.IsCatalogNameNullOrEqual()) + { + var catalog2 = catalogs.FirstOrDefault(x => x.Name == row.CatalogName2); + if (catalog == null) + { + throw new InvalidOperationException($"Catalog name: '{row.CatalogName2}' not found on line '{lineCount}'."); + } + + var item2 = catalog.ColorCatalogsGroups.SelectMany(x => x.ColorCatalogsItems).FirstOrDefault(x => x.Name == row.CatalogItem2); + if (item == null) + { + throw new InvalidOperationException($"Catalog item: '{row.CatalogItem2}' not found in ColorCatalogsGroups on line '{lineCount}'."); + } + BrushStop stop2 = new BrushStop(); + stop2.ColorCatalog = catalog2; + stop2.ColorCatalogsItem = item2; + segment.BrushStops.Add(stop2); + } + } + else if (colorSpace.Space == ColorSpaces.LAB) + { + double number; + if(!double.TryParse(row.L1, out number)) + throw new InvalidOperationException($"Value L1 '{row.L1}' should be a number on line'{lineCount}'."); + stop1.L = number; + if (stop1.L < 0 || stop1.L > 100) throw new InvalidOperationException($"Value L1 '{row.L1}' is out of range on line '{lineCount}'."); + + if (!double.TryParse(row.A1, out number)) + throw new InvalidOperationException($"Value A1 '{row.A1}' should be a number on line'{lineCount}'."); + stop1.A = number; + if (stop1.A < -128 || stop1.A > 128) throw new InvalidOperationException($"Value A1 '{row.A1}' is out of range on line '{lineCount}'."); + + if (!double.TryParse(row.B1, out number)) + throw new InvalidOperationException($"Value B1 '{row.B1}' should be a number on line'{lineCount}'."); + stop1.B = number; + if (stop1.B < -128 || stop1.B > 128) throw new InvalidOperationException($"Value B1 '{row.B1}' is out of range on line '{lineCount}'."); + if (!row.IsLab2NullOrEqual()) + { + BrushStop stop2 = new BrushStop(); + stop2.ColorSpace = stop1.ColorSpace; + stop2.OffsetPercent = 100; + + double l2; + if (!double.TryParse(row.L2, out l2)) + throw new InvalidOperationException($"Value L2 '{row.L2}' should be a number on line'{lineCount}'."); + stop2.L =l2; + if (stop2.L < 0 || stop2.L > 100) throw new InvalidOperationException($"Value L2 '{row.L2}' is out of range on line '{lineCount}'."); + + double a2; + if (!double.TryParse(row.A2, out a2)) + throw new InvalidOperationException($"Value A2 '{row.A2}' should be a number on line'{lineCount}'."); + stop2.A = a2; + if (stop2.A < -128 || stop2.A > 128) throw new InvalidOperationException($"Value A2 '{row.A2}' is out of range on line '{lineCount}'."); + + double b2; + if (!double.TryParse(row.B2, out b2)) + throw new InvalidOperationException($"Value B2 '{row.B2}' should be a number on line'{lineCount}'."); + stop2.B = b2; + if (stop2.B < -128 || stop2.B > 128) throw new InvalidOperationException($"Value B2 '{row.B2}' is out of range on line '{lineCount}'."); + + segment.BrushStops.Add(stop2); + } + } + segments.Add(segment); + } + catch (Exception ex) + { + throw new InvalidOperationException($"Error parsing file on line {lineCount}.\n{ex.FlattenMessage()}"); + } + } + + return segments; + }); + } + + static async void ToFile(String filePath, List<Segment> segments) + { + await Task.Factory.StartNew(() => + { + SegmentCsvModel model = new SegmentCsvModel(); + List<string> columnNames = model.GetType().GetProperties().Select(x => x.Name).ToList(); + CsvFile<SegmentCsvModel> csvFile = new CsvFile<SegmentCsvModel>(new CsvDestination(filePath), new CsvDefinition() { + Columns = columnNames + }); + foreach(var segment in segments) + { + SegmentCsvModel csvmodel = new SegmentCsvModel(); + csvmodel.Index = segment.SegmentIndex.ToString(); + csvmodel.Length = segment.Length.ToString(); + if(segment.BrushStops.Count > 2 ) throw new InvalidOperationException($"Cannot save more than two brush stops!"); + //save first brush stop + if (segment.BrushStops.Count > 0) + { + var brushStop1 = segment.BrushStops[0]; + csvmodel.ColorSpace = brushStop1.ColorSpace.Name; + if (csvmodel.ColorSpace == ColorSpaces.RGB.ToDescription()) + { + csvmodel.Red1 = brushStop1.Red.ToString(); + csvmodel.Green1 = brushStop1.Green.ToString(); + csvmodel.Blue1 = brushStop1.Blue.ToString(); + } + else if (csvmodel.ColorSpace == ColorSpaces.Volume.ToDescription()) + { + csvmodel.Cyan1 = brushStop1.GetVolume(LiquidTypes.Cyan).ToString(); + csvmodel.Magenta1 = brushStop1.GetVolume(LiquidTypes.Magenta).ToString(); + csvmodel.Yellow1 = brushStop1.GetVolume(LiquidTypes.Yellow).ToString(); + csvmodel.Black1 = brushStop1.GetVolume(LiquidTypes.Black).ToString(); + } + else if (csvmodel.ColorSpace == ColorSpaces.Catalog.ToDescription()) + { + csvmodel.CatalogName1 = brushStop1.ColorCatalog.Name; + csvmodel.CatalogItem1 = brushStop1.ColorCatalogsItem.Name; + } + else if (csvmodel.ColorSpace == ColorSpaces.LAB.ToDescription()) + { + csvmodel.L1 = brushStop1.L.ToString(); + csvmodel.A1 = brushStop1.A.ToString(); + csvmodel.B1 = brushStop1.B.ToString(); + } + } + if (segment.BrushStops.Count > 1) + { + var brushStop2 = segment.BrushStops[1]; + if (csvmodel.ColorSpace == ColorSpaces.RGB.ToDescription()) + { + csvmodel.Red2 = brushStop2.Red.ToString(); + csvmodel.Green2 = brushStop2.Green.ToString(); + csvmodel.Blue2 = brushStop2.Blue.ToString(); + } + else if (csvmodel.ColorSpace == ColorSpaces.Volume.ToDescription()) + { + csvmodel.Cyan2 = brushStop2.GetVolume(LiquidTypes.Cyan).ToString(); + csvmodel.Magenta2 = brushStop2.GetVolume(LiquidTypes.Magenta).ToString(); + csvmodel.Yellow2 = brushStop2.GetVolume(LiquidTypes.Yellow).ToString(); + csvmodel.Black2 = brushStop2.GetVolume(LiquidTypes.Black).ToString(); + } + else if (csvmodel.ColorSpace == ColorSpaces.Catalog.ToDescription()) + { + csvmodel.CatalogName2 = brushStop2.ColorCatalog.Name; + csvmodel.CatalogItem2 = brushStop2.ColorCatalogsItem.Name; + } + else if (csvmodel.ColorSpace == ColorSpaces.LAB.ToDescription()) + { + csvmodel.L2 = brushStop2.L.ToString(); + csvmodel.A2 = brushStop2.A.ToString(); + csvmodel.B2 = brushStop2.B.ToString(); + } + } + + csvFile.Append(csvmodel); + } + }); + } + } +} diff --git a/Software/Visual_Studio/Tango.BL/Tango.BL.csproj b/Software/Visual_Studio/Tango.BL/Tango.BL.csproj index 0fbf6c5ab..32b8d3c9b 100644 --- a/Software/Visual_Studio/Tango.BL/Tango.BL.csproj +++ b/Software/Visual_Studio/Tango.BL/Tango.BL.csproj @@ -428,6 +428,7 @@ <Compile Include="Enumerations\TangoUpdateStatuses.cs" /> <Compile Include="Enumerations\RmlQualifications.cs" /> <Compile Include="ExtensionMethods\ColorCatalogItemsExtensions.cs" /> + <Compile Include="Helpers\SegmentsCsvHelper.cs" /> <Compile Include="IObservableEntityDTO.cs" /> <Compile Include="ObservableDTOPropertyAttribute.cs" /> <Compile Include="ObservableEntityDTO.cs" /> @@ -610,6 +611,10 @@ <Project>{a34ee0f0-649d-41c8-8489-b6f1cc6924ee}</Project> <Name>Tango.Core</Name> </ProjectReference> + <ProjectReference Include="..\Tango.CSV\Tango.CSV.csproj"> + <Project>{58e8825f-0c96-449c-b320-1e82b0aa876b}</Project> + <Name>Tango.CSV</Name> + </ProjectReference> <ProjectReference Include="..\Tango.DAL.Remote\Tango.DAL.Remote.csproj"> <Project>{38197109-8610-4d3f-92b9-16d48df94d7c}</Project> <Name>Tango.DAL.Remote</Name> diff --git a/Software/Visual_Studio/Tango.sln b/Software/Visual_Studio/Tango.sln index 5ace654c3..655c00e56 100644 --- a/Software/Visual_Studio/Tango.sln +++ b/Software/Visual_Studio/Tango.sln @@ -459,6 +459,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Notifications.Wpf", "StubsU EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.StubsUtils.ProcedureClient.CLI", "StubsUtils\Tango.StubsUtils.ProcedureClient.CLI\Tango.StubsUtils.ProcedureClient.CLI.csproj", "{8F0BCFC8-AF0F-40D3-882A-902CD221A6DE}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.CsvToJobTester.CLI", "Utilities\Tango.CsvToJobTester.CLI\Tango.CsvToJobTester.CLI.csproj", "{4747A2DE-F419-41B1-95A7-E9FBB4EA0B3B}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -4354,6 +4356,26 @@ Global {8F0BCFC8-AF0F-40D3-882A-902CD221A6DE}.Release|x64.Build.0 = Release|Any CPU {8F0BCFC8-AF0F-40D3-882A-902CD221A6DE}.Release|x86.ActiveCfg = Release|Any CPU {8F0BCFC8-AF0F-40D3-882A-902CD221A6DE}.Release|x86.Build.0 = Release|Any CPU + {4747A2DE-F419-41B1-95A7-E9FBB4EA0B3B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4747A2DE-F419-41B1-95A7-E9FBB4EA0B3B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4747A2DE-F419-41B1-95A7-E9FBB4EA0B3B}.Debug|ARM.ActiveCfg = Debug|Any CPU + {4747A2DE-F419-41B1-95A7-E9FBB4EA0B3B}.Debug|ARM.Build.0 = Debug|Any CPU + {4747A2DE-F419-41B1-95A7-E9FBB4EA0B3B}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {4747A2DE-F419-41B1-95A7-E9FBB4EA0B3B}.Debug|ARM64.Build.0 = Debug|Any CPU + {4747A2DE-F419-41B1-95A7-E9FBB4EA0B3B}.Debug|x64.ActiveCfg = Debug|Any CPU + {4747A2DE-F419-41B1-95A7-E9FBB4EA0B3B}.Debug|x64.Build.0 = Debug|Any CPU + {4747A2DE-F419-41B1-95A7-E9FBB4EA0B3B}.Debug|x86.ActiveCfg = Debug|Any CPU + {4747A2DE-F419-41B1-95A7-E9FBB4EA0B3B}.Debug|x86.Build.0 = Debug|Any CPU + {4747A2DE-F419-41B1-95A7-E9FBB4EA0B3B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4747A2DE-F419-41B1-95A7-E9FBB4EA0B3B}.Release|Any CPU.Build.0 = Release|Any CPU + {4747A2DE-F419-41B1-95A7-E9FBB4EA0B3B}.Release|ARM.ActiveCfg = Release|Any CPU + {4747A2DE-F419-41B1-95A7-E9FBB4EA0B3B}.Release|ARM.Build.0 = Release|Any CPU + {4747A2DE-F419-41B1-95A7-E9FBB4EA0B3B}.Release|ARM64.ActiveCfg = Release|Any CPU + {4747A2DE-F419-41B1-95A7-E9FBB4EA0B3B}.Release|ARM64.Build.0 = Release|Any CPU + {4747A2DE-F419-41B1-95A7-E9FBB4EA0B3B}.Release|x64.ActiveCfg = Release|Any CPU + {4747A2DE-F419-41B1-95A7-E9FBB4EA0B3B}.Release|x64.Build.0 = Release|Any CPU + {4747A2DE-F419-41B1-95A7-E9FBB4EA0B3B}.Release|x86.ActiveCfg = Release|Any CPU + {4747A2DE-F419-41B1-95A7-E9FBB4EA0B3B}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -4515,6 +4537,7 @@ Global {F1B727F5-ADF5-4A81-A740-7E64E48B29D4} = {4A8BD6EC-41CF-46A9-B2CD-9D0DF6465963} {5C9A4F46-263D-4C23-B361-F09E14BB109E} = {4A8BD6EC-41CF-46A9-B2CD-9D0DF6465963} {8F0BCFC8-AF0F-40D3-882A-902CD221A6DE} = {4A8BD6EC-41CF-46A9-B2CD-9D0DF6465963} + {4747A2DE-F419-41B1-95A7-E9FBB4EA0B3B} = {5F6BBAA8-EAD0-4B18-97E5-55B4F56DD760} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {7986F7F4-A86A-4994-B1B6-0988D7F057B6} diff --git a/Software/Visual_Studio/Utilities/Tango.CsvToJobTester.CLI/App.config b/Software/Visual_Studio/Utilities/Tango.CsvToJobTester.CLI/App.config new file mode 100644 index 000000000..4ef5218a0 --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.CsvToJobTester.CLI/App.config @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="utf-8"?> +<configuration> + <configSections> + <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --> + <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> + </configSections> + <startup> + <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" /> + </startup> + <entityFramework> + <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" /> + <providers> + <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /> + </providers> + </entityFramework> + <runtime> + <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> + <dependentAssembly> + <assemblyIdentity name="Microsoft.IdentityModel.Clients.ActiveDirectory" publicKeyToken="31bf3856ad364e35" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-5.0.5.0" newVersion="5.0.5.0" /> + </dependentAssembly> + </assemblyBinding> + </runtime> +</configuration>
\ No newline at end of file diff --git a/Software/Visual_Studio/Utilities/Tango.CsvToJobTester.CLI/Program.cs b/Software/Visual_Studio/Utilities/Tango.CsvToJobTester.CLI/Program.cs new file mode 100644 index 000000000..82971cc1a --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.CsvToJobTester.CLI/Program.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; +using Tango.BL; +using Tango.BL.Builders; +using Tango.BL.Helpers; +using Tango.BL.DTO; +using Tango.Core.ExtensionMethods; +using Tango.Core; + +namespace Tango.CsvToJobTester.CLI +{ + public class Program + { + + static void Main(string[] args) + { + String file = "testCSV.csv"; + + DataSource _dataSource = new DataSource() + { + Address = "localhost\\SQLPPC", + Catalog = "Tango", + IntegratedSecurity = true + }; + ObservablesContext.OverrideSettingsDataSource(_dataSource); + + using (ObservablesContext db = ObservablesContext.CreateDefault()) + { + var machine = new MachineBuilder(db).Set(x => x.SerialNumber == "LENA_TABLET").WithConfiguration().Build(); + var segments = SegmentsCsvHelper.FromFile(file, machine, db).Result; + + List<SegmentDTO> dtos = segments.Select(x => SegmentDTO.FromObservable(x)).ToList(); + + foreach (var segment in dtos) + { + Console.WriteLine(); + Console.WriteLine($"Segment {segment.SegmentIndex}"); + Console.WriteLine(segment.ToJsonString()); + } + Console.WriteLine("Press enter end test..."); + Console.ReadLine(); + } + } + } +} diff --git a/Software/Visual_Studio/Utilities/Tango.CsvToJobTester.CLI/Properties/AssemblyInfo.cs b/Software/Visual_Studio/Utilities/Tango.CsvToJobTester.CLI/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..d96ddfb0b --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.CsvToJobTester.CLI/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Tango.CsvToJobTester.CLI")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Tango.CsvToJobTester.CLI")] +[assembly: AssemblyCopyright("Copyright © 2020")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("4747a2de-f419-41b1-95a7-e9fbb4ea0b3b")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Software/Visual_Studio/Utilities/Tango.CsvToJobTester.CLI/Tango.CsvToJobTester.CLI.csproj b/Software/Visual_Studio/Utilities/Tango.CsvToJobTester.CLI/Tango.CsvToJobTester.CLI.csproj new file mode 100644 index 000000000..9d7d65401 --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.CsvToJobTester.CLI/Tango.CsvToJobTester.CLI.csproj @@ -0,0 +1,74 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProjectGuid>{4747A2DE-F419-41B1-95A7-E9FBB4EA0B3B}</ProjectGuid> + <OutputType>Exe</OutputType> + <RootNamespace>Tango.CsvToJobTester.CLI</RootNamespace> + <AssemblyName>Tango.CsvToJobTester.CLI</AssemblyName> + <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> + <FileAlignment>512</FileAlignment> + <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> + <Deterministic>true</Deterministic> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <PlatformTarget>AnyCPU</PlatformTarget> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <PlatformTarget>AnyCPU</PlatformTarget> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <ItemGroup> + <Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"> + <HintPath>..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll</HintPath> + </Reference> + <Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"> + <HintPath>..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll</HintPath> + </Reference> + <Reference Include="System" /> + <Reference Include="System.ComponentModel.DataAnnotations" /> + <Reference Include="System.Core" /> + <Reference Include="System.Xml.Linq" /> + <Reference Include="System.Data.DataSetExtensions" /> + <Reference Include="Microsoft.CSharp" /> + <Reference Include="System.Data" /> + <Reference Include="System.Net.Http" /> + <Reference Include="System.Xml" /> + </ItemGroup> + <ItemGroup> + <Compile Include="Program.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="App.config" /> + <None Include="packages.config" /> + <None Include="TestCSV.csv"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\..\Tango.BL\Tango.BL.csproj"> + <Project>{f441feee-322a-4943-b566-110e12fd3b72}</Project> + <Name>Tango.BL</Name> + </ProjectReference> + <ProjectReference Include="..\..\Tango.Core\Tango.Core.csproj"> + <Project>{a34ee0f0-649d-41c8-8489-b6f1cc6924ee}</Project> + <Name>Tango.Core</Name> + </ProjectReference> + </ItemGroup> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> +</Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/Utilities/Tango.CsvToJobTester.CLI/TestCSV.csv b/Software/Visual_Studio/Utilities/Tango.CsvToJobTester.CLI/TestCSV.csv new file mode 100644 index 000000000..0fc68a085 --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.CsvToJobTester.CLI/TestCSV.csv @@ -0,0 +1,9 @@ +Index,ColorSpace,Length,CatalogName1,CatalogItem1,Red1,Green1,Blue1,L1,A1,B1,Cyan1,Magenta1,Yellow1,Black1,CatalogName2,CatalogItem2,Red2,Green2,Blue2,L2,A2,B2,Cyan2,Magenta2, Yellow2,Black2 +1,LAB,100,,,,,,45,123,-12,,,,,,,,,,,,,,,, +2,Volume,200,,,,,,,,,23,34,45,56,,,100,0,0,,,,,,, +3,RGB,100,,,120,20,60,,,,,,,,,,,,,,,,,,, +4,Catalog,400,Twine,Red18,,,,,,,,,,,,,,,,,,,,,, +5,LAB,100,,,,,,0,-12,128,,,,,,,,,,12,45,89,,,, +6,Volume,200,,,,,,,,,23,34,45,56,,,100,0,0,,,,67,78,34,67 +7,RGB,100,,,120,20,60,,,,,,,,,,56,123,234,,,,,,, +8,Catalog,400,Twine,Orange22,,,,,,,,,,,Twine,Red18,,,,,,,,,, diff --git a/Software/Visual_Studio/Utilities/Tango.CsvToJobTester.CLI/packages.config b/Software/Visual_Studio/Utilities/Tango.CsvToJobTester.CLI/packages.config new file mode 100644 index 000000000..b3daf0d6c --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.CsvToJobTester.CLI/packages.config @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<packages> + <package id="EntityFramework" version="6.2.0" targetFramework="net461" /> +</packages>
\ No newline at end of file |
