private void ConvertToSSOMessage(string xmlStr, AuthEntity authContent) { XmlDocument doc = new XmlDocument(); doc.LoadXml(xmlStr); #region XmlNode node = doc.SelectSingleNode("/SSOMessage/ResultCode"); if (node != null && !string.IsNullOrEmpty(node.InnerText)) { authContent.ResultCode = node.InnerText; } node = doc.SelectSingleNode("/SSOMessage/ResultMessageCN"); if (node != null && !string.IsNullOrEmpty(node.InnerText)) { authContent.ResultMessageCN = node.InnerText; } node = doc.SelectSingleNode("/SSOMessage/ResultMessageEN"); if (node != null && !string.IsNullOrEmpty(node.InnerText)) { authContent.ResultMessageEN = node.InnerText; } node = doc.SelectSingleNode("/SSOMessage/AuthTime"); if (node != null && !string.IsNullOrEmpty(node.InnerText)) { authContent.AuthTime = Convert.ToDateTime(node.InnerText); } node = doc.SelectSingleNode("/SSOMessage/ExpireTime"); if (node != null && !string.IsNullOrEmpty(node.InnerText)) { authContent.ExpireTime = Convert.ToDateTime(node.InnerText); } #endregion XmlNodeList nodes = doc.SelectNodes("/SSOMessage/Cookies/Cookie"); if (node != null) { foreach (XmlNode item in nodes) { switch (item.Attributes["name"].Value) { case "AuthNum": authContent.AuthNum = item.InnerText; break; case "AuthToken": authContent.AuthToken = item.InnerText; break; case "AuthMAC": authContent.AuthMAC = item.InnerText; break; } } } }
public AuthEntity GetUserToken(string loginName, string password) { AuthEntity authContent = new AuthEntity(); string reqcontent = "ssoLoginSite=" + GetSSOConfigSettings.Informations["LoginSite"].Value + "&SystemCode=" + GetSSOConfigSettings.Informations["SystemCode"].Value + "&ResultMIMEType=" + GetSSOConfigSettings.Informations["ResultMIMEType"].Value + "&UserID=" + loginName + "&UserPassword="******"ApiUrl"].Value); ConvertToSSOMessage(xmlStr, authContent); } catch (Exception e) { authContent.ResultCode = "-1"; authContent.ResultMessageCN = e.Message; authContent.ResultMessageEN = e.Message; } return(authContent); }