hytos / DTI_PID / SPPIDConverter_AutoModeling / Util / SPPIDUtil.cs @ 23eb98bf
이력 | 보기 | 이력해설 | 다운로드 (3.3 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.AutoModeling.DB; |
9 |
using Converter.BaseModel; |
10 |
using System.Windows.Forms; |
11 |
|
12 |
namespace Converter.SPPID.AutoModeling.Util |
13 |
{ |
14 |
public class SPPIDUtil |
15 |
{ |
16 |
public static bool SaveID2ProjectInfo() |
17 |
{ |
18 |
ProjectInfo projectInfo = ProjectInfo.GetInstance(); |
19 |
try |
20 |
{ |
21 |
StreamWriter sw = new StreamWriter(Application.StartupPath + @"\ProjectInfo.info"); |
22 |
sw.Write(JsonConvert.SerializeObject(projectInfo)); |
23 |
sw.Dispose(); |
24 |
} |
25 |
catch (Exception ex) |
26 |
{ |
27 |
return false; |
28 |
} |
29 |
return true; |
30 |
} |
31 |
|
32 |
public static bool ReadID2ProjectInfo() |
33 |
{ |
34 |
ProjectInfo projectInfo = ProjectInfo.GetInstance(); |
35 |
try |
36 |
{ |
37 |
StreamReader sr = new StreamReader(Application.StartupPath + @"\ProjectInfo.info"); |
38 |
ProjectInfo jsonProjectInfo = JsonConvert.DeserializeObject<ProjectInfo>(sr.ReadToEnd()); |
39 |
sr.Dispose(); |
40 |
|
41 |
projectInfo.Path = jsonProjectInfo.Path; |
42 |
projectInfo.Enable = jsonProjectInfo.Enable; |
43 |
} |
44 |
catch (Exception ex) |
45 |
{ |
46 |
return false; |
47 |
} |
48 |
return true; |
49 |
} |
50 |
|
51 |
public static bool SaveSPPIDInfo() |
52 |
{ |
53 |
SPPIDInfo info = SPPIDInfo.GetInstance(); |
54 |
try |
55 |
{ |
56 |
StreamWriter sw = new StreamWriter(Application.StartupPath + @"\SPPIDInfo.info"); |
57 |
sw.Write(JsonConvert.SerializeObject(info)); |
58 |
sw.Dispose(); |
59 |
} |
60 |
catch (Exception ex) |
61 |
{ |
62 |
return false; |
63 |
} |
64 |
return true; |
65 |
} |
66 |
|
67 |
public static bool ReadSPPIDInfo() |
68 |
{ |
69 |
SPPIDInfo _SPPIDInfo = SPPIDInfo.GetInstance(); |
70 |
try |
71 |
{ |
72 |
StreamReader sr = new StreamReader(Application.StartupPath + @"\SPPIDInfo.info"); |
73 |
SPPIDInfo jsonSPPIDInfo = JsonConvert.DeserializeObject<SPPIDInfo>(sr.ReadToEnd()); |
74 |
sr.Dispose(); |
75 |
|
76 |
_SPPIDInfo.DBType = jsonSPPIDInfo.DBType; |
77 |
_SPPIDInfo.Service = jsonSPPIDInfo.Service; |
78 |
_SPPIDInfo.Site = jsonSPPIDInfo.Site; |
79 |
_SPPIDInfo.ServerIP = jsonSPPIDInfo.ServerIP; |
80 |
_SPPIDInfo.Port = jsonSPPIDInfo.Port; |
81 |
_SPPIDInfo.DBUser = jsonSPPIDInfo.DBUser; |
82 |
_SPPIDInfo.DBPassword = jsonSPPIDInfo.DBPassword; |
83 |
_SPPIDInfo.PlantPath = jsonSPPIDInfo.PlantPath; |
84 |
_SPPIDInfo.PlantDic = jsonSPPIDInfo.PlantDic; |
85 |
_SPPIDInfo.PlantPID = jsonSPPIDInfo.PlantPID; |
86 |
_SPPIDInfo.PlantPIDDic = jsonSPPIDInfo.PlantPIDDic; |
87 |
_SPPIDInfo.Plant = jsonSPPIDInfo.Plant; |
88 |
_SPPIDInfo.Enable = jsonSPPIDInfo.Enable; |
89 |
_SPPIDInfo.SelectedPlant = jsonSPPIDInfo.SelectedPlant; |
90 |
_SPPIDInfo.PlantList = jsonSPPIDInfo.PlantList; |
91 |
|
92 |
} |
93 |
catch (Exception ex) |
94 |
{ |
95 |
return false; |
96 |
} |
97 |
return true; |
98 |
} |
99 |
} |
100 |
} |