프로젝트

일반

사용자정보

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

markus / ConvertService / ServiceBase / Markus.Service.Convert / ConvertService.cs @ 950e6b84

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

1
using log4net;
2
using Markus.Message;
3
using Markus.Service.Helper;
4
using Markus.Service.Interface;
5
using System;
6
using System.Collections.Generic;
7
using System.IO;
8
using System.Linq;
9
using System.Net.Http;
10
using System.ServiceModel;
11
using System.Text;
12
using Markus.Service.Extensions;
13
using Markus.Service.WcfClient.StationServiceAsync;
14

    
15
using System.Threading.Tasks;
16
using System.Web;
17
using RestSharp;
18

    
19
namespace Markus.Service.Convert
20
{
21
    public class ConvertService : IDisposable
22
    {
23
        // 1GigaBytes
24
        protected ILog logger;
25

    
26
        readonly ProcessContext ConvertProcessContext;
27
        private string gTempFileName;
28
        private Markus.SaveTask gSaveTask;
29
        private Markus.MarkusPDF gMarkusPDF;
30
        private string gFontsFolder;
31
        private bool gIsApiDownload;
32

    
33
        // 컨버터 완료시 파일갯수를 체크 하여 틀리면 reconvert를 1로 하고 다시 컨버팅 하도록 한다.
34
        private int ReConvert;
35

    
36

    
37
        private StationServiceClient StationServiceClient; 
38

    
39
        /// <summary>
40
        /// 프로세스 초기화
41
        /// </summary>
42
        /// <param name="convertContext"></param>
43
        public ConvertService(ProcessContext convertContext) : base()
44
        {
45
            logger = LogManager.GetLogger(typeof(ConvertService));
46

    
47
            ConvertProcessContext = convertContext;
48
            
49
            BasicHttpBinding myBinding = new BasicHttpBinding();
50
            EndpointAddress myEndpoint = new EndpointAddress(UriHelper.UriCreate(ConvertProcessContext.ServiceStationUri));
51
            StationServiceClient = new StationServiceClient(myBinding, myEndpoint);
52
            gIsApiDownload = ConvertProcessContext.IsApiDownload;
53

    
54
             gMarkusPDF = new MarkusPDF();
55
            
56
            gSaveTask = new SaveTask();
57

    
58
            if (!string.IsNullOrWhiteSpace(ConvertProcessContext.FontsFolder))
59
            {
60
                gFontsFolder = ConvertProcessContext.FontsFolder;
61
                gSaveTask.SetFontsFolder(ConvertProcessContext.FontsFolder);
62
            }
63

    
64
            gSaveTask.StateChangeEvent += MarkusPdfStateChangeEvent;
65
        }
66

    
67
        public ConvertService()
68
        {
69
        }
70

    
71
        public void Dispose()
72
        {
73
            try
74
            {
75
                if(gMarkusPDF != null)
76
                {
77
                    gMarkusPDF.Dispose();
78
                    gMarkusPDF = null;
79
                }
80

    
81
                if (gSaveTask != null)
82
                {
83
                    gSaveTask.StateChangeEvent -= MarkusPdfStateChangeEvent;
84
                    gSaveTask.Dispose();
85
                    gSaveTask = null;
86
                }
87

    
88
                //if (System.IO.File.Exists(gTempFileName))
89
                //{
90
                //    File.Delete(gTempFileName);
91
                //}
92

    
93
            }
94
            catch (Exception ex)
95
            {
96
               logger.Error("Convert Service Dispose Error", ex);
97
            }
98
            finally
99
            {
100
                GC.Collect(2);
101
                GC.Collect(2);
102
            }
103
        }
104

    
105
        /// <summary>
106
        ///  markus lib에서 받는 이벤트
107
        /// </summary>
108
        /// <param name="sender"></param>
109
        /// <param name="e"></param>
110
        private void MarkusPdfStateChangeEvent(object sender, Markus.Message.StateEventArgs e)
111
        {
112
            try
113
            {
114
                int currentPage = e.SaveItem.CurrentPage;
115

    
116
                if (e.SaveItem.CurrentPage == 0)    /// 초기 wait status인 경우 0일수 있다. %계산시 오류 방지
117
                {
118
                    currentPage = 1;
119
                }
120

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

    
147
                StationServiceClient.ConvertProcessStateAsync(e.SaveItem.Id, (int)e.SaveItem.Status, e.SaveItem.CurrentPage, e.SaveItem.TotalPages, e.SaveItem.ErrorMessage);
148
                
149
            }
150
            catch (Exception ex)
151
            {
152
                logger.Error($"Status Change Error", ex);
153
            }
154
        }
155

    
156
        [System.Security.Permissions.FileIOPermission(System.Security.Permissions.SecurityAction.LinkDemand)]
157
        public async Task<SaveResult> SetFileAsync()
158
        {
159
            SaveResult result = new SaveResult();
160

    
161
            SaveItem saveitem = new SaveItem
162
            {
163
                Id = ConvertProcessContext.ConvertID,
164
                PdfFilePath = ConvertProcessContext.OriginFilePath,
165
                SavePath = ConvertProcessContext.SaveDirectory,
166
                Status = StatusCodeType.None,
167
                MinimumFontSize = ConvertProcessContext.MinFontSize,
168
                UseResolution = ConvertProcessContext.UseResolution
169
            };
170

    
171
            try
172
            {
173
#if PROCESS_TEST
174

    
175
            Console.WriteLine($"ConvertID : {ConvertProcessContext.ConvertID} : {StatusCodeType.Wait.ToString()}");
176

    
177
#else
178
                StationServiceClient.ConvertProcessState(ConvertProcessContext.ConvertID, (int)StatusCodeType.Wait, 0, 0, "");
179
#endif
180
                result = await ConvertAsync(saveitem);
181
#if PROCESS_TEST
182

    
183
                Console.WriteLine($"finish!!!");
184
#else
185
                StationServiceClient.ConvertFinish(saveitem.Id, (int)result.StatusCode, saveitem.CurrentPage, saveitem.TotalPages, result.Message);
186

    
187
#endif       
188
                // 플러그인 실행
189
#if PROCESS_TEST
190

    
191
                Console.WriteLine($"run Plugin : {saveitem.Id}");
192
#endif
193
                PluginService.Run(saveitem.Id);
194

    
195
            }
196
            catch (Exception ex)
197
            {
198
                result.StatusCode = StatusCodeType.Error;
199
                logger.Error($"File Convert Error", ex);
200

    
201
#if PROCESS_TEST
202

    
203
                Console.WriteLine($"run Plugin : {saveitem.Id}");
204
#else
205
                StationServiceClient.ConvertFinish(saveitem.Id, (int)result.StatusCode, saveitem.CurrentPage, saveitem.TotalPages, $"ConvertService Error    {saveitem.Id} {ex.Message} {ex.InnerException?.ToString()}");
206
#endif
207
            }
208
            finally
209
            {
210
                this.Dispose();
211
            }
212

    
213
            return result;
214
        }
215

    
216
        [System.Security.Permissions.FileIOPermission(System.Security.Permissions.SecurityAction.LinkDemand)]
217
        private async Task<SaveResult> ConvertAsync(SaveItem saveitem)
218
        { 
219
            SaveResult result = new SaveResult();
220
         
221
            try
222
            {
223
                DateTime deleteTime = DateTime.Now;
224

    
225
                while (System.IO.Directory.Exists(saveitem.SavePath))
226
                {
227
                    try
228
                    {
229
                        System.IO.Directory.Delete(saveitem.SavePath, true);
230
                    }
231
                    catch (Exception ex)
232
                    {
233
#if PROCESS_TEST
234
                        Console.WriteLine(ex.ToString());
235
#endif
236
                    }
237

    
238
                    if ((DateTime.Now - deleteTime) > new TimeSpan(0, 5, 0))
239
                    {
240
                        string msg = $"ConvertService Error {saveitem.SavePath} Delete Error";
241
                        logger.Error(msg);
242
                        result.StatusCode = StatusCodeType.FileError;
243
                        result.Message =  LogHelper.GetStack() + " " +LogHelper.GetStack() + " " + msg;
244
#if PROCESS_TEST
245
                        Console.WriteLine($"{StatusCodeType.FileError.ToString()} : {result.Message} ");
246
#endif
247
                        return result;
248
                    }
249

    
250
                    System.Threading.Thread.SpinWait(10);
251
                }
252

    
253
                System.IO.Directory.CreateDirectory(saveitem.SavePath);
254

    
255
                //파일 다운로드
256
                if (await DownloadFileAsync(saveitem))
257
                {
258
                    gTempFileName = saveitem.PdfFilePath;
259

    
260
                    if(gTempFileName.ToCharArray().Any(x=>x.IsKor()))
261
                    {
262
                        gTempFileName = Path.Combine(Path.GetTempPath(), GuidExtension.shortGuid() + ".pdf");
263

    
264
                        File.Copy(saveitem.PdfFilePath, gTempFileName,true);
265

    
266
                        System.Threading.Thread.Sleep(100);
267
                    }
268

    
269
                    gMarkusPDF.pdfLoad(gTempFileName, saveitem.MinimumFontSize, saveitem.UseResolution, gFontsFolder);
270

    
271
                    if(gMarkusPDF.PageCount() > 0)
272
                    {
273
                        /// 설정된 MultiThreadMaxPages에 따른 컨버터 분기
274
                        //if (gMarkusPDF.PageCount() > ConvertProcessContext.MultiThreadMaxPages)
275
                        //{
276
                        //    // 큰 사이즈의 파일 컨버팅
277
                          result = ConvertBigFileProcess(saveitem);
278
                        //}
279
                        //else
280
                        //{
281
                        //    /// 작은 사이즈의 컨버팅
282
                        //    await Task.Factory.StartNew(new Action(() =>
283
                        //    {
284
                        //        result = gSaveTask.SaveFile(saveitem);
285
                        //    }), TaskCreationOptions.LongRunning);
286
                        //}
287

    
288
                        // 파일 체크 후 갯수가 안맞으면 다시 컨버팅한다.
289
                        if (ReConvert < 1 && (result.PageInfoList.Count() != saveitem.TotalPages
290
                                       || Directory.EnumerateFiles(saveitem.SavePath, "*.png").Count() != saveitem.TotalPages
291
                                           || Directory.EnumerateFiles(saveitem.SavePath, "*.jpg").Count() != saveitem.TotalPages))
292
                        {
293
                            result.StatusCode = StatusCodeType.PageError;
294
                            result.Message =  LogHelper.GetStack() + " " +"Page Count Error";
295
                            ReConvert = 1;
296

    
297
                            result = ConvertBigFileProcess(saveitem);
298
                        }
299

    
300

    
301
                        ///  페이지 정보 저장
302
                        if (result.PageInfoList?.Count() > 0)
303
                        {
304
                            bool docSetResult = false;
305

    
306
                            using (Markus.Service.DataBase.ConvertDatabase database = new Markus.Service.DataBase.ConvertDatabase(ConvertProcessContext.ConnectionString))
307
                            {
308
                                List<EntityModel.DOCPAGE> docPageList = new List<EntityModel.DOCPAGE>();
309

    
310
                                docPageList = result.PageInfoList.Select(f => new EntityModel.DOCPAGE
311
                                {
312
                                    ID = GuidExtension.shortGuid(),
313
                                    PAGE_WIDTH = f.Width.ToString(),
314
                                    PAGE_HEIGHT = f.Height.ToString(),
315
                                    PAGE_NUMBER = f.PageNo
316
                                }).ToList();
317

    
318
                                docSetResult = database.SetDocumentInfo(saveitem.Id, result.PageInfoList.Count, docPageList);
319
                            }
320

    
321
                            if (docSetResult)
322
                            {
323
                                result.StatusCode = StatusCodeType.Completed;
324
                            }
325
                            else
326
                            {
327
                                result.StatusCode = StatusCodeType.FileError;
328
                                result.Message = LogHelper.GetStack() + " " + $"Doc Set Error. {result.Message}";
329
                            }
330
                        }
331
                        else
332
                        {
333
                            result.StatusCode = StatusCodeType.FileError;
334
                            result.Message = LogHelper.GetStack() + " " + $"Page List Get Error. {result.Message} ";
335
                        }
336
                    }
337
                    else
338
                    {
339
                        result.Message = $"File Error Page Count:0 - File path : { saveitem.PdfFilePath}";
340
                        result.StatusCode = StatusCodeType.FileError;
341
                    }
342

    
343
                }
344
                else
345
                {
346
                    result.Message  = $"File Download Error  - File path : { saveitem.PdfFilePath}";
347
                    result.StatusCode = StatusCodeType.FileError;
348
                }
349
            }
350
            catch (Exception ex)
351
            {
352
                result.Message =  LogHelper.GetStack() + " " +"ConvertService Convert Error" + ex.Message;
353
                result.StatusCode = StatusCodeType.Error;
354

    
355
                logger.Error(ex);
356
            }
357
            finally
358
            {
359

    
360
            }
361

    
362
            return result;
363
        }
364

    
365
        /// <summary>
366
        /// 파일 다운로드
367
        /// </summary>
368
        /// <param name="saveItem"></param>
369
        /// <returns></returns>
370
        public async Task<bool> DownloadFileAsync(SaveItem saveItem)
371
        {
372
            bool result = false;
373

    
374
            try
375
            {
376
                Uri pdfFileUri = null;
377

    
378
                //if (saveItem.PdfFilePath.Contains("VPCS_DOCLIB"))
379
                //{
380
                //    FileName = DocUri.Remove(0, DocUri.LastIndexOf("/") + 1);
381
                //    ProjectFolderPath = DownloadDir_PDF + "\\" + ConverterItem.PROJECT_NO + "_Tile"; //프로젝트 폴더
382
                //    ItemListPath = ProjectFolderPath + "\\" + (System.Convert.ToInt64(ConverterItem.DOCUMENT_ID) / 100).ToString();
383
                //    ItemPath = ItemListPath + "\\" + ConverterItem.DOCUMENT_ID;
384
                //    DownloadFilePath = ItemPath + "\\" + FileName;
385
                //}
386
                //else
387
                //{
388
                //    ProjectFolderPath = DownloadDir_PDF + "\\" + ConverterItem.PROJECT_NO + "_Tile"; //프로젝트 폴더
389
                //    ItemListPath = ProjectFolderPath + "\\" + (System.Convert.ToInt64(ConverterItem.DOCUMENT_ID) / 100).ToString();
390
                //    ItemPath = ItemListPath + "\\" + ConverterItem.DOCUMENT_ID;
391
                //    FileName = HttpUtility.ParseQueryString(new Uri(DocUri).Query).Get("fileName");
392
                //    DownloadFilePath = string.IsNullOrWhiteSpace(FileName) ? ItemPath + "\\" + FileName : ItemPath + "\\" + FileName;
393

    
394
                //}
395

    
396
                saveItem.PdfFilePath = HttpUtility.UrlDecode(saveItem.PdfFilePath); //PDF 전체 경로
397

    
398

    
399
                string FileName = "";
400
                string downloadFilePath = "";
401

    
402
                // 드라이브 경로가 포함되었는지 판단.
403
                if (Path.IsPathRooted(saveItem.PdfFilePath))
404
                {
405
                    FileInfo file = new FileInfo(saveItem.PdfFilePath);
406

    
407
                    if (file.Exists)
408
                    {
409
                        FileName = file.Name;
410
                        downloadFilePath = System.IO.Path.Combine(saveItem.SavePath, FileName);
411
                        file.CopyTo(downloadFilePath, true);
412
                    }
413
                    else
414
                    {
415
                        throw new Exception("File Not Found. Please, check the file path.");
416
                    }
417
                }
418
                else if (Uri.TryCreate(saveItem.PdfFilePath, UriKind.RelativeOrAbsolute, out pdfFileUri))
419
                {
420
                    try
421
                    {
422
                        if (gIsApiDownload)
423
                        {
424
                            ///read api download 
425
                            ///벽산
426
                            downloadFilePath = await RestDownloadAsync(pdfFileUri, saveItem.SavePath);
427
                        }
428
                        else
429
                        {
430
                            FileName = DownloadUri.GetFileName(saveItem.PdfFilePath);
431
                            downloadFilePath = System.IO.Path.Combine(saveItem.SavePath, FileName);
432

    
433
                            using (System.Net.WebClient webClient = new System.Net.WebClient())
434
                            {
435
                                webClient.UseDefaultCredentials = true;
436
                                webClient.Headers.Add("Authorization: BASIC SGVsbG8="); //가상의 인증
437
                                webClient.Proxy = null;
438
                                if (!System.IO.Directory.Exists(ConvertProcessContext.TempDirectory))
439
                                {
440
                                    System.IO.Directory.CreateDirectory(ConvertProcessContext.TempDirectory);
441
                                }
442

    
443
                                webClient.DownloadFile(pdfFileUri, downloadFilePath);
444

    
445
                                webClient.Dispose();
446
                            }
447
                        }
448
                        await Task.Delay(300);
449
                    }
450
                    catch (Exception ex)
451
                    {
452
                        logger.Error(ex);
453
                        throw new Exception($"File Download Error. Please, check the file path. {pdfFileUri}");
454
                    }
455
                }
456
                else
457
                {
458
                    throw new Exception("Please, check the file path.");
459
                }
460

    
461
                try
462
                {
463
                    if (File.Exists(downloadFilePath))
464
                    {
465
                        var file = File.Open(downloadFilePath, FileMode.Open);
466

    
467
                        if (file.Length == 0)
468
                        {
469
                            throw new Exception("File Size 0. Please, check the file path.");
470
                        }
471

    
472
                        file.Close();
473
                        file.Dispose();
474

    
475
                        saveItem.PdfFilePath = downloadFilePath;
476
                        result = true;
477

    
478
                    }
479
                }
480
                catch (Exception ex)
481
                {
482
                    logger.Error(ex);
483
                    throw new Exception("File Error ." + downloadFilePath);
484
                }
485
            }
486
            catch (Exception ex)
487
            {
488
                logger.Error(ex);
489
                throw new Exception(ex.ToString());
490
            }
491

    
492
            return result;
493
        }
494

    
495
        private  async Task<string> RestDownloadAsync(Uri uri,string savePath)
496
        {
497
            string downloadFilePath = "";
498

    
499
            var client = new RestClient(uri);
500
            client.Timeout = -1;
501
            var request = new RestRequest(Method.GET);
502
            IRestResponse response = await client.ExecuteAsync(request);
503

    
504
            if (response.StatusCode == System.Net.HttpStatusCode.OK)
505
            {
506
                var fileName = DownloadUri.GetFileNameInDisposition(new System.Net.Mime.ContentDisposition(response.Headers.Where(x => x.Name == "Content-Disposition").First().Value.ToString()));
507

    
508
                downloadFilePath = System.IO.Path.Combine(savePath, fileName);
509

    
510
                var fs = File.Create(downloadFilePath);
511

    
512
                await fs.WriteAsync(response.RawBytes, 0, response.RawBytes.Length);
513
                fs.Close();
514
            }
515

    
516
            return downloadFilePath;
517
        }
518

    
519
        /// <summary>
520
        /// 큰파일 변환
521
        /// </summary>
522
        /// <param name="saveitem"></param>
523
        /// <returns></returns>
524
        private SaveResult ConvertBigFileProcess(SaveItem saveitem)
525
        {
526
            SaveResult result = new SaveResult();
527

    
528
            try
529
            {
530
                saveitem.TotalPages = gMarkusPDF.PageCount();
531

    
532
                for (int currentPageNo = 1; currentPageNo <= saveitem.TotalPages; currentPageNo++)
533
                {
534
                    try
535
                    {
536
                        string saveFile = Path.Combine(saveitem.SavePath, $"{currentPageNo}.png");
537

    
538
                        if (ReConvert < 1 || (ReConvert == 1 && !File.Exists(saveFile)))
539
                         {
540

    
541
                            var saveResult = gMarkusPDF.SavePage(currentPageNo, saveFile);
542

    
543
                            saveitem.Status = StatusCodeType.Saving;
544
                            saveitem.CurrentPage = currentPageNo;
545
                            saveitem.ErrorMessage = saveResult.Message;
546

    
547
                            int pageListCount = 0;
548

    
549
                            if(result.PageInfoList != null)
550
                            {
551
                                pageListCount = result.PageInfoList.Count(f => f.PageNo == saveResult.SavePageInfo.PageNo);
552
                            }
553
                            
554
                            if (pageListCount == 0)
555
                            {
556
                                result.PageInfoAdd(saveResult.SavePageInfo);
557
                            }
558

    
559
                            MarkusPdfStateChangeEvent(this, new StateEventArgs(saveitem));
560
                            Console.WriteLine($"CurrentPage : {currentPageNo}");
561

    
562
                            /// 설정된 최대 페이지이거나 설정된 메모리보다 크면 릴리즈
563
                            if ((currentPageNo % ConvertProcessContext.MultiThreadMaxPages == 0 && ConvertProcessContext.MultiThreadMaxPages  > 0)
564
                                || ConvertProcessContext.ReleaseWorkMemory < Environment.WorkingSet)
565
                            {
566
                                Console.WriteLine($"physical memory : {Environment.WorkingSet}");
567

    
568
                                gMarkusPDF.Dispose();
569
                                gMarkusPDF = null;
570
                                System.Threading.Thread.SpinWait(5);
571

    
572
                                gMarkusPDF = new MarkusPDF();
573
                                gMarkusPDF.pdfLoad(gTempFileName, saveitem.MinimumFontSize, saveitem.UseResolution, gFontsFolder);
574
                            }
575

    
576
                            System.Threading.Thread.SpinWait(2);
577
                        }
578
                    }
579
                    catch (Exception ex)
580
                    {
581
                        result.StatusCode = StatusCodeType.PageError;
582
                        result.Message =  LogHelper.GetStack() + " " +"Save Error - " + ex.Message;
583

    
584
                        if (gMarkusPDF != null)
585
                        {
586
                            gMarkusPDF.Dispose();
587
                            gMarkusPDF = null;
588
                        }
589

    
590
                        gMarkusPDF = new MarkusPDF();
591
                        gMarkusPDF.pdfLoad(gTempFileName, saveitem.MinimumFontSize, saveitem.UseResolution, gFontsFolder);
592

    
593
                        currentPageNo = currentPageNo - 1;
594
                    }
595
                    finally
596
                    {
597
                     
598
                    }
599
                }
600

    
601
                result.StatusCode = StatusCodeType.Completed;
602
            }
603
            catch (Exception ex)
604
            {
605
                result.StatusCode = StatusCodeType.Error;
606
                result.Message =  LogHelper.GetStack() + " " +ex.Message;
607
            }
608

    
609
            return result;
610
        }
611

    
612
        public bool Stop()
613
        {
614
            try
615
            {
616
                gSaveTask.Dispose();
617
            }
618
            catch (Exception ex)
619
            {
620
                System.Diagnostics.Debug.WriteLine(ex.ToString());
621
            }
622

    
623
            return true;
624
        }
625

    
626

    
627
        /// <summary>
628
        /// 사용안함
629
        /// </summary>
630
        /// <param name="param"></param>
631
        /// <returns></returns>
632
        //[System.Runtime.ExceptionServices.HandleProcessCorruptedStateExceptions]
633
        //[System.Security.Permissions.FileIOPermission(System.Security.Permissions.SecurityAction.LinkDemand)]
634
        //private SaveResult SetFile()
635
        //{
636
        //    var saveitem = new SaveItem
637
        //    {
638
        //        Id = ConvertProcessContext.ConvertID,
639
        //        PdfFilePath = ConvertProcessContext.OriginFilePath,
640
        //        SavePath = ConvertProcessContext.SaveDirectory,
641
        //        Status = StatusCodeType.None
642
        //    };
643

    
644
        //    if (System.IO.Directory.Exists(saveitem.SavePath))
645
        //    {
646
        //        System.IO.Directory.Delete(saveitem.SavePath, true);
647
        //    }
648

    
649
        //    System.IO.Directory.CreateDirectory(saveitem.SavePath);
650

    
651
        //    try
652
        //    {
653
        //        Uri pdfFileUri = null;
654

    
655
        //        if (Uri.TryCreate(saveitem.PdfFilePath, UriKind.RelativeOrAbsolute, out pdfFileUri))
656
        //        {
657
        //            using (System.Net.WebClient webClient = new System.Net.WebClient())
658
        //            {
659
        //                webClient.UseDefaultCredentials = true;//.Headers.Add("Authorization: BASIC SGVsbG8="); //가상의 인증
660

    
661
        //                if (!System.IO.Directory.Exists(ConvertProcessContext.TempDirectory))
662
        //                {
663
        //                    System.IO.Directory.CreateDirectory(ConvertProcessContext.TempDirectory);
664
        //                }
665

    
666
        //                var downloadFilePath = System.IO.Path.Combine(ConvertProcessContext.TempDirectory, saveitem.Id.Replace("-", "") + ".pdf");
667
        //                webClient.DownloadFile(pdfFileUri, downloadFilePath);
668

    
669
        //                saveitem.PdfFilePath = downloadFilePath;
670
        //            }
671
        //        }
672
        //    }
673
        //    catch (Exception ex)
674
        //    {
675
        //        throw new Exception($"File Download Error  - File path : {saveitem.PdfFilePath}");
676
        //    }
677

    
678
        //    StationServiceClient.ConvertProcessStateAsync(saveitem.Id, (int)saveitem.Status, saveitem.CurrentPage, saveitem.TotalPages, saveitem.ErrorMessage);
679

    
680
        //    var result = gSaveTask.SaveFile(saveitem);
681

    
682
        //    return result;
683
        //}
684

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