tx
2025-04-09 fa7510e1ed63df0366787fa4ed1b3db6426d2b46
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
using System.Collections.Generic;
using System.Linq;
 
namespace TProduct.BLL
{
    public partial class WorkBenchMonitorPoint
    {
        //Entity to Model
        public static TProduct.Model.WorkBenchMonitorPoint Entity2Model(TProduct.Entity.WorkBenchMonitorPoint entity)
        {
            if (entity == null)
                return default;
            var model = TProduct.AutoMapperHelper.GetSingle<TProduct.Entity.WorkBenchMonitorPoint, TProduct.Model.WorkBenchMonitorPoint>(entity);
 
            if (!string.IsNullOrEmpty(entity.sDigitalParas))
            {
                model.DigitalParas = new Model.DigitalMonitorPointParas(entity.sDigitalParas);
            }
            if (!string.IsNullOrEmpty(entity.sAnalogParas))
            {
                model.AnalogParas = new Model.AnalogMonitorPointParas(entity.sAnalogParas);
            }
            if (!string.IsNullOrEmpty(entity.sValueCoeffParas))
            {
                model.ValueCoeffParas = Model.ValueCoeffParas.ToParameter(entity.sValueCoeffParas);
            }
            if (!string.IsNullOrEmpty(entity.sPointParas))
            {
                model.PointParas = Model.MonitorPointParas.ToParameter(entity.sPointParas);
            }
            return model;
        }
        //Entities to Models
        public static List<TProduct.Model.WorkBenchMonitorPoint> Entity2Models(List<TProduct.Entity.WorkBenchMonitorPoint> entities)
        {
            if (entities == null || entities.Count() < 1)
                return default;
            List<TProduct.Model.WorkBenchMonitorPoint> models = new List<Model.WorkBenchMonitorPoint>(entities.Count());
            foreach (var entity in entities)
            {
                var model = TProduct.AutoMapperHelper.GetSingle<TProduct.Entity.WorkBenchMonitorPoint, TProduct.Model.WorkBenchMonitorPoint>(entity);
 
                if (!string.IsNullOrEmpty(entity.sDigitalParas))
                {
                    model.DigitalParas = new Model.DigitalMonitorPointParas(entity.sDigitalParas);
                }
                if (!string.IsNullOrEmpty(entity.sAnalogParas))
                {
                    model.AnalogParas = new Model.AnalogMonitorPointParas(entity.sAnalogParas);
                }
                if (!string.IsNullOrEmpty(entity.sValueCoeffParas))
                {
                    model.ValueCoeffParas = Model.ValueCoeffParas.ToParameter(entity.sValueCoeffParas);
                }
                if (!string.IsNullOrEmpty(entity.sPointParas))
                {
                    model.PointParas = Model.MonitorPointParas.ToParameter(entity.sPointParas);
                }
                models.Add(model);
            }
 
 
            return models;
        }
 
        //Model to Entity
        public static TProduct.Entity.WorkBenchMonitorPoint Model2Entity(TProduct.Model.WorkBenchMonitorPoint model)
        {
            if (model == null)
                return default;
            var entity = TProduct.AutoMapperHelper.GetSingle<TProduct.Model.WorkBenchMonitorPoint, TProduct.Entity.WorkBenchMonitorPoint>(model);
            if (model.DigitalParas != null)
            {
                entity.sDigitalParas = model.DigitalParas.ToDsString();
            }
            if (model.AnalogParas != null)
            {
                entity.sAnalogParas = model.AnalogParas.ToDsString();
            }
            if (model.ValueCoeffParas != null)
            {
                entity.sValueCoeffParas = model.ValueCoeffParas.ToDsString();
            }
            if (model.PointParas != null)
            {
                entity.sPointParas = model.PointParas.ToDsString();
            }
            return entity;
        }
 
        //Models to Entities
        public static List<TProduct.Entity.WorkBenchMonitorPoint> Model2Entities(List<TProduct.Model.WorkBenchMonitorPoint> models)
        {
            if (models == null || models.Count < 1)
                return default;
            List<TProduct.Entity.WorkBenchMonitorPoint> entities = new List<Entity.WorkBenchMonitorPoint>(models.Count());
 
            foreach (var model in models)
            {
                var entity = TProduct.AutoMapperHelper.GetSingle<TProduct.Model.WorkBenchMonitorPoint, TProduct.Entity.WorkBenchMonitorPoint>(model);
                if (model.DigitalParas != null)
                {
                    entity.sDigitalParas = model.DigitalParas.ToDsString();
                }
                if (model.AnalogParas != null)
                {
                    entity.sAnalogParas = model.AnalogParas.ToDsString();
                }
                if (model.ValueCoeffParas != null)
                {
                    entity.sValueCoeffParas = model.ValueCoeffParas.ToDsString();
                }
                if (model.PointParas != null)
                {
                    entity.sPointParas = model.PointParas.ToDsString();
                }
                entities.Add(entity);
            }
 
 
            return entities;
        }
 
 
    }
}