markus / KCOM / Events / SaveCommand.cs @ 490208bd
이력 | 보기 | 이력해설 | 다운로드 (6.43 KB)
1 | 787a4489 | KangIngu | using IKCOM; |
---|---|---|---|
2 | using KCOM.Common; |
||
3 | using KCOMDataModel.Common; |
||
4 | using KCOMDataModel.DataModel; |
||
5 | using MarkupToPDF.Common; |
||
6 | using MarkupToPDF.Controls.Parsing; |
||
7 | using System; |
||
8 | using System.Collections.Generic; |
||
9 | c00d0547 | humkyung | using System.Collections.ObjectModel; |
10 | 787a4489 | KangIngu | using System.Linq; |
11 | using System.Text; |
||
12 | b42dd24d | taeseongkim | using System.Threading.Tasks; |
13 | 787a4489 | KangIngu | using System.Windows.Controls; |
14 | 6a19b48d | taeseongkim | using System.Windows.Input; |
15 | 787a4489 | KangIngu | |
16 | namespace KCOM.Events |
||
17 | { |
||
18 | de6499db | humkyung | public class SaveCommand |
19 | 787a4489 | KangIngu | { |
20 | de6499db | humkyung | private static readonly SaveCommand _instance = new SaveCommand(); |
21 | |||
22 | // Explicit static constructor to tell C# compiler |
||
23 | // not to mark type as beforefieldinit |
||
24 | static SaveCommand() |
||
25 | { |
||
26 | } |
||
27 | |||
28 | private SaveCommand() |
||
29 | { |
||
30 | } |
||
31 | |||
32 | public static SaveCommand Instance |
||
33 | { |
||
34 | get |
||
35 | { |
||
36 | return _instance; |
||
37 | } |
||
38 | } |
||
39 | |||
40 | 787a4489 | KangIngu | #region Properties |
41 | |||
42 | public ViewInfo _ViewInfo; |
||
43 | public string Project_No |
||
44 | { |
||
45 | get; |
||
46 | set; |
||
47 | } |
||
48 | public string document_id |
||
49 | { |
||
50 | get; |
||
51 | set; |
||
52 | } |
||
53 | |||
54 | public string user_id |
||
55 | { |
||
56 | get; |
||
57 | set; |
||
58 | } |
||
59 | |||
60 | public int page_no |
||
61 | { |
||
62 | get; |
||
63 | set; |
||
64 | } |
||
65 | #endregion |
||
66 | |||
67 | de6499db | humkyung | /// <summary> |
68 | /// save comments related to given markup information |
||
69 | /// </summary> |
||
70 | /// <param name="UserState"></param> |
||
71 | /// <param name="iPageNo"></param> |
||
72 | b42dd24d | taeseongkim | public async Task<bool> Execute(ICollection<MarkupInfoItem> UserStates) |
73 | 787a4489 | KangIngu | { |
74 | b42dd24d | taeseongkim | bool result = false; |
75 | |||
76 | 6c781c0c | djkim | try |
77 | 787a4489 | KangIngu | { |
78 | eeb0a39c | taeseongkim | var mainmenu = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu; |
79 | |||
80 | de6499db | humkyung | foreach (var UserState in UserStates) |
81 | 787a4489 | KangIngu | { |
82 | de6499db | humkyung | List<MARKUP_DATA> markupdata = new List<MARKUP_DATA>(); |
83 | b2d0f316 | humkyung | ViewerDataModel.Instance.MyMarkupList.Where(d => d.MarkupInfoID == UserState.MarkupInfoID).ToList() |
84 | .GroupBy(p => p.ID).Select(g => g.First()) |
||
85 | .OrderBy(x => x.ZIndex).ToList().ForEach(value => |
||
86 | de6499db | humkyung | { |
87 | c00d0547 | humkyung | markupdata.Add(new MARKUP_DATA() |
88 | { |
||
89 | ID = value.ID, |
||
90 | PAGENUMBER = value.PageNumber, |
||
91 | DATA = value.Data, |
||
92 | MARKUPINFO_VERSION_ID = UserState.MarkupVersionID, |
||
93 | DATA_TYPE = value.Data_Type |
||
94 | }); |
||
95 | 6a19b48d | taeseongkim | System.Diagnostics.Debug.WriteLine(value.ID); |
96 | de6499db | humkyung | }); |
97 | 6b6e937c | taeseongkim | |
98 | 2b1f30fe | taeseongkim | try |
99 | { |
||
100 | var SaveResult = await ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseTaskClient.SaveMarkupDataAsync(UserState, Project_No, document_id, user_id, markupdata); |
||
101 | result = SaveResult; |
||
102 | } |
||
103 | catch(Exception ex) |
||
104 | { |
||
105 | b2d0f316 | humkyung | #region 저장에 실패했을때 다시 시도한다.(다시 시도한다고 될까?) |
106 | 2b1f30fe | taeseongkim | var client = new KcomService.ServiceDeepViewClient(App._binding, App._EndPoint); |
107 | var SaveResult = await client.SaveMarkupDataAsync(UserState, Project_No, document_id, user_id, markupdata); |
||
108 | result = SaveResult; |
||
109 | b2d0f316 | humkyung | #endregion |
110 | 2b1f30fe | taeseongkim | |
111 | if (!SaveResult) |
||
112 | { |
||
113 | Logger.sendResLog("SaveCommand.Instance.Execute", ex.ToString(), 1); |
||
114 | } |
||
115 | } |
||
116 | b42dd24d | taeseongkim | |
117 | 664ea2e1 | taeseongkim | //Logger.sendResLog("SaveCommand.Instance.Execute" , $"SaveMarkupData Call Project : {Project_No} DocID :{document_id} User ID {user_id} result {SaveResult}",1); |
118 | 6b6e937c | taeseongkim | |
119 | eeb0a39c | taeseongkim | mainmenu.MarkupitemViewUpdate(UserState.MarkupInfoID); |
120 | de6499db | humkyung | } |
121 | 073f6118 | djkim | //User Information List Rebind |
122 | eeb0a39c | taeseongkim | |
123 | mainmenu.gridViewMarkup.Rebind(); |
||
124 | 2b1f30fe | taeseongkim | //TempFile.Remove(); //임시파일삭제 |
125 | 787a4489 | KangIngu | } |
126 | b2d0f316 | humkyung | catch (Exception ex) |
127 | 6c781c0c | djkim | { |
128 | b2d0f316 | humkyung | throw new InvalidOperationException(ex.Message); |
129 | 6c781c0c | djkim | } |
130 | b42dd24d | taeseongkim | |
131 | return result; |
||
132 | 787a4489 | KangIngu | } |
133 | |||
134 | public void SymbolSave(string Name, string Url, string Data) |
||
135 | { |
||
136 | 6c781c0c | djkim | try |
137 | 787a4489 | KangIngu | { |
138 | SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE |
||
139 | { |
||
140 | 5a223b60 | humkyung | ID = Commons.ShortGuid(), |
141 | 787a4489 | KangIngu | MEMBER_USER_ID = App.ViewInfo.UserID, |
142 | NAME = Name, |
||
143 | IMAGE_URL = Url, |
||
144 | DATA = Data |
||
145 | }; |
||
146 | 0f065e57 | ljiyeon | |
147 | 664ea2e1 | taeseongkim | //Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1); |
148 | 6c781c0c | djkim | Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private); |
149 | } |
||
150 | catch(Exception) |
||
151 | { |
||
152 | throw; |
||
153 | } |
||
154 | } |
||
155 | 498f0fc9 | ljiyeon | public void SymbolSave_Public(string Name, string Url, string Data, string Department) |
156 | { |
||
157 | try |
||
158 | { |
||
159 | SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC |
||
160 | { |
||
161 | 5a223b60 | humkyung | ID = Commons.ShortGuid(), |
162 | 498f0fc9 | ljiyeon | DEPARTMENT = Department, |
163 | NAME = Name, |
||
164 | IMAGE_URL = Url, |
||
165 | DATA = Data |
||
166 | }; |
||
167 | 787a4489 | KangIngu | |
168 | 664ea2e1 | taeseongkim | //Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1); |
169 | 498f0fc9 | ljiyeon | Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public); |
170 | } |
||
171 | catch (Exception) |
||
172 | { |
||
173 | throw; |
||
174 | } |
||
175 | } |
||
176 | 129ca191 | humkyung | |
177 | eeb0a39c | taeseongkim | public async void PageAngleSave(string project_no, List<DOCPAGE> _mldocpage) |
178 | 6c781c0c | djkim | { |
179 | try |
||
180 | { |
||
181 | eeb0a39c | taeseongkim | var result = await Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseTaskClient.SavePageAngleAsync(project_no, _mldocpage); |
182 | b2c6901f | swate0609 | Common.ViewerDataModel.Instance.RotationDocs.Clear(); |
183 | eeb0a39c | taeseongkim | |
184 | 664ea2e1 | taeseongkim | //Logger.sendReqLog("SavePageAngle: ", project_no + "," + _mldocpage, 1); |
185 | //Logger.sendResLog("SavePageAngle", result.ToString(), 1); |
||
186 | eeb0a39c | taeseongkim | |
187 | 6c781c0c | djkim | } |
188 | catch (Exception) |
||
189 | { |
||
190 | throw; |
||
191 | 787a4489 | KangIngu | } |
192 | } |
||
193 | } |
||
194 | } |