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