프로젝트

일반

사용자정보

개정판 a2a64028

IDa2a64028aa7d857c5b336add73650b0232fbf097
상위 f5c6a3d5
하위 1a3656c9

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

ConvertService Webclient Dispose

Change-Id: I2da15bf6437478fb2724f83139ba2e130ced6da2

차이점 보기:

ConvertService/ServiceBase/Markus.Service.Convert/ConvertService.cs
283 283
            {
284 284
                result.Message = "ConvertService Convert Error" + ex.Message;
285 285
                result.StatusCode = StatusCodeType.Error;
286

  
287
                logger.Error(ex);
286 288
            }
287 289
            finally
288 290
            {
......
355 357
                        using (System.Net.WebClient webClient = new System.Net.WebClient())
356 358
                        {
357 359
                            webClient.UseDefaultCredentials = true;//.Headers.Add("Authorization: BASIC SGVsbG8="); //가상의 인증
358

  
360
                            webClient.Proxy = null;
359 361
                            //if (!System.IO.Directory.Exists(ConvertProcessContext.TempDirectory))
360 362
                            //{
361 363
                            //    System.IO.Directory.CreateDirectory(ConvertProcessContext.TempDirectory);
362 364
                            //}
363 365

  
364 366
                            await webClient.DownloadFileTaskAsync(pdfFileUri, downloadFilePath);
367
                            webClient.Dispose();
365 368
                        }
366 369
                    }
367
                    catch (Exception)
370
                    catch (Exception ex)
368 371
                    {
372
                        logger.Error(ex);
369 373
                        throw new Exception("File Download Error. Please, check the file path.");
370 374
                    }
371 375
                }
......
393 397

  
394 398
                    }
395 399
                }
396
                catch (Exception)
400
                catch (Exception ex)
397 401
                {
402
                    logger.Error(ex);
398 403
                    throw new Exception("File Error ." + downloadFilePath);
399
                    throw;
400 404
                }
401 405
            }
402 406
            catch (Exception ex)
403 407
            {
408
                logger.Error(ex);
404 409
                throw new Exception(ex.ToString());
405
                result = false;
406 410
            }
407 411

  
408 412
            return result;
ConvertService/ServiceBase/ServiceTestApp/MainWindow.xaml.cs
554 554

  
555 555
        private async void DownLoadTest_click(object sender, RoutedEventArgs e)
556 556
        {
557
            await DownloadFileAsync("http://172.20.110.75:8880/ifweb/external/DLMFileDownload.jsp?objectId=33808.61925.45058.48300&format=Original PDF&fileName=MARKUS_20190731_0001_A.pdf");
557
            for (int i = 0; i < 100; i++)
558
            {
559
                await DownloadFileAsync("http://cloud.devdoftech.co.kr:5977/PDF/000000_app/VPCS_DOCLIB/110001/11000102/ToVendor/VP-DRAWINGS-SAMPLE-002.pdf");
560

  
561
                await Task.Delay(new TimeSpan(0,0,0,1));
562
            }
563
            
558 564
        }
559 565

  
560 566
        private async Task<bool> DownloadFileAsync(string FileaPath)
561 567
        {
568
            System.Diagnostics.Stopwatch stopwatch = new Stopwatch();
569
            stopwatch.Start();
570

  
562 571
            bool result = false;
563 572

  
564 573
            try
......
584 593
                //}
585 594

  
586 595
                FileaPath = HttpUtility.UrlDecode(FileaPath); //PDF 전체 경로
587
                string FileName = DownloadUri.GetFileName(FileaPath);
596
                string FileName = System.IO.Path.GetRandomFileName();// DownloadUri.GetFileName(FileaPath);
597

  
588 598

  
589 599
                string downloadFilePath = System.IO.Path.Combine(@"c:\temp", FileName);
590 600

  
......
608 618
                        {
609 619
                            webClient.UseDefaultCredentials = true;//.Headers.Add("Authorization: BASIC SGVsbG8="); //가상의 인증
610 620

  
621
                            webClient.Proxy = null;
622
                            //System.Net.IWebProxy webProxy = webClient.Proxy;
623

  
624
                            //if (webProxy != null)
625
                            //{
626
                            //    // Use the default credentials of the logged on user.
627
                            //    webProxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
628
                            //}
611 629
                            //if (!System.IO.Directory.Exists(ConvertProcessContext.TempDirectory))
612 630
                            //{
613 631
                            //    System.IO.Directory.CreateDirectory(ConvertProcessContext.TempDirectory);
614 632
                            //}
615 633

  
634
                            System.Diagnostics.Debug.WriteLine("file download Test");
616 635
                            await webClient.DownloadFileTaskAsync(pdfFileUri, downloadFilePath);
636
                            System.Diagnostics.Debug.WriteLine("file download Test : " + new TimeSpan(stopwatch.ElapsedTicks));
637
                            webClient.Dispose();
617 638
                        }
618 639
                    }
619
                    catch (Exception)
640
                    catch (Exception ex)
620 641
                    {
621 642
                        throw new Exception("File Download Error. Please, check the file path.");
622 643
                    }
......
626 647
                    throw new Exception("Please, check the file path.");
627 648
                }
628 649

  
650
                System.Diagnostics.Debug.WriteLine("file download Test File.Exists : " + new TimeSpan(stopwatch.ElapsedTicks));
651

  
629 652
                if (File.Exists(downloadFilePath))
630 653
                {
631 654
                    var file = File.Open(downloadFilePath, FileMode.Open);

내보내기 Unified diff

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