프로젝트

일반

사용자정보

통계
| 브랜치(Branch): | 개정판:

markus / KCOM_API_AutoStamping / AutoStamping.svc.cs @ e1c892f7

이력 | 보기 | 이력해설 | 다운로드 (31 KB)

1
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
        /// <summary>
74
        /// 심볼로 변경
75
        /// </summary>
76
        /// <param name="project_no"></param>
77
        /// <param name="slip_no"></param>
78
        /// <param name="user_id"></param>
79
        private string StampSave(string project_no, string slip_no, string user_id)
80
        {
81
            string result = string.Empty;
82
            try
83
            {
84
                logger.Info($"Stamp  ProjecNO : {project_no}  SlipNO : {slip_no}  UserID : {user_id}");
85

    
86
                string _stampData = null;
87

    
88
                using (KCOMEntities _entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
89
                {
90
                    var stamp = _entity.PROPERTIES.Where(x=> x.TYPE == "STAMP");
91
                    
92
                    if(stamp.Count() > 0)
93
                    {
94
                        _stampData = stamp.First().VALUE;
95
                    }
96
                    else
97
                    {
98
                        result = "STAMP IS NULL.";
99
                    }
100
                };
101

    
102
                if (_stampData != null)
103
                {
104
                    using (CIEntities cIEntity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
105
                    {
106
                        logger.Info($"Connection CI DataBase :{cIEntity.Connection.Database} DataSource :{cIEntity.Connection.DataSource}");
107

    
108
                        var list = (from doc in cIEntity.DOCUMENT_ITEM
109
                                    where doc.GROUP_NO == slip_no && doc.PROJECT_NO == project_no
110
                                    select doc).ToList();
111

    
112
                        string userName = null;
113

    
114
                        var user = GetSelectMember(cIEntity, project_no, slip_no, user_id);
115

    
116

    
117
                        if (user.IS_ORIGINATOR == 0)
118
                        {
119
                            result = "You are not an originator of the slip.";
120
                        }
121
                        else
122
                        {
123
                            if (user.USER_NAME == null)
124
                            {
125
                                result = "user name IS NULL.";
126
                            }
127
                            else
128
                            {
129
                                userName = user.USER_NAME;
130

    
131
                                foreach (DOCUMENT_ITEM dOCUMENTITEM in list)
132
                                {
133
                                    DOCINFO dOCINFO = (
134
                                        from x in cIEntity.DOCINFO
135
                                        where x.PROJECT_NO == project_no && x.DOCUMENT_ID == dOCUMENTITEM.DOCUMENT_ID
136
                                        select x).FirstOrDefault<DOCINFO>();
137

    
138
                                    MARKUP_INFO mARKUPINFO = (
139
                                        from x in cIEntity.MARKUP_INFO
140
                                        where x.DOCINFO_ID == dOCINFO.ID && x.AVOID_CONSOLIDATE == 0 && x.CONSOLIDATE == 1
141
                                        select x).FirstOrDefault<MARKUP_INFO>();
142

    
143
                                    if (mARKUPINFO == null)
144
                                    {
145
                                        var pageInfo = dOCINFO.DOCPAGE.First();
146

    
147
                                        mARKUPINFO = new MARKUP_INFO()
148
                                        {
149
                                            ID = shortGuid(),
150
                                            DOCINFO_ID = dOCINFO.ID,
151
                                            USER_ID = user_id,
152
                                            CREATE_TIME = DateTime.Now,
153
                                            CONSOLIDATE = 1,
154
                                            AVOID_CONSOLIDATE = 0,
155
                                            PART_CONSOLIDATE = 0,
156
                                            DESCRIPTION = "",
157
                                            UPDATE_TIME = new DateTime?(DateTime.Now),
158
                                        };
159

    
160
                                        cIEntity.MARKUP_INFO.AddObject(mARKUPINFO);
161

    
162
                                        MARKUP_INFO_VERSION mARKUPINFOVERSION = new MARKUP_INFO_VERSION()
163
                                        {
164
                                            ID = shortGuid(),
165
                                            MARKUPINFO_ID = mARKUPINFO.ID,
166
                                            CREATE_DATE = DateTime.Now
167
                                        };
168

    
169
                                        cIEntity.MARKUP_INFO_VERSION.AddObject(mARKUPINFOVERSION);
170

    
171
                                        Point startPoint = new Point(15, 15);
172

    
173
                                        var symCtrl = GetSymNControl(Convert.ToDouble(pageInfo.PAGE_WIDTH), Convert.ToDouble(pageInfo.PAGE_HEIGHT), mARKUPINFO.USER_ID, mARKUPINFO.ID, startPoint, _stampData);
174

    
175
                                        var bottom = Rect.Offset(symCtrl.ItemRect, new Vector(0, symCtrl.ItemRect.Height));
176

    
177
                                        var txtOriginator = GetTextControl(Convert.ToDouble(pageInfo.PAGE_WIDTH), Convert.ToDouble(pageInfo.PAGE_HEIGHT), mARKUPINFO.USER_ID, mARKUPINFO.ID
178
                                                       , userName, 20, System.Windows.Media.Color.FromArgb(255, 0, 0, 255), FontWeights.Bold, TextAlignment.Center, bottom, bottom.Top + 3);
179

    
180
                                        var dtfi = new System.Globalization.DateTimeFormatInfo { DateSeparator = "-", ShortDatePattern = @"yyyy/MM/dd" };
181

    
182
                                        var txtDate = GetTextControl(Convert.ToDouble(pageInfo.PAGE_WIDTH), Convert.ToDouble(pageInfo.PAGE_HEIGHT), mARKUPINFO.USER_ID, mARKUPINFO.ID
183
                                                       , 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);
184

    
185
                                        var symData = symCtrl.GetMarkupData(mARKUPINFO.USER_ID, 1, mARKUPINFOVERSION.ID);
186
                                        cIEntity.MARKUP_DATA.AddObject(symData);
187
                                        cIEntity.MARKUP_DATA.AddObject(txtOriginator.GetMarkupData(mARKUPINFO.USER_ID, 1, mARKUPINFOVERSION.ID));
188
                                        cIEntity.MARKUP_DATA.AddObject(txtDate.GetMarkupData(mARKUPINFO.USER_ID, 1, mARKUPINFOVERSION.ID));
189
                                    }
190
                                    cIEntity.SaveChanges();
191

    
192

    
193
                                    this.SetFinalPDF(project_no, dOCINFO.ID, mARKUPINFO.ID, user_id);
194
                                }
195
                            }
196
                        }
197
                    }
198
                }
199

    
200
            }
201
            catch (Exception ex)
202
            {
203
                logger.Error($"StampSave ProjectNO : {project_no} slipNo : {slip_no} userID : {user_id}" + ex);
204
                result = "Stamp Save Error";
205
            }
206

    
207
            return result;
208
        }
209

    
210
        private List<MEMBER> GetMemberQuery(System.Data.Objects.ObjectContext context, string UserID)
211
        {
212
            List<MEMBER> result = new List<MEMBER>();
213

    
214
            try
215
            {
216
                string query = "SELECT members.ID,members.NAME,members.DEPARTMENT FROM CIEntities.MEMBER as members where members.ID = @userId";
217

    
218
                var param = new[] { new System.Data.Objects.ObjectParameter("userId", UserID) };
219

    
220
                System.Data.Objects.ObjectQuery<System.Data.Common.DbDataRecord> memberQuery
221
                              = context.CreateQuery<System.Data.Common.DbDataRecord>(query, param);
222
             
223
                if (memberQuery.Count() > 0)
224
                {
225
                    foreach (var dataRecord in memberQuery)
226
                    {
227
                        MEMBER member = new MEMBER();
228

    
229
                        string userName = dataRecord["NAME"]?.ToString().Trim();
230
                        string ID = dataRecord["ID"]?.ToString().Trim();
231
                        string depatment = dataRecord["DEPARTMENT"]?.ToString().Trim();
232

    
233
                        member.NAME = userName;
234
                        member.ID = ID;
235
                        member.DEPARTMENT = depatment;
236

    
237
                        result.Add(member);
238
                    }
239
                }
240
            }
241
            catch (Exception ex)
242
            {
243
                throw new Exception("GetMember(System.Data.Objects.ObjectContext context, string UserID) ", ex);
244
            }
245

    
246
            return result;
247
        }
248

    
249
        private SelectMember GetSelectMember(System.Data.Objects.ObjectContext context,string ProjectNo,string SlipNo, string UserID)
250
        {
251
            SelectMember result = new SelectMember();
252

    
253
            try
254
            {
255
                string query = "SELECT_SLIP_ORIGINATOR @P_PROJECT_NO = @ProjectNo , @P_SLIP_NO = @SlipNo  ,@P_USER_ID = @UserID";
256

    
257
                var param = new[]{
258
                    new System.Data.SqlClient.SqlParameter("ProjectNo", ProjectNo),
259
                    new System.Data.SqlClient.SqlParameter("SlipNo", SlipNo),
260
                    new System.Data.SqlClient.SqlParameter("UserID", UserID)
261

    
262
                };
263

    
264
                //var memberQuery = context.ExecuteStoreQuery<System.Data.Common.DbDataRecord>(query, param).ToList();
265

    
266
                //if (memberQuery.Count() > 0)
267
                //{
268
                //    result.USER_NAME = memberQuery.First()["USER_NAME"]?.ToString();
269
                //    result.IS_ORIGINATOR = Convert.ToInt32(memberQuery.First()["IS_ORIGINATOR"]);
270
                //}
271

    
272
                var memberQuery = context.ExecuteStoreQuery<SelectMember>(query, param).ToList();
273
            
274
                if (memberQuery.Count() > 0)
275
                {
276
                    result = memberQuery.First();
277
                }
278
            }
279
            catch (Exception ex)
280
            {
281
                throw new Exception("GetMember(System.Data.Objects.ObjectContext context, string UserID) ", ex);
282
            }
283

    
284
            return result;
285
        }
286

    
287
        private void StampSave_NoneSymbol(string project_no, string slip_no, string user_id)
288
        {
289
            try
290
            {
291
                logger.Info($"Stamp  ProjecNO : {project_no}  SlipNO : {slip_no}  UserID : {user_id}");
292

    
293
                using (CIEntities cIEntity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(project_no).ToString()))
294
                {
295
                    logger.Info($"Connection CI DataBase :{cIEntity.Connection.Database} DataSource :{cIEntity.Connection.DataSource}");
296

    
297
                    var list = (from doc in cIEntity.DOCUMENT_ITEM
298
                                where doc.GROUP_NO == slip_no && doc.PROJECT_NO == project_no
299
                                select doc).ToList();
300

    
301
                    foreach (DOCUMENT_ITEM dOCUMENTITEM in list)
302
                    {
303
                        DOCINFO dOCINFO = (
304
                            from x in cIEntity.DOCINFO
305
                            where x.PROJECT_NO == project_no && x.DOCUMENT_ID == dOCUMENTITEM.DOCUMENT_ID
306
                            select x).FirstOrDefault<DOCINFO>();
307

    
308
                        MARKUP_INFO mARKUPINFO = (
309
                            from x in cIEntity.MARKUP_INFO
310
                            where x.DOCINFO_ID == dOCINFO.ID && x.AVOID_CONSOLIDATE == 0 && x.CONSOLIDATE == 1
311
                            select x).FirstOrDefault<MARKUP_INFO>();
312

    
313
                        if (mARKUPINFO == null)
314
                        {
315
                            var pageInfo = dOCINFO.DOCPAGE.First();
316

    
317
                            mARKUPINFO = new MARKUP_INFO()
318
                            {
319
                                ID = shortGuid(),
320
                                DOCINFO_ID = dOCINFO.ID,
321
                                USER_ID = user_id,
322
                                CREATE_TIME = DateTime.Now,
323
                                CONSOLIDATE = 1,
324
                                AVOID_CONSOLIDATE = 0,
325
                                PART_CONSOLIDATE = 0,
326
                                DESCRIPTION = "",
327
                                UPDATE_TIME = new DateTime?(DateTime.Now),
328
                            };
329

    
330
                            cIEntity.MARKUP_INFO.AddObject(mARKUPINFO);
331

    
332
                            MARKUP_INFO_VERSION mARKUPINFOVERSION = new MARKUP_INFO_VERSION()
333
                            {
334
                                ID = shortGuid(),
335
                                MARKUPINFO_ID = mARKUPINFO.ID,
336
                                CREATE_DATE = DateTime.Now
337
                            };
338

    
339
                            cIEntity.MARKUP_INFO_VERSION.AddObject(mARKUPINFOVERSION);
340

    
341
                            Point startPoint = new Point(15, 15);
342
                   
343
                            var rect = Common.GetRectControl(Convert.ToDouble(pageInfo.PAGE_WIDTH), Convert.ToDouble(pageInfo.PAGE_HEIGHT),
344
                                                    mARKUPINFO.USER_ID, mARKUPINFO.ID, startPoint);
345

    
346
                            var txtApproved = GetTextControl(Convert.ToDouble(pageInfo.PAGE_WIDTH), Convert.ToDouble(pageInfo.PAGE_HEIGHT), mARKUPINFO.USER_ID, mARKUPINFO.ID,
347
                                                         "APPROVED", 30, System.Windows.Media.Color.FromArgb(255, 255, 0, 0), FontWeights.Bold, TextAlignment.Center, rect.ItemRect, 18);
348

    
349
                            var txtCreator = GetTextControl(Convert.ToDouble(pageInfo.PAGE_WIDTH), Convert.ToDouble(pageInfo.PAGE_HEIGHT), mARKUPINFO.USER_ID, mARKUPINFO.ID
350
                                            , "By HYOSUNG", 18, System.Windows.Media.Color.FromArgb(255, 255, 0, 0), FontWeights.Bold, TextAlignment.Center, rect.ItemRect, txtApproved.StartPoint.Y + txtApproved.BoxHeight + 3);
351

    
352
                            var bottom = Rect.Offset(rect.ItemRect, new Vector(0, rect.ItemRect.Height));
353

    
354
                            var txtOriginator = GetTextControl(Convert.ToDouble(pageInfo.PAGE_WIDTH), Convert.ToDouble(pageInfo.PAGE_HEIGHT), mARKUPINFO.USER_ID, mARKUPINFO.ID
355
                                           , mARKUPINFO.USER_ID, 18,System.Windows.Media.Color.FromArgb(255, 255, 0, 0), FontWeights.Bold, TextAlignment.Left, bottom, bottom.Top + 3);
356

    
357
                            var dtfi = new System.Globalization.DateTimeFormatInfo { DateSeparator = "-", ShortDatePattern = @"yyyy/MM/dd" };
358

    
359
                            var txtDate = GetTextControl(Convert.ToDouble(pageInfo.PAGE_WIDTH), Convert.ToDouble(pageInfo.PAGE_HEIGHT), mARKUPINFO.USER_ID, mARKUPINFO.ID
360
                                           , 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);
361

    
362
                            var rectData = rect.GetMarkupData(mARKUPINFO.USER_ID, 1, mARKUPINFOVERSION.ID);
363
                            cIEntity.MARKUP_DATA.AddObject(rectData);
364

    
365
                            cIEntity.MARKUP_DATA.AddObject(txtApproved.GetMarkupData(mARKUPINFO.USER_ID, 1, mARKUPINFOVERSION.ID));
366
                            cIEntity.MARKUP_DATA.AddObject(txtCreator.GetMarkupData(mARKUPINFO.USER_ID, 1, mARKUPINFOVERSION.ID));
367
                            cIEntity.MARKUP_DATA.AddObject(txtOriginator.GetMarkupData(mARKUPINFO.USER_ID, 1, mARKUPINFOVERSION.ID));
368
                            cIEntity.MARKUP_DATA.AddObject(txtDate.GetMarkupData(mARKUPINFO.USER_ID, 1, mARKUPINFOVERSION.ID));
369
                        }
370
                        cIEntity.SaveChanges();
371

    
372

    
373
                        this.SetFinalPDF(project_no, dOCINFO.ID, mARKUPINFO.ID, user_id);
374
                    }
375
                }
376

    
377
            }
378
            catch (Exception ex)
379
            {
380
                logger.Error($"StampSave ProjectNO : {project_no} slipNo : {slip_no} userID : {user_id}" + ex);
381
            }
382
        }
383

    
384
        private static string shortGuid()
385
        {
386
            byte[] bytes = new byte[16];
387
            using (var provider = System.Security.Cryptography.RandomNumberGenerator.Create())
388
            {
389
                provider.GetBytes(bytes);
390
            }
391

    
392
            var guid = new Guid(bytes);
393

    
394
            return Convert.ToBase64String(guid.ToByteArray())
395
                .Substring(0, 10)
396
                .Replace("/", "")
397
                .Replace("+", "") + DateTime.UtcNow.Ticks.ToString("x");
398
        }
399

    
400
        private SymControlN GetSymNControl(double PageWidth, double PageHeight, string userId, string markupInfoId, Point startPosition,string StampData)
401
        {
402
            SymControlN result = null;
403

    
404
            try
405
            {
406
                double height = 80;
407
                double itemWidth = 180;
408

    
409
                System.Windows.Point startPoint = new System.Windows.Point(startPosition.X, startPosition.Y);
410
                System.Windows.Point endPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y + height);
411
                System.Windows.Point leftBottomPoint = new System.Windows.Point(startPosition.X, startPosition.Y + height);
412
                System.Windows.Point topRightPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y);
413

    
414
                result = new SymControlN
415
                {
416
                    CommentID = shortGuid(),
417
                    MarkupInfoID = markupInfoId,
418
                    UserID = userId,
419
                    PointSet = new List<Point> { startPoint, leftBottomPoint, endPoint, topRightPoint },
420
                    StartPoint = startPoint,
421
                    EndPoint = endPoint,
422
                    CommentAngle = 0,
423
                    LeftBottomPoint = leftBottomPoint,
424
                    TopRightPoint = topRightPoint,
425
                    Opacity = 1,
426
                    PathXathData = StampData,
427
                    Memo = null
428
                };
429

    
430
            }
