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