|
|
@@ -3,14 +3,17 @@ using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.ComponentModel;
|
|
|
using System.Data;
|
|
|
+using System.IO;
|
|
|
+using System.Net;
|
|
|
using System.Runtime.InteropServices;
|
|
|
using System.Text;
|
|
|
+using System.Text.RegularExpressions;
|
|
|
using System.Web.Script.Serialization;
|
|
|
|
|
|
-namespace UMES.DLLService
|
|
|
+namespace UMESDLLService
|
|
|
{
|
|
|
|
|
|
- [Guid("99D0E96E-1058-415D-9874-D34537625284")]
|
|
|
+ [Guid("974DEAD2-9D4C-4728-87EA-2407752E300F")]
|
|
|
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
|
|
|
public interface IMESHelper
|
|
|
{
|
|
|
@@ -18,29 +21,34 @@ namespace UMES.DLLService
|
|
|
bool CheckRoutePassed(string iSN, string iResCode, out string oErrMessage);
|
|
|
bool GetRcardMOInfo(string iSN, out string oMoCode, out string oErrMessage);
|
|
|
bool CheckUserAndResourcePassed(string iUserCode, string iResCode, string iPassWord, out string oErrMessage);
|
|
|
- bool GetAddressRangeByMO(string iSN, out Dictionary<string, string> oInfo, out string oErrMessage);
|
|
|
+ bool GetAddressRangeByMO(string iSN, out string oInfo, out string oErrMessage);
|
|
|
bool SetAddressInfo(string iSN, string iMac, string iBT, string iCode1, string iCode2, string iCode3, out string oErrorMessage);
|
|
|
bool SetTestDetail(string iSN, string iTestResult, string iResCode, string[,] iTestDetail, out string oErrMessage);
|
|
|
- bool GetMEIOrNetCodeRange(string iSnCode, string iIMEI1, string iNetCode, out Dictionary<string, string> oInfo, out string oErrMessage);
|
|
|
- bool SetIMEIInfo(string iSnCode, string iIMEI1, out string oErrMessage);
|
|
|
+ bool GetMEIOrNetCodeRange(string iSnCode, string iIMEI1, string iNetCode, out string oInfo, out string oErrMessage);
|
|
|
+ bool SetIMEIInfo(string iSN, string iIMEI1, string iIMEI2, string iIMEI3, string iMEID, string iNETCODE, string iID1, string iID2, string iID3, out string oErrMessage);
|
|
|
bool GetMobileAllInfo(string iSnCode, out string oInfo, out string oErrorMessage);
|
|
|
bool SetMobileData(string iTSN, string iSN, string iSourceCode, string iOperator, string iResult, string iErrCode, string flag, out string oErrorMessage);
|
|
|
bool SetPcbaData(string iSN, string iResCode, string iOperator, string iResult, string iErrCode, out string oErrMessage);
|
|
|
bool GoMo(string iMO, string iSN, string iResCode, out string oErrMessage);
|
|
|
+ bool GetInfoByMaterial(string iPCBA, out string oSN, out string oErrMessage);
|
|
|
+ bool GetSoftVersion(string iSN, out string oSoftVersion, out string oErrMessage);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- [Guid("41EAB546-6EF4-464A-895A-9C34013A5D8C")]
|
|
|
+ [Guid("5379A8F6-EB38-4A2B-9050-52AD9757E12D")]
|
|
|
[ComSourceInterfaces(typeof(IMESHelper))]
|
|
|
[ClassInterface(ClassInterfaceType.None)]
|
|
|
- [ProgId("DllService.MESHelper")]
|
|
|
+ [ProgId("UMES.DllService.MESHelper")]
|
|
|
public class MESHelper : IMESHelper
|
|
|
{
|
|
|
//用于拼接SQL
|
|
|
StringBuilder sql = new StringBuilder();
|
|
|
//用于存放批量执行的SQL
|
|
|
List<string> sqls = new List<string>();
|
|
|
+
|
|
|
+ string Master = "N_MES";
|
|
|
//系统默认的的连接字符串
|
|
|
- private string ConnectionStrings = "Data Source=10.8.0.34/orcl;User ID=MES;PassWord=select!#%*(;";
|
|
|
+ private string ConnectionStrings = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=N_MES;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.23)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
|
|
|
//用户选择的数据库的连接字符串
|
|
|
private OracleConnection connection;
|
|
|
//用户选择的数据库的连接字符串
|
|
|
@@ -53,7 +61,51 @@ namespace UMES.DLLService
|
|
|
|
|
|
public MESHelper(string IP)
|
|
|
{
|
|
|
- connection = new OracleConnection("Data Source=" + IP + "/orcl;User ID=MES;PassWord=select!#%*(;");
|
|
|
+ connection = new OracleConnection("Data Source=" + IP + "/orcl;User ID=N_MES;PassWord=select!#%*(;");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ [Description("获取工单软件版本")]
|
|
|
+ public bool GetSoftVersion(string iMakeCode, out string oSoftVersion, out string oErrMessage)
|
|
|
+ {
|
|
|
+ string oMakeCode = "";
|
|
|
+ oErrMessage = "";
|
|
|
+ oSoftVersion = "";
|
|
|
+ //GetRcardMOInfo(iSN, out oMakeCode, out oErrMessage);
|
|
|
+ if (!CheckExist("Make", "ma_Code='" + iMakeCode + "'"))
|
|
|
+ {
|
|
|
+ oErrMessage = "工单号" + iMakeCode + "不存在";
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ oSoftVersion = getFieldDataByCondition("make", "ma_softversion", "ma_code='" + iMakeCode + "'").ToString();
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ public bool GetInfoByMaterial(string iPCBA, out string oSN, out string oErrMessage)
|
|
|
+ {
|
|
|
+ oSN = "";
|
|
|
+ oErrMessage = "";
|
|
|
+ if (iPCBA == "")
|
|
|
+ {
|
|
|
+ oErrMessage = "主板SN不能为空";
|
|
|
+ }
|
|
|
+
|
|
|
+ DataTable dt = (DataTable)ExecuteSql("select ms_firstsn,ms_sncode from CRAFTMATERIAL left join make on cm_makecode=ma_code " +
|
|
|
+ "left join makeserial on ms_firstsn=cm_firstsn and cm_makecode=ms_makecode where cm_barcode='" + iPCBA + "' and nvl(cm_status,0)<>-1 order by cm_id desc", "select");
|
|
|
+ if (dt.Rows.Count > 0)
|
|
|
+ {
|
|
|
+ oSN = dt.Rows[0]["ms_sncode"].ToString();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ oErrMessage = "主板SN未查询到关联信息";
|
|
|
+ }
|
|
|
+ if (oErrMessage == "" || oErrMessage == null || oErrMessage == "null")
|
|
|
+ {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
@@ -71,6 +123,15 @@ namespace UMES.DLLService
|
|
|
oErrMessage = "SN不能为空";
|
|
|
return false;
|
|
|
}
|
|
|
+ string SNcode = iSN;
|
|
|
+ if (!GetInfoByMaterial(iSN, out iSN, out oErrMessage))
|
|
|
+ {
|
|
|
+ oErrMessage = "";
|
|
|
+ }
|
|
|
+ if (iSN == "")
|
|
|
+ {
|
|
|
+ iSN = SNcode;
|
|
|
+ }
|
|
|
oErrMessage = "";
|
|
|
string[] param = new string[] { "", iResCode, iSN, "", "", "", oErrMessage };
|
|
|
string[] ParamName = new string[] { "v_i_macode", "v_i_sourcecode", "v_i_sncode", "v_i_usercode", "v_o_macode", "v_o_msid", "v_o_errmsg" };
|
|
|
@@ -89,7 +150,7 @@ namespace UMES.DLLService
|
|
|
string stepcode = GetStepCodeBySource(iResCode);
|
|
|
if (ms_nextstepcode != "" && ms_nextstepcode != stepcode)
|
|
|
{
|
|
|
- oErrMessage = "当前序列号下一工序" + ms_nextstepcode;
|
|
|
+ oErrMessage = "当前序列号" + iSN + "下一工序" + ms_nextstepcode;
|
|
|
return false;
|
|
|
}
|
|
|
if (oErrMessage == "" || oErrMessage == null || oErrMessage == "null" || (ms_status == "3" && stepcode == ms_stepcode))
|
|
|
@@ -149,7 +210,7 @@ namespace UMES.DLLService
|
|
|
oErrMessage = "用户名,密码,岗位资源必须填写";
|
|
|
return false;
|
|
|
}
|
|
|
- if (CheckUserLogin(iUserCode, iPassWord, out oErrMessage))
|
|
|
+ if (CheckUserLogin(iUserCode, iPassWord, "N_MES", out oErrMessage))
|
|
|
{
|
|
|
string SQL = "select em_code,em_type,em_name from employee where em_code=:UserName ";
|
|
|
DataTable dt;
|
|
|
@@ -211,9 +272,9 @@ namespace UMES.DLLService
|
|
|
/// <param name="oErrMessage"></param>
|
|
|
/// <returns></returns>
|
|
|
[Description("分配MAC和BT信息")]
|
|
|
- public bool GetAddressRangeByMO(string iSN, out Dictionary<string, string> oInfo, out string oErrMessage)
|
|
|
+ public bool GetAddressRangeByMO(string iSN, out string oInfo, out string oErrMessage)
|
|
|
{
|
|
|
- oInfo = new Dictionary<string, string>();
|
|
|
+ oInfo = "";
|
|
|
string oWIFI = "";
|
|
|
string oBT = "";
|
|
|
string oCode1 = "";
|
|
|
@@ -230,11 +291,11 @@ namespace UMES.DLLService
|
|
|
string[] param = new string[] { iSN, omakeCode, oWIFI, oBT, oCode1, oCode2, oCdoe3, oErrMessage };
|
|
|
string[] ParamName = new string[] { "v_i_sncode", "v_i_macode", "v_o_mac", "v_o_bt", "v_o_code1", "v_o_code2", "v_o_code3", "v_o_errmsg" };
|
|
|
CallProcedure("CS_GETADDRESSBYMAKECODE", ParamName, ref param);
|
|
|
- oInfo.Add("MAC", param[2]);
|
|
|
- oInfo.Add("BT", param[3]);
|
|
|
- oInfo.Add("Code1", param[4]);
|
|
|
- oInfo.Add("Code2", param[5]);
|
|
|
- oInfo.Add("Code3", param[6]);
|
|
|
+ oInfo += "MAC:" + param[2].ToString() + "^".Replace("null", "");
|
|
|
+ oInfo += "BT:" + param[3].ToString() + "^".Replace("null", "");
|
|
|
+ oInfo += "Code1:" + param[4].ToString() + "^".Replace("null", "");
|
|
|
+ oInfo += "Code2:" + param[5].ToString() + "^".Replace("null", "");
|
|
|
+ oInfo += "Code3:" + param[6].ToString() + "";
|
|
|
oErrMessage = param[7];
|
|
|
if (oErrMessage == "" || oErrMessage == null || oErrMessage == "null")
|
|
|
return true;
|
|
|
@@ -261,9 +322,9 @@ namespace UMES.DLLService
|
|
|
/// <param name="oErrMessage"></param>
|
|
|
/// <returns></returns>
|
|
|
[Description("分配IMEI和NetCode信息")]
|
|
|
- public bool GetMEIOrNetCodeRange(string iSN, string iIMEI1, string iNetCode, out Dictionary<string, string> oInfo, out string oErrMessage)
|
|
|
+ public bool GetMEIOrNetCodeRange(string iSN, string iIMEI1, string iNetCode, out string oInfo, out string oErrMessage)
|
|
|
{
|
|
|
- oInfo = new Dictionary<string, string>();
|
|
|
+ oInfo = "";
|
|
|
string oIMEI1 = "";
|
|
|
string oIMEI2 = "";
|
|
|
string oMEID = "";
|
|
|
@@ -278,18 +339,20 @@ namespace UMES.DLLService
|
|
|
oErrMessage = "SN不能为空";
|
|
|
return false;
|
|
|
}
|
|
|
+
|
|
|
oErrMessage = "";
|
|
|
string[] param = new string[] { iSN, "", iIMEI1, iNetCode, oIMEI1, oIMEI2, "", oMEID, oNetCode, oPSN, oID1, oID2, oID3, oErrMessage };
|
|
|
string[] ParamName = new string[] { "v_i_sncode", "v_i_macode", "v_i_imei", "v_i_netcode", "v_o_imei1", "v_o_imei2", "v_o_imei3", "v_o_meid", "v_o_netcode", "v_o_psn", "v_o_id1", "v_o_id2", "v_o_id3", "v_o_errmsg" };
|
|
|
CallProcedure("CS_GETIMEIORNETCODERANGE", ParamName, ref param);
|
|
|
- oInfo.Add("IMEI1", param[4]);
|
|
|
- oInfo.Add("IMEI2", param[5]);
|
|
|
- oInfo.Add("MEID", param[7]);
|
|
|
- oInfo.Add("NETCODE", param[8]);
|
|
|
- oInfo.Add("PSN", param[9]);
|
|
|
- oInfo.Add("ID1", param[10]);
|
|
|
- oInfo.Add("ID2", param[11]);
|
|
|
- oInfo.Add("ID3", param[12]);
|
|
|
+
|
|
|
+ oInfo += "IMEI1:" + param[4].ToString() + "^".Replace("null", "");
|
|
|
+ oInfo += "IMEI2:" + param[5].ToString() + "^".Replace("null", "");
|
|
|
+ oInfo += "MEID:" + param[7].ToString() + "^".Replace("null", "");
|
|
|
+ oInfo += "NETCODE:" + param[8].ToString() + "^".Replace("null", "");
|
|
|
+ oInfo += "PSN:" + param[9].ToString() + "^".Replace("null", "");
|
|
|
+ oInfo += "ID1:" + param[10].ToString() + "^".Replace("null", "");
|
|
|
+ oInfo += "ID2:" + param[11].ToString() + "^".Replace("null", "");
|
|
|
+ oInfo += "ID3:" + param[12].ToString() + "".Replace("null", "");
|
|
|
oErrMessage = param[13];
|
|
|
if (oErrMessage == "" || oErrMessage == null || oErrMessage == "null")
|
|
|
return true;
|
|
|
@@ -364,21 +427,49 @@ namespace UMES.DLLService
|
|
|
oErrMessage = "SN不能为空";
|
|
|
return false;
|
|
|
}
|
|
|
- Dictionary<string, string> MacInfo = new Dictionary<string, string>();
|
|
|
- if (!GetAddressRangeByMO(iSN, out MacInfo, out oErrMessage))
|
|
|
- {
|
|
|
- if (oErrMessage == "" || oErrMessage == null || oErrMessage == "null")
|
|
|
- return true;
|
|
|
- else
|
|
|
- return false;
|
|
|
- }
|
|
|
- if (!SetAddressInfo(iSN, MacInfo["MAC"] == "null" ? "" : MacInfo["MAC"], MacInfo["BT"] == "null" ? "" : MacInfo["BT"], MacInfo["Code1"] == "null" ? "" : MacInfo["Code1"], MacInfo["Code2"] == "null" ? "" : MacInfo["Code2"], MacInfo["Code3"] == "null" ? "" : MacInfo["Code3"], out oErrMessage))
|
|
|
- {
|
|
|
- if (oErrMessage == "" || oErrMessage == null || oErrMessage == "null")
|
|
|
- return true;
|
|
|
- else
|
|
|
- return false;
|
|
|
- }
|
|
|
+ string MacInfo;
|
|
|
+ //if (!GetAddressRangeByMO(iSN, out MacInfo, out oErrMessage))
|
|
|
+ //{
|
|
|
+ // if (oErrMessage == "" || oErrMessage == null || oErrMessage == "null")
|
|
|
+ // return true;
|
|
|
+ // else
|
|
|
+ // return false;
|
|
|
+ //}
|
|
|
+ //string MAC = MacInfo.Split('^')[0].Replace("MAC:", "");
|
|
|
+ //string BT = MacInfo.Split('^')[1].Replace("BT:", "");
|
|
|
+ //string TCode1 = MacInfo.Split('^')[2].Replace("Code1:", "");
|
|
|
+ //string TCode2 = MacInfo.Split('^')[3].Replace("Code2:", "");
|
|
|
+ //string TCode3 = MacInfo.Split('^')[4].Replace("Code3:", "");
|
|
|
+ //if (!SetAddressInfo(iSN, MAC == "null" ? "" : MAC, BT == "null" ? "" : BT, TCode1 == "null" ? "" : TCode1, TCode2 == "null" ? "" : TCode2, TCode3 == "null" ? "" : TCode3, out oErrMessage))
|
|
|
+ //{
|
|
|
+ // if (oErrMessage == "" || oErrMessage == null || oErrMessage == "null")
|
|
|
+ // return true;
|
|
|
+ // else
|
|
|
+ // return false;
|
|
|
+ //}
|
|
|
+ //string ImeiInfo;
|
|
|
+ //if (!GetMEIOrNetCodeRange(iSN, "", "", out ImeiInfo, out oErrMessage))
|
|
|
+ //{
|
|
|
+ // if (oErrMessage == "" || oErrMessage == null || oErrMessage == "null")
|
|
|
+ // return true;
|
|
|
+ // else
|
|
|
+ // return false;
|
|
|
+ //}
|
|
|
+ //string IMEI1 = ImeiInfo.Split('^')[0].Replace("IMEI1:", "");
|
|
|
+ //string IMEI2 = ImeiInfo.Split('^')[1].Replace("IMEI2:", "");
|
|
|
+ //string MEID = ImeiInfo.Split('^')[2].Replace("MEID:", "");
|
|
|
+ //string NETCODE = ImeiInfo.Split('^')[3].Replace("NETCODE:", "");
|
|
|
+ //string PSN = ImeiInfo.Split('^')[4].Replace("PSN:", "");
|
|
|
+ //string ID1 = ImeiInfo.Split('^')[5].Replace("ID1:", "");
|
|
|
+ //string ID2 = ImeiInfo.Split('^')[6].Replace("ID2:", "");
|
|
|
+ //string ID3 = ImeiInfo.Split('^')[7].Replace("ID3:", "");
|
|
|
+ //if (!SetIMEIInfo(iSN, IMEI1 == "null" ? "" : IMEI1, IMEI2 == "null" ? "" : IMEI2, "", MEID == "null" ? "" : MEID, NETCODE == "null" ? "" : NETCODE, ID1 == "null" ? "" : ID1, ID2 == "null" ? "" : ID2, ID3 == "null" ? "" : ID3, out oErrMessage))
|
|
|
+ //{
|
|
|
+ // if (oErrMessage == "" || oErrMessage == null || oErrMessage == "null")
|
|
|
+ // return true;
|
|
|
+ // else
|
|
|
+ // return false;
|
|
|
+ //}
|
|
|
//通过序列号获取最近操作的工单号
|
|
|
string ms_id = getFieldDataByCondition("makeserial", "max(ms_id)", "ms_sncode='" + iSN + "' or ms_firstsn='" + iSN + "'").ToString();
|
|
|
if (ms_id != "")
|
|
|
@@ -494,7 +585,7 @@ namespace UMES.DLLService
|
|
|
}
|
|
|
|
|
|
[Description("序列号跳到下一 步")]
|
|
|
- public bool SetStepFinish(string iMakeCode, string iSourceCode, string iSN, string iMPKind, string iResult, string iUserCode, string iErrCode, out string oErrMessage)
|
|
|
+ private bool SetStepFinish(string iMakeCode, string iSourceCode, string iSN, string iMPKind, string iResult, string iUserCode, string iErrCode, out string oErrMessage)
|
|
|
{
|
|
|
if (iSN == "")
|
|
|
{
|
|
|
@@ -578,7 +669,7 @@ namespace UMES.DLLService
|
|
|
if (iSN == "") { oErrorMessage = "SN不能为空"; return false; }
|
|
|
string[] param = new string[] { iTSN, iSN, iSourceCode, iOperater, iResult, iErrCode, oErrorMessage };
|
|
|
string[] ParamName = new string[] { "v_i_tsn", "v_i_sncode", "v_i_sourcecode", "v_i_usercode", "v_i_result", "v_i_errcode", "v_o_errmsg" };
|
|
|
- CallProcedure("CS_DLLSNCHANGE", ParamName, ref param);
|
|
|
+ CallProcedure("CS_DLLSNCHANGE_TOOL", ParamName, ref param);
|
|
|
oErrorMessage = param[6];
|
|
|
if (oErrorMessage == "" || oErrorMessage == null || oErrorMessage == "null")
|
|
|
return true;
|
|
|
@@ -596,7 +687,7 @@ namespace UMES.DLLService
|
|
|
oErrMessage = "";
|
|
|
string[] param = new string[] { iMakeCode, iSourceCode, iSN, iUserCode, iResult, oErrMessage };
|
|
|
string[] ParamName = new string[] { "v_i_macode", "v_i_sourcecode", "v_i_sncode", "v_i_usercode", "v_i_result", "v_o_errmsg" };
|
|
|
- CallProcedure("CS_SETSTEPRESULT", ParamName, ref param);
|
|
|
+ CallProcedure("CS_SETSTEPRESULT_TOOL", ParamName, ref param);
|
|
|
oErrMessage = param[5];
|
|
|
if (oErrMessage == "" || oErrMessage == null || oErrMessage == "null")
|
|
|
return true;
|
|
|
@@ -686,7 +777,7 @@ namespace UMES.DLLService
|
|
|
/// <param name="oErrorMessage"></param>
|
|
|
/// <returns></returns>
|
|
|
[Description("设置IMEI信息")]
|
|
|
- public bool SetIMEIInfo(string iSN, string iIMEI1, out string oErrMessage)
|
|
|
+ public bool SetIMEIInfo(string iSN, string iIMEI1, string iIMEI2, string iIMEI3, string iMEID, string iNETCODE, string iID1, string iID2, string iID3, out string oErrMessage)
|
|
|
{
|
|
|
if (iSN == "")
|
|
|
{
|
|
|
@@ -694,7 +785,7 @@ namespace UMES.DLLService
|
|
|
return false;
|
|
|
}
|
|
|
oErrMessage = "";
|
|
|
- string[] param = new string[] { iSN, iIMEI1, "", "", "", "", "", "", "", "", oErrMessage };
|
|
|
+ string[] param = new string[] { iSN, iIMEI1, iIMEI2, iIMEI3, iMEID, iNETCODE, "", iID1, iID2, iID3, oErrMessage };
|
|
|
string[] ParamName = new string[] { "v_i_sncode", "v_i_imei1", "v_i_imei2", "v_i_imei3", "v_i_meid", "v_i_netcode", "v_i_psn", "v_i_id1", "v_i_id2", "v_i_id3", "v_o_errmsg" };
|
|
|
CallProcedure("CS_SETIMEIINFO", ParamName, ref param);
|
|
|
oErrMessage = param[10];
|
|
|
@@ -722,6 +813,15 @@ namespace UMES.DLLService
|
|
|
oErrMessage = "SN不能为空";
|
|
|
return false;
|
|
|
}
|
|
|
+ string SNcode = iSN;
|
|
|
+ if (!GetInfoByMaterial(iSN, out iSN, out oErrMessage))
|
|
|
+ {
|
|
|
+ oErrMessage = "";
|
|
|
+ }
|
|
|
+ if (iSN == "")
|
|
|
+ {
|
|
|
+ iSN = SNcode;
|
|
|
+ }
|
|
|
oErrMessage = "";
|
|
|
string oMakeCode = "";
|
|
|
GetRcardMOInfo(iSN, out oMakeCode, out oErrMessage);
|
|
|
@@ -1179,5 +1279,115 @@ namespace UMES.DLLService
|
|
|
cmd.Connection.Open();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 验证用户身份信息
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="iUserCode"></param>
|
|
|
+ /// <param name="oErrorMessage"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ private bool CheckUserLogin(string iUserCode, string iPassWord, string Master, out string oErrorMessage)
|
|
|
+ {
|
|
|
+ oErrorMessage = "";
|
|
|
+ try
|
|
|
+ {
|
|
|
+ string url = "http://10.98.0.21:8099/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 = ToDictionary(Content);
|
|
|
+ if (!dic.ContainsKey("erpaccount"))
|
|
|
+ {
|
|
|
+ oErrorMessage = dic["reason"].ToString();
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ newReader.Close();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ oErrorMessage = ex.Message.ToString();
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Dictionary<string, object> ToDictionary(string JsonData)
|
|
|
+ {
|
|
|
+ object Data = null;
|
|
|
+ Dictionary<string, object> Dic = new Dictionary<string, object>();
|
|
|
+ if (JsonData.StartsWith("["))
|
|
|
+ {
|
|
|
+ //如果目标直接就为数组类型,则将会直接输出一个Key为List的List<Dictionary<string, object>>集合
|
|
|
+ //使用示例List<Dictionary<string, object>> ListDic = (List<Dictionary<string, object>>)Dic["List"];
|
|
|
+ List<Dictionary<string, object>> List = new List<Dictionary<string, object>>();
|
|
|
+ MatchCollection ListMatch = Regex.Matches(JsonData, @"{[\s\S]+?}");//使用正则表达式匹配出JSON数组
|
|
|
+ foreach (Match ListItem in ListMatch)
|
|
|
+ {
|
|
|
+ List.Add(ToDictionary(ListItem.ToString()));//递归调用
|
|
|
+ }
|
|
|
+ Data = List;
|
|
|
+ Dic.Add("List", Data);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ MatchCollection Match = Regex.Matches(JsonData, @"""(.+?)"": {0,1}(\[[\s\S]+?\]|null|"".+?""|-{0,1}\d*)");//使用正则表达式匹配出JSON数据中的键与值
|
|
|
+ foreach (Match item in Match)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ if (item.Groups[2].ToString().StartsWith("["))
|
|
|
+ {
|
|
|
+ //如果目标是数组,将会输出一个Key为当前Json的List<Dictionary<string, object>>集合
|
|
|
+ //使用示例List<Dictionary<string, object>> ListDic = (List<Dictionary<string, object>>)Dic["Json中的Key"];
|
|
|
+ List<Dictionary<string, object>> List = new List<Dictionary<string, object>>();
|
|
|
+ MatchCollection ListMatch = Regex.Matches(item.Groups[2].ToString(), @"{[\s\S]+?}");//使用正则表达式匹配出JSON数组
|
|
|
+ foreach (Match ListItem in ListMatch)
|
|
|
+ {
|
|
|
+ List.Add(ToDictionary(ListItem.ToString()));//递归调用
|
|
|
+ }
|
|
|
+ Data = List;
|
|
|
+ }
|
|
|
+ else if (item.Groups[2].ToString().ToLower() == "null") Data = null;//如果数据为null(字符串类型),直接转换成null
|
|
|
+ else Data = item.Groups[2].ToString(); //数据为数字、字符串中的一类,直接写入
|
|
|
+ Dic.Add(item.Groups[1].ToString(), Data);
|
|
|
+ }
|
|
|
+ catch { }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return Dic;
|
|
|
+ }
|
|
|
}
|
|
|
}
|