프로젝트

일반

사용자정보

개정판 1d79913e

ID1d79913ed251f7cde902fe7017e289cdc350ab0e
상위 42d49521
하위 b4a1c7ff

김태성이(가) 약 2년 전에 추가함

issue #00000 error notice mail 안 되는 문제 수정

Change-Id: I307236bdea2ca63347b99a174c02e1e53f05a3a7

차이점 보기:

ConvertService/ServiceBase/Markus.Service.Convert/ConvertService.cs
14 14

  
15 15
using System.Threading.Tasks;
16 16
using System.Web;
17
using StatusCodeType = Markus.Message.StatusCodeType;
17 18

  
18 19
namespace Markus.Service.Convert
19 20
{
......
118 119

  
119 120
                switch (e.SaveItem.Status)
120 121
                {
121
                    case StatusCodeType.None:
122
                    case Message.StatusCodeType.None:
122 123
                        break;
123
                    case StatusCodeType.Wait:
124
                    case Message.StatusCodeType.Wait:
124 125
                        break;
125
                    case StatusCodeType.PageLoading:
126
                    case Message.StatusCodeType.PageLoading:
126 127
                        break;
127
                    case StatusCodeType.Saving:
128
                    case Message.StatusCodeType.Saving:
128 129
                        break;
129
                    case StatusCodeType.Completed:
130
                    case Message.StatusCodeType.Completed:
130 131
                        break;
131
                    case StatusCodeType.FileError:
132
                    case Message.StatusCodeType.FileError:
132 133
                        break;
133
                    case StatusCodeType.PageError:
134
                    case Message.StatusCodeType.PageError:
134 135
                        break;
135
                    case StatusCodeType.FontNotFound:
136
                    case Message.StatusCodeType.FontNotFound:
136 137
                        break;
137
                    case StatusCodeType.NeedsPassword:
138
                    case Message.StatusCodeType.NeedsPassword:
138 139
                        break;
139
                    case StatusCodeType.Error:
140
                    case Message.StatusCodeType.Error:
140 141
                        break;
141 142
                    default:
142 143
                        break;
143 144
                }
144

  
145 145
#if PROCESS_TEST
146 146
                Console.WriteLine($"send wcf service {e.SaveItem.Status}  currentPage : {e.SaveItem.CurrentPage} error message : {(string.IsNullOrWhiteSpace(e.SaveItem.ErrorMessage)?"null":e.SaveItem.ErrorMessage)}");
147 147
#endif
......
181 181

  
182 182
                saveitem.Status = result.StatusCode;
183 183
                saveitem.ErrorMessage = result.Message;
184

  
185
                if(saveitem.Status < StatusCodeType.Completed)
186
                {
187
                    saveitem.Status = StatusCodeType.Error;
188
                    saveitem.ErrorMessage = "unknown error";
189
                }
190

  
191
                MarkusPdfStateChangeEvent(this, new StateEventArgs(new SaveItem
192
                {
193
                    ErrorMessage = saveitem.ErrorMessage,
194
                    Id = saveitem.Id,
195
                    CurrentPage = saveitem.CurrentPage,
196
                    TotalPages = saveitem.TotalPages,
197
                    Status = saveitem.Status
198
                }));
199

  
200
                // 플러그인 실행
201
#if PROCESS_TEST
202

  
203
                Console.WriteLine($"run Plugin : {saveitem.Id}");
204
#endif
205
                PluginService.Run(saveitem.Id);
206

  
184 207
#if PROCESS_TEST
185 208

  
186 209
                Console.WriteLine($"finish!!!");
187
#endif     
210
#endif
188 211

  
189 212
                StationServiceClient.ConvertFinish(saveitem.Id, (int)saveitem.Status, saveitem.CurrentPage, saveitem.TotalPages, saveitem.ErrorMessage);
190

  
191 213
            }
192 214
            catch (Exception ex)
193 215
            {
......
213 235
                StationServiceClient.ConvertFinish(saveitem.Id, (int)saveitem.Status, saveitem.CurrentPage, saveitem.TotalPages, $"ConvertService Error    {saveitem.Id} {saveitem.ErrorMessage }");
214 236

  
215 237
            }
216
            finally
217
            {
218
                this.Dispose();
219
            }
220

  
221
            // 플러그인 실행
222
#if PROCESS_TEST
223

  
224
                Console.WriteLine($"run Plugin : {saveitem.Id}");
225
#endif
226
            PluginService.Run(saveitem.Id);
227 238

  
228 239
            return saveitem;
229 240
        }
......
267 278
                System.IO.Directory.CreateDirectory(saveitem.SavePath);
268 279

  
269 280
                //파일 다운로드
270
                if (DownloadFile(saveitem,out string downloadFilePath))
281
                var fileDownloadResult = DownloadFile(saveitem);
