aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/TCC/Tango.TCC.Service/DTO/ResultDTO.cs
blob: ea689e22e7a0ef20fe34d2ac99af6af5a0c299c7 (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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
using ColorMine.ColorSpaces;
using ColorMine.ColorSpaces.Comparisons;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Tango.Core.Helpers;
using Tango.TCC.BL.Entities;

namespace Tango.TCC.Service.DTO
{
    public class ResultDTO
    {
        public ResultDTO( )
        {
        }
        
        public String Guid { get; set; }

        public DateTime Date { get; set; }
        
        public String DeviceGuid { get; set; }

        public String CardGuid { get; set; }
        
        public int RawColor { get; set; }
        
        public int ProcessedColor { get; set; }
        
        public int ProcessTime { get; set; }

        public String SampleImageURL { get; set; }
        
        public String SourceImageURL { get; set; }

        public DeviceDTO Device { get; set; }

        public String DeviceId { get; set; }

        public CardDTO Card { get; set; }

        public String DeviceModel { get; set; }

        public String CardCode { get; set; }

        public String Email { get; set; }

        public double DeltaE
        {
            get
            {
                double deltaE = 0;
                var rawColor = ColorHelper.IntegerToColor(RawColor);
                var processedColor = ColorHelper.IntegerToColor(ProcessedColor);

                Rgb rawRgb = new Rgb(rawColor.R, rawColor.G, rawColor.B);
                Rgb processedRgb = new Rgb(processedColor.R, processedColor.G, processedColor.B);

                deltaE = rawRgb.Compare(processedRgb, new CieDe2000Comparison());

                return deltaE;
            }
        }

        public static ResultDTO createResultDTO( Result result, string cardCode, string deviceModel, string email, string deviceGuid)
        {
            ResultDTO dto = new ResultDTO();
            dto.Guid = result.Guid;
            dto.Date = result.Date;
            dto.RawColor = result.RawColor;
            dto.ProcessedColor = result.ProcessedColor;
            dto.SampleImageURL = "/api/Results/GetResultSampleImage?blobName=" + result.SampleImageBlobName;
            dto.SourceImageURL = "/api/Results/GetResultSourceImage?blobName=" + result.SourceImageBlobName;
            dto.ProcessTime = result.ProcessTime;
            dto.CardGuid = result.CardGuid;
            dto.CardCode = cardCode;
            dto.DeviceModel = deviceModel;
            dto.Email = email;
            dto.DeviceGuid = deviceGuid;

            return dto;
        }
        public static ResultDTO createsampleResultDTO(Result result)
        {
            ResultDTO dto = new ResultDTO();
            dto.Guid = result.Guid;
            dto.Date = result.Date;
            dto.RawColor = result.RawColor;
            dto.ProcessedColor = result.ProcessedColor;
            //dto.SampleImageURL = "/api/Results/GetResultSampleImage?blobName=" + result.SampleImageBlobName;
            //dto.SourceImageURL = "/api/Results/GetResultSourceImage?blobName=" + result.SourceImageBlobName;
            dto.ProcessTime = result.ProcessTime;
            dto.CardGuid = result.CardGuid;
            return dto;
        }

    }
}