markus / FinalService / KCOM_FinalService / UploadTest / MainWindow.xaml.cs @ f3ab410f
이력 | 보기 | 이력해설 | 다운로드 (3.82 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 |
|
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 UploadCall() |
50 |
{ |
51 |
if(string.IsNullOrEmpty(tbFinalPDFID.Text)) |
52 |
{ |
53 |
LogWrite("final id null."); |
54 |
return; |
55 |
} |
56 |
|
57 |
if (string.IsNullOrEmpty(tbRemoteFilePath.Text)) |
58 |
{ |
59 |
LogWrite("remote file path null."); |
60 |
return; |
61 |
} |
62 |
|
63 |
if (string.IsNullOrEmpty(tbServiceUri.Text)) |
64 |
{ |
65 |
LogWrite("service url null."); |
66 |
return; |
67 |
} |
68 |
|
69 |
LogWrite("Kcom Connection String : " + ConnectStringBuilder.KCOMConnectionString().ConnectionString); |
70 |
|
71 |
using (KCOMEntities entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString())) |
72 |
{ |
73 |
var items = entity.FINAL_PDF.Where(x => x.ID == tbFinalPDFID.Text); |
74 |
|
75 |
if(items.Count() > 0) |
76 |
{ |
77 |
var item = items.First(); |
78 |
string filename = ""; |
79 |
|
80 |
LogWrite("CI Connection String : " + ConnectStringBuilder.ProjectCIConnectString(item.PROJECT_NO).ConnectionString); |
81 |
|
82 |
using (CIEntities dc = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(item.PROJECT_NO).ToString())) |
83 |
{ |
84 |
var _docInfoList = dc.DOCINFO.Where(doc => doc.ID == item.DOCINFO_ID); |
85 |
|
86 |
if (_docInfoList.Count() > 0) |
87 |
{ |
88 |
var file = _docInfoList.First().ORIGINAL_FILE; |
89 |
|
90 |
var decodeFile = System.Web.HttpUtility.UrlDecode(file); |
91 |
|
92 |
if (System.Web.HttpUtility.ParseQueryString(decodeFile).AllKeys.Count(x => x.ToLower() == ("filename").ToLower()) > 0) |
93 |
{ |
94 |
filename = System.Web.HttpUtility.ParseQueryString(decodeFile).Get("filename"); |
95 |
} |
96 |
else |
97 |
{ |
98 |
filename = decodeFile.Split('/').Last(); |
99 |
} |
100 |
} |
101 |
} |
102 |
|
103 |
LogWrite("ORIGINAL_FILE : " + filename); |
104 |
|
105 |
var result = UploadFinal.UploadFinal.UploadFinalPDF(tbRemoteFilePath.Text, filename, items.First(), tbServiceUri.Text); |
106 |
|
107 |
LogWrite("result : " + result.Value); |
108 |
} |
109 |
else |
110 |
{ |
111 |
LogWrite("final item not found."); |
112 |
} |
113 |
} |
114 |
} |
115 |
|
116 |
StringBuilder builder = new StringBuilder(); |
117 |
|
118 |
private void LogWrite(string Msg) |
119 |
{ |
120 |
builder.AppendLine(Msg); |
121 |
tbLog.Text = builder.ToString(); |
122 |
} |
123 |
} |
124 |
} |