282

  
283
                if (fileDownloadResult.IsSuccess)
271 284
                {
285
                    string downloadFilePath = fileDownloadResult.DownloadFilePath;
286

  
272 287
                    var status =  gMarkusPDF.pdfLoad(downloadFilePath, saveitem.MinimumFontSize, saveitem.UseResolution, gFontsFolder);
273 288

  
274 289
                    if (gMarkusPDF.PageCount() > 0)
275 290
                    {
291
                        saveitem.TotalPages = gMarkusPDF.PageCount();
292

  
276 293
                        /// 설정된 MultiThreadMaxPages에 따른 컨버터 분기
277 294
                        if (gMarkusPDF.PageCount() > ConvertProcessContext.MultiThreadMaxPages)
278 295
                        {
279 296
                            // 큰 사이즈의 파일 컨버팅
280
                            result = ConvertBigFileProcess(saveitem, downloadFilePath);
297
                            result = ConvertBigFileProcess(saveitem.TotalPages, saveitem.Id, downloadFilePath,saveitem.SavePath, saveitem.MinimumFontSize,saveitem.UseResolution,gFontsFolder);
281 298
                        }
282 299
                        else
283 300
                        {
284 301
                            /// 작은 사이즈의 컨버팅
285
                            var task = new Task(new Action(() =>
302
                            result = gSaveTask.SaveFile(new Markus.Message.SaveItem
286 303
                            {
287
                                result = gSaveTask.SaveFile(saveitem);
288
                            }), TaskCreationOptions.LongRunning);
289

  
290
                            task.Start();
291
                            task.Wait();
304
                                PdfFilePath = downloadFilePath,
305
                                SavePath = saveitem.SavePath,
306
                                MinimumFontSize = saveitem.MinimumFontSize,
307
                                UseResolution = saveitem.UseResolution
308
                            });
292 309
                        }
310
                        
311
                        saveitem.Status = result.StatusCode;
312
                        saveitem.ErrorMessage = result.Message;
293 313

  
294 314
                        if ((int)result.StatusCode <= (int)StatusCodeType.Completed)
295 315
                        {
......
308 328

  
309 329
                                ReConvert = 1;
310 330

  
311
                                result = ConvertBigFileProcess(saveitem, downloadFilePath);
331
                                result = ConvertBigFileProcess(saveitem.TotalPages, saveitem.Id, downloadFilePath, saveitem.SavePath, saveitem.MinimumFontSize, saveitem.UseResolution, gFontsFolder);
332

  
333
                                saveitem.Status = result.StatusCode;
334
                                saveitem.ErrorMessage = result.Message;
312 335
                            }
313 336

  
314 337
                            ///  페이지 정보 저장
......
387 410
            return result;
388 411
        }
389 412

  
390
        public bool DownloadFile(SaveItem saveItem,out string DownloadFilePath)
413
        public FileDownloadResult DownloadFile(SaveItem saveItem)
391 414
        {
392
            bool result = false;
393
            string downloadFilePath = null;
415
            FileDownloadResult result = new FileDownloadResult();
416

  
394 417
            try
395 418
            {
396
                result = DownloadPluginService.Download(saveItem.PdfFilePath, saveItem.SavePath, ref downloadFilePath);
419
                result = DownloadPluginService.Download(saveItem.PdfFilePath, saveItem.SavePath);
397 420
            }
398 421
            catch (Exception ex)
399 422
            {
400 423
                logger.Error(ex);
401
                throw new Exception(ex.ToString());
424
                result.IsSuccess = false;
425
                result.Exception = new Exception(ex.ToString());
402 426
            }
403 427

  
404
            DownloadFilePath = downloadFilePath;
405 428
            return result;
406 429
        }
407 430

  
......
564 587
        /// </summary>
565 588
        /// <param name="saveitem"></param>
566 589
        /// <returns></returns>
567
        private SaveResult ConvertBigFileProcess(SaveItem saveitem,string downloadFilePath)
590
        private SaveResult ConvertBigFileProcess(int totalPages,string convertId, string downloadFilePath, string savePath, int minimumFontSize,int useResolution,string fontsFolder)
