|
|
@@ -1,6 +1,8 @@
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Data;
|
|
|
+using System.IO;
|
|
|
+using System.Net;
|
|
|
using System.Text;
|
|
|
using System.Windows;
|
|
|
using System.Windows.Forms;
|
|
|
@@ -89,6 +91,63 @@ namespace UAS_MES_NEW.PublicMethod
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public static bool CheckUserLogin(string iUserCode, string iPassWord, string Master, out string oErrorMessage)
|
|
|
+ {
|
|
|
+ oErrorMessage = "";
|
|
|
+ try
|
|
|
+ {
|
|
|
+ string url = "http://192.168.1.92:8088/mes/" + "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", iUserCode);
|
|
|
+ pars.Add("password", iPassWord);
|
|
|
+ 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"))
|
|
|
+ {
|
|
|
+ oErrorMessage = dic["reason"].ToString();
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ newReader.Close();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ LogManager.DoLog(ex.Message.ToString());
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 记录登陆信息
|
|
|
/// </summary>
|