markus / Site / SNI / UploadFinal / UploadPDF.cs @ c206d293
이력 | 보기 | 이력해설 | 다운로드 (4.18 KB)
1 |
using System; |
---|---|
2 |
using System.Collections.Generic; |
3 |
using System.Linq; |
4 |
using System.Text; |
5 |
using System.IO; |
6 |
using System.Net; |
7 |
using System.Xml; |
8 |
using System.Xml.Linq; |
9 |
using System.Net.Mail; |
10 |
using System.Data.SqlClient; |
11 |
using KCOMDataModel.DataModel; |
12 |
using KCOMDataModel.Common; |
13 |
namespace UploadFinal |
14 |
{ |
15 |
public class UploadFinal |
16 |
{ |
17 |
|
18 |
public static KeyValuePair<bool, string> UploadFinalPDF(string PdfFilePath, string OriginFileName, FINAL_PDF FinalPDF, string UploadServiceUrl) |
19 |
{ |
20 |
|
21 |
try |
22 |
{ |
23 |
WebClient webClient = new WebClient(); |
24 |
string data = string.Empty; |
25 |
data = "<soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:tem=\"http://tempuri.org/\"><soap:Header/><soap:Body><tem:CreateFinalPDF>" |
26 |
+ "<tem:userID>"+ FinalPDF.CREATE_USER_ID +"</tem:userID>" |
27 |
+ "<tem:objectID>"+FinalPDF.DOCUMENT_ID+"</tem:objectID>" |
28 |
+ "<tem:filePath>"+ PdfFilePath+"</tem:filePath>" |
29 |
+ " </tem:CreateFinalPDF></soap:Body></soap:Envelope>"; |
30 |
|
31 |
webClient.Headers.Add(HttpRequestHeader.ContentType, "text/xml;charset=utf-8"); |
32 |
webClient.Headers.Add("SOAPAction", "http://tempuri.org/CreateFinalPDF"); |
33 |
webClient.Encoding = Encoding.UTF8; |
34 |
|
35 |
var result = webClient.UploadString(new Uri(UploadServiceUrl), data); |
36 |
XmlDocument xmlDoc = new XmlDocument(); |
37 |
xmlDoc.LoadXml(result); |
38 |
XmlNodeList list = xmlDoc.GetElementsByTagName("CreateFinalPDFResult"); |
39 |
if (list.Count > 0) |
40 |
{ |
41 |
if (!string.IsNullOrEmpty(list[0].InnerText)) |
42 |
{ |
43 |
return new KeyValuePair<bool, string>(true, "Success"); |
44 |
} |
45 |
else |
46 |
{ |
47 |
return new KeyValuePair<bool, string>(false, "Fail"); |
48 |
} |
49 |
} |
50 |
else |
51 |
{ |
52 |
return new KeyValuePair<bool, string>(false, "Not Completed"); |
53 |
} |
54 |
|
55 |
|
56 |
|
57 |
|
58 |
} |
59 |
catch (Exception ex) |
60 |
{ |
61 |
return new KeyValuePair<bool, string>(false, ex.Message); |
62 |
} |
63 |
|
64 |
//return new KeyValuePair<bool, string>(_ResultFlag,_ResultMsg); |
65 |
} |
66 |
|
67 |
static void webClient_UploadStringCompleted(object sender, UploadStringCompletedEventArgs e) |
68 |
{ |
69 |
Console.WriteLine("UploadStringCompleted: {0}", e.Result); |
70 |
} |
71 |
public static void SendOnMessage(string subject, string content) |
72 |
{ |
73 |
|
74 |
//MailMessage mail = new MailMessage(); |
75 |
//mail.From = new MailAddress("h2011357@daelim.co.kr", "시스템관리자", System.Text.Encoding.UTF8); |
76 |
//mail.To.Add("h2011357@daelim.co.kr"); |
77 |
//mail.Subject = subject; |
78 |
//mail.Body = content; |
79 |
//mail.BodyEncoding = System.Text.Encoding.UTF8;//한글이 안깨지기 위해서 사용 |
80 |
//mail.SubjectEncoding = System.Text.Encoding.UTF8;//한글이 안깨지기 위해서 사용 |
81 |
|
82 |
//SmtpClient SmtpServer = new SmtpClient("any.daelim.co.kr"); |
83 |
//SmtpServer.Send(mail); // 메일 발송 |
84 |
//mail.Dispose(); |
85 |
} |
86 |
public static void WriteLog(string strLog) |
87 |
{ |
88 |
StreamWriter log; |
89 |
FileStream fileStream = null; |
90 |
DirectoryInfo logDirInfo = null; |
91 |
FileInfo logFileInfo; |
92 |
|
93 |
string logFilePath = "C:\\Logs\\"; |
94 |
logFilePath = logFilePath + "Log-" + System.DateTime.Today.ToString("MM-dd-yyyy") + "." + "txt"; |
95 |
logFileInfo = new FileInfo(logFilePath); |
96 |
logDirInfo = new DirectoryInfo(logFileInfo.DirectoryName); |
97 |
if (!logDirInfo.Exists) logDirInfo.Create(); |
98 |
if (!logFileInfo.Exists) |
99 |
{ |
100 |
fileStream = logFileInfo.Create(); |
101 |
} |
102 |
else |
103 |
{ |
104 |
fileStream = new FileStream(logFilePath, FileMode.Append); |
105 |
} |
106 |
log = new StreamWriter(fileStream); |
107 |
log.WriteLine(strLog); |
108 |
log.Close(); |
109 |
} |
110 |
} |
111 |
} |