431
            catch (Exception ex)
432
            {
433
                System.Diagnostics.Debug.WriteLine(ex.ToString());
434
            }
435

    
436
            return result;
437
        }
438

    
439

    
440
        private static RectangleControl GetRectControl(double PageWidth, double PageHeight, string USER_ID, string markupInfoId, Point startPosition)
441
        {
442
            RectangleControl result = null;
443

    
444
            try
445
            {
446
                double height = 80;
447
                double itemWidth = 180;
448

    
449
                System.Windows.Point startPoint = new System.Windows.Point(startPosition.X, startPosition.Y);
450
                System.Windows.Point endPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y + height);
451
                System.Windows.Point leftBottomPoint = new System.Windows.Point(startPosition.X, startPosition.Y + height);
452
                System.Windows.Point topRightPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y);
453

    
454
                result = new RectangleControl
455
                {
456
                    CommentID = shortGuid(),
457
                    MarkupInfoID = markupInfoId,
458
                    LineSize = 5,
459
                    Paint = MarkupToPDF.Controls.Common.PaintSet.None,
460
                    StartPoint = startPoint,
461
                    EndPoint = endPoint,
462
                    CommentAngle = 0,
463
                    StrokeColor = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 255, 0x0, 0x0)),
464
                    //StrokeColor = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 64, 224, 208)),
