|
|
@@ -1,13 +1,17 @@
|
|
|
-using System;
|
|
|
+using DevExpress.Utils.Drawing.Helpers;
|
|
|
+using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Data;
|
|
|
using System.Drawing;
|
|
|
+using System.IO;
|
|
|
+using System.Net;
|
|
|
using System.Text;
|
|
|
using System.Windows;
|
|
|
using System.Windows.Forms;
|
|
|
using UAS_MES_NEW.DataOperate;
|
|
|
using UAS_MES_NEW.Entity;
|
|
|
using UAS_MES_NEW.PublicForm;
|
|
|
+using static System.Windows.Forms.VisualStyles.VisualStyleElement.StartPanel;
|
|
|
|
|
|
namespace UAS_MES_NEW.PublicMethod
|
|
|
{
|
|
|
@@ -76,19 +80,61 @@ namespace UAS_MES_NEW.PublicMethod
|
|
|
/// <param name="iUserCode"></param>
|
|
|
/// <param name="oErrorMessage"></param>
|
|
|
/// <returns></returns>
|
|
|
- public static bool CheckUserLogin(string iUserCode, string iPassWord, out string oErrorMessage)
|
|
|
+ public static bool CheckUserLogin(string iUserCode, string iPassWord, string Master, out string oErrorMessage)
|
|
|
{
|
|
|
oErrorMessage = "";
|
|
|
- string SQL = "select em_code from employee where (upper(em_code)=:UserName or em_mobile=:UserName) and em_password =:PassWord";
|
|
|
- DataTable dt;
|
|
|
- dt = (DataTable)dh.ExecuteSql(SQL, "select", iUserCode.ToUpper(), iUserCode.ToUpper(), iPassWord);
|
|
|
- if (dt.Rows.Count > 0)
|
|
|
- return true;
|
|
|
- else
|
|
|
+ try
|
|
|
{
|
|
|
- oErrorMessage = "用户名或者密码不正确!";
|
|
|
- return false;
|
|
|
+ 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", 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>
|