hytos / DTI_PID / SPPIDConverter / Util / SPPIDUtil.cs @ bca81f4c
이력 | 보기 | 이력해설 | 다운로드 (4.35 KB)
1 |
using System; |
---|---|
2 |
using System.Collections.Generic; |
3 |
using System.Linq; |
4 |
using System.Text; |
5 |
using System.Threading.Tasks; |
6 |
using Newtonsoft.Json; |
7 |
using System.IO; |
8 |
using Converter.SPPID.DB; |
9 |
using Converter.BaseModel; |
10 |
using System.Windows.Forms; |
11 |
using Converter.SPPID.Model; |
12 |
|
13 |
namespace Converter.SPPID.Util |
14 |
{ |
15 |
public class SPPIDUtil |
16 |
{ |
17 |
public static bool ConvertToSPPIDInfo(string jsonString) |
18 |
{ |
19 |
SPPID_DBInfo _SPPIDInfo = SPPID_DBInfo.GetInstance(); |
20 |
try |
21 |
{ |
22 |
SPPID_DBInfo jsonSPPIDInfo = JsonConvert.DeserializeObject<SPPID_DBInfo>(jsonString); |
23 |
|
24 |
_SPPIDInfo.DBType = jsonSPPIDInfo.DBType; |
25 |
_SPPIDInfo.Service = jsonSPPIDInfo.Service; |
26 |
_SPPIDInfo.Site = jsonSPPIDInfo.Site; |
27 |
_SPPIDInfo.ServerIP = jsonSPPIDInfo.ServerIP; |
28 |
_SPPIDInfo.Port = jsonSPPIDInfo.Port; |
29 |
_SPPIDInfo.DBUser = jsonSPPIDInfo.DBUser; |
30 |
_SPPIDInfo.DBPassword = jsonSPPIDInfo.DBPassword; |
31 |
_SPPIDInfo.PlantPath = jsonSPPIDInfo.PlantPath; |
32 |
_SPPIDInfo.PlantDic = jsonSPPIDInfo.PlantDic; |
33 |
_SPPIDInfo.PlantPID = jsonSPPIDInfo.PlantPID; |
34 |
_SPPIDInfo.PlantPIDDic = jsonSPPIDInfo.PlantPIDDic; |
35 |
_SPPIDInfo.Plant = jsonSPPIDInfo.Plant; |
36 |
_SPPIDInfo.Enable = jsonSPPIDInfo.Enable; |
37 |
_SPPIDInfo.SelectedPlant = jsonSPPIDInfo.SelectedPlant; |
38 |
_SPPIDInfo.PlantList = jsonSPPIDInfo.PlantList; |
39 |
|
40 |
} |
41 |
catch (Exception ex) |
42 |
{ |
43 |
_SPPIDInfo.Enable = false; |
44 |
return false; |
45 |
} |
46 |
return true; |
47 |
} |
48 |
public static bool ConvertToETCSetting(string jsonString) |
49 |
{ |
50 |
ETCSetting _ETCSetting = ETCSetting.GetInstance(); |
51 |
try |
52 |
{ |
53 |
ETCSetting jsonETCSetting = JsonConvert.DeserializeObject<ETCSetting>(jsonString); |
54 |
|
55 |
_ETCSetting.NoteSymbolPath = jsonETCSetting.NoteSymbolPath; |
56 |
_ETCSetting.TextSymbolPath = jsonETCSetting.TextSymbolPath; |
57 |
_ETCSetting.DrainValveSize = jsonETCSetting.DrainValveSize; |
58 |
|
59 |
} |
60 |
catch (Exception ex) |
61 |
{ |
62 |
return false; |
63 |
} |
64 |
return true; |
65 |
} |
66 |
|
67 |
public static string GetSPPIDMappingPath(SPPID_Document document, object itemObj) |
68 |
{ |
69 |
if (itemObj.GetType() == typeof(Symbol)) |
70 |
{ |
71 |
Symbol item = itemObj as Symbol; |
72 |
return document.SymbolMappings.Find(x => x.SYMBOLNAME == item.NAME).SPPIDSYMBOLNAME; |
73 |
} |
74 |
else if (itemObj.GetType() == typeof(Line)) |
75 |
{ |
76 |
Line item = itemObj as Line; |
77 |
return document.LineMappings.Find(x => x.LINENAME == item.TYPE).SPPIDSYMBOLNAME; |
78 |
} |
79 |
else if (itemObj.GetType() == typeof(Text)) |
80 |
{ |
81 |
|
82 |
} |
83 |
else if (itemObj.GetType() == typeof(Note)) |
84 |
{ |
85 |
|
86 |
} |
87 |
|
88 |
return null; |
89 |
} |
90 |
|
91 |
|
92 |
|
93 |
#region |
94 |
public static bool IsBranchLine(string UID, Line connectedLine) |
95 |
{ |
96 |
try |
97 |
{ |
98 |
if (connectedLine.CONNECTORS[0].CONNECTEDITEM != UID && connectedLine.CONNECTORS[1].CONNECTEDITEM != UID) |
99 |
return true; |
100 |
} |
101 |
catch (Exception ex) |
102 |
{ |
103 |
|
104 |
} |
105 |
|
106 |
return false; |
107 |
} |
108 |
public static object FindObjectByUID(Document document, string UID) |
109 |
{ |
110 |
foreach (Symbol item in document.SYMBOLS) |
111 |
{ |
112 |
if (item.UID == UID) |
113 |
return item; |
114 |
} |
115 |
|
116 |
foreach (Line item in document.LINES) |
117 |
{ |
118 |
if (item.UID == UID) |
119 |
return item; |
120 |
} |
121 |
|
122 |
foreach (Text item in document.TEXTINFOS) |
123 |
{ |
124 |
if (item.UID == UID) |
125 |
return item; |
126 |
} |
127 |
|
128 |
foreach (Note item in document.NOTES) |
129 |
{ |
130 |
if (item.UID == UID) |
131 |
return item; |
132 |
} |
133 |
|
134 |
foreach (LineNumber item in document.LINENUMBERS) |
135 |
{ |
136 |
if (item.UID == UID) |
137 |
return item; |
138 |
} |
139 |
|
140 |
return null; |
141 |
} |
142 |
#endregion |
143 |
} |
144 |
} |