568 591
        {
569 592
            SaveResult result = new SaveResult();
570 593

  
571 594
            try
572 595
            {
573
                saveitem.TotalPages = gMarkusPDF.PageCount();
574

  
575
                for (int currentPageNo = 1; currentPageNo <= saveitem.TotalPages; currentPageNo++)
596
                for (int currentPageNo = 1; currentPageNo <= totalPages; currentPageNo++)
576 597
                {
577 598
                    try
578 599
                    {
579
                        string saveFile = Path.Combine(saveitem.SavePath, $"{currentPageNo}.png");
600
                        string saveFile = Path.Combine(savePath, $"{currentPageNo}.png");
580 601

  
581 602
                        if (ReConvert < 1 || (ReConvert == 1 && !File.Exists(saveFile)))
582 603
                        {
583 604
                            SaveResult saveResult = new SaveResult { StatusCode = StatusCodeType.None };
605
                            StatusCodeType stateCode = StatusCodeType.Saving;
584 606

  
585 607
                            try
586 608
                            {
......
588 610
                            }
589 611
                            catch (Exception ex)
590 612
                            {
591
                                saveitem.ErrorMessage = LogHelper.GetStack() + " " + saveResult.Message + " " + ex.ToString();
613
                                result.Message = LogHelper.GetStack() + " " + ex.ToString() + " " + result.Message;
592 614
                            }
593 615

  
594
                            if(saveResult.StatusCode == StatusCodeType.Completed)
595
                            {
596
                                saveitem.Status = StatusCodeType.Saving;
597
                                saveitem.CurrentPage = currentPageNo;
598
                                saveitem.ErrorMessage = saveResult.Message;
616
                            result.StatusCode = saveResult.StatusCode;
599 617

  
600
                                int pageListCount = 0;
601

  
602
                                if (result.PageInfoList != null)
603
                                {
604
                                    pageListCount = result.PageInfoList.Count(f => f.PageNo == saveResult.SavePageInfo.PageNo);
605
                                }
618
                            if (result.StatusCode != StatusCodeType.Completed)
619
                            {
620
                                stateCode = result.StatusCode;
621
                            }
606 622

  
607
                                if (pageListCount == 0)
608
                                {
609
                                    result.PageInfoAdd(saveResult.SavePageInfo);
610
                                }
623
                            MarkusPdfStateChangeEvent(this, new StateEventArgs(new SaveItem
624
                            {
625
                                ErrorMessage = result.Message,
626
                                Id = convertId,
627
                                CurrentPage = currentPageNo,
628
                                TotalPages = totalPages,
629
                                Status = stateCode
630
                            }));
631

  
632
                            if (saveResult.StatusCode == StatusCodeType.Completed)
633
                            {
634
                                result.PageInfoAdd(saveResult.SavePageInfo);
611 635

  
612
                                MarkusPdfStateChangeEvent(this, new StateEventArgs(saveitem));
613 636
                                Console.WriteLine($"CurrentPage : {currentPageNo}");
614 637

  
615 638
                                /// 설정된 최대 페이지이거나 설정된 메모리보다 크면 릴리즈
......
623 646
                                    System.Threading.Thread.SpinWait(5);
624 647

  
625 648
                                    gMarkusPDF = new MarkusPDF();
626
                                    gMarkusPDF.pdfLoad(downloadFilePath, saveitem.MinimumFontSize, saveitem.UseResolution, gFontsFolder);
649
                                    gMarkusPDF.pdfLoad(downloadFilePath,minimumFontSize,useResolution, fontsFolder);
627 650
                                }
628 651

  
629 652
                                System.Threading.Thread.SpinWait(2);
630 653
                            }
631 654
                            else
632 655
                            {
633
                                saveitem.Status = saveResult.StatusCode;
634
                                saveitem.CurrentPage = currentPageNo;
635
                                saveitem.ErrorMessage = saveResult.Message;
636

  
637
                                result.StatusCode = saveitem.Status;
638
                                result.Message = saveitem.ErrorMessage;
639

  
640
                                MarkusPdfStateChangeEvent(this, new StateEventArgs(saveitem));
641
                                
642 656
                                Console.WriteLine($"CurrentPage : {currentPageNo}");
643
                                Console.WriteLine($"convert ID : {saveitem.Id}");
644
                                Console.WriteLine($"pdf file Path : {saveitem.PdfFilePath}");
645
                                Console.WriteLine($"save file path : {saveitem.SavePath}");
646
                                Console.WriteLine($"last status code : {saveitem.Status}");
647
                                Console.WriteLine($"error message : {saveitem.ErrorMessage}");
657
                                Console.WriteLine($"convert ID : {convertId}");
658
                                Console.WriteLine($"pdf file Path : {downloadFilePath}");
659
                                Console.WriteLine($"save file path : {savePath}");
660
                                Console.WriteLine($"last status code : {result.StatusCode}");
661
                                Console.WriteLine($"error message : {result.Message}");
662

  
648 663
                                break;
649 664
                            }
650 665
                        }
......
661 676
                        }
662 677

  
663 678
                        gMarkusPDF = new MarkusPDF();
664
                        gMarkusPDF.pdfLoad(downloadFilePath, saveitem.MinimumFontSize, saveitem.UseResolution, gFontsFolder);
679
                        gMarkusPDF.pdfLoad(downloadFilePath, minimumFontSize, useResolution, fontsFolder);
665 680

  
666 681
                        currentPageNo = currentPageNo - 1;
667 682
                    }

내보내기 Unified diff

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