using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.Text; using System.Data.SqlClient; using System.Collections.Generic; using System.Xml; using DSWeb.Models; using DSWeb.EntityDA; namespace DSWeb.FeeCodes { public partial class WebCrmClientAdapterAll : System.Web.UI.Page { private string strMark; private string strPos; private int iPos = 0; public string strIS = ""; public string strIS2 = ""; public string strCompanyID;//公司GID public string strBeing = String.Empty; protected void Page_Load(object sender, EventArgs e) { if (Session["COMPANYID"] != null) { strCompanyID = Session["COMPANYID"].ToString(); } if (!IsPostBack) { string strPost = Request.Url.ToString(); if (Request.QueryString["mask"] != null) { strMark = Request.QueryString["mask"].ToString(); } if (Request.QueryString["pos"] != null) { strPos = Request.QueryString["pos"].ToString(); iPos = int.Parse(strPos); } if (Request.QueryString["strIS"] != null) { strIS = Request.QueryString["strIS"].ToString(); } if (Request.QueryString["strIS2"] != null) { strIS2 = Request.QueryString["strIS2"].ToString(); } if (Request.QueryString["isbeing"] != null) { strBeing = getBeing(Request.QueryString["isbeing"].ToString()); Response.Write(strBeing.Trim()); return; } if (Request.QueryString["djqstr"] != null) { UnicodeEncoding unicode = new UnicodeEncoding(); string djq = unicode.GetString(unicode.GetBytes(Request.QueryString["djqstr"].ToString())); djq = getdjq(djq.Trim()); Response.Write(djq.Trim()); return; } XmlDocument docs = GetDoc(); Response.ContentType = "text/xml"; Response.Write(docs.OuterXml.ToString()); } } public string getBeing(string strClientID) { string alt = ""; T_ALL_DA T_ALL_DA = new T_ALL_DA(); alt = T_ALL_DA.GetBeing(strClientID); return alt; } public string getdjq(string strClientID) { string alt = ""; T_ALL_DA T_ALL_DA = new T_ALL_DA(); DataSet ds = T_ALL_DA.GetAllSQL("select top 1 * from info_client where SHORTNAME='" + strClientID + "' and ISSTOP=0"); if (ds != null) { alt = ds.Tables[0].Rows[0]["GID"].ToString().Trim() + "," + ds.Tables[0].Rows[0]["CODENAME"].ToString().Trim() + "," + ds.Tables[0].Rows[0]["SHORTNAME"].ToString().Trim() + "," + ds.Tables[0].Rows[0]["DESCRIPTION"].ToString().Trim(); } return alt; } public string BuildXML() { StringBuilder resultBuilder = new StringBuilder(); resultBuilder.Append(""); resultBuilder.AppendFormat("", iPos == 0 ? string.Empty : " add=\"true\""); if (!string.IsNullOrEmpty(strMark)) { string js = ""; if (strIS == "" && strIS2 == "") { CRMClientDA crmClientDA = new CRMClientDA(); string strSql = "SELECT CODENAME,SHORTNAME FROM info_client where ISSTOP=0 ORDER BY CODENAME ASC "; DataTable sourceTable = crmClientDA.GetExcuteSql(strSql).Tables[0]; if (sourceTable.Rows.Count > 0) { for (int i = 0; i < sourceTable.Rows.Count; i++) { string strName = sourceTable.Rows[i][0].ToString().Trim() + " | " + sourceTable.Rows[i][1].ToString().Trim(); resultBuilder.AppendFormat("", sourceTable.Rows[i][0].ToString().Trim(), strName); } } } else { T_ALL_DA T_ALL_DA = new T_ALL_DA(); DataSet ds = T_ALL_DA.GetWebCrmClient(strIS, strIS2, strCompanyID); if (ds != null) { foreach (DataRow dr in ds.Tables[0].Rows) { if (dr["CODENAME"].ToString().Trim() != "" || dr["SHORTNAME"].ToString().Trim() != "") { js = dr["CODENAME"].ToString().Trim() + " | " + dr["SHORTNAME"].ToString().Trim(); resultBuilder.AppendFormat("", dr["CODENAME"].ToString().Trim(), js);//dr["SHORTNAME"].ToString().Trim()); } } } } } resultBuilder.AppendFormat("", "", ""); resultBuilder.Append(""); return resultBuilder.ToString().Replace("&", "&"); } public XmlDocument GetDoc() { XmlDocument xmldoc = new XmlDocument(); string content = BuildXML(); try { xmldoc.LoadXml(content); } catch (Exception) { } return xmldoc; } } }