hytos / DTI_PID / APIDConverter / AvevaInfo.cs @ 4328cb06
이력 | 보기 | 이력해설 | 다운로드 (3.37 KB)
1 |
using System; |
---|---|
2 |
using System.Collections.Generic; |
3 |
using System.Linq; |
4 |
using System.Text; |
5 |
using System.Threading.Tasks; |
6 |
using AVEVA.PID.CustomizationUtility.DB; |
7 |
using AVEVA.PID.CustomizationUtility.Model; |
8 |
using AVEVA.PID.CustomizationUtility.Properties; |
9 |
using System.Data; |
10 |
|
11 |
namespace AVEVA.PID.CustomizationUtility |
12 |
{ |
13 |
public class AvevaInfo |
14 |
{ |
15 |
static AvevaInfo avevaInfo; |
16 |
|
17 |
public DataTable AvevaSymbolTable { get; set; } |
18 |
public List<SymbolInfo> SymbolInfo { get; set; } |
19 |
public List<AttributeInfo> AttributeInfo { get; set; } |
20 |
public static AvevaInfo GetInstance() |
21 |
{ |
22 |
if (avevaInfo == null) |
23 |
{ |
24 |
avevaInfo = new AvevaInfo(); |
25 |
Refresh(); |
26 |
} |
27 |
return avevaInfo; |
28 |
} |
29 |
public static void Refresh() |
30 |
{ |
31 |
if (avevaInfo == null) |
32 |
avevaInfo = new AvevaInfo(); |
33 |
|
34 |
avevaInfo.AvevaSymbolTable = Project_DB.SelectSymbolTable(); |
35 |
SetSymbolInfo(); |
36 |
SetAttributeInfo(); |
37 |
} |
38 |
private static void SetSymbolInfo() |
39 |
{ |
40 |
avevaInfo.SymbolInfo = new List<SymbolInfo>(); |
41 |
DataTable dt = Project_DB.GetSymbolMappingTableOnlySymbol(); |
42 |
foreach (DataRow row in dt.Rows) |
43 |
{ |
44 |
SymbolInfo info = new SymbolInfo(); |
45 |
info.UID = DBNull.Value.Equals(row["UID"]) ? string.Empty : row["UID"].ToString(); |
46 |
info.NAME = DBNull.Value.Equals(row["NAME"]) ? string.Empty : row["NAME"].ToString(); |
47 |
info.APID_SYMBOL = DBNull.Value.Equals(row["APID_SYMBOL"]) ? string.Empty : row["APID_SYMBOL"].ToString(); |
48 |
info.DATA1 = DBNull.Value.Equals(row["DATA1"]) ? string.Empty : row["DATA1"].ToString(); |
49 |
avevaInfo.SymbolInfo.Add(info); |
50 |
} |
51 |
dt.Dispose(); |
52 |
} |
53 |
private static void SetAttributeInfo() |
54 |
{ |
55 |
avevaInfo.AttributeInfo = new List<AttributeInfo>(); |
56 |
DataTable dt = Project_DB.GetAttributeMappingTableOnlyAttribute(); |
57 |
foreach (DataRow row in dt.Rows) |
58 |
{ |
59 |
AttributeInfo info = new AttributeInfo(); |
60 |
info.UID = DBNull.Value.Equals(row["UID"]) ? string.Empty : row["UID"].ToString(); |
61 |
info.APID_ATTRIBUTE = DBNull.Value.Equals(row["APID_ATTRIBUTE"]) ? string.Empty : row["APID_ATTRIBUTE"].ToString(); |
62 |
info.APID_ATTRIBUTE_TYPE = DBNull.Value.Equals(row["APID_ATTRIBUTE_TYPE"]) ? string.Empty : row["APID_ATTRIBUTE_TYPE"].ToString(); |
63 |
if (!string.IsNullOrEmpty(info.APID_ATTRIBUTE) && !string.IsNullOrEmpty(info.APID_ATTRIBUTE_TYPE)) |
64 |
{ |
65 |
string sRemove = "|" + info.APID_ATTRIBUTE_TYPE; |
66 |
info.APID_ATTRIBUTE = info.APID_ATTRIBUTE.Remove(info.APID_ATTRIBUTE.LastIndexOf(sRemove), sRemove.Length); |
67 |
} |
68 |
avevaInfo.AttributeInfo.Add(info); |
69 |
} |
70 |
dt.Dispose(); |
71 |
} |
72 |
} |
73 |
|
74 |
public class SymbolInfo |
75 |
{ |
76 |
public string UID { get; set; } |
77 |
public string NAME { get; set; } |
78 |
public string APID_SYMBOL { get; set; } |
79 |
public string DATA1 { get; set; } |
80 |
} |
81 |
|
82 |
public class AttributeInfo |
83 |
{ |
84 |
public string UID { get; set; } |
85 |
public string APID_ATTRIBUTE { get; set; } |
86 |
public string APID_ATTRIBUTE_TYPE { get; set; } |
87 |
} |
88 |
|
89 |
} |