markus / FinalService / FinalServiceBase / UploadTest / MainWindow.xaml.cs @ 42d49521
이력 | 보기 | 이력해설 | 다운로드 (4.29 KB)
1 |
using KCOMDataModel.Common; |
---|---|
2 |
using KCOMDataModel.DataModel; |
3 |
using System; |
4 |
using System.Collections.Generic; |
5 |
using System.Linq; |
6 |
using System.Text; |
7 |
using System.Threading.Tasks; |
8 |
using System.Web; |
9 |
using System.Windows; |
10 |
using System.Windows.Controls; |
11 |
using System.Windows.Data; |
12 |
using System.Windows.Documents; |
13 |
using System.Windows.Input; |
14 |
using System.Windows.Media; |
15 |
using System.Windows.Media.Imaging; |
16 |
using System.Windows.Navigation; |
17 |
using System.Windows.Shapes; |
18 |
|
19 |
namespace UploadTest |
20 |
{ |
21 |
/// <summary> |
22 |
/// MainWindow.xaml에 대한 상호 작용 논리 |
23 |
/// </summary> |
24 |
public partial class MainWindow : Window |
25 |
{ |
26 |
public MainWindow() |
27 |
{ |
28 |
InitializeComponent(); |
29 |
} |
30 |
|
31 |
private void Button_Click(object sender, RoutedEventArgs e) |
32 |
{ |
33 |
try |
34 |
{ |
35 |
UploadCall2(); |
36 |
UploadCall(); |
37 |
} |
38 |
catch (Exception ex) |
39 |
{ |
40 |
LogWrite(ex.ToString()); |
41 |
|
42 |
if(ex.InnerException != null) |
43 |
{ |
44 |
LogWrite(ex.InnerException.ToString()); |
45 |
} |
46 |
} |
47 |
} |
48 |
|
49 |
private void UploadCall2() |
50 |
{ |
51 |
var final = new FINAL_PDF(); |
52 |
final.DOCUMENT_ID = "2278058250"; |
53 |
final.PROJECT_NO = "150128"; |
54 |
|
55 |
var result = UploadFinal.UploadFinal.UploadFinalPDF(@"\\172.20.121.220\comment3\finalPDF\tmp776A.pdf", "ONPZ-ORG-PR-8121-0412.002-0000-DDD-001_R0.pdf", final, ""); |
56 |
} |
57 |
|
58 |
private void UploadCall() |
59 |
{ |
60 |
if(string.IsNullOrEmpty(tbFinalPDFID.Text)) |
61 |
{ |
62 |
LogWrite("final id null."); |
63 |
return; |
64 |
} |
65 |
|
66 |
if (string.IsNullOrEmpty(tbRemoteFilePath.Text)) |
67 |
{ |
68 |
LogWrite("remote file path null."); |
69 |
return; |
70 |
} |
71 |
|
72 |
if (string.IsNullOrEmpty(tbServiceUri.Text)) |
73 |
{ |
74 |
LogWrite("service url null."); |
75 |
return; |
76 |
} |
77 |
|
78 |
LogWrite("Kcom Connection String : " + ConnectStringBuilder.KCOMConnectionString().ConnectionString); |
79 |
|
80 |
using (KCOMEntities entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString())) |
81 |
{ |
82 |
var items = entity.FINAL_PDF.Where(x => x.ID == tbFinalPDFID.Text); |
83 |
|
84 |
if(items.Count() > 0) |
85 |
{ |
86 |
var item = items.First(); |
87 |
string filename = ""; |
88 |
|
89 |
LogWrite("CI Connection String : " + ConnectStringBuilder.ProjectCIConnectString(item.PROJECT_NO).ConnectionString); |
90 |
|
91 |
using (CIEntities dc = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(item.PROJECT_NO).ToString())) |
92 |
{ |
93 |
var _docInfoList = dc.DOCINFO.Where(doc => doc.ID == item.DOCINFO_ID); |
94 |
|
95 |
if (_docInfoList.Count() > 0) |
96 |
{ |
97 |
var file = _docInfoList.First().ORIGINAL_FILE; |
98 |
|
99 |
LogWrite("ORIGINAL_FILE Full Url : " + file); |
100 |
|
101 |
|
102 |
var decodeFile = System.Web.HttpUtility.UrlDecode(file); |
103 |
|
104 |
//if (System.Web.HttpUtility.ParseQueryString(decodeFile).AllKeys.Count(x => x.ToLower() == ("filename").ToLower()) > 0) |
105 |
//{ |
106 |
// filename = System.Web.HttpUtility.ParseQueryString(decodeFile).Get("filename"); |
107 |
//} |
108 |
//else |
109 |
//{ |
110 |
filename = decodeFile.Split('/').Last(); |
111 |
//} |
112 |
} |
113 |
} |
114 |
|
115 |
LogWrite("ORIGINAL_FILE : " + filename); |
116 |
|
117 |
var result = UploadFinal.UploadFinal.UploadFinalPDF(tbRemoteFilePath.Text, filename, items.First(), tbServiceUri.Text); |
118 |
|
119 |
LogWrite("result : " + result.Value); |
120 |
} |
121 |
else |
122 |
{ |
123 |
LogWrite("final item not found."); |
124 |
} |
125 |
} |
126 |
} |
127 |
|
128 |
StringBuilder builder = new StringBuilder(); |
129 |
|
130 |
private void LogWrite(string Msg) |
131 |
{ |
132 |
builder.AppendLine(Msg); |
133 |
tbLog.Text = builder.ToString(); |
134 |
} |
135 |
} |
136 |
} |