|
|
@@ -0,0 +1,86 @@
|
|
|
+using System;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.IO;
|
|
|
+using System.Net;
|
|
|
+using System.Text;
|
|
|
+using System.Web;
|
|
|
+
|
|
|
+namespace UAS_LabelMachine.PublicMethod
|
|
|
+{
|
|
|
+ public class HttpHandler : IHttpHandler
|
|
|
+ {
|
|
|
+ /// <summary>
|
|
|
+ /// 您将需要在网站的 Web.config 文件中配置此处理程序
|
|
|
+ /// 并向 IIS 注册它,然后才能使用它。有关详细信息,
|
|
|
+ /// 请参见下面的链接: http://go.microsoft.com/?linkid=8101007
|
|
|
+ /// </summary>
|
|
|
+ public bool IsReusable
|
|
|
+ {
|
|
|
+ // 如果无法为其他请求重用托管处理程序,则返回 false。
|
|
|
+ // 如果按请求保留某些状态信息,则通常这将为 false。
|
|
|
+ get { return true; }
|
|
|
+ }
|
|
|
+ public void ProcessRequest(HttpContext context)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public static bool CheckUserLogin(string UserName, string PassWord, string Master, out string oMsg)
|
|
|
+ {
|
|
|
+ oMsg = "";
|
|
|
+ try
|
|
|
+ {
|
|
|
+ string url = DataHelper.ERPAddesss + "mobile/login.action";//html调用的地址
|
|
|
+ HttpWebRequest webrequest = (HttpWebRequest)WebRequest.Create(url);
|
|
|
+ if (webrequest == null)
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ webrequest.Method = "POST";
|
|
|
+ webrequest.Timeout = 1000;
|
|
|
+ webrequest.ContentType = "application/x-www-form-urlencoded";
|
|
|
+ System.Collections.Hashtable pars = new System.Collections.Hashtable();
|
|
|
+ pars.Add("username", UserName);
|
|
|
+ pars.Add("password", PassWord);
|
|
|
+ pars.Add("master", Master);
|
|
|
+ string buffer = "";
|
|
|
+ //发送POST数据
|
|
|
+ if (!(pars == null || pars.Count == 0))
|
|
|
+ {
|
|
|
+ foreach (string key in pars.Keys)
|
|
|
+ {
|
|
|
+ buffer = buffer + "&" + key + "=" + pars[key].ToString();
|
|
|
+ }
|
|
|
+ byte[] data = Encoding.UTF8.GetBytes(buffer);
|
|
|
+ using (Stream stream = webrequest.GetRequestStream())
|
|
|
+ {
|
|
|
+ stream.Write(data, 0, data.Length);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ string[] values = webrequest.Headers.GetValues("Content-Type");
|
|
|
+ WebResponse myResponse = webrequest.GetResponse();
|
|
|
+
|
|
|
+ using (Stream resStream = myResponse.GetResponseStream())//得到回写的流
|
|
|
+ {
|
|
|
+ StreamReader newReader = new StreamReader(myResponse.GetResponseStream(), Encoding.UTF8);
|
|
|
+ string Content = newReader.ReadToEnd();
|
|
|
+ Dictionary<string, object> dic = new Dictionary<string, object>();
|
|
|
+ dic = BaseUtil.ToDictionary(Content);
|
|
|
+ if (!dic.ContainsKey("erpaccount"))
|
|
|
+ {
|
|
|
+ oMsg = dic["reason"].ToString();
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ newReader.Close();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ LogManager.DoLog(ex.Message.ToString());
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|