📄 question.cs
字号:
namespace PowerEasy.WebSite.User.Crm
{
using PowerEasy.Analytics;
using PowerEasy.Common;
using PowerEasy.Components;
using PowerEasy.Controls;
using PowerEasy.Controls.Editor;
using PowerEasy.Crm;
using PowerEasy.Model.Crm;
using PowerEasy.Web.UI;
using PowerEasy.WebSite.Controls;
using System;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Xml;
public class Question : DynamicPage
{
protected Button BtnCancel;
protected Button ButSubmit;
protected CheckBox ChkIsPublic;
protected DropDownList DropDBType;
protected DropDownList DropProductVersion;
protected DropDownList DropQuestionDiff;
protected DropDownList DropQuestionType;
protected DropDownList DropSystemType;
protected FckEditorValidator FckEditorValidator1;
protected HtmlForm form1;
protected PowerEasy.Controls.RequiredFieldValidator RequiredFieldValidator1;
protected PowerEasy.Controls.RequiredFieldValidator RequiredFieldValidator2;
protected ServiceCenterInfomation ServiceCenterInfomation1;
protected TextBox TxtAntiVirus;
protected TextBox TxtErrorCode;
protected TextBox TxtErrorText;
protected TextBox TxtFireWall;
protected PEeditor TxtQuestionContent;
protected TextBox TxtQuestionTitle;
protected TextBox TxtUrl;
protected UserNavigation UserCenterNavigation;
protected RegularExpressionValidator ValeUrl;
protected PowerEasy.Controls.RequiredFieldValidator ValrDb;
protected PowerEasy.Controls.RequiredFieldValidator ValrProductVersion;
protected PowerEasy.Controls.RequiredFieldValidator ValrQuestionDiff;
protected PowerEasy.Controls.RequiredFieldValidator ValrQuestionType;
protected PowerEasy.Controls.RequiredFieldValidator ValrUrl;
protected ExtendedSiteMapPath YourPosition;
private void AddListItem(DropDownList lc, string xPath, XmlDocument doc, bool twins)
{
lc.Items.Add(new ListItem("选请择...", "0"));
XmlNodeList list = doc.SelectNodes(xPath);
if (twins)
{
foreach (XmlNode node in list)
{
lc.Items.Add(new ListItem(node.Attributes["Text"].Value, node.Attributes["Value"].Value.Trim()));
}
}
else
{
foreach (XmlNode node2 in list)
{
lc.Items.Add(new ListItem(node2.Attributes["Text"].Value.Trim()));
}
}
}
protected void BtnCancel_Click(object sender, EventArgs e)
{
BasePage.ResponseRedirect("MyQuestions.aspx");
}
protected void ButSubmit_Click(object sender, EventArgs e)
{
if (base.IsValid)
{
bool flag = string.Compare(BasePage.RequestString("Action"), "Modify", true) == 0;
QuestionInfo info = new QuestionInfo();
if (flag)
{
info.Id = BasePage.RequestInt32("ID");
}
else
{
info.Id = PowerEasy.Crm.Question.GetMaxId() + 1;
info.IsReply = info.IsSolved = false;
}
info.AntiVirus = this.TxtAntiVirus.Text.Trim();
info.ErrorCode = this.TxtErrorCode.Text.Trim();
info.ErrorText = this.TxtErrorText.Text.Trim();
info.FireWall = this.TxtFireWall.Text.Trim();
info.IP = Counter.GetIP(base.Request);
info.IsPublic = !this.ChkIsPublic.Checked;
info.ProductDBType = this.DropDBType.SelectedValue;
info.ProductVersion = this.DropProductVersion.SelectedValue;
info.QuestionContent = this.TxtQuestionContent.Value;
info.QuestionCreateTime = DateTime.Now;
info.QuestionCreator = PEContext.Current.User.UserName;
info.QuestionTitle = this.TxtQuestionTitle.Text.Trim();
info.Score = DataConverter.CLng(this.DropQuestionDiff.SelectedValue);
info.SystemType = this.DropSystemType.SelectedValue;
info.TypeId = DataConverter.CLng(this.DropQuestionType.SelectedValue);
info.Url = this.TxtUrl.Text.Trim();
if (flag)
{
if (PowerEasy.Crm.Question.Update(info))
{
DynamicPage.WriteSuccessMsg("问题修改成功,对于您的提问我们会尽快给予回复!", "ReplyQuestion.aspx?ID=" + BasePage.RequestString("ID"));
}
else
{
DynamicPage.WriteErrMsg("问题修改失败!");
}
}
else if (PowerEasy.Crm.Question.Add(info))
{
DynamicPage.WriteSuccessMsg("问题提交成功,对于您的提问我们会尽快给予回复!", "MyQuestions.aspx");
}
else
{
DynamicPage.WriteErrMsg("问题提交失败!");
}
}
}
protected void DropDownList_DataBound(object sender, EventArgs e)
{
DropDownList list = (DropDownList) sender;
list.Items.Insert(0, new ListItem("请选择...", "0"));
}
private void DropDownListDataBind()
{
XmlDocument doc = new XmlDocument();
doc.Load(base.Server.MapPath("~/Config/Question.Config"));
XmlNode node = doc.SelectSingleNode("Config/GroupAllowQuestion");
bool flag = false;
if ((node != null) && node.HasChildNodes)
{
string[] strArray = node["Item"].Attributes["Text"].Value.Split(new char[] { ',' });
int groupId = PEContext.Current.User.UserInfo.GroupId;
foreach (string str in strArray)
{
if (groupId == DataConverter.CLng(str))
{
flag = true;
break;
}
}
}
if (!flag)
{
DynamicPage.WriteErrMsg("对不起,用户的所属用户组没有提问权限!", "../Default.aspx");
}
this.AddListItem(this.DropProductVersion, "Config/ProductVersion/Item", doc, false);
this.AddListItem(this.DropDBType, "Config/DBType/Item", doc, false);
this.AddListItem(this.DropSystemType, "Config/SystemType/Item", doc, false);
this.AddListItem(this.DropQuestionDiff, "Config/QuestionDifficulty/Item", doc, true);
this.DropQuestionType.DataSource = QuestionType.GetTypeList();
this.DropQuestionType.DataBind();
}
protected void Page_Load(object sender, EventArgs e)
{
if (!base.IsPostBack)
{
this.DropDownListDataBind();
int id = BasePage.RequestInt32("ID");
if (id > 0)
{
QuestionInfo questionById = PowerEasy.Crm.Question.GetQuestionById(id);
if (questionById.IsNull)
{
DynamicPage.WriteErrMsg("请选择要修改的问题!", "MyQuestions.aspx");
}
else
{
if (string.Compare(questionById.QuestionCreator, PEContext.Current.User.UserName, true) != 0)
{
DynamicPage.WriteErrMsg("这个不是您提出的问题,不能修改!", "../Default.aspx");
}
if (!this.ValidEditProblemUserPoint(questionById.Score))
{
DynamicPage.WriteErrMsg("对不起,您的动易币不足,不能提问,请尽快充值!", "../Default.aspx");
}
BasePage.SetSelectedIndexByValue(this.DropQuestionDiff, questionById.Score.ToString());
BasePage.SetSelectedIndexByValue(this.DropDBType, questionById.ProductDBType);
BasePage.SetSelectedIndexByValue(this.DropProductVersion, questionById.ProductVersion);
BasePage.SetSelectedIndexByValue(this.DropSystemType, questionById.SystemType);
BasePage.SetSelectedIndexByValue(this.DropQuestionType, questionById.TypeId.ToString());
this.TxtAntiVirus.Text = questionById.AntiVirus;
this.TxtErrorCode.Text = questionById.ErrorCode;
this.TxtErrorText.Text = questionById.ErrorText;
this.TxtFireWall.Text = questionById.FireWall;
this.ChkIsPublic.Checked = !questionById.IsPublic;
this.TxtQuestionContent.Value = questionById.QuestionContent;
this.TxtQuestionTitle.Text = questionById.QuestionTitle;
this.TxtUrl.Text = questionById.Url;
}
}
else if (!this.ValidNewProblemUserPoint())
{
DynamicPage.WriteErrMsg("对不起,您的动易币不足,不能提问,请尽快充值!", "Knowledge.aspx");
}
}
}
private bool ValidEditProblemUserPoint(int currentProbolemPoint)
{
int num = PowerEasy.Crm.Question.GetUserPointByUserName(PEContext.Current.User.UserName) + currentProbolemPoint;
int num2 = 1;
foreach (ListItem item in this.DropQuestionDiff.Items)
{
if (DataConverter.CLng(item.Value) > num)
{
item.Enabled = false;
num2++;
}
}
return (num2 != this.DropQuestionDiff.Items.Count);
}
private bool ValidNewProblemUserPoint()
{
return this.ValidEditProblemUserPoint(0);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -