markus / KCOM / Events / SaveCommand.cs @ fd19a116
이력 | 보기 | 이력해설 | 다운로드 (6.43 KB)
1 |
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 |
using System.Collections.ObjectModel; |
10 |
using System.Linq; |
11 |
using System.Text; |
12 |
using System.Threading.Tasks; |
13 |
using System.Windows.Controls; |
14 |
using System.Windows.Input; |
15 |
|
16 |
namespace KCOM.Events |
17 |
{ |
18 |
public class SaveCommand |
19 |
{ |
20 |
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 |
#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 |
/// <summary> |
68 |
/// save comments related to given markup information |
69 |
/// </summary> |
70 |
/// <param name="UserState"></param> |
71 |
/// <param name="iPageNo"></param> |
72 |
public async Task<bool> Execute(ICollection<MarkupInfoItem> UserStates) |
73 |
{ |
74 |
bool result = false; |
75 |
|
76 |
try |
77 |
{ |
78 |
var mainmenu = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu; |
79 |
|
80 |
foreach (var UserState in UserStates) |
81 |
{ |
82 |
List<MARKUP_DATA> markupdata = new List<MARKUP_DATA>(); |
83 |
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 |
{ |
87 |
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 |
System.Diagnostics.Debug.WriteLine(value.ID); |
96 |
}); |
97 |
|
98 |
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 |
#region 저장에 실패했을때 다시 시도한다.(다시 시도한다고 될까?) |
106 |
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 |
#endregion |
110 |
|
111 |
if (!SaveResult) |
112 |
{ |
113 |
Logger.sendResLog("SaveCommand.Instance.Execute", ex.ToString(), 1); |
114 |
} |
115 |
} |
116 |
|
117 |
//Logger.sendResLog("SaveCommand.Instance.Execute" , $"SaveMarkupData Call Project : {Project_No} DocID :{document_id} User ID {user_id} result {SaveResult}",1); |
118 |
|
119 |
mainmenu.MarkupitemViewUpdate(UserState.MarkupInfoID); |
120 |
} |
121 |
//User Information List Rebind |
122 |
|
123 |
mainmenu.gridViewMarkup.Rebind(); |
124 |
//TempFile.Remove(); //임시파일삭제 |
125 |
} |
126 |
catch (Exception ex) |
127 |
{ |
128 |
throw new InvalidOperationException(ex.Message); |
129 |
} |
130 |
|
131 |
return result; |
132 |
} |
133 |
|
134 |
public void SymbolSave(string Name, string Url, string Data) |
135 |
{ |
136 |
try |
137 |
{ |
138 |
SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE |
139 |
{ |
140 |
ID = Commons.ShortGuid(), |
141 |
MEMBER_USER_ID = App.ViewInfo.UserID, |
142 |
NAME = Name, |
143 |
IMAGE_URL = Url, |
144 |
DATA = Data |
145 |
}; |
146 |
|
147 |
//Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1); |
148 |
Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private); |
149 |
} |
150 |
catch(Exception) |
151 |
{ |
152 |
throw; |
153 |
} |
154 |
} |
155 |
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 |
ID = Commons.ShortGuid(), |
162 |
DEPARTMENT = Department, |
163 |
NAME = Name, |
164 |
IMAGE_URL = Url, |
165 |
DATA = Data |
166 |
}; |
167 |
|
168 |
//Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1); |
169 |
Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public); |
170 |
} |
171 |
catch (Exception) |
172 |
{ |
173 |
throw; |
174 |
} |
175 |
} |
176 |
|
177 |
public async void PageAngleSave(string project_no, List<DOCPAGE> _mldocpage) |
178 |
{ |
179 |
try |
180 |
{ |
181 |
var result = await Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseTaskClient.SavePageAngleAsync(project_no, _mldocpage); |
182 |
Common.ViewerDataModel.Instance.RotationDocs.Clear(); |
183 |
|
184 |
//Logger.sendReqLog("SavePageAngle: ", project_no + "," + _mldocpage, 1); |
185 |
//Logger.sendResLog("SavePageAngle", result.ToString(), 1); |
186 |
|
187 |
} |
188 |
catch (Exception) |
189 |
{ |
190 |
throw; |
191 |
} |
192 |
} |
193 |
} |
194 |
} |