📄 servicecenterconfig.cs
字号:
namespace PowerEasy.WebSite.Admin.Crm
{
using PowerEasy.Controls;
using PowerEasy.UserManage;
using PowerEasy.Web.UI;
using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml;
public class ServiceCenterConfig : AdminPage
{
protected Button BtnSave;
protected CheckBox ChkAll;
protected CheckBoxList ChkListGroup;
private XmlDocument m_doc;
private static string m_ProblemConfigFilePath;
protected ScriptManager ScriptManager1;
protected ExtendedSiteMapPath SmpNavigator;
protected TextBox TxtDBType;
protected TextBox TxtDifficulty;
protected TextBox TxtPhoneNum;
protected TextBox TxtProductVersion;
protected TextBox TxtQueryReplyText;
protected TextBox TxtSystemType;
protected System.Web.UI.UpdatePanel UpdatePanel1;
protected void BtnSave_Click(object sender, EventArgs e)
{
if (base.IsValid)
{
this.UpdateValue("ProductVersion", this.TxtProductVersion.Text);
this.UpdateValue("DBType", this.TxtDBType.Text);
this.UpdateValue("SystemType", this.TxtSystemType.Text);
this.UpdateValue("QuestionDifficulty", this.TxtDifficulty.Text);
this.UpdateValue("QueryReplyText", this.TxtQueryReplyText.Text);
this.UpdateValue("GroupAllowQuestion", this.GetGroupIdList());
this.doc.DocumentElement.SelectSingleNode("PhoneNum").InnerText = this.TxtPhoneNum.Text.Trim();
try
{
this.doc.Save(m_ProblemConfigFilePath);
AdminPage.WriteSuccessMsg("参数设置成功!", "ServiceCenterConfig.aspx");
}
catch (XmlException exception)
{
AdminPage.WriteErrMsg(exception.Message);
}
catch (UnauthorizedAccessException exception2)
{
AdminPage.WriteErrMsg(exception2.Message);
}
}
}
protected void ChkAll_CheckedChanged(object sender, EventArgs e)
{
foreach (ListItem item in this.ChkListGroup.Items)
{
item.Selected = this.ChkAll.Checked;
}
}
protected void ChkListGroup_SelectedIndexChanged(object sender, EventArgs e)
{
int num = 0;
foreach (ListItem item in this.ChkListGroup.Items)
{
if (item.Selected)
{
num++;
continue;
}
this.ChkAll.Checked = false;
return;
}
this.ChkAll.Checked = num == this.ChkListGroup.Items.Count;
}
private string GetGroupIdList()
{
StringBuilder builder = new StringBuilder();
foreach (ListItem item in this.ChkListGroup.Items)
{
if (item.Selected)
{
builder.Append(item.Value).Append(",");
}
}
return builder.ToString().TrimEnd(new char[] { ',' });
}
private string GetXmlNodeList(string nodeName)
{
XmlNode node = this.doc.DocumentElement.SelectSingleNode(nodeName);
StringBuilder builder = new StringBuilder(0x40);
if (node != null)
{
if (nodeName == "QuestionDifficulty")
{
foreach (XmlNode node2 in node.ChildNodes)
{
builder.Append(node2.Attributes["Text"].Value).Append("|").Append(node2.Attributes["Value"].Value).Append("\n");
}
}
else
{
foreach (XmlNode node3 in node.ChildNodes)
{
builder.Append(node3.Attributes["Text"].Value).Append("\n");
}
}
}
return builder.ToString().TrimEnd(new char[] { '\n' });
}
protected void Page_Load(object sender, EventArgs e)
{
m_ProblemConfigFilePath = base.Server.MapPath("~") + @"\Config\Question.Config";
if (!base.IsPostBack)
{
this.SmpNavigator.CurrentNode = "参数设置";
this.TxtProductVersion.Text = this.GetXmlNodeList("ProductVersion");
this.TxtDBType.Text = this.GetXmlNodeList("DBType");
this.TxtSystemType.Text = this.GetXmlNodeList("SystemType");
this.TxtDifficulty.Text = this.GetXmlNodeList("QuestionDifficulty");
this.TxtQueryReplyText.Text = this.GetXmlNodeList("QueryReplyText");
this.TxtPhoneNum.Text = this.doc.DocumentElement.SelectSingleNode("PhoneNum").InnerText;
IList<UserGroupsInfo> userGroupList = UserGroups.GetUserGroupList(0, 0);
this.ChkListGroup.DataSource = userGroupList;
this.ChkListGroup.DataBind();
string[] strArray = this.GetXmlNodeList("GroupAllowQuestion").Split(new char[] { ',' });
int num = 0;
foreach (string str in strArray)
{
ListItem item = this.ChkListGroup.Items.FindByValue(str);
if (item != null)
{
item.Selected = true;
num++;
}
}
this.ChkAll.Checked = num == this.ChkListGroup.Items.Count;
}
}
private void UpdateValue(string nodeName, string valueList)
{
string[] strArray = valueList.Trim().Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
XmlNode newChild = this.doc.DocumentElement.SelectSingleNode(nodeName);
if (newChild == null)
{
newChild = this.doc.CreateElement(nodeName);
this.doc["Config"].AppendChild(newChild);
}
newChild.RemoveAll();
if (nodeName == "QuestionDifficulty")
{
foreach (string str in strArray)
{
string[] strArray2 = str.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
XmlElement element = this.doc.CreateElement("Item");
XmlAttribute node = this.doc.CreateAttribute("Text");
XmlAttribute attribute2 = this.doc.CreateAttribute("Value");
node.Value = strArray2[0];
attribute2.Value = (strArray2.Length >= 2) ? strArray2[1].Trim() : "0";
element.Attributes.Append(node);
element.Attributes.Append(attribute2);
newChild.AppendChild(element);
}
}
else
{
foreach (string str2 in strArray)
{
XmlElement element2 = this.doc.CreateElement("Item");
XmlAttribute attribute3 = this.doc.CreateAttribute("Text");
attribute3.Value = str2.Trim();
element2.Attributes.Append(attribute3);
newChild.AppendChild(element2);
}
}
}
private XmlDocument doc
{
get
{
if (this.m_doc == null)
{
this.m_doc = new XmlDocument();
this.m_doc.Load(m_ProblemConfigFilePath);
}
return this.m_doc;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -