markus / KCOM / Common / TempFile.cs @ 68daae12
이력 | 보기 | 이력해설 | 다운로드 (24.3 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 | 3b484ebb | ljiyeon | using System.Windows.Threading; |
25 | 6707a5c7 | ljiyeon | using System.Xml; |
26 | using System.Xml.Serialization; |
||
27 | ccf944bb | ljiyeon | |
28 | namespace KCOM |
||
29 | 6707a5c7 | ljiyeon | { |
30 | ccf944bb | ljiyeon | public class TempFile |
31 | { |
||
32 | 68daae12 | ljiyeon | //public static string TempFolder = AppDomain.CurrentDomain.BaseDirectory + "Temp"; |
33 | //public static string TempFolder = Path.GetTempPath() + "\\MARKUS"; |
||
34 | //public static string TempFilePath = TempFolder + "\\" + App.ViewInfo.DocumentItemID + ".tmp"; |
||
35 | |||
36 | public static string TempFolder |
||
37 | { |
||
38 | get |
||
39 | { |
||
40 | return Path.Combine(Path.GetTempPath(), "MARKUS"); |
||
41 | } |
||
42 | } |
||
43 | |||
44 | public static string TempFilePath |
||
45 | { |
||
46 | get |
||
47 | { |
||
48 | return Path.Combine(Path.GetTempPath(), "MARKUS\\" + App.ViewInfo.DocumentItemID + ".tmp"); |
||
49 | } |
||
50 | } |
||
51 | 6707a5c7 | ljiyeon | |
52 | 3b484ebb | ljiyeon | internal static void WriteTemp(List<TempDt> tempDtList) |
53 | ccf944bb | ljiyeon | { |
54 | 6707a5c7 | ljiyeon | if (tempDtList.Count > 0) |
55 | ccf944bb | ljiyeon | { |
56 | XmlDocument xmlDoc; |
||
57 | 6707a5c7 | ljiyeon | XmlElement xmlEle1, xmlEle2, xmlEle3, xmlEle4, xmlEle5, xmlEle6; |
58 | ccf944bb | ljiyeon | XmlNode newNode; |
59 | xmlDoc = new XmlDocument(); |
||
60 | |||
61 | 68daae12 | ljiyeon | if ((System.IO.File.Exists(TempFilePath)) == false) |
62 | ccf944bb | ljiyeon | { |
63 | 68daae12 | ljiyeon | if (!File.Exists(TempFolder)) |
64 | 6707a5c7 | ljiyeon | { |
65 | 68daae12 | ljiyeon | Directory.CreateDirectory(TempFolder); |
66 | 6707a5c7 | ljiyeon | } |
67 | |||
68 | ccf944bb | ljiyeon | XmlWriterSettings settings = new XmlWriterSettings(); |
69 | settings.Indent = true; |
||
70 | settings.NewLineOnAttributes = true; |
||
71 | |||
72 | 68daae12 | ljiyeon | XmlWriter xmlWriter = XmlWriter.Create(TempFilePath); |
73 | ccf944bb | ljiyeon | xmlWriter.WriteStartDocument(); |
74 | xmlWriter.WriteStartElement("Root"); |
||
75 | 6707a5c7 | ljiyeon | |
76 | ccf944bb | ljiyeon | xmlWriter.WriteEndDocument(); |
77 | |||
78 | xmlWriter.Flush(); |
||
79 | xmlWriter.Close(); |
||
80 | } |
||
81 | |||
82 | 68daae12 | ljiyeon | xmlDoc.Load(TempFilePath); // XML문서 로딩 |
83 | 6707a5c7 | ljiyeon | var nodes = xmlDoc.SelectNodes("/Root/CommentID"); |
84 | for (int i = 0; i < tempDtList.Count; i++) |
||
85 | { |
||
86 | bool check = true; |
||
87 | ccf944bb | ljiyeon | |
88 | 6707a5c7 | ljiyeon | foreach (XmlNode e in xmlDoc.GetElementsByTagName("CommentID")) |
89 | { |
||
90 | if (e.Attributes["Value"].Value.Equals(tempDtList[i].CommentID)) //CommentID가 같은경우 |
||
91 | { |
||
92 | //데이터 수정 |
||
93 | e.SelectSingleNode("ConvertData").InnerText = tempDtList[i].ConvertData; |
||
94 | e.SelectSingleNode("DATA_TYPE").InnerText = tempDtList[i].DATA_TYPE.ToString(); |
||
95 | e.SelectSingleNode("MarkupInfoID").InnerText = tempDtList[i].MarkupInfoID; |
||
96 | e.SelectSingleNode("PageNumber").InnerText = tempDtList[i].PageNumber.ToString(); |
||
97 | e.SelectSingleNode("IsUpdate").InnerText = tempDtList[i].IsUpdate.ToString(); |
||
98 | ccf944bb | ljiyeon | |
99 | 68daae12 | ljiyeon | xmlDoc.Save(TempFilePath); // XML문서 저장 |
100 | ccf944bb | ljiyeon | |
101 | 6707a5c7 | ljiyeon | check = false; |
102 | break; |
||
103 | } |
||
104 | } |
||
105 | ccf944bb | ljiyeon | |
106 | 6707a5c7 | ljiyeon | if (check == true) |
107 | { |
||
108 | newNode = xmlDoc.SelectSingleNode("Root"); // 추가할 부모 Node 찾기 |
||
109 | xmlEle1 = xmlDoc.CreateElement("CommentID"); |
||
110 | xmlEle1.SetAttribute("Value", tempDtList[i].CommentID); |
||
111 | newNode.AppendChild(xmlEle1); |
||
112 | ccf944bb | ljiyeon | |
113 | 6707a5c7 | ljiyeon | xmlEle2 = xmlDoc.CreateElement("ConvertData"); // 추가할 Node 생성 |
114 | xmlEle2.InnerText = tempDtList[i].ConvertData; |
||
115 | xmlEle1.AppendChild(xmlEle2); |
||
116 | ccf944bb | ljiyeon | |
117 | 6707a5c7 | ljiyeon | xmlEle3 = xmlDoc.CreateElement("DATA_TYPE"); // 추가할 Node 생성 |
118 | xmlEle3.InnerText = tempDtList[i].DATA_TYPE.ToString(); |
||
119 | xmlEle1.AppendChild(xmlEle3); |
||
120 | ccf944bb | ljiyeon | |
121 | 6707a5c7 | ljiyeon | xmlEle4 = xmlDoc.CreateElement("MarkupInfoID"); // 추가할 Node 생성 |
122 | xmlEle4.InnerText = tempDtList[i].MarkupInfoID; |
||
123 | xmlEle1.AppendChild(xmlEle4); |
||
124 | ccf944bb | ljiyeon | |
125 | 6707a5c7 | ljiyeon | xmlEle5 = xmlDoc.CreateElement("PageNumber"); // 추가할 Node 생성 |
126 | xmlEle5.InnerText = tempDtList[i].PageNumber.ToString(); |
||
127 | xmlEle1.AppendChild(xmlEle5); |
||
128 | ccf944bb | ljiyeon | |
129 | 6707a5c7 | ljiyeon | xmlEle6 = xmlDoc.CreateElement("IsUpdate"); |
130 | xmlEle6.InnerText = tempDtList[i].IsUpdate.ToString(); |
||
131 | xmlEle1.AppendChild(xmlEle6); |
||
132 | ccf944bb | ljiyeon | |
133 | 68daae12 | ljiyeon | xmlDoc.Save(TempFilePath); // XML문서 저장.. |
134 | 6707a5c7 | ljiyeon | } |
135 | } |
||
136 | xmlDoc = null; |
||
137 | ccf944bb | ljiyeon | } |
138 | } |
||
139 | 6707a5c7 | ljiyeon | |
140 | public void AddTemp(MarkupToPDF.Common.Undo_data undoDataList, int PageNumber, double x, double y) |
||
141 | ccf944bb | ljiyeon | { |
142 | 6707a5c7 | ljiyeon | XmlDocument xmlDoc; |
143 | XmlElement xmlEle1, xmlEle2, xmlEle3, xmlEle4, xmlEle5, xmlEle6; |
||
144 | XmlNode newNode; |
||
145 | xmlDoc = new XmlDocument(); |
||
146 | ccf944bb | ljiyeon | |
147 | 68daae12 | ljiyeon | if ((System.IO.File.Exists(TempFilePath)) == false) |
148 | 6707a5c7 | ljiyeon | { |
149 | 68daae12 | ljiyeon | if (!File.Exists(TempFolder)) |
150 | ccf944bb | ljiyeon | { |
151 | 68daae12 | ljiyeon | Directory.CreateDirectory(TempFolder); |
152 | 6707a5c7 | ljiyeon | } |
153 | ccf944bb | ljiyeon | |
154 | 6707a5c7 | ljiyeon | XmlWriterSettings settings = new XmlWriterSettings(); |
155 | settings.Indent = true; |
||
156 | settings.NewLineOnAttributes = true; |
||
157 | ccf944bb | ljiyeon | |
158 | 68daae12 | ljiyeon | XmlWriter xmlWriter = XmlWriter.Create(TempFilePath); |
159 | 6707a5c7 | ljiyeon | xmlWriter.WriteStartDocument(); |
160 | xmlWriter.WriteStartElement("Root"); |
||
161 | |||
162 | xmlWriter.WriteEndDocument(); |
||
163 | ccf944bb | ljiyeon | |
164 | 6707a5c7 | ljiyeon | xmlWriter.Flush(); |
165 | xmlWriter.Close(); |
||
166 | ccf944bb | ljiyeon | } |
167 | 6707a5c7 | ljiyeon | |
168 | 68daae12 | ljiyeon | xmlDoc.Load(TempFilePath); // XML문서 로딩 |
169 | 6707a5c7 | ljiyeon | var nodes = xmlDoc.SelectNodes("/Root/CommentID"); |
170 | for (int i = 0; i < undoDataList.Markup_List.Count; i++) |
||
171 | ccf944bb | ljiyeon | { |
172 | 036650a0 | humkyung | var root = MarkupParser.MarkupToString(undoDataList.Markup_List[i].Markup, App.ViewInfo.UserID); |
173 | 6707a5c7 | ljiyeon | bool check = true; |
174 | |||
175 | foreach (XmlNode e in xmlDoc.GetElementsByTagName("CommentID")) |
||
176 | { |
||
177 | if (e.Attributes["Value"].Value.Equals(root.CommentID)) //CommentID가 같은경우 |
||
178 | { |
||
179 | //데이터 수정 |
||
180 | e.SelectSingleNode("ConvertData").InnerText = root.ConvertData; |
||
181 | e.SelectSingleNode("DATA_TYPE").InnerText = root.DATA_TYPE.ToString(); |
||
182 | e.SelectSingleNode("MarkupInfoID").InnerText = undoDataList.Markup_List[i].Markup.MarkupInfoID; |
||
183 | e.SelectSingleNode("PageNumber").InnerText = PageNumber.ToString(); |
||
184 | e.SelectSingleNode("IsUpdate").InnerText = 1.ToString(); |
||
185 | ccf944bb | ljiyeon | |
186 | 68daae12 | ljiyeon | xmlDoc.Save(TempFilePath); // XML문서 저장 |
187 | ccf944bb | ljiyeon | |
188 | 6707a5c7 | ljiyeon | check = false; |
189 | break; |
||
190 | } |
||
191 | } |
||
192 | ccf944bb | ljiyeon | |
193 | 6707a5c7 | ljiyeon | if (check == true) |
194 | ccf944bb | ljiyeon | { |
195 | 6707a5c7 | ljiyeon | newNode = xmlDoc.SelectSingleNode("Root"); |
196 | xmlEle1 = xmlDoc.CreateElement("CommentID"); |
||
197 | xmlEle1.SetAttribute("Value", root.CommentID); |
||
198 | newNode.AppendChild(xmlEle1); |
||
199 | ccf944bb | ljiyeon | |
200 | 6707a5c7 | ljiyeon | xmlEle2 = xmlDoc.CreateElement("ConvertData"); |
201 | xmlEle2.InnerText = root.ConvertData; |
||
202 | xmlEle1.AppendChild(xmlEle2); |
||
203 | ccf944bb | ljiyeon | |
204 | 6707a5c7 | ljiyeon | xmlEle3 = xmlDoc.CreateElement("DATA_TYPE"); |
205 | xmlEle3.InnerText = root.DATA_TYPE.ToString(); |
||
206 | xmlEle1.AppendChild(xmlEle3); |
||
207 | ccf944bb | ljiyeon | |
208 | 6707a5c7 | ljiyeon | xmlEle4 = xmlDoc.CreateElement("MarkupInfoID"); |
209 | xmlEle4.InnerText = undoDataList.Markup_List[i].Markup.MarkupInfoID; |
||
210 | xmlEle1.AppendChild(xmlEle4); |
||
211 | ccf944bb | ljiyeon | |
212 | 6707a5c7 | ljiyeon | xmlEle5 = xmlDoc.CreateElement("PageNumber"); |
213 | xmlEle5.InnerText = PageNumber.ToString(); |
||
214 | xmlEle1.AppendChild(xmlEle5); |
||
215 | ccf944bb | ljiyeon | |
216 | 6707a5c7 | ljiyeon | xmlEle6 = xmlDoc.CreateElement("IsUpdate"); |
217 | xmlEle6.InnerText = 1.ToString(); |
||
218 | xmlEle1.AppendChild(xmlEle6); |
||
219 | ccf944bb | ljiyeon | |
220 | 68daae12 | ljiyeon | xmlDoc.Save(TempFilePath); |
221 | ccf944bb | ljiyeon | } |
222 | 6707a5c7 | ljiyeon | } |
223 | xmlDoc = null; |
||
224 | } |
||
225 | ccf944bb | ljiyeon | |
226 | a20d338f | ljiyeon | public static void Remove() |
227 | 6707a5c7 | ljiyeon | { |
228 | 68daae12 | ljiyeon | FileInfo fileDel = new FileInfo(TempFilePath); |
229 | 6707a5c7 | ljiyeon | if (fileDel.Exists) |
230 | { |
||
231 | fileDel.Delete(); |
||
232 | } |
||
233 | } |
||
234 | ccf944bb | ljiyeon | |
235 | a20d338f | ljiyeon | internal static void DelTemp(string CommentID, string PageNumber) //Control 삭제시 |
236 | 6707a5c7 | ljiyeon | { |
237 | 68daae12 | ljiyeon | if ((System.IO.File.Exists(TempFilePath)) == false) |
238 | 6707a5c7 | ljiyeon | { |
239 | 68daae12 | ljiyeon | if (!File.Exists(TempFolder)) |
240 | 6707a5c7 | ljiyeon | { |
241 | 68daae12 | ljiyeon | Directory.CreateDirectory(TempFolder); |
242 | 6707a5c7 | ljiyeon | } |
243 | ccf944bb | ljiyeon | |
244 | 6707a5c7 | ljiyeon | XmlWriterSettings settings = new XmlWriterSettings(); |
245 | settings.Indent = true; |
||
246 | settings.NewLineOnAttributes = true; |
||
247 | ccf944bb | ljiyeon | |
248 | 68daae12 | ljiyeon | XmlWriter xmlWriter = XmlWriter.Create(TempFilePath); |
249 | 6707a5c7 | ljiyeon | xmlWriter.WriteStartDocument(); |
250 | xmlWriter.WriteStartElement("Root"); |
||
251 | ccf944bb | ljiyeon | |
252 | 6707a5c7 | ljiyeon | xmlWriter.WriteEndDocument(); |
253 | ccf944bb | ljiyeon | |
254 | 6707a5c7 | ljiyeon | xmlWriter.Flush(); |
255 | xmlWriter.Close(); |
||
256 | } |
||
257 | ccf944bb | ljiyeon | |
258 | 6707a5c7 | ljiyeon | XmlDocument xmlDoc; |
259 | xmlDoc = new XmlDocument(); |
||
260 | 68daae12 | ljiyeon | xmlDoc.Load(TempFilePath); |
261 | ccf944bb | ljiyeon | |
262 | 6707a5c7 | ljiyeon | var nodes = xmlDoc.SelectNodes("/Root/CommentID"); |
263 | XmlElement root = xmlDoc.DocumentElement; |
||
264 | ccf944bb | ljiyeon | |
265 | 6707a5c7 | ljiyeon | bool check = true; |
266 | ccf944bb | ljiyeon | |
267 | 6707a5c7 | ljiyeon | /* |
268 | foreach (XmlNode node in nodes) |
||
269 | ccf944bb | ljiyeon | { |
270 | 6707a5c7 | ljiyeon | string sCommentID = node.Attributes["Value"].Value; |
271 | |||
272 | if (sCommentID == CommentID) |
||
273 | { |
||
274 | root.RemoveChild(xmlDoc.SelectNodes("//CommentID[@Value='" + CommentID + "']")[0]); |
||
275 | check = false; |
||
276 | } |
||
277 | }*/ |
||
278 | ccf944bb | ljiyeon | |
279 | 6707a5c7 | ljiyeon | if (check == true) |
280 | { |
||
281 | XmlElement xmlEle1, xmlEle2, xmlEle3, xmlEle4, xmlEle5, xmlEle6; |
||
282 | XmlNode newNode; |
||
283 | newNode = xmlDoc.SelectSingleNode("Root"); |
||
284 | xmlEle1 = xmlDoc.CreateElement("CommentID"); |
||
285 | xmlEle1.SetAttribute("Value", CommentID); |
||
286 | newNode.AppendChild(xmlEle1); |
||
287 | |||
288 | xmlEle2 = xmlDoc.CreateElement("ConvertData"); |
||
289 | xmlEle2.InnerText = ""; |
||
290 | xmlEle1.AppendChild(xmlEle2); |
||
291 | |||
292 | xmlEle3 = xmlDoc.CreateElement("DATA_TYPE"); |
||
293 | xmlEle3.InnerText = ""; |
||
294 | xmlEle1.AppendChild(xmlEle3); |
||
295 | |||
296 | xmlEle4 = xmlDoc.CreateElement("MarkupInfoID"); |
||
297 | xmlEle4.InnerText = ""; |
||
298 | xmlEle1.AppendChild(xmlEle4); |
||
299 | |||
300 | xmlEle5 = xmlDoc.CreateElement("PageNumber"); |
||
301 | xmlEle5.InnerText = PageNumber; |
||
302 | xmlEle1.AppendChild(xmlEle5); |
||
303 | |||
304 | xmlEle6 = xmlDoc.CreateElement("IsUpdate"); |
||
305 | xmlEle6.InnerText = 2.ToString(); |
||
306 | xmlEle1.AppendChild(xmlEle6); |
||
307 | ccf944bb | ljiyeon | } |
308 | 6707a5c7 | ljiyeon | |
309 | 68daae12 | ljiyeon | xmlDoc.Save(TempFilePath); |
310 | 6707a5c7 | ljiyeon | xmlDoc = null; |
311 | } |
||
312 | 3b484ebb | ljiyeon | |
313 | public class TempLoadData |
||
314 | { |
||
315 | public int PageNumber { get; set; } |
||
316 | public string CommentID { get; set; } |
||
317 | public string ConvertData { get; set; } |
||
318 | public string DATA_TYPE { get; set; } |
||
319 | public string MarkupInfoID { get; set; } |
||
320 | public int IsUpdate { get; set; } |
||
321 | } |
||
322 | |||
323 | static List<TempLoadData> tempLoadData = new List<TempLoadData>(); |
||
324 | |||
325 | |||
326 | public static Undo_data UndoData { get; set; } |
||
327 | |||
328 | public class TempDt |
||
329 | { |
||
330 | public int PageNumber { get; set; } |
||
331 | public string CommentID { get; set; } |
||
332 | public string ConvertData { get; set; } |
||
333 | public int DATA_TYPE { get; set; } |
||
334 | public string MarkupInfoID { get; set; } |
||
335 | public int IsUpdate { get; set; } |
||
336 | } |
||
337 | |||
338 | public static List<TempDt> tempDtList = new List<TempDt>(); |
||
339 | |||
340 | public static void TempLoad() |
||
341 | { |
||
342 | 68daae12 | ljiyeon | if ((System.IO.File.Exists(TempFilePath)) == true) |
343 | 3b484ebb | ljiyeon | { |
344 | XmlDocument xdoc = new XmlDocument(); |
||
345 | 68daae12 | ljiyeon | xdoc.Load(TempFilePath); |
346 | 3b484ebb | ljiyeon | XmlNodeList nodes = xdoc.SelectNodes("/Root/CommentID"); |
347 | int PageNumber = 0; |
||
348 | if (nodes.Count > 0) |
||
349 | { |
||
350 | if (MessageBox.Show("저장하지 못한 데이터가 있습니다. 불러오시겠습니까?", "MARKUS", MessageBoxButton.OKCancel) == MessageBoxResult.OK) |
||
351 | { |
||
352 | foreach (XmlNode node in nodes) |
||
353 | { |
||
354 | string CommentID = node.Attributes["Value"].Value; |
||
355 | string ConvertData = node.SelectSingleNode("ConvertData").InnerText; |
||
356 | string DATA_TYPE = node.SelectSingleNode("DATA_TYPE").InnerText; |
||
357 | string MarkupInfoID = node.SelectSingleNode("MarkupInfoID").InnerText; |
||
358 | int IsUpdate = Convert.ToInt32(node.SelectSingleNode("IsUpdate").InnerText); |
||
359 | PageNumber = Convert.ToInt32(node.SelectSingleNode("PageNumber").InnerText); |
||
360 | |||
361 | tempLoadData.Add(new TempLoadData() |
||
362 | { |
||
363 | PageNumber = PageNumber, |
||
364 | CommentID = CommentID, |
||
365 | ConvertData = ConvertData, |
||
366 | DATA_TYPE = DATA_TYPE, |
||
367 | MarkupInfoID = MarkupInfoID, |
||
368 | IsUpdate = IsUpdate |
||
369 | }); |
||
370 | } |
||
371 | |||
372 | if (PageNumber > 0) |
||
373 | { |
||
374 | Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.GotoPage(PageNumber); |
||
375 | } |
||
376 | |||
377 | // Temp Object add |
||
378 | if (Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber == PageNumber) |
||
379 | { |
||
380 | TempControlLoad(); |
||
381 | } |
||
382 | tempLoadData.Clear(); |
||
383 | } |
||
384 | } |
||
385 | else //파일 삭제 |
||
386 | { |
||
387 | TempFile.Remove(); |
||
388 | } |
||
389 | } |
||
390 | } |
||
391 | |||
392 | |||
393 | //Temp Control Load |
||
394 | public static void TempControlLoad() |
||
395 | { |
||
396 | List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>(); |
||
397 | |||
398 | for (int k = 0; k < tempLoadData.Count; k++) |
||
399 | { |
||
400 | System.Windows.Controls.Control item = null; |
||
401 | Multi_Undo_data multi_Undo_Data; |
||
402 | |||
403 | |||
404 | switch (tempLoadData[k].IsUpdate) |
||
405 | { |
||
406 | case 0://추가 |
||
407 | var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.CommentID == tempLoadData[k].CommentID).FirstOrDefault(); |
||
408 | if (control != null) |
||
409 | { |
||
410 | ViewerDataModel.Instance.MarkupControls_USER.Remove(control); |
||
411 | var Item_ = ViewerDataModel.Instance.MarkupList_USER.Where(d => d.ID == (control as MarkupToPDF.Common.CommentUserInfo).CommentID).FirstOrDefault(); |
||
412 | ViewerDataModel.Instance.MarkupList_USER.Remove(Item_); |
||
413 | } |
||
414 | |||
415 | //Control |
||
416 | item = MarkupParser.ParseEx(App.ViewInfo.ProjectNO, tempLoadData[k].ConvertData, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", tempLoadData[k].MarkupInfoID, tempLoadData[k].CommentID); |
||
417 | |||
418 | UndoData = new Undo_data() |
||
419 | { |
||
420 | IsUndo = false, |
||
421 | Event = Event_Type.Create, |
||
422 | EventTime = DateTime.Now, |
||
423 | Opacity = ViewerDataModel.Instance.ControlOpacity, |
||
424 | Markup_List = new List<Multi_Undo_data>() |
||
425 | }; |
||
426 | |||
427 | multi_Undo_Data = new Multi_Undo_data(); |
||
428 | multi_Undo_Data = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(item as MarkupToPDF.Common.CommentUserInfo); |
||
429 | UndoData.Markup_List.Add(multi_Undo_Data); |
||
430 | ViewerDataModel.Instance.UndoDataList.Add(UndoData); |
||
431 | break; |
||
432 | case 1://수정 |
||
433 | control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.CommentID == tempLoadData[k].CommentID).FirstOrDefault(); |
||
434 | if (control != null) |
||
435 | { |
||
436 | ViewerDataModel.Instance.MarkupControls_USER.Remove(control); |
||
437 | var Item_ = ViewerDataModel.Instance.MarkupList_USER.Where(d => d.ID == (control as MarkupToPDF.Common.CommentUserInfo).CommentID).FirstOrDefault(); |
||
438 | ViewerDataModel.Instance.MarkupList_USER.Remove(Item_); |
||
439 | } |
||
440 | |||
441 | //Control |
||
442 | item = MarkupParser.ParseEx(App.ViewInfo.ProjectNO, tempLoadData[k].ConvertData, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", tempLoadData[k].MarkupInfoID, tempLoadData[k].CommentID); |
||
443 | |||
444 | UndoData = new Undo_data() |
||
445 | { |
||
446 | IsUndo = false, |
||
447 | Event = Event_Type.Thumb, |
||
448 | EventTime = DateTime.Now, |
||
449 | Opacity = ViewerDataModel.Instance.ControlOpacity, |
||
450 | Markup_List = new List<Multi_Undo_data>() |
||
451 | }; |
||
452 | |||
453 | multi_Undo_Data = new Multi_Undo_data(); |
||
454 | multi_Undo_Data = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(item as MarkupToPDF.Common.CommentUserInfo); |
||
455 | UndoData.Markup_List.Add(multi_Undo_Data); |
||
456 | ViewerDataModel.Instance.UndoDataList.Add(UndoData); |
||
457 | break; |
||
458 | case 2://삭제 |
||
459 | |||
460 | control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.CommentID == tempLoadData[k].CommentID).FirstOrDefault(); |
||
461 | if (control != null) |
||
462 | { |
||
463 | ViewerDataModel.Instance.MarkupControls_USER.Remove(control); |
||
464 | var Item_ = ViewerDataModel.Instance.MarkupList_USER.Where(d => d.ID == (control as MarkupToPDF.Common.CommentUserInfo).CommentID).FirstOrDefault(); |
||
465 | ViewerDataModel.Instance.MarkupList_USER.Remove(Item_); |
||
466 | } |
||
467 | break; |
||
468 | } |
||
469 | } |
||
470 | } |
||
471 | // public static Dispatcher Dispatcher { get; } |
||
472 | public static void TempFileAdd() |
||
473 | { |
||
474 | System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate |
||
475 | { |
||
476 | if (ViewerDataModel.Instance.UndoDataList.Count > 0) |
||
477 | { |
||
478 | DateTime undoTime = ViewerDataModel.Instance.UndoDataList.OrderByDescending(order => order.EventTime).FirstOrDefault().EventTime; |
||
479 | DateTime updatetime = DateTime.Now.AddDays(-1); |
||
480 | if (ViewerDataModel.Instance._markupInfoList.Count > 0) |
||
481 | { |
||
482 | updatetime = ViewerDataModel.Instance._markupInfoList.OrderByDescending(order => order.UpdateTime).FirstOrDefault().UpdateTime; |
||
483 | } |
||
484 | |||
485 | Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.EmptyControlCheck(); |
||
486 | |||
487 | if (undoTime > updatetime) |
||
488 | { |
||
489 | if (ViewerDataModel.Instance.MarkupControls_USER.Count > 0) |
||
490 | { |
||
491 | foreach (var control in ViewerDataModel.Instance.MarkupControls_USER) |
||
492 | { |
||
493 | var root = MarkupParser.MarkupToString(control, App.ViewInfo.UserID); |
||
494 | |||
495 | var existItem = ViewerDataModel.Instance.MarkupList_USER.Where(data => data.ID == root.CommentID).FirstOrDefault(); |
||
496 | if (existItem != null) |
||
497 | { |
||
498 | if (existItem.Data != root.ConvertData) |
||
499 | { |
||
500 | tempDtList.Add(new TempDt() |
||
501 | { |
||
502 | CommentID = control.CommentID, |
||
503 | ConvertData = root.ConvertData, |
||
504 | DATA_TYPE = root.DATA_TYPE, |
||
505 | MarkupInfoID = App.Custom_ViewInfoId, |
||
506 | PageNumber = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber, |
||
507 | IsUpdate = 1 |
||
508 | }); |
||
509 | } |
||
510 | } |
||
511 | else //신규 추가 된 코멘트 |
||
512 | { |
||
513 | if (root.CommentID != null) |
||
514 | { |
||
515 | var currentCommentCheck = ViewerDataModel.Instance.MarkupList_USER.Where(dt => dt.ID == control.CommentID).FirstOrDefault(); |
||
516 | if (currentCommentCheck != null) |
||
517 | { |
||
518 | tempDtList.Add(new TempDt() |
||
519 | { |
||
520 | CommentID = control.CommentID, |
||
521 | ConvertData = root.ConvertData, |
||
522 | DATA_TYPE = root.DATA_TYPE, |
||
523 | MarkupInfoID = App.Custom_ViewInfoId, |
||
524 | PageNumber = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber, |
||
525 | IsUpdate = 1 |
||
526 | }); |
||
527 | } |
||
528 | else |
||
529 | { |
||
530 | tempDtList.Add(new TempDt() |
||
531 | { |
||
532 | CommentID = control.CommentID, |
||
533 | ConvertData = root.ConvertData, |
||
534 | DATA_TYPE = root.DATA_TYPE, |
||
535 | MarkupInfoID = App.Custom_ViewInfoId, |
||
536 | PageNumber = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber, |
||
537 | IsUpdate = 0 |
||
538 | }); |
||
539 | } |
||
540 | } |
||
541 | } |
||
542 | } |
||
543 | } |
||
544 | |||
545 | WriteTemp(tempDtList); |
||
546 | tempDtList.Clear(); |
||
547 | } |
||
548 | } |
||
549 | })); |
||
550 | |||
551 | } |
||
552 | |||
553 | 68daae12 | ljiyeon | //public static string TempFolder = System.IO.Path.GetTempPath() + "\\MARKUS\\" + App.ViewInfo.DocumentItemID + ".tmp"; |
554 | 3b484ebb | ljiyeon | |
555 | } |
||
556 | ccf944bb | ljiyeon | } |