프로젝트

일반

사용자정보

개정판 e8fc231d

IDe8fc231dfb225ba81557688c22552098d387c127
상위 7e810f54
하위 7c110a46

백흠경이(가) 10달 전에 추가함

Fix: FinalService 주석 처리

Change-Id: I1f1b6cb226b8dd0b0f31e362acd92c9c60b7ea60

차이점 보기:

FinalService/KCOM_FinalService_DL/IFinalPDF/Cache.cs
7 7
{
8 8
    public class Cache
9 9
    {
10
        private static Cache myInstance;
11
        public static InterfaceFinalPDF Observer;
10
        private static readonly Lazy<Cache> lazy = new Lazy<Cache>(() => new Cache());
12 11

  
12
        public static InterfaceFinalPDF Observer { get; set; }
13

  
14
        /// <summary>
15
        /// private 생성자 선언
16
        /// </summary>
13 17
        private Cache()
14 18
        {
15

  
16 19
        }
17 20

  
18
        public static void Attach(InterfaceFinalPDF observer)
21
        public static Cache Instance
19 22
        {
20
            Observer = observer;
23
            get { return lazy.Value; }
21 24
        }
22 25

  
23
        public static Cache GetInstance()
26
        public static void Attach(InterfaceFinalPDF observer)
24 27
        {
25
            if (myInstance == null)
26
            {
27
                myInstance = new Cache();
28
            }
29
            return myInstance;
28
            if(observer != null) Observer = observer;
30 29
        }
31
        //public Final
30

  
31
        /// <summary>
32
        /// Final PDF를 수행한다.
33
        /// </summary>
34
        /// <param name="ProjectNo"></param>
35
        /// <param name="FinalID"></param>
36
        /// <returns></returns>
32 37
        public FinalPDFResult SetFinalPDF(string ProjectNo, string FinalID)
33 38
        {
34 39
            return Observer.Notify(ProjectNo, FinalID);
35 40
        }
36 41
    }
37

  
38 42
}
FinalService/KCOM_FinalService_DL/IFinalPDF/InterfaceFinalPDF.cs
7 7
{
8 8
    public interface InterfaceFinalPDF
9 9
    {
10

  
11 10
        FinalPDFResult Notify(string ProjectNo, string FinalID);
12 11
        void Finish(string ProjectNo, string FinalID, string OriginFileName, string FinalPDFPath, string remodeFilePath);
13 12

  
FinalService/KCOM_FinalService_DL/IFinalPDF/RemFinalPDFObject.cs
11 11
        {
12 12

  
13 13
        }
14
        
15
        /// <summary>
16
        /// Final PDF를 수행한다.
17
        /// </summary>
18
        /// <param name="ProjectNo"></param>
19
        /// <param name="FinalID"></param>
20
        /// <returns></returns>
14 21
        public FinalPDFResult SetFinalPDF(string ProjectNo, string FinalID)
15 22
        {
16
            return Cache.GetInstance().SetFinalPDF(ProjectNo, FinalID);
23
            return Cache.Instance.SetFinalPDF(ProjectNo, FinalID);
17 24
        }
18 25
    }
19 26
}
FinalService/KCOM_FinalService_DL/KCOM_FinalService/FinalService.cs
16 16
    {
17 17
        #region PROPERTIES
18 18
        System.Timers.Timer _Timer;
19
        RemFinalPDFStation _remotingFinal = null;
19
        RemFinalPDFStation _remotingFinal { get; set; } = null;
20 20

  
21 21
        public Logger logger = null;
22 22
  
23 23
        Thread _FirewallOpenThread = null;
24 24
        #endregion
25 25

  
26

  
27 26
        private void Init()
28 27
        {
29 28
            if (logger == null)
......
63 62
            this.OnStart(args);
64 63
            logger.Write("TestStartupAndStop",LogLevel.Info);
65 64

  
66
            Console.ReadLine();
65
            Console.ReadLine(); /// 사용자 입력 대기
67 66
            this.OnStop();
68 67
        }
69 68

  
FinalService/KCOM_FinalService_DL/KCOM_FinalService/Program.cs
20 20
            get
21 21
            {
22 22
                return AppDomain.CurrentDomain.BaseDirectory;
23
                //.return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "MARKUS");
24 23
            }
25 24
        }
26 25

  
......
41 40

  
42 41
            log4net.GlobalContext.Properties["LogFilePath"] = Path.Combine(AppDataFolder, "Log", "FinalService.log");
43 42

  
44
            /// get legacy interface for upload final pdf file
43
            #region get legacy interface for upload final pdf file
45 44
            string UploadFinalDllPath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UploadFinal.dll");
46 45
            if (File.Exists(UploadFinalDllPath))
