markus / KCOM / Events / Save.cs.bak @ 116801c9
이력 | 보기 | 이력해설 | 다운로드 (9.71 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.Linq; |
10 |
using System.Text; |
11 |
using System.Windows.Controls; |
12 |
using static MarkupToPDF.Controls.Parsing.LayerControl; |
13 |
|
14 |
namespace KCOM.Events |
15 |
{ |
16 |
public class Save |
17 |
{ |
18 |
#region Properties |
19 |
|
20 |
public ViewInfo _ViewInfo; |
21 |
public string Project_No |
22 |
{ |
23 |
get; |
24 |
set; |
25 |
} |
26 |
public string document_id |
27 |
{ |
28 |
get; |
29 |
set; |
30 |
} |
31 |
|
32 |
public string user_id |
33 |
{ |
34 |
get; |
35 |
set; |
36 |
} |
37 |
|
38 |
public int page_no |
39 |
{ |
40 |
get; |
41 |
set; |
42 |
} |
43 |
#endregion |
44 |
|
45 |
|
46 |
|
47 |
//GUID생성(최민수 사원 수정) //조장원 대리 다시 변경 |
48 |
public static string shortGuid() |
49 |
{ |
50 |
byte[] bytes = new byte[16]; |
51 |
using (var provider = System.Security.Cryptography.RandomNumberGenerator.Create()) |
52 |
{ |
53 |
provider.GetBytes(bytes); |
54 |
} |
55 |
|
56 |
var guid = new Guid(bytes); |
57 |
|
58 |
return Convert.ToBase64String(guid.ToByteArray()) |
59 |
.Substring(0, 10) |
60 |
.Replace("/", "") |
61 |
.Replace("+", "") + DateTime.UtcNow.Ticks.ToString("x"); |
62 |
} |
63 |
|
64 |
//조장원 네자리 |
65 |
public static string shortCommentKey() |
66 |
{ |
67 |
byte[] bytes = new byte[3]; |
68 |
using (var provider = System.Security.Cryptography.RandomNumberGenerator.Create()) |
69 |
{ |
70 |
provider.GetBytes(bytes); |
71 |
} |
72 |
|
73 |
return Convert.ToBase64String(bytes); |
74 |
} |
75 |
|
76 |
//강인구 추가 |
77 |
public static string shortFileKey() |
78 |
{ |
79 |
//byte[] bytes = new byte[3]; |
80 |
//using (var provider = System.IO.Path.GetRandomFileName()) |
81 |
//{ |
82 |
// provider.GetBytes(bytes); |
83 |
//} |
84 |
|
85 |
return System.IO.Path.GetRandomFileName(); |
86 |
} |
87 |
|
88 |
public void MarkupConsolidate() |
89 |
{ |
90 |
|
91 |
} |
92 |
|
93 |
//마크업 저장하기 |
94 |
public void MarkupSave(MarkupInfoItem UserState) |
95 |
{ |
96 |
using (CIEntities Entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(App.ViewInfo.ProjectNO).ToString())) |
97 |
{ |
98 |
LayerControl layerControl = new LayerControl(); |
99 |
DateTime DATE = DateTime.Now.Date; |
100 |
|
101 |
//마크업 데이터 Serialize //테스트로 유저 아이디 넣기 |
102 |
|
103 |
#region Docinfo 정보 가져오기 |
104 |
|
105 |
string docinfoid_ = (from info in Entity.DOCINFO |
106 |
where info.DOCUMENT_ID == document_id |
107 |
&& info.PROJECT_NO == Project_No |
108 |
select info.ID |
109 |
).First().ToString(); |
110 |
#endregion |
111 |
|
112 |
#region Markup_Info 저장 |
113 |
|
114 |
MARKUP_INFO markup_info = new MARKUP_INFO(); |
115 |
try |
116 |
{ |
117 |
markup_info = (from info in Entity.MARKUP_INFO |
118 |
where info.ID == UserState.MarkupInfoID && info.USER_ID == user_id |
119 |
select info).FirstOrDefault(); |
120 |
} |
121 |
catch (Exception) |
122 |
{ |
123 |
markup_info = null; |
124 |
} |
125 |
|
126 |
//markup_info가 없을 경우 생성 |
127 |
if (markup_info == null) |
128 |
{ |
129 |
//MarkupInfo 저장 |
130 |
markup_info = new MARKUP_INFO |
131 |
{ |
132 |
ID = UserState.MarkupInfoID, |
133 |
DOCINFO_ID = docinfoid_, |
134 |
USER_ID = user_id, |
135 |
CREATE_TIME = DateTime.Now, |
136 |
CONSOLIDATE = UserState.Consolidate, |
137 |
AVOID_CONSOLIDATE = UserState.AvoidConsolidate, |
138 |
PART_CONSOLIDATE = UserState.PartConsolidate, |
139 |
DESCRIPTION = UserState.Description, |
140 |
UPDATE_TIME = DateTime.Now |
141 |
}; |
142 |
Entity.MARKUP_INFO.AddObject(markup_info); |
143 |
} |
144 |
//markup_info가 있을 경우 업데이트 |
145 |
else |
146 |
{ |
147 |
markup_info.UPDATE_TIME = DateTime.Now; |
148 |
} |
149 |
Entity.SaveChanges(); |
150 |
#endregion |
151 |
|
152 |
#region Markup_Info_Version 저장 |
153 |
|
154 |
MARKUP_INFO_VERSION markup_info_version = new MARKUP_INFO_VERSION(); |
155 |
|
156 |
try |
157 |
{ |
158 |
//markup_info_version = (from info in Entity.MARKUP_INFO_VERSION |
159 |
// where info.MARKUPINFO_ID == markup_info.ID && info.CREATE_DATE >= DATE |
160 |
// orderby info.CREATE_DATE descending |
161 |
// select info).FirstOrDefault(); |
162 |
|
163 |
markup_info_version = (from info in Entity.MARKUP_INFO_VERSION |
164 |
where info.MARKUPINFO_ID == markup_info.ID |
165 |
select info).FirstOrDefault(); |
166 |
} |
167 |
catch (Exception EX) |
168 |
{ |
169 |
markup_info_version = null; |
170 |
} |
171 |
|
172 |
//markup_info_version 없을 경우 생성 |
173 |
if (markup_info_version == null) |
174 |
{ |
175 |
//MarkupInfo_version 저장 |
176 |
markup_info_version = new MARKUP_INFO_VERSION() |
177 |
{ |
178 |
ID = UserState.MarkupVersionID, |
179 |
MARKUPINFO_ID = markup_info.ID, |
180 |
CREATE_DATE = DateTime.Now |
181 |
}; |
182 |
Entity.MARKUP_INFO_VERSION.AddObject(markup_info_version); |
183 |
Entity.SaveChanges(); |
184 |
} |
185 |
#endregion |
186 |
|
187 |
|
188 |
///강인구 추가(2017.11.02) |
189 |
///DATA_TYPE추가로 인한 클래스 변수 대입 |
190 |
MarkupReturn markupdata = new MarkupReturn(); |
191 |
|
192 |
//Entity.MARKUP_DATA.Where(data => data.MARKUPINFO_VERSION_ID == markup_info_version.ID && data.PAGENUMBER == page_no).ToList().ForEach(item => |
193 |
Entity.MARKUP_DATA.Where(data => data.MARKUPINFO_VERSION_ID == markup_info_version.ID).ToList().ForEach(item => |
194 |
{ |
195 |
Entity.MARKUP_DATA.DeleteObject(item); |
196 |
}); |
197 |
Entity.SaveChanges(); |
198 |
|
199 |
|
200 |
//if (UserState.MarkupList !=null) |
201 |
//{ |
202 |
// UserState.MarkupList.ForEach(d => |
203 |
// { |
204 |
// Entity.MARKUP_DATA.AddObject(new MARKUP_DATA |
205 |
// { |
206 |
// ID = shortGuid(), |
207 |
// PAGENUMBER = d.PageNumber, |
208 |
// DATA_TYPE = d.Data_Type, |
209 |
// DATA = d.Data, |
210 |
// MARKUPINFO_VERSION_ID = markup_info_version.ID |
211 |
// }); |
212 |
// }); |
213 |
// Entity.SaveChanges(); |
214 |
//} |
215 |
//else |
216 |
//{ |
217 |
try |
218 |
{ |
219 |
ViewerDataModel.Instance.MarkupList_USER.Where(d => d.MarkupInfoID == UserState.MarkupInfoID).ToList().ForEach(value => |
220 |
{ |
221 |
Entity.MARKUP_DATA.AddObject(new MARKUP_DATA |
222 |
{ |
223 |
ID = value.ID, |
224 |
DATA = value.Data, |
225 |
DATA_TYPE = value.Data_Type, |
226 |
PAGENUMBER = value.PageNumber, |
227 |
MARKUPINFO_VERSION_ID = markup_info_version.ID |
228 |
}); |
229 |
}); |
230 |
Entity.SaveChanges(); |
231 |
} |
232 |
catch (Exception ex) |
233 |
{ |
234 |
|
235 |
throw; |
236 |
} |
237 |
|
238 |
//} |
239 |
|
240 |
|
241 |
|
242 |
|
243 |
|
244 |
//foreach (CommentUserInfo control in ViewerDataModel.Instance.MarkupControls) |
245 |
//{ |
246 |
// markupdata = layerControl.MarkupToString(control, user_id); |
247 |
// MARKUP_DATA markup_Data = new MARKUP_DATA() |
248 |
// { |
249 |
// ID = shortGuid(), |
250 |
// PAGENUMBER = page_no, |
251 |
|
252 |
// ///강인구 추가(2017.11.02) |
253 |
// ///DATA_TYPE추가로 인한 클래스 변수 대입 |
254 |
// //DATA = MarkupString, |
255 |
// DATA_TYPE = markupdata.DATA_TYPE, |
256 |
// DATA = markupdata.ConvertData, |
257 |
|
258 |
// MARKUPINFO_VERSION_ID = markup_info_version.ID |
259 |
// }; |
260 |
// Entity.MARKUP_DATA.AddObject(markup_Data); |
261 |
// Entity.SaveChanges(); |
262 |
//} |
263 |
} |
264 |
} |
265 |
|
266 |
|
267 |
public void SymbolSave(string Name, string Url, string Data) |
268 |
{ |
269 |
using (KCOMDataModel.DataModel.KCOMEntities uc = new KCOMDataModel.DataModel.KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString())) |
270 |
{ |
271 |
SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE |
272 |
{ |
273 |
ID = shortGuid(), |
274 |
MEMBER_USER_ID = App.ViewInfo.UserID, |
275 |
NAME = Name, |
276 |
IMAGE_URL = Url, |
277 |
DATA = Data |
278 |
}; |
279 |
|
280 |
uc.AddToSYMBOL_PRIVATE(symbol_private); |
281 |
uc.SaveChanges(); |
282 |
} |
283 |
} |
284 |
} |
285 |
} |