프로젝트

일반

사용자정보

통계
| 브랜치(Branch): | 개정판:

markus / Site / SNI / UploadFinal / UploadPDF.cs @ 4a41c345

이력 | 보기 | 이력해설 | 다운로드 (4.11 KB)

1 5e7c6f56 humkyung
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");
32
                webClient.Headers.Add("SOAPAction", "http://tempuri.org/CreateFinalPDF");
33
34
                var result = webClient.UploadString(new Uri(UploadServiceUrl), data);
35
                XmlDocument xmlDoc = new XmlDocument();
36
                xmlDoc.LoadXml(result);
37
                XmlNodeList list = xmlDoc.GetElementsByTagName("CreateFinalPDFResult");
38
                if (list.Count > 0)
39
                {
40
                    if (!string.IsNullOrEmpty(list[0].InnerText))
41
                    {
42
                        return new KeyValuePair<bool, string>(true, "Success");
43
                    }
44
                    else
45
                    {
46
                        return new KeyValuePair<bool, string>(false, "Fail");
47
                    }
48
                }
49
                else
50
                {
51
                    return new KeyValuePair<bool, string>(false, "Not Completed");
52
                }
53
54
55
56
57
            }
58
            catch (Exception ex)
59
            {
60
                return new KeyValuePair<bool, string>(false, ex.Message);
61
            }
62
63
            //return new KeyValuePair<bool, string>(_ResultFlag,_ResultMsg);
64
        }
65
66
        static void webClient_UploadStringCompleted(object sender, UploadStringCompletedEventArgs e)
67
        {
68
            Console.WriteLine("UploadStringCompleted: {0}", e.Result);
69
        }
70
        public static void SendOnMessage(string subject, string content)
71
        {
72
73
            //MailMessage mail = new MailMessage();
74
            //mail.From = new MailAddress("h2011357@daelim.co.kr", "시스템관리자", System.Text.Encoding.UTF8);
75
            //mail.To.Add("h2011357@daelim.co.kr");
76
            //mail.Subject = subject;
77
            //mail.Body = content;
78
            //mail.BodyEncoding = System.Text.Encoding.UTF8;//한글이 안깨지기 위해서 사용
79
            //mail.SubjectEncoding = System.Text.Encoding.UTF8;//한글이 안깨지기 위해서 사용
80
81
            //SmtpClient SmtpServer = new SmtpClient("any.daelim.co.kr");
82
            //SmtpServer.Send(mail); // 메일 발송
83
            //mail.Dispose();
84
        }
85
        public static void WriteLog(string strLog)
86
        {
87
            StreamWriter log;
88
            FileStream fileStream = null;
89
            DirectoryInfo logDirInfo = null;
90
            FileInfo logFileInfo;
91
92
            string logFilePath = "C:\\Logs\\";
93
            logFilePath = logFilePath + "Log-" + System.DateTime.Today.ToString("MM-dd-yyyy") + "." + "txt";
94
            logFileInfo = new FileInfo(logFilePath);
95
            logDirInfo = new DirectoryInfo(logFileInfo.DirectoryName);
96
            if (!logDirInfo.Exists) logDirInfo.Create();
97
            if (!logFileInfo.Exists)
98
            {
99
                fileStream = logFileInfo.Create();
100
            }
101
            else
102
            {
103
                fileStream = new FileStream(logFilePath, FileMode.Append);
104
            }
105
            log = new StreamWriter(fileStream);
106
            log.WriteLine(strLog);
107
            log.Close();
108
        }
109
    }
110
}
클립보드 이미지 추가 (최대 크기: 500 MB)