/// <summary> /// 身份验证 /// </summary> /// <param name="xmlParams"></param> /// <returns></returns> public static string IdentityVerification(string xmlParams) { try { if (!Current.mes.IsPingSuccess) { throw new Exception("无法连接到MES服务器:" + Current.mes.Host); } return(IdentityVerificationProxy.IdentityVerification(xmlParams)); } catch (Exception ex) { return(ex.Message); } }
/// <summary> /// 身份验证 /// </summary> /// <param name="msg"></param> /// <returns></returns> public static bool IdentityVerification(out string msg) { try { if (!Current.mes.IsPingSuccess) { throw new Exception("无法连接到MES服务器:" + Current.mes.Host); } var request = new IdentityVerificationRequest() { AccountNumber = Current.mes.Username, Password = Current.mes.Password }; msg = string.Empty; var xmlRequest = XmlHelper.Serialize(request).Replace("<?xml version=\"1.0\" encoding=\"utf-8\"?>", ""); var xmlResponse = IdentityVerificationProxy.IdentityVerification(xmlRequest); var response = XmlHelper.Deserialize <IdentityVerificationResponse>(xmlResponse); if (response.Result) { Current.mes.DeviceId = response.DeviceId; Current.mes.StationCode = response.StationCode; Current.mes.ProcessCode = response.ProcessCode; //LogHelper.WriteInfo(string.Format("MES身份验证OK,xmlRequest:{1},xmlResponse:{2}", "", xmlRequest, xmlResponse)); //LogHelper.WriteInfo(string.Format("MES身份验证OK")); } else { msg = "MES身份验证不通过,原因:" + response.Message; } return(response.Result); } catch (Exception ex) { LogHelper.WriteError(ex); msg = "MES身份验证异常报错:" + ex.Message; } return(false); }