47 46
            {
48
                Assembly asm = Assembly.LoadFrom(UploadFinalDllPath);
47
                Assembly asm = Assembly.Load(UploadFinalDllPath);
49 48

  
50 49
                UploadFinalAssmPath = UploadFinalDllPath;
51 50

  
......
58 57
                    Program.UploadFinalPDFInst = Activator.CreateInstance(_UploadFinalClassType, null);
59 58
                }
60 59
            }
60
            #endregion
61 61

  
62 62
            try
63 63
            {
64
                
65 64
                if (Environment.UserInteractive)
66 65
                {
67 66
                    service = new MarkusFinalService();
FinalService/KCOM_FinalService_DL/KCOM_FinalService/Remoting/RemFinalPDFStation.cs
52 52
            _Logger = eventLog;
53 53

  
54 54
            Init();
55

  
56 55
            if (!Environment.UserInteractive)
57 56
            {
58

  
59 57
                TryReFinal();
60 58
            }
61

  
62 59
        }
63 60

  
64 61
        public RemFinalPDFStation(Logger eventLog,string RemotingPort)
......
103 100
                string endpoint = "remFinalPDF";
104 101

  
105 102
                string port = CommonLib.Common.GetConfigString("Remoting", "Port", "");
106

  
107 103
                if (Environment.UserInteractive)
108 104
                {
109 105
                    port = "7707";
......
163 159
        }
164 160

  
165 161

  
162
        /// <summary>
163
        /// DATABASE에서 상태를 변경한다.
164
        /// </summary>
165
        /// <param name="finalID"></param>
166
        /// <param name="status"></param>
167
        /// <param name="log"></param>
166 168
        private void SetFinalState(string finalID, FinalStatus status,string log = null)
167 169
        {
168 170
            using (KCOMDataModel.DataModel.KCOMEntities _entity = new KCOMDataModel.DataModel.KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString()))
......
182 184
                    }
183 185
                    if (status == FinalStatus.Success)
184 186
                    {
185
                        
186 187
                        finalList.First().END_DATETIME = DateTime.Now;
187 188
                    }
188
                    if(status == FinalStatus.PdfStamp)
189
                    if(status == FinalStatus.PdfStamp && !string.IsNullOrWhiteSpace(log))
189 190
                    {
190
                        if (!string.IsNullOrWhiteSpace(log))
191
                        {
192
                            var sb = new System.Text.StringBuilder();
193
                            sb.AppendLine(log);
194
                            sb.AppendLine(finalList.First().EXCEPTION);
191
                        var sb = new System.Text.StringBuilder();
192
                        sb.AppendLine(log);
193
                        sb.AppendLine(finalList.First().EXCEPTION);
195 194

  
196
                            finalList.First().EXCEPTION = log;
197
                        }
195
                        finalList.First().EXCEPTION = log;
198 196
                    }
199 197

  
200 198
                    finalList.First().STATUS = (int)status;
201 199
                    _entity.SaveChanges();
202 200
                }
203
            };
201
            }
204 202
        }
205 203

  
206 204
        public void Dispose()
......
215 213
        /// 큐에 finalpdf를 넣고 작업 실행한다
216 214
        /// </summary>
217 215
        /// <param name="pdf"></param>
218
        private void MakeMergedPDF(object pdf)
216
        private void MakeMergedPDF(object _pdf)
219 217
        {
218
            ///TODO: 프로세스를 생성하여 실행하는 방향 고려
220 219
            /// 동시 수행 작업 갯수가 정해진 값보다 작을 경우 쓰레드를 생성하여 작업을 수행한다
221
            if (WorkingList.Count < Properties.Settings.Default.MultipleFinalCount)
220
            if (WorkingList.Count < Properties.Settings.Default.MultipleFinalCount && _pdf is FINAL_PDF pdf)
222 221
            {
223 222
                /// 작업중인 동일한 merged pdf가 없을 경우 작업 수행
224
                IEnumerable<FINAL_PDF> matched = WorkingList.Where(item => item.DOCUMENT_ID == ((FINAL_PDF)pdf).DOCUMENT_ID);
223
                IEnumerable<FINAL_PDF> matched = WorkingList.Where(item => item.DOCUMENT_ID == (pdf).DOCUMENT_ID);
225 224
                if (matched.Count() == 0)
226 225
                {
227 226
                    lock(WorkingList)
228 227
                    {
229
                        WorkingList.Add(pdf as FINAL_PDF);
228
                        WorkingList.Add(pdf);
230 229
                        Thread.Sleep(1000);
231 230
                    };
232 231

  
......
236 235
                }
237 236
                else
238 237
                {
239
                    WaitingQueue.Enqueue((FINAL_PDF)pdf);
238
                    WaitingQueue.Enqueue(pdf);
240 239
                }
241 240
            }
242 241
            else
243 242
            {
244
                WaitingQueue.Enqueue((FINAL_PDF)pdf);
243
                WaitingQueue.Enqueue(_pdf as FINAL_PDF);
245 244
            }
246 245
        }
247 246

  
......
292 291
                }
293 292
            });
294 293
        }
