markus / KCOM / Events / SaveCommand.cs @ 5c64268e
이력 | 보기 | 이력해설 | 다운로드 (5.68 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 |
public void MarkupConsolidate() |
68 |
{ |
69 |
|
70 |
} |
71 |
|
72 |
/// <summary> |
73 |
/// save comments related to given markup information |
74 |
/// </summary> |
75 |
/// <param name="UserState"></param> |
76 |
/// <param name="iPageNo"></param> |
77 |
public async Task<bool> Execute(ICollection<MarkupInfoItem> UserStates) |
78 |
{ |
79 |
bool result = false; |
80 |
|
81 |
try |
82 |
{ |
83 |
var mainmenu = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu; |
84 |
//var client = mainmenu.BaseClient; |
85 |
|
86 |
foreach (var UserState in UserStates) |
87 |
{ |
88 |
List<MARKUP_DATA> markupdata = new List<MARKUP_DATA>(); |
89 |
ViewerDataModel.Instance.MyMarkupList.Where(d => d.MarkupInfoID == UserState.MarkupInfoID).ToList().GroupBy(p => p.ID).Select(g => g.First()).ToList().ForEach(value => |
90 |
{ |
91 |
markupdata.Add(new MARKUP_DATA() |
92 |
{ |
93 |
ID = value.ID, |
94 |
PAGENUMBER = value.PageNumber, |
95 |
DATA = value.Data, |
96 |
MARKUPINFO_VERSION_ID = UserState.MarkupVersionID, |
97 |
DATA_TYPE = value.Data_Type |
98 |
}); |
99 |
System.Diagnostics.Debug.WriteLine(value.ID); |
100 |
}); |
101 |
|
102 |
var SaveResult = await ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseTaskClient.SaveMarkupDataAsync(UserState, Project_No, document_id, user_id, markupdata); |
103 |
|
104 |
result = SaveResult; |
105 |
|
106 |
//Logger.sendResLog("SaveCommand.Instance.Execute" , $"SaveMarkupData Call Project : {Project_No} DocID :{document_id} User ID {user_id} result {SaveResult}",1); |
107 |
|
108 |
mainmenu.MarkupitemViewUpdate(UserState.MarkupInfoID); |
109 |
} |
110 |
//User Information List Rebind |
111 |
|
112 |
mainmenu.gridViewMarkup.Rebind(); |
113 |
TempFile.Remove(); //임시파일삭제 |
114 |
|
115 |
} |
116 |
catch (Exception) |
117 |
{ |
118 |
throw; |
119 |
} |
120 |
|
121 |
return result; |
122 |
} |
123 |
|
124 |
public void SymbolSave(string Name, string Url, string Data) |
125 |
{ |
126 |
try |
127 |
{ |
128 |
SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE |
129 |
{ |
130 |
ID = Commons.shortGuid(), |
131 |
MEMBER_USER_ID = App.ViewInfo.UserID, |
132 |
NAME = Name, |
133 |
IMAGE_URL = Url, |
134 |
DATA = Data |
135 |
}; |
136 |
|
137 |
//Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1); |
138 |
Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private); |
139 |
} |
140 |
catch(Exception) |
141 |
{ |
142 |
throw; |
143 |
} |
144 |
} |
145 |
public void SymbolSave_Public(string Name, string Url, string Data, string Department) |
146 |
{ |
147 |
try |
148 |
{ |
149 |
SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC |
150 |
{ |
151 |
ID = Commons.shortGuid(), |
152 |
DEPARTMENT = Department, |
153 |
NAME = Name, |
154 |
IMAGE_URL = Url, |
155 |
DATA = Data |
156 |
}; |
157 |
|
158 |
//Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1); |
159 |
Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public); |
160 |
} |
161 |
catch (Exception) |
162 |
{ |
163 |
throw; |
164 |
} |
165 |
} |
166 |
|
167 |
public async void PageAngleSave(string project_no, List<DOCPAGE> _mldocpage) |
168 |
{ |
169 |
try |
170 |
{ |
171 |
var result = await Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseTaskClient.SavePageAngleAsync(project_no, _mldocpage); |
172 |
Common.ViewerDataModel.Instance.RotationDocs.Clear(); |
173 |
|
174 |
//Logger.sendReqLog("SavePageAngle: ", project_no + "," + _mldocpage, 1); |
175 |
//Logger.sendResLog("SavePageAngle", result.ToString(), 1); |
176 |
|
177 |
} |
178 |
catch (Exception) |
179 |
{ |
180 |
throw; |
181 |
} |
182 |
} |
183 |
} |
184 |
} |