465
                    FillColor = null,
466
                    DashSize = new System.Windows.Media.DoubleCollection(new[] { 999999.0 }),
467
                    Opacity = 1,
468
                    LeftBottomPoint = leftBottomPoint,
469
                    TopRightPoint = topRightPoint,
470
                    PointSet = new List<Point> { startPoint, leftBottomPoint, endPoint, topRightPoint },
471
                    UserID = USER_ID,
472
                    Memo = null,
473
                    SymbolID = null
474
                    
475
                };
476
            }
477
            catch (Exception ex)
478
            {
479
                System.Diagnostics.Debug.WriteLine(ex.ToString());
480
            }
481

    
482
            return result;
483
        }
484

    
485
        [STAThread]
486
        private static TextControl GetTextControl(double PageWidth, double PageHeight, string USER_ID, string markupInfoId, 
487
            string Text, double fontSize, System.Windows.Media.Color Foreground, FontWeight fontWeight, TextAlignment textAlignment, Rect parentRect, double positionY)
488
        {
489
            TextControl result = null;
490

    
491
            try
492
            {
493

    
494
                var txtSize = ShapeMeasure(new TextBlock
495
                {
496
                    Text = Text,
497
                    FontSize = fontSize,
498
                    FontWeight = fontWeight,
499
                    FontFamily = new System.Windows.Media.FontFamily("Arial")
500
                });
501

    
502
                double startPositionX = parentRect.X;
503

    
504
                switch (textAlignment)
505
                {
506
                    case TextAlignment.Right:
507
                        startPositionX = parentRect.X + parentRect.Width - txtSize.Width;
508
                        break;
509
                    case TextAlignment.Center:
510
                        startPositionX = parentRect.X + parentRect.Width / 2 - txtSize.Width / 2;
511
                        break;
512
                }
513

    
514
                Point startPosition = new Point
515
                {
516
                    X = startPositionX,
517
                    Y = positionY
518
                };
519

    
520
                System.Windows.Point startPoint = new System.Windows.Point(startPosition.X, startPosition.Y);
521
                System.Windows.Point endPoint = new System.Windows.Point(startPosition.X + txtSize.Width, startPosition.Y + txtSize.Height);
522
                System.Windows.Point leftBottomPoint = new System.Windows.Point(startPosition.X, startPosition.Y + txtSize.Height);
523
                System.Windows.Point topRightPoint = new System.Windows.Point(startPosition.X + txtSize.Width, startPosition.Y);
524

    
525
                result = new TextControl
526
                {
527
                    CommentID = shortGuid(),
528
                    MarkupInfoID = markupInfoId,
529
                    Text = Text,
530
                    StartPoint = startPoint,
531
                    EndPoint = endPoint,
532
                    CanvasX = startPosition.X,
533
                    CanvasY = startPosition.Y,
534
                    BoxWidth = txtSize.Width,
535
                    BoxHeight = txtSize.Height,
536
                    ControlType_No = 0,
537
                    LineSize = new Thickness(5),
538
                    TextSize = fontSize,
539
                    Foreground = new System.Windows.Media.SolidColorBrush(Foreground),
540
                    FontSize = 10,
541
                    UserID = USER_ID,
542
                    IsHighLight = false,
543
                    CommentAngle = 0,
544
                    PointSet = new List<Point>(),
545
                    Opacity = 1,
546
                    IsSelected = false,
547
                    TextFamily = new System.Windows.Media.FontFamily("Arial"),
548
                    TextStyle = FontStyles.Normal,
549
                    TextWeight = FontWeights.Bold
550
                };
551

    
552
            }
553
            catch (Exception ex)
554
            {
555
                throw new Exception("Text Control error");
556
            }
557

    
558
            return result;
559
        }
