markus / KCOM_API_AutoStamping / AutoStamping.svc.cs @ 669a91cf
이력 | 보기 | 이력해설 | 다운로드 (32.4 KB)
1 | e1c892f7 | taeseongkim | using IFinalPDF; |
---|---|---|---|
2 | using KCOMDataModel.Common; |
||
3 | using KCOMDataModel.DataModel; |
||
4 | using log4net; |
||
5 | using log4net.Config; |
||
6 | using MarkupToPDF.Controls.Etc; |
||
7 | using MarkupToPDF.Controls.Shape; |
||
8 | using MarkupToPDF.Controls.Text; |
||
9 | using System; |
||
10 | using System.Collections.Generic; |
||
11 | using System.Configuration; |
||
12 | using System.Linq; |
||
13 | using System.Runtime.Remoting.Channels.Tcp; |
||
14 | using System.Runtime.Serialization; |
||
15 | using System.ServiceModel; |
||
16 | using System.ServiceModel.Activation; |
||
17 | using System.ServiceModel.Web; |
||
18 | using System.Text; |
||
19 | using System.Threading; |
||
20 | using System.Windows; |
||
21 | using System.Windows.Controls; |
||
22 | using System.Windows.Threading; |
||
23 | |||
24 | namespace KCOM_API |
||
25 | { |
||
26 | [ServiceContract(Namespace = "")] |
||
27 | [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] |
||
28 | //[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Single, InstanceContextMode = InstanceContextMode.PerCall)] |
||
29 | public class Common : System.Web.Services.WebService |
||
30 | { |
||
31 | private static log4net.ILog logger; |
||
32 | |||
33 | public Common() |
||
34 | { |
||
35 | XmlConfigurator.Configure(); |
||
36 | //Get logger |
||
37 | logger = LogManager.GetLogger(typeof(Common)); |
||
38 | //Start logging |
||
39 | logger.Info("KCOM_API Common Call"); |
||
40 | } |
||
41 | |||
42 | |||
43 | [OperationContract] |
||
44 | public string AutoStamping(string project_no, string slip_no, string user_id) |
||
45 | { |
||
46 | string result = string.Empty; |
||
47 | try |
||
48 | { |
||
49 | var waiter = new ManualResetEvent(false); |
||
50 | |||
51 | var staThread = new Thread(() => |
||
52 | { |
||
53 | result = StampSave(project_no, slip_no, user_id); |
||
54 | |||
55 | waiter.Set(); |
||
56 | }); |
||
57 | |||
58 | staThread.SetApartmentState(ApartmentState.STA); |
||
59 | staThread.Start(); |
||
60 | |||
61 | var timeout = new TimeSpan(0,1,0); |
||
62 | waiter.WaitOne(timeout); |
||
63 | } |
||
64 | catch (Exception exception) |
||
65 | { |
||
66 | logger.Error(exception); |
||
67 | |||
68 | result = exception.ToString(); |
||
69 | } |
||
70 | return result; |
||
71 | } |
||
72 | |||
73 | 669a91cf | taeseongkim | [OperationContract] |
74 | public ProjectInfo[] GetProjectList() |
||
75 | { |
||
76 | ProjectInfo[] result = null; |
||
77 | |||
78 | try |
||
79 | { |
||
80 | using (KCOMEntities _entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString())) |
||
81 | { |
||
82 | result = _entity.RUN_PROJECTS.ToList().Select(x => new ProjectInfo { No = x.PROJECT_NO, Name = $"{x.PROJECT_NO} - {x.PROJECT_NAME}"}).ToArray(); |
||
83 | } |
||
84 | |||
85 | } |
||
86 | catch (Exception) |
||
87 | { |
||
88 | } |
||
89 | |||
90 | return result; |
||
91 | } |
||
92 | |||
93 | e1c892f7 | taeseongkim | /// <summary> |
94 | /// 심볼로 변경 |
||
95 | /// </summary> |
||
96 | /// <param name="project_no"></param> |
||
97 | /// <param name="slip_no"></param> |
||
98 | /// <param name="user_id"></param> |
||
99 | private string StampSave(string project_no, string slip_no, string user_id) |
||
100 | { |
||
101 | string result = string.Empty; |
||
102 | try |
||
103 | { |
||
104 | logger.Info($"Stamp ProjecNO : {project_no} SlipNO : {slip_no} UserID : {user_id}"); |
||
105 | |||
106 | string _stampData = null; |
||
107 | |||
108 | using (KCOMEntities _entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString())) |
||
109 | { |
||
110 | var stamp = _entity.PROPERTIES.Where(x=> x.TYPE == "STAMP"); |
||
111 | |||
112 | if(stamp.Count() > 0) |
||
113 | { |
||
114 | _stampData = stamp.First().VALUE; |
||
115 | } |
||
116 | else |
||
117 | { |
||
118 | result = "STAMP IS NULL."; |
||
119 | } |
||
120 | }; |
||
121 | |||
122 | if (_stampData != null) |
||
123 | { |
||
124 | using (CIEntities cIEntity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString())) |
||
125 | { |
||
126 | logger.Info($"Connection CI DataBase :{cIEntity.Connection.Database} DataSource :{cIEntity.Connection.DataSource}"); |
||
127 | |||
128 | var list = (from doc in cIEntity.DOCUMENT_ITEM |
||
129 | where doc.GROUP_NO == slip_no && doc.PROJECT_NO == project_no |
||
130 | select doc).ToList(); |
||
131 | |||
132 | string userName = null; |
||
133 | |||
134 | var user = GetSelectMember(cIEntity, project_no, slip_no, user_id); |
||
135 | |||
136 | |||
137 | 669a91cf | taeseongkim | if (user.SLIP_COUNT == 0) |
138 | e1c892f7 | taeseongkim | { |
139 | 669a91cf | taeseongkim | result = "Slip No does not exist."; |
140 | e1c892f7 | taeseongkim | } |
141 | else |
||
142 | { |
||
143 | 669a91cf | taeseongkim | if (user.IS_ORIGINATOR == 0) |
144 | e1c892f7 | taeseongkim | { |
145 | 669a91cf | taeseongkim | result = "User ID is not the Originator for that Slip No."; |
146 | e1c892f7 | taeseongkim | } |
147 | else |
||
148 | { |
||
149 | 669a91cf | taeseongkim | if (user.USER_NAME == null) |
150 | e1c892f7 | taeseongkim | { |
151 | 669a91cf | taeseongkim | result = "user name IS NULL."; |
152 | } |
||
153 | else |
||
154 | { |
||
155 | userName = user.USER_NAME; |
||
156 | e1c892f7 | taeseongkim | |
157 | 669a91cf | taeseongkim | foreach (DOCUMENT_ITEM dOCUMENTITEM in list) |
158 | e1c892f7 | taeseongkim | { |
159 | 669a91cf | taeseongkim | DOCINFO dOCINFO = ( |
160 | from x in cIEntity.DOCINFO |
||
161 | where x.PROJECT_NO == project_no && x.DOCUMENT_ID == dOCUMENTITEM.DOCUMENT_ID |
||
162 | select x).FirstOrDefault<DOCINFO>(); |
||
163 | e1c892f7 | taeseongkim | |
164 | 669a91cf | taeseongkim | MARKUP_INFO mARKUPINFO = ( |
165 | from x in cIEntity.MARKUP_INFO |
||
166 | where x.DOCINFO_ID == dOCINFO.ID && x.AVOID_CONSOLIDATE == 0 && x.CONSOLIDATE == 1 |
||
167 | select x).FirstOrDefault<MARKUP_INFO>(); |
||
168 | |||
169 | if (mARKUPINFO == null) |
||
170 | e1c892f7 | taeseongkim | { |
171 | 669a91cf | taeseongkim | var pageInfo = dOCINFO.DOCPAGE.First(); |
172 | e1c892f7 | taeseongkim | |
173 | 669a91cf | taeseongkim | mARKUPINFO = new MARKUP_INFO() |
174 | { |
||
175 | ID = shortGuid(), |
||
176 | DOCINFO_ID = dOCINFO.ID, |
||
177 | USER_ID = user_id, |
||
178 | CREATE_TIME = DateTime.Now, |
||
179 | CONSOLIDATE = 1, |
||
180 | AVOID_CONSOLIDATE = 0, |
||
181 | PART_CONSOLIDATE = 0, |
||
182 | DESCRIPTION = "", |
||
183 | UPDATE_TIME = new DateTime?(DateTime.Now), |
||
184 | }; |
||
185 | e1c892f7 | taeseongkim | |
186 | 669a91cf | taeseongkim | cIEntity.MARKUP_INFO.AddObject(mARKUPINFO); |
187 | e1c892f7 | taeseongkim | |
188 | 669a91cf | taeseongkim | MARKUP_INFO_VERSION mARKUPINFOVERSION = new MARKUP_INFO_VERSION() |
189 | { |
||
190 | ID = shortGuid(), |
||
191 | MARKUPINFO_ID = mARKUPINFO.ID, |
||
192 | CREATE_DATE = DateTime.Now |
||
193 | }; |
||
194 | e1c892f7 | taeseongkim | |
195 | 669a91cf | taeseongkim | cIEntity.MARKUP_INFO_VERSION.AddObject(mARKUPINFOVERSION); |
196 | e1c892f7 | taeseongkim | |
197 | 669a91cf | taeseongkim | Point startPoint = new Point(15, 15); |
198 | e1c892f7 | taeseongkim | |
199 | 669a91cf | taeseongkim | var symCtrl = GetSymNControl(Convert.ToDouble(pageInfo.PAGE_WIDTH), Convert.ToDouble(pageInfo.PAGE_HEIGHT), mARKUPINFO.USER_ID, mARKUPINFO.ID, startPoint, _stampData); |
200 | e1c892f7 | taeseongkim | |
201 | 669a91cf | taeseongkim | var bottom = Rect.Offset(symCtrl.ItemRect, new Vector(0, symCtrl.ItemRect.Height)); |
202 | e1c892f7 | taeseongkim | |
203 | 669a91cf | taeseongkim | var txtOriginator = GetTextControl(Convert.ToDouble(pageInfo.PAGE_WIDTH), Convert.ToDouble(pageInfo.PAGE_HEIGHT), mARKUPINFO.USER_ID, mARKUPINFO.ID |
204 | , userName, 20, System.Windows.Media.Color.FromArgb(255, 0, 0, 255), FontWeights.Bold, TextAlignment.Center, bottom, bottom.Top + 3); |
||
205 | e1c892f7 | taeseongkim | |
206 | 669a91cf | taeseongkim | var dtfi = new System.Globalization.DateTimeFormatInfo { DateSeparator = "-", ShortDatePattern = @"yyyy/MM/dd" }; |
207 | e1c892f7 | taeseongkim | |
208 | 669a91cf | taeseongkim | var txtDate = GetTextControl(Convert.ToDouble(pageInfo.PAGE_WIDTH), Convert.ToDouble(pageInfo.PAGE_HEIGHT), mARKUPINFO.USER_ID, mARKUPINFO.ID |
209 | , DateTime.Now.ToString("d", dtfi), 20, System.Windows.Media.Color.FromArgb(255, 255, 0, 0), FontWeights.Bold, TextAlignment.Center, bottom, txtOriginator.StartPoint.Y + txtOriginator.BoxHeight + 2); |
||
210 | |||
211 | var symData = symCtrl.GetMarkupData(mARKUPINFO.USER_ID, 1, mARKUPINFOVERSION.ID); |
||
212 | cIEntity.MARKUP_DATA.AddObject(symData); |
||
213 | cIEntity.MARKUP_DATA.AddObject(txtOriginator.GetMarkupData(mARKUPINFO.USER_ID, 1, mARKUPINFOVERSION.ID)); |
||
214 | cIEntity.MARKUP_DATA.AddObject(txtDate.GetMarkupData(mARKUPINFO.USER_ID, 1, mARKUPINFOVERSION.ID)); |
||
215 | } |
||
216 | cIEntity.SaveChanges(); |
||
217 | |||
218 | |||
219 | this.SetFinalPDF(project_no, dOCINFO.ID, mARKUPINFO.ID, user_id); |
||
220 | } |
||
221 | e1c892f7 | taeseongkim | } |
222 | } |
||
223 | } |
||
224 | } |
||
225 | } |
||
226 | |||
227 | } |
||
228 | catch (Exception ex) |
||
229 | { |
||
230 | logger.Error($"StampSave ProjectNO : {project_no} slipNo : {slip_no} userID : {user_id}" + ex); |
||
231 | result = "Stamp Save Error"; |
||
232 | } |
||
233 | |||
234 | return result; |
||
235 | } |
||
236 | |||
237 | private List<MEMBER> GetMemberQuery(System.Data.Objects.ObjectContext context, string UserID) |
||
238 | { |
||
239 | List<MEMBER> result = new List<MEMBER>(); |
||
240 | |||
241 | try |
||
242 | { |
||
243 | string query = "SELECT members.ID,members.NAME,members.DEPARTMENT FROM CIEntities.MEMBER as members where members.ID = @userId"; |
||
244 | |||
245 | var param = new[] { new System.Data.Objects.ObjectParameter("userId", UserID) }; |
||
246 | |||
247 | System.Data.Objects.ObjectQuery<System.Data.Common.DbDataRecord> memberQuery |
||
248 | = context.CreateQuery<System.Data.Common.DbDataRecord>(query, param); |
||
249 | |||
250 | if (memberQuery.Count() > 0) |
||
251 | { |
||
252 | foreach (var dataRecord in memberQuery) |
||
253 | { |
||
254 | MEMBER member = new MEMBER(); |
||
255 | |||
256 | string userName = dataRecord["NAME"]?.ToString().Trim(); |
||
257 | string ID = dataRecord["ID"]?.ToString().Trim(); |
||
258 | string depatment = dataRecord["DEPARTMENT"]?.ToString().Trim(); |
||
259 | |||
260 | member.NAME = userName; |
||
261 | member.ID = ID; |
||
262 | member.DEPARTMENT = depatment; |
||
263 | |||
264 | result.Add(member); |
||
265 | } |
||
266 | } |
||
267 | } |
||
268 | catch (Exception ex) |
||
269 | { |
||
270 | throw new Exception("GetMember(System.Data.Objects.ObjectContext context, string UserID) ", ex); |
||
271 | } |
||
272 | |||
273 | return result; |
||
274 | } |
||
275 | |||
276 | private SelectMember GetSelectMember(System.Data.Objects.ObjectContext context,string ProjectNo,string SlipNo, string UserID) |
||
277 | { |
||
278 | SelectMember result = new SelectMember(); |
||
279 | |||
280 | try |
||
281 | { |
||
282 | string query = "SELECT_SLIP_ORIGINATOR @P_PROJECT_NO = @ProjectNo , @P_SLIP_NO = @SlipNo ,@P_USER_ID = @UserID"; |
||
283 | |||
284 | var param = new[]{ |
||
285 | new System.Data.SqlClient.SqlParameter("ProjectNo", ProjectNo), |
||
286 | new System.Data.SqlClient.SqlParameter("SlipNo", SlipNo), |
||
287 | new System.Data.SqlClient.SqlParameter("UserID", UserID) |
||
288 | |||
289 | }; |
||
290 | |||
291 | //var memberQuery = context.ExecuteStoreQuery<System.Data.Common.DbDataRecord>(query, param).ToList(); |
||
292 | |||
293 | //if (memberQuery.Count() > 0) |
||
294 | //{ |
||
295 | // result.USER_NAME = memberQuery.First()["USER_NAME"]?.ToString(); |
||
296 | // result.IS_ORIGINATOR = Convert.ToInt32(memberQuery.First()["IS_ORIGINATOR"]); |
||
297 | //} |
||
298 | |||
299 | var memberQuery = context.ExecuteStoreQuery<SelectMember>(query, param).ToList(); |
||
300 | |||
301 | if (memberQuery.Count() > 0) |
||
302 | { |
||
303 | result = memberQuery.First(); |
||
304 | } |
||
305 | } |
||
306 | catch (Exception ex) |
||
307 | { |
||
308 | throw new Exception("GetMember(System.Data.Objects.ObjectContext context, string UserID) ", ex); |
||
309 | } |
||
310 | |||
311 | return result; |
||
312 | } |
||
313 | |||
314 | private void StampSave_NoneSymbol(string project_no, string slip_no, string user_id) |
||
315 | { |
||
316 | try |
||
317 | { |
||
318 | logger.Info($"Stamp ProjecNO : {project_no} SlipNO : {slip_no} UserID : {user_id}"); |
||
319 | |||
320 | using (CIEntities cIEntity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString())) |
||
321 | { |
||
322 | logger.Info($"Connection CI DataBase :{cIEntity.Connection.Database} DataSource :{cIEntity.Connection.DataSource}"); |
||
323 | |||
324 | var list = (from doc in cIEntity.DOCUMENT_ITEM |
||
325 | where doc.GROUP_NO == slip_no && doc.PROJECT_NO == project_no |
||
326 | select doc).ToList(); |
||
327 | |||
328 | foreach (DOCUMENT_ITEM dOCUMENTITEM in list) |
||
329 | { |
||
330 | DOCINFO dOCINFO = ( |
||
331 | from x in cIEntity.DOCINFO |
||
332 | where x.PROJECT_NO == project_no && x.DOCUMENT_ID == dOCUMENTITEM.DOCUMENT_ID |
||
333 | select x).FirstOrDefault<DOCINFO>(); |
||
334 | |||
335 | MARKUP_INFO mARKUPINFO = ( |
||
336 | from x in cIEntity.MARKUP_INFO |
||
337 | where x.DOCINFO_ID == dOCINFO.ID && x.AVOID_CONSOLIDATE == 0 && x.CONSOLIDATE == 1 |
||
338 | select x).FirstOrDefault<MARKUP_INFO>(); |
||
339 | |||
340 | if (mARKUPINFO == null) |
||
341 | { |
||
342 | var pageInfo = dOCINFO.DOCPAGE.First(); |
||
343 | |||
344 | mARKUPINFO = new MARKUP_INFO() |
||
345 | { |
||
346 | ID = shortGuid(), |
||
347 | DOCINFO_ID = dOCINFO.ID, |
||
348 | USER_ID = user_id, |
||
349 | CREATE_TIME = DateTime.Now, |
||
350 | CONSOLIDATE = 1, |
||
351 | AVOID_CONSOLIDATE = 0, |
||
352 | PART_CONSOLIDATE = 0, |
||
353 | DESCRIPTION = "", |
||
354 | UPDATE_TIME = new DateTime?(DateTime.Now), |
||
355 | }; |
||
356 | |||
357 | cIEntity.MARKUP_INFO.AddObject(mARKUPINFO); |
||
358 | |||
359 | MARKUP_INFO_VERSION mARKUPINFOVERSION = new MARKUP_INFO_VERSION() |
||
360 | { |
||
361 | ID = shortGuid(), |
||
362 | MARKUPINFO_ID = mARKUPINFO.ID, |
||
363 | CREATE_DATE = DateTime.Now |
||
364 | }; |
||
365 | |||
366 | cIEntity.MARKUP_INFO_VERSION.AddObject(mARKUPINFOVERSION); |
||
367 | |||
368 | Point startPoint = new Point(15, 15); |
||
369 | |||
370 | var rect = Common.GetRectControl(Convert.ToDouble(pageInfo.PAGE_WIDTH), Convert.ToDouble(pageInfo.PAGE_HEIGHT), |
||
371 | mARKUPINFO.USER_ID, mARKUPINFO.ID, startPoint); |
||
372 | |||
373 | var txtApproved = GetTextControl(Convert.ToDouble(pageInfo.PAGE_WIDTH), Convert.ToDouble(pageInfo.PAGE_HEIGHT), mARKUPINFO.USER_ID, mARKUPINFO.ID, |
||
374 | "APPROVED", 30, System.Windows.Media.Color.FromArgb(255, 255, 0, 0), FontWeights.Bold, TextAlignment.Center, rect.ItemRect, 18); |
||
375 | |||
376 | var txtCreator = GetTextControl(Convert.ToDouble(pageInfo.PAGE_WIDTH), Convert.ToDouble(pageInfo.PAGE_HEIGHT), mARKUPINFO.USER_ID, mARKUPINFO.ID |
||
377 | , "By HYOSUNG", 18, System.Windows.Media.Color.FromArgb(255, 255, 0, 0), FontWeights.Bold, TextAlignment.Center, rect.ItemRect, txtApproved.StartPoint.Y + txtApproved.BoxHeight + 3); |
||
378 | |||
379 | var bottom = Rect.Offset(rect.ItemRect, new Vector(0, rect.ItemRect.Height)); |
||
380 | |||
381 | var txtOriginator = GetTextControl(Convert.ToDouble(pageInfo.PAGE_WIDTH), Convert.ToDouble(pageInfo.PAGE_HEIGHT), mARKUPINFO.USER_ID, mARKUPINFO.ID |
||
382 | , mARKUPINFO.USER_ID, 18,System.Windows.Media.Color.FromArgb(255, 255, 0, 0), FontWeights.Bold, TextAlignment.Left, bottom, bottom.Top + 3); |
||
383 | |||
384 | var dtfi = new System.Globalization.DateTimeFormatInfo { DateSeparator = "-", ShortDatePattern = @"yyyy/MM/dd" }; |
||
385 | |||
386 | var txtDate = GetTextControl(Convert.ToDouble(pageInfo.PAGE_WIDTH), Convert.ToDouble(pageInfo.PAGE_HEIGHT), mARKUPINFO.USER_ID, mARKUPINFO.ID |
||
387 | , DateTime.Now.ToString("d", dtfi), 18, System.Windows.Media.Color.FromArgb(255, 255, 0, 0), FontWeights.Bold, TextAlignment.Left, bottom, txtOriginator.StartPoint.Y + txtOriginator.BoxHeight + 2); |
||
388 | |||
389 | var rectData = rect.GetMarkupData(mARKUPINFO.USER_ID, 1, mARKUPINFOVERSION.ID); |
||
390 | cIEntity.MARKUP_DATA.AddObject(rectData); |
||
391 | |||
392 | cIEntity.MARKUP_DATA.AddObject(txtApproved.GetMarkupData(mARKUPINFO.USER_ID, 1, mARKUPINFOVERSION.ID)); |
||
393 | cIEntity.MARKUP_DATA.AddObject(txtCreator.GetMarkupData(mARKUPINFO.USER_ID, 1, mARKUPINFOVERSION.ID)); |
||
394 | cIEntity.MARKUP_DATA.AddObject(txtOriginator.GetMarkupData(mARKUPINFO.USER_ID, 1, mARKUPINFOVERSION.ID)); |
||
395 | cIEntity.MARKUP_DATA.AddObject(txtDate.GetMarkupData(mARKUPINFO.USER_ID, 1, mARKUPINFOVERSION.ID)); |
||
396 | } |
||
397 | cIEntity.SaveChanges(); |
||
398 | |||
399 | |||
400 | this.SetFinalPDF(project_no, dOCINFO.ID, mARKUPINFO.ID, user_id); |
||
401 | } |
||
402 | } |
||
403 | |||
404 | } |
||
405 | catch (Exception ex) |
||
406 | { |
||
407 | logger.Error($"StampSave ProjectNO : {project_no} slipNo : {slip_no} userID : {user_id}" + ex); |
||
408 | } |
||
409 | } |
||
410 | |||
411 | private static string shortGuid() |
||
412 | { |
||
413 | byte[] bytes = new byte[16]; |
||
414 | using (var provider = System.Security.Cryptography.RandomNumberGenerator.Create()) |
||
415 | { |
||
416 | provider.GetBytes(bytes); |
||
417 | } |
||
418 | |||
419 | var guid = new Guid(bytes); |
||
420 | |||
421 | return Convert.ToBase64String(guid.ToByteArray()) |
||
422 | .Substring(0, 10) |
||
423 | .Replace("/", "") |
||
424 | .Replace("+", "") + DateTime.UtcNow.Ticks.ToString("x"); |
||
425 | } |
||
426 | |||
427 | private SymControlN GetSymNControl(double PageWidth, double PageHeight, string userId, string markupInfoId, Point startPosition,string StampData) |
||
428 | { |
||
429 | SymControlN result = null; |
||
430 | |||
431 | try |
||
432 | { |
||
433 | double height = 80; |
||
434 | double itemWidth = 180; |
||
435 | |||
436 | System.Windows.Point startPoint = new System.Windows.Point(startPosition.X, startPosition.Y); |
||
437 | System.Windows.Point endPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y + height); |
||
438 | System.Windows.Point leftBottomPoint = new System.Windows.Point(startPosition.X, startPosition.Y + height); |
||
439 | System.Windows.Point topRightPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y); |
||
440 | |||
441 | result = new SymControlN |
||
442 | { |
||
443 | CommentID = shortGuid(), |
||
444 | MarkupInfoID = markupInfoId, |
||
445 | UserID = userId, |
||
446 | PointSet = new List<Point> { startPoint, leftBottomPoint, endPoint, topRightPoint }, |
||
447 | StartPoint = startPoint, |
||
448 | EndPoint = endPoint, |
||
449 | CommentAngle = 0, |
||
450 | LeftBottomPoint = leftBottomPoint, |
||
451 | TopRightPoint = topRightPoint, |
||
452 | Opacity = 1, |
||
453 | PathXathData = StampData, |
||
454 | Memo = null |
||
455 | }; |
||
456 | |||
457 | } |
||
458 | catch (Exception ex) |
||
459 | { |
||
460 | System.Diagnostics.Debug.WriteLine(ex.ToString()); |
||
461 | } |
||
462 | |||
463 | return result; |
||
464 | } |
||
465 | |||
466 | |||
467 | private static RectangleControl GetRectControl(double PageWidth, double PageHeight, string USER_ID, string markupInfoId, Point startPosition) |
||
468 | { |
||
469 | RectangleControl result = null; |
||
470 | |||
471 | try |
||
472 | { |
||
473 | double height = 80; |
||
474 | double itemWidth = 180; |
||
475 | |||
476 | System.Windows.Point startPoint = new System.Windows.Point(startPosition.X, startPosition.Y); |
||
477 | System.Windows.Point endPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y + height); |
||
478 | System.Windows.Point leftBottomPoint = new System.Windows.Point(startPosition.X, startPosition.Y + height); |
||
479 | System.Windows.Point topRightPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y); |
||
480 | |||
481 | result = new RectangleControl |
||
482 | { |
||
483 | CommentID = shortGuid(), |
||
484 | MarkupInfoID = markupInfoId, |
||
485 | LineSize = 5, |
||
486 | Paint = MarkupToPDF.Controls.Common.PaintSet.None, |
||
487 | StartPoint = startPoint, |
||
488 | EndPoint = endPoint, |
||
489 | CommentAngle = 0, |
||
490 | StrokeColor = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 255, 0x0, 0x0)), |
||
491 | //StrokeColor = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 64, 224, 208)), |
||
492 | FillColor = null, |
||
493 | DashSize = new System.Windows.Media.DoubleCollection(new[] { 999999.0 }), |
||
494 | Opacity = 1, |
||
495 | LeftBottomPoint = leftBottomPoint, |
||
496 | TopRightPoint = topRightPoint, |
||
497 | PointSet = new List<Point> { startPoint, leftBottomPoint, endPoint, topRightPoint }, |
||
498 | UserID = USER_ID, |
||
499 | Memo = null, |
||
500 | SymbolID = null |
||
501 | |||
502 | }; |
||
503 | } |
||
504 | catch (Exception ex) |
||
505 | { |
||
506 | System.Diagnostics.Debug.WriteLine(ex.ToString()); |
||
507 | } |
||
508 | |||
509 | return result; |
||
510 | } |
||
511 | |||
512 | [STAThread] |
||
513 | private static TextControl GetTextControl(double PageWidth, double PageHeight, string USER_ID, string markupInfoId, |
||
514 | string Text, double fontSize, System.Windows.Media.Color Foreground, FontWeight fontWeight, TextAlignment textAlignment, Rect parentRect, double positionY) |
||
515 | { |
||
516 | TextControl result = null; |
||
517 | |||
518 | try |
||
519 | { |
||
520 | |||
521 | var txtSize = ShapeMeasure(new TextBlock |
||
522 | { |
||
523 | Text = Text, |
||
524 | FontSize = fontSize, |
||
525 | FontWeight = fontWeight, |
||
526 | FontFamily = new System.Windows.Media.FontFamily("Arial") |
||
527 | }); |
||
528 | |||
529 | double startPositionX = parentRect.X; |
||
530 | |||
531 | switch (textAlignment) |
||
532 | { |
||
533 | case TextAlignment.Right: |
||
534 | startPositionX = parentRect.X + parentRect.Width - txtSize.Width; |
||
535 | break; |
||
536 | case TextAlignment.Center: |
||
537 | startPositionX = parentRect.X + parentRect.Width / 2 - txtSize.Width / 2; |
||
538 | break; |
||
539 | } |
||
540 | |||
541 | Point startPosition = new Point |
||
542 | { |
||
543 | X = startPositionX, |
||
544 | Y = positionY |
||
545 | }; |
||
546 | |||
547 | System.Windows.Point startPoint = new System.Windows.Point(startPosition.X, startPosition.Y); |
||
548 | System.Windows.Point endPoint = new System.Windows.Point(startPosition.X + txtSize.Width, startPosition.Y + txtSize.Height); |
||
549 | System.Windows.Point leftBottomPoint = new System.Windows.Point(startPosition.X, startPosition.Y + txtSize.Height); |
||
550 | System.Windows.Point topRightPoint = new System.Windows.Point(startPosition.X + txtSize.Width, startPosition.Y); |
||
551 | |||
552 | result = new TextControl |
||
553 | { |
||
554 | CommentID = shortGuid(), |
||
555 | MarkupInfoID = markupInfoId, |
||
556 | Text = Text, |
||
557 | StartPoint = startPoint, |
||
558 | EndPoint = endPoint, |
||
559 | CanvasX = startPosition.X, |
||
560 | CanvasY = startPosition.Y, |
||
561 | BoxWidth = txtSize.Width, |
||
562 | BoxHeight = txtSize.Height, |
||
563 | ControlType_No = 0, |
||
564 | LineSize = new Thickness(5), |
||
565 | TextSize = fontSize, |
||
566 | Foreground = new System.Windows.Media.SolidColorBrush(Foreground), |
||
567 | FontSize = 10, |
||
568 | UserID = USER_ID, |
||
569 | IsHighLight = false, |
||
570 | CommentAngle = 0, |
||
571 | PointSet = new List<Point>(), |
||
572 | Opacity = 1, |
||
573 | IsSelected = false, |
||
574 | TextFamily = new System.Windows.Media.FontFamily("Arial"), |
||
575 | TextStyle = FontStyles.Normal, |
||
576 | TextWeight = FontWeights.Bold |
||
577 | }; |
||
578 | |||
579 | } |
||
580 | catch (Exception ex) |
||
581 | { |
||
582 | throw new Exception("Text Control error"); |
||
583 | } |
||
584 | |||
585 | return result; |
||
586 | } |
||
587 | public static Size ShapeMeasure(UIElement e) |
||
588 | { |
||
589 | // Measured Size is bounded to be less than maxSize |
||
590 | Size maxSize = new Size( |
||
591 | double.PositiveInfinity, |
||
592 | double.PositiveInfinity); |
||
593 | e.Measure(maxSize); |
||
594 | return e.DesiredSize; |
||
595 | } |
||
596 | private void SetTextControl(TextControl textControl) |
||
597 | { |
||
598 | textControl.Base_TextBlock.Margin = new Thickness(0, 0, 10, 0); |
||
599 | textControl.Base_TextBox.Visibility = Visibility.Collapsed; |
||
600 | textControl.Base_TextBlock.Visibility = Visibility.Visible; |
||
601 | |||
602 | } |
||
603 | |||
604 | #region Final PDF |
||
605 | private string _ChanID = null; |
||
606 | TcpChannel chan = null; |
||
607 | |||
608 | [OperationContract] |
||
609 | public FinalPDFResult SetFinalPDF(string ProjectNo, string DocInfoID, string MarkupInfoID, string CreateUSER_ID) |
||
610 | { |
||
611 | #region 임시보관 |
||
612 | #endregion |
||
613 | FinalPDFResult _result = new FinalPDFResult(); |
||
614 | RemFinalPDFObject remObj = null; |
||
615 | try |
||
616 | { |
||
617 | string _finalID = shortGuid(); |
||
618 | int _DocTotalPages = -1; |
||
619 | string docItemId; |
||
620 | |||
621 | logger.Info($"SetFinalPDF ProjectNo :{ProjectNo} DocInfoID :{DocInfoID} MarkupInfoID:{MarkupInfoID} CreateUSER_ID:{CreateUSER_ID}"); |
||
622 | |||
623 | //string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString; |
||
624 | using (CIEntities _ci = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(ProjectNo).ToString())) |
||
625 | { |
||
626 | logger.Info($"Connection CI DataBase :{_ci.Connection.Database} DataSource :{_ci.Connection.DataSource}"); |
||
627 | var _doc = _ci.DOCINFO.Where(info => info.ID == DocInfoID); |
||
628 | |||
629 | if (_doc.Count() > 0) |
||
630 | { |
||
631 | _DocTotalPages = _doc.First().PAGE_COUNT; |
||
632 | docItemId = _doc.First().DOCUMENT_ID; |
||
633 | } |
||
634 | else |
||
635 | { |
||
636 | _result.Status = FinalStatus.Error; |
||
637 | _result.Exception = "페이지 정보를 가져올 수 없습니다."; |
||
638 | return _result; |
||
639 | } |
||
640 | } |
||
641 | if (_DocTotalPages > 0) |
||
642 | { |
||
643 | FINAL_PDF fm = new FINAL_PDF() |
||
644 | { |
||
645 | ID = _finalID, |
||
646 | PROJECT_NO = ProjectNo, |
||
647 | DOCINFO_ID = DocInfoID, |
||
648 | DOCUMENT_ID = docItemId, |
||
649 | MARKUPINFO_ID = MarkupInfoID, |
||
650 | CREATE_USER_ID = CreateUSER_ID, |
||
651 | TOTAL_PAGE = _DocTotalPages, |
||
652 | CREATE_DATETIME = DateTime.Now, |
||
653 | STATUS = (int)IFinalPDF.FinalStatus.Insert |
||
654 | }; |
||
655 | |||
656 | //string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; |
||
657 | using (KCOMEntities _entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString())) |
||
658 | { |
||
659 | logger.Info($"Connection KCOM DataBase :{_entity.Connection.Database} DataSource :{_entity.Connection.DataSource}"); |
||
660 | |||
661 | _entity.AddToFINAL_PDF(fm); |
||
662 | _entity.SaveChanges(System.Data.Objects.SaveOptions.AcceptAllChangesAfterSave); |
||
663 | }; |
||
664 | |||
665 | System.Runtime.Remoting.Channels.IChannel _ch = System.Runtime.Remoting.Channels.ChannelServices.GetChannel("tcp"); |
||
666 | if (_ch == null) |
||
667 | { |
||
668 | chan = new TcpChannel(); |
||
669 | _ChanID = chan.ChannelName; |
||
670 | System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(chan, false); |
||
671 | // Create an instance of the remote object |
||
672 | |||
673 | using (KCOMEntities ec = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString())) |
||
674 | { |
||
675 | |||
676 | //remObj = (RemFinalPDFObject)Activator.GetObject(typeof(RemFinalPDFObject), |
||
677 | // "tcp://localhost:9092/remFinalPDF"); |
||
678 | remObj = (RemFinalPDFObject)Activator.GetObject(typeof(RemFinalPDFObject), |
||
679 | //"tcp://192.168.0.67:9092/remFinalPDF"); |
||
680 | "tcp://localhost:9092/remFinalPDF"); |
||
681 | } |
||
682 | |||
683 | //"tcp://localhost:8080/remFinalPDF"); |
||
684 | |||
685 | _result = remObj.SetFinalPDF(ProjectNo, _finalID); |
||
686 | _result.FinalID = _finalID; |
||
687 | _result.Status = FinalStatus.Success; |
||
688 | |||
689 | //MarkupToPDF.MarkupToPDF fa = new MarkupToPDF.MarkupToPDF(); |
||
690 | //fa.MakeFinalPDF(fm); |
||
691 | } |
||
692 | else |
||
693 | { |
||
694 | _ChanID = _ch.ChannelName; |
||
695 | } |
||
696 | } |
||
697 | } |
||
698 | catch (Exception ex) |
||
699 | { |
||
700 | logger.Error($"SetFinalPDF - " + ex); |
||
701 | |||
702 | _result.Status = FinalStatus.Error; |
||
703 | |||
704 | if (ex.GetType() == typeof(System.Net.Sockets.SocketException)) |
||
705 | _result.Exception = "Final Server Not Connection"; |
||
706 | else _result.Exception = ex.ToString(); |
||
707 | } |
||
708 | finally |
||
709 | { |
||
710 | remObj = null; |
||
711 | if (System.Runtime.Remoting.Channels.ChannelServices.GetChannel("tcp") != null) |
||
712 | System.Runtime.Remoting.Channels.ChannelServices.UnregisterChannel(chan); |
||
713 | |||
714 | GC.Collect(2); |
||
715 | } |
||
716 | return _result; |
||
717 | } |
||
718 | #endregion |
||
719 | |||
720 | } |
||
721 | |||
722 | public class SelectMember |
||
723 | { |
||
724 | public string USER_NAME { get; set; } |
||
725 | |||
726 | /// <summary> |
||
727 | /// 0보다 크면 originator |
||
728 | /// </summary> |
||
729 | public int IS_ORIGINATOR { get; set; } |
||
730 | 669a91cf | taeseongkim | |
731 | /// <summary> |
||
732 | /// 해당 SLIP NO가 있는지 |
||
733 | /// </summary> |
||
734 | public int SLIP_COUNT { get; set; } |
||
735 | } |
||
736 | |||
737 | |||
738 | [DataContract] |
||
739 | public class ProjectInfo |
||
740 | { |
||
741 | [DataMember] |
||
742 | public string No { get; set; } |
||
743 | |||
744 | [DataMember] |
||
745 | public string Name { get; set; } |
||
746 | e1c892f7 | taeseongkim | } |
747 | } |