diff options
| author | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2020-12-27 17:37:28 +0200 |
|---|---|---|
| committer | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2020-12-27 17:37:28 +0200 |
| commit | 78e2602610d1712bf7dfac08d082a8467bcd0210 (patch) | |
| tree | f359311fd99015057fcce86a999c60792ffa7bf0 /Software/Visual_Studio | |
| parent | 36928d513d8091c20b248e065ef7b6a0e3bc61ee (diff) | |
| download | Tango-78e2602610d1712bf7dfac08d082a8467bcd0210.tar.gz Tango-78e2602610d1712bf7dfac08d082a8467bcd0210.zip | |
Added test to check loading segments from csv file.
Diffstat (limited to 'Software/Visual_Studio')
8 files changed, 452 insertions, 116 deletions
diff --git a/Software/Visual_Studio/Tango.BL/Helpers/SegmentsCsvHelper.cs b/Software/Visual_Studio/Tango.BL/Helpers/SegmentsCsvHelper.cs index e2bffcc03..636f84fdf 100644 --- a/Software/Visual_Studio/Tango.BL/Helpers/SegmentsCsvHelper.cs +++ b/Software/Visual_Studio/Tango.BL/Helpers/SegmentsCsvHelper.cs @@ -29,60 +29,65 @@ namespace Tango.BL.Helpers public String Red1 { get; set; } public String Green1 { get; set; } public String Blue1 { get; set; } - public String Red2 { get; set; } - public String Green2 { get; set; } - public String Blue2 { 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 Cyan2{ get; set; } - public String Magenta2 { get; set; } - public String Yellow2 { get; set; } - public String Black2 { 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 L1 { get; set; } - public String A1 { get; set; } - public String B1 { get; set; } public String L2 { get; set; } public String A2 { get; set; } public String B2 { get; set; } - public String CatalogName2 { get; set; } - public String CatalogItem2 { 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 (Red2 == null && Green2 == null && Blue2 == null) return true; + 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 (Cyan2 == null && Magenta2 == null && Yellow2 == null && Black2 == null) return true; + 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.IsNullOrEmpty(CatalogName2) && String.IsNullOrEmpty(CatalogItem2)) return true; + if (String.IsNullOrWhiteSpace(CatalogName2) || String.IsNullOrEmpty(CatalogItem2)) return true; if (CatalogName1 == CatalogName2 && CatalogItem1 == CatalogItem2) return true; return false; } internal bool IsLab2NullOrEqual() { - if (L2 == null && A2 == null && B2 == null) return true; + if (String.IsNullOrWhiteSpace(L2) || String.IsNullOrWhiteSpace(A2) || String.IsNullOrWhiteSpace(B2)) return true; if (L1 == L2 && A1 == A2 && B1 == B2) return true; return false; } } - static public Task<List<Segment>> FromFile(String filePath, Machine machine, ObservablesContext context) + public static Task<List<Segment>> FromFile(String filePath, Machine machine, ObservablesContext context) { return Task.Factory.StartNew(() => { @@ -105,139 +110,251 @@ namespace Tango.BL.Helpers 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) { - Segment segment = new Segment(); - segment.Length = double.Parse(row.Length); - segment.SegmentIndex = int.Parse(row.Index); + lineCount++; - ColorSpace colorSpace = colorSpaces.SingleOrDefault(x => x.Name == row.ColorSpace); + try + { + Segment segment = new Segment(); + segment.Length = double.Parse(row.Length); + segment.SegmentIndex = int.Parse(row.Index); - if (colorSpace == null) throw new InvalidOperationException($"Color space '{row.ColorSpace}' not found!"); + ColorSpace colorSpace = colorSpaces.SingleOrDefault(x => x.Name == row.ColorSpace); - BrushStop stop1 = new BrushStop(); - stop1.ColorSpace = colorSpace; - stop1.OffsetPercent = 0; - segment.BrushStops.Add(stop1); + if (colorSpace == null) throw new InvalidOperationException($"Color space '{row.ColorSpace}' not found on line '{lineCount}'."); - if (colorSpace.Space == ColorSpaces.RGB) - { - stop1.Red = int.Parse(row.Red1); - if (stop1.Red < 0 || stop1.Red > 255) throw new InvalidOperationException($"Value red1 '{row.Red1}' is out of bounds!"); - stop1.Green = int.Parse(row.Green1); - if (stop1.Green < 0 || stop1.Green > 255) throw new InvalidOperationException($"Value green1 '{row.Green1}' is out of bounds!"); - stop1.Blue = int.Parse(row.Blue1); - if (stop1.Blue < 0 || stop1.Blue > 255) throw new InvalidOperationException($"Value blue1 '{row.Blue1}' is out of bounds!"); + BrushStop stop1 = new BrushStop(); + stop1.ColorSpace = colorSpace; + stop1.OffsetPercent = 0; + segment.BrushStops.Add(stop1); - if (!row.IsRgb2NullOrEqual()) + if (colorSpace.Space == ColorSpaces.RGB) { - BrushStop stop2 = new BrushStop(); - stop2.ColorSpace = stop1.ColorSpace; - stop2.OffsetPercent = 100; + 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}'."); - stop2.Red = int.Parse(row.Red2); - if (stop2.Red < 0 || stop2.Red > 255) throw new InvalidOperationException($"Value red2 '{row.Red2}' is out of bounds!"); - stop2.Green = int.Parse(row.Green2); - if (stop2.Green < 0 || stop2.Green > 255) throw new InvalidOperationException($"Value green2 '{row.Green2}' is out of bounds!"); - stop2.Blue = int.Parse(row.Blue2); - if (stop2.Blue < 0 || stop2.Blue > 255) throw new InvalidOperationException($"Value blue2 '{row.Blue2}' is out of bounds!"); + 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}'."); - segment.BrushStops.Add(stop2); - } - } - else if (colorSpace.Space == ColorSpaces.Volume) - { - double cyan1 = double.Parse(row.Cyan1); - stop1.SetVolume(cyanIdsPack.PackIndex, cyan1); + 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; - double magenta1 = double.Parse(row.Magenta1); - stop1.SetVolume(magentaIdsPack.PackIndex, magenta1); + 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}'."); - double yellow1 = double.Parse(row.Yellow1); - stop1.SetVolume(yellowIdsPack.PackIndex, yellow1); + 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}'."); - double black1 = double.Parse(row.Black1); - stop1.SetVolume(cyanIdsPack.PackIndex, cyan1); + 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}'."); - if (!row.IsVolumeNullOrEqual()) + segment.BrushStops.Add(stop2); + } + } + else if (colorSpace.Space == ColorSpaces.Volume) { - BrushStop stop2 = new BrushStop(); - stop2.ColorSpace = stop1.ColorSpace; - stop2.OffsetPercent = 100; + 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 cyan2 = double.Parse(row.Cyan2); - stop2.SetVolume(cyanIdsPack.PackIndex, cyan2); + 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}.'!"); - double magenta2 = double.Parse(row.Magenta2); - stop2.SetVolume(magentaIdsPack.PackIndex, magenta2); + stop1.SetVolume(magentaIdsPack.PackIndex, magenta1); - double yellow2 = double.Parse(row.Yellow2); - stop2.SetVolume(yellowIdsPack.PackIndex, yellow2); + 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}.'!"); - double black2 = double.Parse(row.Black2); - stop2.SetVolume(cyanIdsPack.PackIndex, cyan2); + stop1.SetVolume(yellowIdsPack.PackIndex, yellow1); - 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 name: '{row.CatalogName1}' not found!"); - } - - 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 in ColorCatalogsGroups!"); + 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); + } } - - stop1.ColorCatalog = catalog; - stop1.ColorCatalogsItem = item; - if(!row.IsCatalogNameNullOrEqual()) + else if (colorSpace.Space == ColorSpaces.Catalog) { - var catalog2 = catalogs.FirstOrDefault(x => x.Name == row.CatalogName2); + var catalog = catalogs.FirstOrDefault(x => x.Name == row.CatalogName1); if (catalog == null) { - throw new InvalidOperationException($"Catalog name: '{row.CatalogName2}' not found!"); + throw new InvalidOperationException($"Catalog '{row.CatalogName1}' not found on line '{lineCount}'."); } - var item2 = catalog.ColorCatalogsGroups.SelectMany(x => x.ColorCatalogsItems).FirstOrDefault(x => x.Name == row.CatalogItem2); + var item = catalog.ColorCatalogsGroups.SelectMany(x => x.ColorCatalogsItems).FirstOrDefault(x => x.Name == row.CatalogItem1); if (item == null) { - throw new InvalidOperationException($"Catalog item: '{row.CatalogItem2}' not found in ColorCatalogsGroups!"); + 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); } - BrushStop stop2 = new BrushStop(); - stop2.ColorCatalog = catalog2; - stop2.ColorCatalogsItem = item2; - segment.BrushStops.Add(stop2); } - } - else if(colorSpace.Space == ColorSpaces.LAB) - { - stop1.L = int.Parse(row.L1); - if (stop1.L < 0 || stop1.L > 100) throw new InvalidOperationException($"Value L1 '{row.L1}' is out of bounds!"); - stop1.A = int.Parse(row.A1); - if (stop1.A < -128 || stop1.A > 128) throw new InvalidOperationException($"Value A1 '{row.A1}' is out of bounds!"); - stop1.B = int.Parse(row.B1); - if (stop1.B < -128 || stop1.B > 128) throw new InvalidOperationException($"Value B1 '{row.B1}' is out of bounds!"); - if (!row.IsLab2NullOrEqual()) + else if (colorSpace.Space == ColorSpaces.LAB) { - BrushStop stop2 = new BrushStop(); - stop2.ColorSpace = stop1.ColorSpace; - stop2.OffsetPercent = 100; + 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; - stop2.L = int.Parse(row.L2); - if (stop2.L < 0 || stop2.L > 100) throw new InvalidOperationException($"Value L2 '{row.L2}' is out of bounds!"); - stop2.A = int.Parse(row.A2); - if (stop2.A < -128 || stop2.A > 128) throw new InvalidOperationException($"Value A2 '{row.A2}' is out of bounds!"); - stop2.B = int.Parse(row.B2); - if (stop2.B < -128 || stop2.B > 128) throw new InvalidOperationException($"Value B2 '{row.B2}' is out of bounds!"); + 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}'."); - segment.BrushStops.Add(stop2); + 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()}"); } } 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 |