560
        public static Size ShapeMeasure(UIElement e)
561
        {
562
            // Measured Size is bounded to be less than maxSize
563
            Size maxSize = new Size(
564
                 double.PositiveInfinity,
565
                 double.PositiveInfinity);
566
            e.Measure(maxSize);
567
            return e.DesiredSize;
568
        }
569
        private void SetTextControl(TextControl textControl)
570
        {
571
            textControl.Base_TextBlock.Margin = new Thickness(0, 0, 10, 0);
572
            textControl.Base_TextBox.Visibility = Visibility.Collapsed;
573
            textControl.Base_TextBlock.Visibility = Visibility.Visible;
574

    
575
        }
576

    
577
        #region Final PDF
578
        private string _ChanID = null;
579
        TcpChannel chan = null;
580

    
581
        [OperationContract]
582
        public FinalPDFResult SetFinalPDF(string ProjectNo, string DocInfoID, string MarkupInfoID, string CreateUSER_ID)
583
        {
584
            #region 임시보관
585
            #endregion
586
            FinalPDFResult _result = new FinalPDFResult();
587
            RemFinalPDFObject remObj = null;
588
            try
589
            {
590
                string _finalID = shortGuid();
591
                int _DocTotalPages = -1;
592
                string docItemId;
593

    
594
                logger.Info($"SetFinalPDF ProjectNo :{ProjectNo} DocInfoID :{DocInfoID}  MarkupInfoID:{MarkupInfoID}  CreateUSER_ID:{CreateUSER_ID}");
595

    
596
                //string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString;
597
                using (CIEntities _ci = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(ProjectNo).ToString()))
598
                {
599
                    logger.Info($"Connection CI DataBase :{_ci.Connection.Database} DataSource :{_ci.Connection.DataSource}");
600
                    var _doc = _ci.DOCINFO.Where(info => info.ID == DocInfoID);
601

    
602
                    if (_doc.Count() > 0)
603
                    {
604
                        _DocTotalPages = _doc.First().PAGE_COUNT;
605
                        docItemId = _doc.First().DOCUMENT_ID;
606
                    }
607
                    else
608
                    {
609
                        _result.Status = FinalStatus.Error;
610
                        _result.Exception = "페이지 정보를 가져올 수 없습니다.";
611
                        return _result;
612
                    }
613
                }
614
                if (_DocTotalPages > 0)
615
                {
616
                    FINAL_PDF fm = new FINAL_PDF()
617
                    {
618
                        ID = _finalID,
619
                        PROJECT_NO = ProjectNo,
620
                        DOCINFO_ID = DocInfoID,
621
                        DOCUMENT_ID = docItemId,
622
                        MARKUPINFO_ID = MarkupInfoID,
623
                        CREATE_USER_ID = CreateUSER_ID,
624
                        TOTAL_PAGE = _DocTotalPages,
625
                        CREATE_DATETIME = DateTime.Now,
626
                        STATUS = (int)IFinalPDF.FinalStatus.Insert
627
                    };
628

    
629
                    //string sConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
630
                    using (KCOMEntities _entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
631
                    {
632
                        logger.Info($"Connection KCOM DataBase :{_entity.Connection.Database} DataSource :{_entity.Connection.DataSource}");
633

    
634
                        _entity.AddToFINAL_PDF(fm);
635
                        _entity.SaveChanges(System.Data.Objects.SaveOptions.AcceptAllChangesAfterSave);
636
                    };
637

    
638
                    System.Runtime.Remoting.Channels.IChannel _ch = System.Runtime.Remoting.Channels.ChannelServices.GetChannel("tcp");
639
                    if (_ch == null)
640
                    {
641
                        chan = new TcpChannel();
642
                        _ChanID = chan.ChannelName;
643
                        System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(chan, false);
644
                        // Create an instance of the remote object
645

    
646
                        using (KCOMEntities ec = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
647
                        {
648

    
649
                            //remObj = (RemFinalPDFObject)Activator.GetObject(typeof(RemFinalPDFObject),
650
                            //                          "tcp://localhost:9092/remFinalPDF");
651
                            remObj = (RemFinalPDFObject)Activator.GetObject(typeof(RemFinalPDFObject),
652
                                                      //"tcp://192.168.0.67:9092/remFinalPDF");
653
                                                      "tcp://localhost:9092/remFinalPDF");
654
                        }
655

    
656
                        //"tcp://localhost:8080/remFinalPDF");
657

    
658
                        _result = remObj.SetFinalPDF(ProjectNo, _finalID);
659
                        _result.FinalID = _finalID;
660
                        _result.Status = FinalStatus.Success;
661

    
662
                        //MarkupToPDF.MarkupToPDF fa = new MarkupToPDF.MarkupToPDF();
663
                        //fa.MakeFinalPDF(fm);
664
                    }
665
                    else
666
                    {
667
                        _ChanID = _ch.ChannelName;
668
                    }
669
                }
670
            }
671
            catch (Exception ex)
672
            {
673
                logger.Error($"SetFinalPDF - " + ex);
674

    
675
                _result.Status = FinalStatus.Error;
676

    
677
                if (ex.GetType() == typeof(System.Net.Sockets.SocketException))
678
                    _result.Exception = "Final Server Not Connection";
679
                else _result.Exception = ex.ToString();
680
            }
681
            finally
682
            {
683
                remObj = null;
684
                if (System.Runtime.Remoting.Channels.ChannelServices.GetChannel("tcp") != null)
685
                    System.Runtime.Remoting.Channels.ChannelServices.UnregisterChannel(chan);
686

    
687
                GC.Collect(2);
688
            }
689
            return _result;
690
        }
691
        #endregion
692

    
693
    }
694

    
695
    public class SelectMember
696
    {
697
        public string USER_NAME { get; set; }
698

    
699
        /// <summary>
700
        /// 0보다 크면 originator
701
        /// </summary>
702
        public int IS_ORIGINATOR { get; set; }
703
    }
704
}
클립보드 이미지 추가 (최대 크기: 500 MB)