markus / KCOM_API_AutoStamping / AutoApprovalTest.aspx.cs @ 6d6f32bb
이력 | 보기 | 이력해설 | 다운로드 (5.66 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 |
protected void Button1_Click(object sender, EventArgs e) |
94 |
{ |
95 |
string project_no = this.PROJECT_LIST.SelectedValue.Trim().ToString(); |
96 |
string slip_no = this.txtslip_no.Text.Trim().ToString(); |
97 |
string user_id = this.txtuser_id.Text.Trim().ToString(); |
98 |
|
99 |
WebClient client = new WebClient(); |
100 |
string reqstr = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">" |
101 |
+ "<soapenv:Header/>" |
102 |
+ "<soapenv:Body>" |
103 |
+ "<AutoStamping>" |
104 |
+ "<project_no>" + project_no + "</project_no>" |
105 |
+ "<slip_no>" + slip_no + "</slip_no>" |
106 |
+ "<user_id>" + user_id + "</user_id>" |
107 |
+ "</AutoStamping>" |
108 |
+ "</soapenv:Body>" |
109 |
+ "</soapenv:Envelope>"; |
110 |
client.Headers.Add(HttpRequestHeader.ContentType, "text/xml"); |
111 |
client.Headers.Add("SOAPAction", "urn:Common/AutoStamping"); |
112 |
|
113 |
string _result = client.UploadString(new Uri($"http://{Request.Url.Host.ToString()}:{Request.Url.Port}/AutoStamping.svc"), reqstr); |
114 |
XmlTextReader reader = new XmlTextReader(new System.IO.StringReader(_result)); |
115 |
|
116 |
string msg = "Success\\naaaa"; |
117 |
|
118 |
while (reader.Read()) |
119 |
{ |
120 |
switch (reader.NodeType) |
121 |
{ |
122 |
case XmlNodeType.Element: |
123 |
if (reader.Name == "AutoStampingResult") |
124 |
{ |
125 |
reader.Read(); |
126 |
if (!string.IsNullOrEmpty(reader.Value)) |
127 |
msg = "Error:" + reader.Value; |
128 |
} |
129 |
break; |
130 |
} |
131 |
} |
132 |
|
133 |
Response.Write("<script language='Javascript'> "); |
134 |
Response.Write("alert('" + msg + "'); "); |
135 |
Response.Write("</script>"); |
136 |
SaveCookies(cookieKeySelectPrj, project_no); |
137 |
} |
138 |
|
139 |
private void SaveCookies(string Key,string value) |
140 |
{ |
141 |
HttpCookie cookies = new HttpCookie(Key, value); |
142 |
cookies.Expires = DateTime.Now.AddDays(10); |
143 |
|
144 |
Response.Cookies[Key].Expires = DateTime.Now.AddDays(10); |
145 |
Response.Cookies.Add(cookies); |
146 |
} |
147 |
|
148 |
private string LoadCookies(string Key) |
149 |
{ |
150 |
return (Request.Cookies[Key] != null) ? Request.Cookies[Key].Value : null; |
151 |
} |
152 |
} |
153 |
} |