294

  
295 295
        /// <summary>
296 296
        /// callback for WebService
297 297
        /// </summary>
......
307 307
                    FINAL_PDF finalpdf = _entity.FINAL_PDF.Where(final =>final.PROJECT_NO == ProjectNo && final.ID == FinalID).FirstOrDefault();
308 308
                    if (finalpdf != null)
309 309
                    {
310
                        #region 쓰레드를 실행하여 MakeMergedPDF 수행
310 311
                        ThreadPool.QueueUserWorkItem(this.MakeMergedPDF, finalpdf);
312
                        #endregion
311 313
                    }
312 314
                    else
313 315
                    {
......
328 330
        private void _markuptoPDF_StatusChange(object sender, StatusChangedEventArgs e)
329 331
        {
330 332
            var _T = WorkingList.Where(t => t == (sender as MarkupToPDF.MarkupToPDF).FinalItem);
331

  
332
            if (_T.Count() > 0)
333
            if (_T.Any())
333 334
            {
334 335
                FINAL_PDF _item = _T.First();
335 336

  
......
350 351
        }
351 352

  
352 353
        /// <summary>
353
        /// final pdf 종료
354
        /// final pdf 종료, Queue에 merged pdf할 내용이 남아 있으면 merged pdf를 수행한다.
354 355
        /// </summary>
355 356
        /// <param name="sender"></param>
356 357
        /// <param name="e"></param>
......
359 360
            _Logger.Write($"End Final FinalID:{e.FinalPDF.ID} / Output:{e.FinalPDFPath} / Message :{e.Message}", LogLevel.Info);
360 361

  
361 362
            var _T = WorkingList.Where(t => t == (sender as MarkupToPDF.MarkupToPDF).FinalItem);
362
            if (_T.Count() > 0)
363
            if (_T.Any())
363 364
            {
364 365
                FINAL_PDF _item = _T.First();
365 366
                SetFinalState(_item.ID, FinalStatus.PdfStamp);
......
485 486
                string Msg = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + "\t" + name + "\t" + text + "\r\n";
486 487
                string Dir = Path.Combine(@"D:\finalpdf\error");
487 488

  
488
                if (Directory.Exists(Dir) == false)
489
                if (!Directory.Exists(Dir))
489 490
                {
490 491
                    Directory.CreateDirectory(Dir);
491 492
                }
......
534 535
            SetError(e.FinalID, e.Message);
535 536

  
536 537
            var _T = WorkingList.Where(t => t == (sender as MarkupToPDF.MarkupToPDF).FinalItem);
537
            if (_T.Count() > 0)
538
            if (_T.Any())
538 539
            {
539 540
                FINAL_PDF _Item = _T.First();
540 541
                (sender as MarkupToPDF.MarkupToPDF).FinalMakeError -= new EventHandler<MarkupToPDF.MakeFinalErrorArgs>(_markuptoPDF_FinalMakeError);
......
561 562

  
562 563
            var _T = WorkingList.Where(t => t.ID == FinalID);
563 564

  
564
            if (_T.Count() > 0)
565
            if (_T.Any())
565 566
            {
566 567
                FINAL_PDF _item = _T.First();
567 568
                SetFinalState(_item.ID, FinalStatus.PdfStamp);
......
686 687

  
687 688
                    var _T = WorkingList.Where(t => t.ID == finalPdf.ID);
688 689

  
689
                    if (_T.Count() > 0)
690
                    if (_T.Any())
690 691
                    {
691 692
                        FINAL_PDF _Item = _T.First();
692 693
                        WorkingList.Remove(_Item);
......
703 704
                    }
704 705
                }
705 706
            }
706

  
707 707
        }
708 708
    }
709 709
}
FinalService/KCOM_FinalService_DL/MarkupToPDF/MarkupToPDF.cs
596 596
                {
597 597
                    FINAL_PDF pdfLink = _entity.FINAL_PDF.Where(data => data.ID == finaldata.ID).FirstOrDefault();
598 598

  
599
                    #region 색상 적용(기본값은 Red)
599 600
                    System.Drawing.Color _SetColor = System.Drawing.Color.FromArgb(255, System.Drawing.Color.Red);
600 601
                  
601 602
                    var colorProper = _entity.PROPERTIES.Where(x => x.TYPE == colorTypeName && x.PROPERTY == pdfLink.PROJECT_NO);
602

  
603 603
                    if (colorProper.Count() > 0)
604 604
                    {
605 605
                        int param = int.Parse(colorProper.First().VALUE, System.Globalization.NumberStyles.AllowHexSpecifier);
......
616 616

  
617 617
                        _entity.SaveChanges();
618 618
                    }
619
                    #endregion
619 620

  
620 621
                    #region 코멘트 적용 + 커버시트
621 622
                    using (Stream pdfStream = new FileInfo(testFile).Open(FileMode.Open, FileAccess.ReadWrite)) //

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)