markus / KCOM_API_AutoStamping / old / AutoApprovalTest.aspx.cs @ 95e6fe93
이력 | 보기 | 이력해설 | 다운로드 (5.63 KB)
1 | 95e6fe93 | taeseongkim | using System; |
---|---|---|---|
2 | using System.Data; |
||
3 | using System.Configuration; |
||
4 | using System.Web; |
||
5 | using System.Web.Security; |
||
6 | using System.Web.UI; |
||
7 | using System.Web.UI.WebControls; |
||
8 | using System.Web.UI.WebControls.WebParts; |
||
9 | using System.Web.UI.HtmlControls; |
||
10 | |||
11 | using Microsoft.SharePoint; |
||
12 | using System.Net; |
||
13 | using System.Xml; |
||
14 | |||
15 | public partial class AutoApprovalTest: System.Web.UI.Page |
||
16 | { |
||
17 | public string sSiteId = string.Empty; |
||
18 | public string sWebId = string.Empty; |
||
19 | public string sType = string.Empty; |
||
20 | private const string cookieName = "autoStampCookie"; |
||
21 | private const string cookieKeySelectPrj = "SelectProject"; |
||
22 | |||
23 | protected void Page_Load(object sender, EventArgs e) |
||
24 | { |
||
25 | if (!IsPostBack) |
||
26 | { |
||
27 | DataSet ds = new DataSet(); |
||
28 | |||
29 | WebClient client = new WebClient(); |
||
30 | string reqstr = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">" |
||
31 | + "<soapenv:Header/>" |
||
32 | + "<soapenv:Body>" |
||
33 | + "</soapenv:Body>" |
||
34 | + "</soapenv:Envelope>"; |
||
35 | client.Headers.Add(HttpRequestHeader.ContentType, "text/xml"); |
||
36 | client.Headers.Add("SOAPAction", "urn:Common/GetProjectList"); |
||
37 | |||
38 | |||
39 | string _result = client.UploadString(new Uri("http://10.11.252.3:9877/AutoStamping.svc"), reqstr); |
||
40 | |||
41 | XmlTextReader reader = new XmlTextReader(new System.IO.StringReader(_result)); |
||
42 | ds.ReadXml(reader); |
||
43 | |||
44 | PROJECT_LIST.DataSource = ds.Tables["ProjectInfo"]; |
||
45 | PROJECT_LIST.DataTextField = "Name"; |
||
46 | PROJECT_LIST.DataValueField = "No"; |
||
47 | PROJECT_LIST.DataBind(); |
||
48 | |||
49 | var selectPrj = LoadCookies(cookieKeySelectPrj); |
||
50 | |||
51 | if (selectPrj == null) |
||
52 | { |
||
53 | PROJECT_LIST.SelectedIndex = 0; |
||
54 | } |
||
55 | else |
||
56 | { |
||
57 | PROJECT_LIST.SelectedValue = selectPrj; |
||
58 | } |
||
59 | |||
60 | try |
||
61 | { |
||
62 | |||
63 | if (Request.QueryString["siteId"] != null) |
||
64 | hdnSiteid.Value = Request.QueryString["siteId"].ToString(); |
||
65 | |||
66 | if (Request.QueryString["webId"] != null) |
||
67 | hdnWebid.Value = Request.QueryString["webId"].ToString(); |
||
68 | |||
69 | if (Request.QueryString["NODE"] != null) |
||
70 | hdnNode.Value = Request.QueryString["NODE"].ToString(); |
||
71 | |||
72 | if (Request.QueryString["pjtno"] != null) |
||
73 | hdnpjtno.Value = Request.QueryString["pjtno"].ToString(); |
||
74 | |||
75 | //Guid guidSite = new Guid(hdnSiteid.Value); |
||
76 | //Guid guidWeb = new Guid(hdnWebid.Value); |
||
77 | |||
78 | |||
79 | string sspURL = "http://www.hsdh2.com"; |
||
80 | |||
81 | SPSite site = new SPSite(sspURL); |
||
82 | |||
83 | SPWeb web = site.OpenWeb(); |
||
84 | |||
85 | SPUser user = web.CurrentUser; |
||
86 | |||
87 | txtuser_id.Text = (user == null) ? web.Description : user.LoginName.Split('\\')[1].ToUpper(); |
||
88 | |||
89 | } |
||
90 | catch (Exception ex) |
||
91 | { |
||
92 | } |
||
93 | } |
||
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://10.11.252.3:9877/AutoStamping.svc"), reqstr); |
||
117 | XmlTextReader reader = new XmlTextReader(new System.IO.StringReader(_result)); |
||
118 | string msg = "Success!\\nAfer a while, please check the generation of Merged PDFs on the VP Circulation inquiry screen."; |
||
119 | |||
120 | while (reader.Read()) |
||
121 | { |
||
122 | switch (reader.NodeType) |
||
123 | { |
||
124 | case XmlNodeType.Element: |
||
125 | if (reader.Name == "AutoStampingResult") |
||
126 | { |
||
127 | reader.Read(); |
||
128 | if (!string.IsNullOrEmpty(reader.Value)) |
||
129 | msg = "Error:"+reader.Value; |
||
130 | } |
||
131 | break; |
||
132 | } |
||
133 | } |
||
134 | |||
135 | SaveCookies(cookieKeySelectPrj, project_no); |
||
136 | |||
137 | Response.Write("<script language='Javascript'> "); |
||
138 | Response.Write("alert('" + msg + "'); "); |
||
139 | Response.Write("</script>"); |
||
140 | } |
||
141 | |||
142 | private void SaveCookies(string Key, string value) |
||
143 | { |
||
144 | HttpCookie cookies = new HttpCookie(Key, value); |
||
145 | cookies.Expires = DateTime.Now.AddDays(10); |
||
146 | |||
147 | Response.Cookies[Key].Expires = DateTime.Now.AddDays(10); |
||
148 | Response.Cookies.Add(cookies); |
||
149 | } |
||
150 | |||
151 | private string LoadCookies(string Key) |
||
152 | { |
||
153 | return (Request.Cookies[Key] != null) ? Request.Cookies[Key].Value : null; |
||
154 | } |
||
155 | } |