프로젝트

일반

사용자정보

개정판 77cdac33

ID77cdac33b7bca4641193c97216f85dde1a21cb5e
상위 74abcf6f
하위 a7bee7cf

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

벽산 수정 후 백업

Change-Id: I8e3eb48f615478a49efa0ab4014a8ef17d273d0a

차이점 보기:

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

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

  
18 19
namespace Markus.Service.Convert
19 20
{
......
379 380
                {
380 381
                    try
381 382
                    {
383
                       
384
                        downloadFilePath = await RestDownloadAsync(pdfFileUri, saveItem.SavePath);
385
                        /*bseng
386
   */
387
                        /* 벽산으로 임시 주석 
388
                        
382 389
                        FileName = DownloadUri.GetFileName(saveItem.PdfFilePath);
383 390
                        downloadFilePath = System.IO.Path.Combine(saveItem.SavePath, FileName);
384 391

  
385
                        using (System.Net.WebClient webClient = new System.Net.WebClient())
386
                        {
387
                            webClient.UseDefaultCredentials = true;//.Headers.Add("Authorization: BASIC SGVsbG8="); //가상의 인증
388
                            webClient.Proxy = null;
389
                            //if (!System.IO.Directory.Exists(ConvertProcessContext.TempDirectory))
390
                            //{
391
                            //    System.IO.Directory.CreateDirectory(ConvertProcessContext.TempDirectory);
392
                            //}
393

  
394
                            webClient.DownloadFile(pdfFileUri, downloadFilePath);
395
                            webClient.Dispose();
396
                        }
397

  
392
                         using (System.Net.WebClient webClient = new System.Net.WebClient())
393
                         {
394
                             webClient.UseDefaultCredentials = true;//.Headers.Add("Authorization: BASIC SGVsbG8="); //가상의 인증
395
                             webClient.Proxy = null;
396
                             if (!System.IO.Directory.Exists(ConvertProcessContext.TempDirectory))
397
                             {
398
                                 System.IO.Directory.CreateDirectory(ConvertProcessContext.TempDirectory);
399
                             }
400

  
401
                             webClient.DownloadFile(pdfFileUri, downloadFilePath);
402

  
403
                             webClient.Dispose();
404
                         }
405
                       *    */
398 406
                        await Task.Delay(300);
399 407
                    }
400 408
                    catch (Exception ex)
401 409
                    {
402 410
                        logger.Error(ex);
403
                        throw new Exception("File Download Error. Please, check the file path.");
411
                        throw new Exception($"File Download Error. Please, check the file path. {pdfFileUri}");
404 412
                    }
405 413
                }
406 414
                else
......
442 450
            return result;
443 451
        }
444 452

  
453
        private  async Task<string> RestDownloadAsync(Uri uri,string savePath)
454
        {
455
            string downloadFilePath = "";
456

  
457
            var client = new RestClient(uri);
458
            client.Timeout = -1;
459
            var request = new RestRequest(Method.GET);
460
            IRestResponse response = await client.ExecuteAsync(request);
461

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

  
466
                downloadFilePath = System.IO.Path.Combine(savePath, fileName);
467

  
468
                var fs = File.Create(downloadFilePath);
469

  
470
                await fs.WriteAsync(response.RawBytes, 0, response.RawBytes.Length);
471
                fs.Close();
472
            }
473
           
474
            //var fileInfo = new FileInfo(downloadFilePath);
475

  
476
            //using (var fileStream = fileInfo.OpenWrite())
477
            //{
478
            //    await fileStream.WriteAsync(response.RawBytes, 0, response.RawBytes.Length);
479
            //    fileStream.Close();
480
            //    //int position = 0;
481
            //    //int step = 300000;
482
            //    //int length = 300000;
483

  
484
            //    //while (position < response.RawBytes.Length)
485
            //    //{
486
            //    //    if (position + step < response.RawBytes.Length)
487
            //    //    {
488
            //    //        length = position + step;
489
            //    //    }
490
            //    //    else
491
            //    //    {
492
            //    //        length = response.RawBytes.Length - position;
493
            //    //    }
494

  
495
            //    //    await fileStream.WriteAsync(response.RawBytes, position, length);
496

  
497
            //    //    position = position + step;
498
            //    //}
499
            //}
500

  
501
            return downloadFilePath;
502
        }
503

  
445 504
        /// <summary>
446 505
        /// 큰파일 변환
447 506
        /// </summary>

내보내기 Unified diff

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