markus / KCOM / Common / TempFile.cs @ 0d99c609
이력 | 보기 | 이력해설 | 다운로드 (11.5 KB)
1 | 6707a5c7 | ljiyeon | using KCOM.Common; |
---|---|---|---|
2 | using KCOM.Controls; |
||
3 | using KCOM.Views; |
||
4 | ccf944bb | ljiyeon | using MarkupToPDF.Common; |
5 | 6707a5c7 | ljiyeon | using Newtonsoft.Json; |
6 | using Newtonsoft.Json.Converters; |
||
7 | using Newtonsoft.Json.Linq; |
||
8 | using Newtonsoft.Json.Serialization; |
||
9 | ccf944bb | ljiyeon | using System; |
10 | 6707a5c7 | ljiyeon | using System.Collections; |
11 | ccf944bb | ljiyeon | using System.Collections.Generic; |
12 | 6707a5c7 | ljiyeon | using System.ComponentModel; |
13 | using System.Data; |
||
14 | ccf944bb | ljiyeon | using System.IO; |
15 | using System.Linq; |
||
16 | 6707a5c7 | ljiyeon | using System.Reflection; |
17 | using System.Runtime.Serialization.Formatters; |
||
18 | using System.Runtime.Serialization.Formatters.Binary; |
||
19 | using System.Runtime.Serialization.Json; |
||
20 | ccf944bb | ljiyeon | using System.Text; |
21 | using System.Windows; |
||
22 | using System.Windows.Media; |
||
23 | 6707a5c7 | ljiyeon | using System.Xml; |
24 | using System.Xml.Serialization; |
||
25 | ccf944bb | ljiyeon | |
26 | namespace KCOM |
||
27 | 6707a5c7 | ljiyeon | { |
28 | ccf944bb | ljiyeon | public class TempFile |
29 | { |
||
30 | public class MarkupReturn |
||
31 | { |
||
32 | public string ConvertData { get; set; } |
||
33 | public int DATA_TYPE { get; set; } |
||
34 | public string CommentID { get; set; } |
||
35 | } |
||
36 | |||
37 | MarkupToPDF.Controls.Parsing.LayerControl layerControl = new MarkupToPDF.Controls.Parsing.LayerControl(); |
||
38 | |||
39 | 6707a5c7 | ljiyeon | public static string PathString = AppDomain.CurrentDomain.BaseDirectory + "Temp"; |
40 | public static string FilePath = PathString + "\\" + App.ViewInfo.DocumentItemID + ".tmp"; |
||
41 | |||
42 | internal void WriteTemp(List<MainMenu.TempDt> tempDtList) |
||
43 | ccf944bb | ljiyeon | { |
44 | 6707a5c7 | ljiyeon | if (tempDtList.Count > 0) |
45 | ccf944bb | ljiyeon | { |
46 | XmlDocument xmlDoc; |
||
47 | 6707a5c7 | ljiyeon | XmlElement xmlEle1, xmlEle2, xmlEle3, xmlEle4, xmlEle5, xmlEle6; |
48 | ccf944bb | ljiyeon | XmlNode newNode; |
49 | xmlDoc = new XmlDocument(); |
||
50 | |||
51 | 6707a5c7 | ljiyeon | if ((System.IO.File.Exists(FilePath)) == false) |
52 | ccf944bb | ljiyeon | { |
53 | 6707a5c7 | ljiyeon | if (!File.Exists(PathString)) |
54 | { |
||
55 | Directory.CreateDirectory(PathString); |
||
56 | } |
||
57 | |||
58 | ccf944bb | ljiyeon | XmlWriterSettings settings = new XmlWriterSettings(); |
59 | settings.Indent = true; |
||
60 | settings.NewLineOnAttributes = true; |
||
61 | |||
62 | 6707a5c7 | ljiyeon | XmlWriter xmlWriter = XmlWriter.Create(FilePath); |
63 | ccf944bb | ljiyeon | xmlWriter.WriteStartDocument(); |
64 | xmlWriter.WriteStartElement("Root"); |
||
65 | 6707a5c7 | ljiyeon | |
66 | ccf944bb | ljiyeon | xmlWriter.WriteEndDocument(); |
67 | |||
68 | xmlWriter.Flush(); |
||
69 | xmlWriter.Close(); |
||
70 | } |
||
71 | |||
72 | 6707a5c7 | ljiyeon | xmlDoc.Load(FilePath); // XML문서 로딩 |
73 | var nodes = xmlDoc.SelectNodes("/Root/CommentID"); |
||
74 | for (int i = 0; i < tempDtList.Count; i++) |
||
75 | { |
||
76 | bool check = true; |
||
77 | ccf944bb | ljiyeon | |
78 | 6707a5c7 | ljiyeon | foreach (XmlNode e in xmlDoc.GetElementsByTagName("CommentID")) |
79 | { |
||
80 | if (e.Attributes["Value"].Value.Equals(tempDtList[i].CommentID)) //CommentID가 같은경우 |
||
81 | { |
||
82 | //데이터 수정 |
||
83 | e.SelectSingleNode("ConvertData").InnerText = tempDtList[i].ConvertData; |
||
84 | e.SelectSingleNode("DATA_TYPE").InnerText = tempDtList[i].DATA_TYPE.ToString(); |
||
85 | e.SelectSingleNode("MarkupInfoID").InnerText = tempDtList[i].MarkupInfoID; |
||
86 | e.SelectSingleNode("PageNumber").InnerText = tempDtList[i].PageNumber.ToString(); |
||
87 | e.SelectSingleNode("IsUpdate").InnerText = tempDtList[i].IsUpdate.ToString(); |
||
88 | ccf944bb | ljiyeon | |
89 | 6707a5c7 | ljiyeon | xmlDoc.Save(FilePath); // XML문서 저장 |
90 | ccf944bb | ljiyeon | |
91 | 6707a5c7 | ljiyeon | check = false; |
92 | break; |
||
93 | } |
||
94 | } |
||
95 | ccf944bb | ljiyeon | |
96 | 6707a5c7 | ljiyeon | if (check == true) |
97 | { |
||
98 | newNode = xmlDoc.SelectSingleNode("Root"); // 추가할 부모 Node 찾기 |
||
99 | xmlEle1 = xmlDoc.CreateElement("CommentID"); |
||
100 | xmlEle1.SetAttribute("Value", tempDtList[i].CommentID); |
||
101 | newNode.AppendChild(xmlEle1); |
||
102 | ccf944bb | ljiyeon | |
103 | 6707a5c7 | ljiyeon | xmlEle2 = xmlDoc.CreateElement("ConvertData"); // 추가할 Node 생성 |
104 | xmlEle2.InnerText = tempDtList[i].ConvertData; |
||
105 | xmlEle1.AppendChild(xmlEle2); |
||
106 | ccf944bb | ljiyeon | |
107 | 6707a5c7 | ljiyeon | xmlEle3 = xmlDoc.CreateElement("DATA_TYPE"); // 추가할 Node 생성 |
108 | xmlEle3.InnerText = tempDtList[i].DATA_TYPE.ToString(); |
||
109 | xmlEle1.AppendChild(xmlEle3); |
||
110 | ccf944bb | ljiyeon | |
111 | 6707a5c7 | ljiyeon | xmlEle4 = xmlDoc.CreateElement("MarkupInfoID"); // 추가할 Node 생성 |
112 | xmlEle4.InnerText = tempDtList[i].MarkupInfoID; |
||
113 | xmlEle1.AppendChild(xmlEle4); |
||
114 | ccf944bb | ljiyeon | |
115 | 6707a5c7 | ljiyeon | xmlEle5 = xmlDoc.CreateElement("PageNumber"); // 추가할 Node 생성 |
116 | xmlEle5.InnerText = tempDtList[i].PageNumber.ToString(); |
||
117 | xmlEle1.AppendChild(xmlEle5); |
||
118 | ccf944bb | ljiyeon | |
119 | 6707a5c7 | ljiyeon | xmlEle6 = xmlDoc.CreateElement("IsUpdate"); |
120 | xmlEle6.InnerText = tempDtList[i].IsUpdate.ToString(); |
||
121 | xmlEle1.AppendChild(xmlEle6); |
||
122 | ccf944bb | ljiyeon | |
123 | 6707a5c7 | ljiyeon | xmlDoc.Save(FilePath); // XML문서 저장.. |
124 | } |
||
125 | } |
||
126 | xmlDoc = null; |
||
127 | ccf944bb | ljiyeon | } |
128 | } |
||
129 | 6707a5c7 | ljiyeon | |
130 | public void AddTemp(MarkupToPDF.Common.Undo_data undoDataList, int PageNumber, double x, double y) |
||
131 | ccf944bb | ljiyeon | { |
132 | 6707a5c7 | ljiyeon | XmlDocument xmlDoc; |
133 | XmlElement xmlEle1, xmlEle2, xmlEle3, xmlEle4, xmlEle5, xmlEle6; |
||
134 | XmlNode newNode; |
||
135 | xmlDoc = new XmlDocument(); |
||
136 | ccf944bb | ljiyeon | |
137 | 6707a5c7 | ljiyeon | if ((System.IO.File.Exists(FilePath)) == false) |
138 | { |
||
139 | if (!File.Exists(PathString)) |
||
140 | ccf944bb | ljiyeon | { |
141 | 6707a5c7 | ljiyeon | Directory.CreateDirectory(PathString); |
142 | } |
||
143 | ccf944bb | ljiyeon | |
144 | 6707a5c7 | ljiyeon | XmlWriterSettings settings = new XmlWriterSettings(); |
145 | settings.Indent = true; |
||
146 | settings.NewLineOnAttributes = true; |
||
147 | ccf944bb | ljiyeon | |
148 | 6707a5c7 | ljiyeon | XmlWriter xmlWriter = XmlWriter.Create(FilePath); |
149 | xmlWriter.WriteStartDocument(); |
||
150 | xmlWriter.WriteStartElement("Root"); |
||
151 | |||
152 | xmlWriter.WriteEndDocument(); |
||
153 | ccf944bb | ljiyeon | |
154 | 6707a5c7 | ljiyeon | xmlWriter.Flush(); |
155 | xmlWriter.Close(); |
||
156 | ccf944bb | ljiyeon | } |
157 | 6707a5c7 | ljiyeon | |
158 | xmlDoc.Load(FilePath); // XML문서 로딩 |
||
159 | var nodes = xmlDoc.SelectNodes("/Root/CommentID"); |
||
160 | for (int i = 0; i < undoDataList.Markup_List.Count; i++) |
||
161 | ccf944bb | ljiyeon | { |
162 | 6707a5c7 | ljiyeon | var root = layerControl.MarkupToString(undoDataList.Markup_List[i].Markup, App.ViewInfo.UserID); |
163 | bool check = true; |
||
164 | |||
165 | foreach (XmlNode e in xmlDoc.GetElementsByTagName("CommentID")) |
||
166 | { |
||
167 | if (e.Attributes["Value"].Value.Equals(root.CommentID)) //CommentID가 같은경우 |
||
168 | { |
||
169 | //데이터 수정 |
||
170 | e.SelectSingleNode("ConvertData").InnerText = root.ConvertData; |
||
171 | e.SelectSingleNode("DATA_TYPE").InnerText = root.DATA_TYPE.ToString(); |
||
172 | e.SelectSingleNode("MarkupInfoID").InnerText = undoDataList.Markup_List[i].Markup.MarkupInfoID; |
||
173 | e.SelectSingleNode("PageNumber").InnerText = PageNumber.ToString(); |
||
174 | e.SelectSingleNode("IsUpdate").InnerText = 1.ToString(); |
||
175 | ccf944bb | ljiyeon | |
176 | 6707a5c7 | ljiyeon | xmlDoc.Save(FilePath); // XML문서 저장 |
177 | ccf944bb | ljiyeon | |
178 | 6707a5c7 | ljiyeon | check = false; |
179 | break; |
||
180 | } |
||
181 | } |
||
182 | ccf944bb | ljiyeon | |
183 | 6707a5c7 | ljiyeon | if (check == true) |
184 | ccf944bb | ljiyeon | { |
185 | 6707a5c7 | ljiyeon | newNode = xmlDoc.SelectSingleNode("Root"); |
186 | xmlEle1 = xmlDoc.CreateElement("CommentID"); |
||
187 | xmlEle1.SetAttribute("Value", root.CommentID); |
||
188 | newNode.AppendChild(xmlEle1); |
||
189 | ccf944bb | ljiyeon | |
190 | 6707a5c7 | ljiyeon | xmlEle2 = xmlDoc.CreateElement("ConvertData"); |
191 | xmlEle2.InnerText = root.ConvertData; |
||
192 | xmlEle1.AppendChild(xmlEle2); |
||
193 | ccf944bb | ljiyeon | |
194 | 6707a5c7 | ljiyeon | xmlEle3 = xmlDoc.CreateElement("DATA_TYPE"); |
195 | xmlEle3.InnerText = root.DATA_TYPE.ToString(); |
||
196 | xmlEle1.AppendChild(xmlEle3); |
||
197 | ccf944bb | ljiyeon | |
198 | 6707a5c7 | ljiyeon | xmlEle4 = xmlDoc.CreateElement("MarkupInfoID"); |
199 | xmlEle4.InnerText = undoDataList.Markup_List[i].Markup.MarkupInfoID; |
||
200 | xmlEle1.AppendChild(xmlEle4); |
||
201 | ccf944bb | ljiyeon | |
202 | 6707a5c7 | ljiyeon | xmlEle5 = xmlDoc.CreateElement("PageNumber"); |
203 | xmlEle5.InnerText = PageNumber.ToString(); |
||
204 | xmlEle1.AppendChild(xmlEle5); |
||
205 | ccf944bb | ljiyeon | |
206 | 6707a5c7 | ljiyeon | xmlEle6 = xmlDoc.CreateElement("IsUpdate"); |
207 | xmlEle6.InnerText = 1.ToString(); |
||
208 | xmlEle1.AppendChild(xmlEle6); |
||
209 | ccf944bb | ljiyeon | |
210 | 6707a5c7 | ljiyeon | xmlDoc.Save(FilePath); |
211 | ccf944bb | ljiyeon | } |
212 | 6707a5c7 | ljiyeon | } |
213 | xmlDoc = null; |
||
214 | } |
||
215 | ccf944bb | ljiyeon | |
216 | 6707a5c7 | ljiyeon | public void Remove() |
217 | { |
||
218 | FileInfo fileDel = new FileInfo(FilePath); |
||
219 | if (fileDel.Exists) |
||
220 | { |
||
221 | fileDel.Delete(); |
||
222 | } |
||
223 | } |
||
224 | ccf944bb | ljiyeon | |
225 | 6707a5c7 | ljiyeon | internal void DelTemp(string CommentID, string PageNumber) //Control 삭제시 |
226 | { |
||
227 | if ((System.IO.File.Exists(FilePath)) == false) |
||
228 | { |
||
229 | if (!File.Exists(PathString)) |
||
230 | { |
||
231 | Directory.CreateDirectory(PathString); |
||
232 | } |
||
233 | ccf944bb | ljiyeon | |
234 | 6707a5c7 | ljiyeon | XmlWriterSettings settings = new XmlWriterSettings(); |
235 | settings.Indent = true; |
||
236 | settings.NewLineOnAttributes = true; |
||
237 | ccf944bb | ljiyeon | |
238 | 6707a5c7 | ljiyeon | XmlWriter xmlWriter = XmlWriter.Create(FilePath); |
239 | xmlWriter.WriteStartDocument(); |
||
240 | xmlWriter.WriteStartElement("Root"); |
||
241 | ccf944bb | ljiyeon | |
242 | 6707a5c7 | ljiyeon | xmlWriter.WriteEndDocument(); |
243 | ccf944bb | ljiyeon | |
244 | 6707a5c7 | ljiyeon | xmlWriter.Flush(); |
245 | xmlWriter.Close(); |
||
246 | } |
||
247 | ccf944bb | ljiyeon | |
248 | 6707a5c7 | ljiyeon | XmlDocument xmlDoc; |
249 | xmlDoc = new XmlDocument(); |
||
250 | xmlDoc.Load(FilePath); |
||
251 | ccf944bb | ljiyeon | |
252 | 6707a5c7 | ljiyeon | var nodes = xmlDoc.SelectNodes("/Root/CommentID"); |
253 | XmlElement root = xmlDoc.DocumentElement; |
||
254 | ccf944bb | ljiyeon | |
255 | 6707a5c7 | ljiyeon | bool check = true; |
256 | ccf944bb | ljiyeon | |
257 | 6707a5c7 | ljiyeon | /* |
258 | foreach (XmlNode node in nodes) |
||
259 | ccf944bb | ljiyeon | { |
260 | 6707a5c7 | ljiyeon | string sCommentID = node.Attributes["Value"].Value; |
261 | |||
262 | if (sCommentID == CommentID) |
||
263 | { |
||
264 | root.RemoveChild(xmlDoc.SelectNodes("//CommentID[@Value='" + CommentID + "']")[0]); |
||
265 | check = false; |
||
266 | } |
||
267 | }*/ |
||
268 | ccf944bb | ljiyeon | |
269 | 6707a5c7 | ljiyeon | if (check == true) |
270 | { |
||
271 | XmlElement xmlEle1, xmlEle2, xmlEle3, xmlEle4, xmlEle5, xmlEle6; |
||
272 | XmlNode newNode; |
||
273 | newNode = xmlDoc.SelectSingleNode("Root"); |
||
274 | xmlEle1 = xmlDoc.CreateElement("CommentID"); |
||
275 | xmlEle1.SetAttribute("Value", CommentID); |
||
276 | newNode.AppendChild(xmlEle1); |
||
277 | |||
278 | xmlEle2 = xmlDoc.CreateElement("ConvertData"); |
||
279 | xmlEle2.InnerText = ""; |
||
280 | xmlEle1.AppendChild(xmlEle2); |
||
281 | |||
282 | xmlEle3 = xmlDoc.CreateElement("DATA_TYPE"); |
||
283 | xmlEle3.InnerText = ""; |
||
284 | xmlEle1.AppendChild(xmlEle3); |
||
285 | |||
286 | xmlEle4 = xmlDoc.CreateElement("MarkupInfoID"); |
||
287 | xmlEle4.InnerText = ""; |
||
288 | xmlEle1.AppendChild(xmlEle4); |
||
289 | |||
290 | xmlEle5 = xmlDoc.CreateElement("PageNumber"); |
||
291 | xmlEle5.InnerText = PageNumber; |
||
292 | xmlEle1.AppendChild(xmlEle5); |
||
293 | |||
294 | xmlEle6 = xmlDoc.CreateElement("IsUpdate"); |
||
295 | xmlEle6.InnerText = 2.ToString(); |
||
296 | xmlEle1.AppendChild(xmlEle6); |
||
297 | ccf944bb | ljiyeon | } |
298 | 6707a5c7 | ljiyeon | |
299 | xmlDoc.Save(FilePath); |
||
300 | xmlDoc = null; |
||
301 | } |
||
302 | ccf944bb | ljiyeon | } |
303 | } |