프로젝트

일반

사용자정보

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

markus / KCOM_API_AutoStamping / AutoApprovalTest.aspx.cs @ master

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

1
using System;
2
using System.Collections.Generic;
3
using System.Data;
4
using System.Linq;
5
using System.Net;
6
using System.Web;
7
using System.Web.UI;
8
using System.Web.UI.WebControls;
9
using System.Xml;
10
//using Microsoft.SharePoint;
11

    
12
namespace KCOM_API_AutoStamping
13
{
14
    public partial class AutoApprovalTest : System.Web.UI.Page
15
    {
16
        private const string cookieName = "autoStampCookie";
17
        private const string cookieKeySelectPrj = "SelectProject";
18

    
19
        protected void Page_Load(object sender, EventArgs e)
20
        {
21
            if (!IsPostBack)
22
            {
23
                DataSet ds = new DataSet();
24

    
25
                WebClient client = new WebClient();
26
                string reqstr = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">"
27
                                + "<soapenv:Header/>"
28
                                + "<soapenv:Body>"
29
                                + "</soapenv:Body>"
30
                                + "</soapenv:Envelope>";
31
                client.Headers.Add(HttpRequestHeader.ContentType, "text/xml");
32
                client.Headers.Add("SOAPAction", "urn:Common/GetProjectList");
33

    
34

    
35
                string _result = client.UploadString(new Uri($"http://{Request.Url.Host.ToString()}:{Request.Url.Port}/AutoStamping.svc"), reqstr);
36

    
37
                XmlTextReader reader = new XmlTextReader(new System.IO.StringReader(_result));
38
                ds.ReadXml(reader);
39

    
40
                PROJECT_LIST.DataSource = ds.Tables["ProjectInfo"];
41
                PROJECT_LIST.DataTextField = "Name";
42
                PROJECT_LIST.DataValueField = "No";
43
                PROJECT_LIST.DataBind();
44

    
45
                var selectPrj = LoadCookies(cookieKeySelectPrj);
46

    
47
                if(selectPrj == null)
48
                {
49
                    PROJECT_LIST.SelectedIndex = 0;
50
                }
51
                else
52
                {
53
                    PROJECT_LIST.SelectedValue = selectPrj;
54
                }
55

    
56

    
57
                //try
58
                //{
59

    
60
                //    if (Request.QueryString["siteId"] != null)
61
                //        hdnSiteid.Value = Request.QueryString["siteId"].ToString();
62

    
63
                //    if (Request.QueryString["webId"] != null)
64
                //        hdnWebid.Value = Request.QueryString["webId"].ToString();
65

    
66
                //    if (Request.QueryString["NODE"] != null)
67
                //        hdnNode.Value = Request.QueryString["NODE"].ToString();
68

    
69
                //    if (Request.QueryString["pjtno"] != null)
70
                //        hdnpjtno.Value = Request.QueryString["pjtno"].ToString();
71

    
72
                //    //Guid guidSite = new Guid(hdnSiteid.Value);
73
                //    //Guid guidWeb = new Guid(hdnWebid.Value);
74

    
75

    
76
                //    string sspURL = "http://www.hsdh2.com";
77

    
78
                //    SPSite site = new SPSite(sspURL);
79

    
80
                //    SPWeb web = site.OpenWeb();
81

    
82
                //    SPUser user = web.CurrentUser;
83

    
84
                //    txtuser_id.Text = (user == null) ? web.Description : user.LoginName.Split('\\')[1].ToUpper();
85

    
86
                //}
87
                //catch (Exception ex)
88
                //{
89
                //}
90

    
91
            }
92

    
93
            BtnHiddenYes.Click += Button1_Click;
94
        }
95

    
96
        protected void Button1_Click(object sender, EventArgs e)
97
        {
98
            string project_no = this.PROJECT_LIST.SelectedValue.Trim().ToString();
99
            string slip_no = this.txtslip_no.Text.Trim().ToString();
100
            string user_id = this.txtuser_id.Text.Trim().ToString();
101

    
102
            WebClient client = new WebClient();
103
            string reqstr = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">"
104
                            + "<soapenv:Header/>"
105
                            + "<soapenv:Body>"
106
                            + "<AutoStamping>"
107
                            + "<project_no>" + project_no + "</project_no>"
108
                            + "<slip_no>" + slip_no + "</slip_no>"
109
                            + "<user_id>" + user_id + "</user_id>"
110
                            + "</AutoStamping>"
111
                            + "</soapenv:Body>"
112
                            + "</soapenv:Envelope>";
113
            client.Headers.Add(HttpRequestHeader.ContentType, "text/xml");
114
            client.Headers.Add("SOAPAction", "urn:Common/AutoStamping");
115

    
116
           string _result = client.UploadString(new Uri($"http://{Request.Url.Host.ToString()}:{Request.Url.Port}/AutoStamping.svc"), reqstr);
117
            //string _result = client.UploadString(new Uri("http://10.11.252.3:9877/AutoStamping.svc"), reqstr);
118
            XmlTextReader reader = new XmlTextReader(new System.IO.StringReader(_result));
119
            string msg = "Success!\\nAfer a while, please check the generation of Merged PDFs on the VP Circulation inquiry screen.";
120

    
121
            while (reader.Read())
122
            {
123
                switch (reader.NodeType)
124
                {
125
                    case XmlNodeType.Element:
126
                        if (reader.Name == "AutoStampingResult")
127
                        {
128
                            reader.Read();
129
                            if (!string.IsNullOrEmpty(reader.Value))
130
                                msg = "Error:" + reader.Value;
131
                        }
132
                        break;
133
                }
134
            }
135

    
136
            SaveCookies(cookieKeySelectPrj, project_no);
137

    
138
            Response.Write("<script language='Javascript'> ");
139
            Response.Write("alertify.alert('" + msg + "'); ");
140
            Response.Write("</script>");
141
        }
142

    
143
        private void SaveCookies(string Key,string value)
144
        {
145
            HttpCookie cookies = new HttpCookie(Key, value);
146
            cookies.Expires = DateTime.Now.AddDays(10);
147

    
148
            Response.Cookies[Key].Expires = DateTime.Now.AddDays(10);
149
            Response.Cookies.Add(cookies);
150
        }
151

    
152
        private string LoadCookies(string Key)
153
        {
154
            return (Request.Cookies[Key] != null) ? Request.Cookies[Key].Value : null;
155
        }
156
    }
157
}
클립보드 이미지 추가 (최대 크기: 500 MB)