aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Utilities/Tango.CsvToJobTester.CLI/Program.cs
blob: 82971cc1aef56fbf3eac2588933fe2e08c149a03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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();
            }
        }
    }
}