📄 question.cs
字号:
namespace PowerEasy.SqlServerDal.Crm
{
using Microsoft.Practices.EnterpriseLibrary.Data;
using PowerEasy.Common;
using PowerEasy.Components;
using PowerEasy.IDal.Crm;
using PowerEasy.Model.Crm;
using PowerEasy.SqlServerDal;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Text;
public class Question : IQuestion
{
private int m_StatisticCount;
private int m_TotalCount;
private int m_TotalScore;
private const string SEARCH_TABLENAME = "PE_Question q inner join PE_QuestionType t on q.TypeID=t.TypeID";
public bool Add(QuestionInfo info)
{
return DBHelper.ExecuteSql("INSERT INTO PE_Question(ID,ProductVersion,ProductDBType,SystemType,TypeId,QuestionTitle,QuestionContent,QuestionCreateTime,QuestionCreator,IsPublic,IP,ReplyCreator,ReplyTime,IsReply,AntiVirus,FireWall,ErrorCode,ErrorText,IsSolved,Url,Score) VALUES(@ID,@ProductVersion,@ProductDBType,@SystemType,@TypeId,@QuestionTitle,@QuestionContent,@QuestionCreateTime,@QuestionCreator,@IsPublic,@IP,@ReplyCreator,@ReplyTime,@IsReply,@AntiVirus,@FireWall,@ErrorCode,@ErrorText,@IsSolved,@Url,@Score) ", GetParameters(info));
}
public bool BatchSetSolved(string questionIdList)
{
return DBHelper.ExecuteSql("Update PE_Question Set IsSolved=1 Where ID IN (" + questionIdList + ") ");
}
public bool BatchSetTypeId(string questionIdList, int typeId)
{
return DBHelper.ExecuteSql("Update PE_Question Set TypeId=" + typeId.ToString() + " Where ID IN(" + questionIdList + ")");
}
public bool Delete(int questionId)
{
return DBHelper.ExecuteSql("Delete PE_Question Where ID=@ID", new Parameters("@ID", DbType.Int32, questionId));
}
public bool Delete(string questionIdList)
{
return DBHelper.ExecuteSql("Delete PE_Question Where ID IN (" + questionIdList + ")");
}
private static string GetFilterByComplexSearch(string keyword)
{
string[] strArray = keyword.Split(new char[] { '|' });
if (strArray.Length == 0)
{
return string.Empty;
}
string complexSearchItem = strArray[0];
string str2 = strArray[1];
string str3 = strArray[2];
string str4 = strArray[3];
string str5 = strArray[4];
string str6 = strArray[5];
string str7 = strArray[6];
string str8 = strArray[7];
string str9 = strArray[8];
string str10 = strArray[9];
string str11 = strArray[10];
string str12 = strArray[11];
string str13 = strArray[12];
string str14 = PEContext.Current.Admin.AdministratorInfo.AdminId.ToString();
StringBuilder builder = new StringBuilder(0x80);
builder.Append(HasValue(str2) ? (" and q.Score=" + str2) : string.Empty);
builder.Append(HasValue(str3) ? (" and q.IsReply=" + ((str3 == "1") ? str3 : "0")) : string.Empty);
builder.Append(HasValue(str4) ? (" and q.IsSolved=" + ((str4 == "1") ? str4 : "0")) : string.Empty);
builder.Append(HasValue(str5) ? (" and q.IsPublic = " + ((str5 == "1") ? str5 : "0")) : string.Empty);
builder.Append(HasValue(str12) ? (" and q.QuestionCreator ='" + str12 + "'") : string.Empty);
if (HasValue(str8) || HasValue(str9))
{
if (HasValue(str9) && HasValue(str8))
{
builder.Append(" and ( q.QuestionCreateTime between '" + str8 + "' and '" + str9 + "')");
}
else if (HasValue(str8) && !HasValue(str9))
{
builder.Append(" and ( q.QuestionCreateTime between '" + str8 + "' and getdate())");
}
else
{
builder.Append(" and datediff(dd,q.QuestionCreateTime,'" + str9 + "') >=0");
}
}
if (HasValue(str7))
{
builder.Append(" and q.QuestionTitle like '%" + str7 + "%'");
}
if (HasValue(str6) || HasValue(complexSearchItem))
{
string str15 = string.Empty;
if (HasValue(str6))
{
str15 = (str6 == "1") ? "=" : "<>";
}
if (HasValue(str6) && HasValue(complexSearchItem))
{
builder.Append(" and ( q.TypeId in (" + complexSearchItem + ") OR q.TypeId in (select TypeId from PE_QuestionType_Admin where AdminID" + str15 + str14 + "))");
}
else if (HasValue(str6))
{
builder.Append(" and q.TypeID in (select TypeID from PE_QuestionType where AdminID" + str15 + str14 + ")");
}
else
{
builder.Append(" and q.TypeId in (" + complexSearchItem + ")");
}
}
if (HasValue(str13))
{
builder.Append(" and q.ID in(select questionID from PE_Reply where replyCreator = '" + str13 + "'");
if (HasValue(str10) || HasValue(str11))
{
if (HasValue(str10) && HasValue(str11))
{
builder.Append(" and (replyTime Between '" + str10 + "' and '" + str11 + "')");
}
else if (HasValue(str10) && !HasValue(str11))
{
builder.Append(" and (replyTime Between '" + str10 + "' and getdate())");
}
else
{
builder.Append(" and datediff(dd,replyTime,'" + str11 + "')>=0");
}
}
builder.Append(")");
}
else if (HasValue(str10) || HasValue(str11))
{
builder.Append(" and q.ID in (select questionID from PE_Reply where ");
if (HasValue(str10) && HasValue(str11))
{
builder.Append("replytime Between '" + str10 + "' and '" + str11 + "'");
}
else if (HasValue(str10) && !HasValue(str11))
{
builder.Append("replyTime Between '" + str10 + "' and getdate()");
}
else
{
builder.Append("datediff(dd,replyTime,'" + str11 + "')>=0");
}
builder.Append(")");
}
return builder.ToString();
}
private static QuestionInfo GetInfoByReader(NullableDataReader rdr, bool getAll)
{
QuestionInfo info = new QuestionInfo();
info.Id = rdr.GetInt32("ID");
info.TypeId = rdr.GetInt32("TypeID");
info.TypeName = rdr.GetString("TypeName");
info.QuestionTitle = rdr.GetString("QuestionTitle");
info.QuestionCreateTime = rdr.GetDateTime("QuestionCreateTime");
info.QuestionCreator = rdr.GetString("QuestionCreator");
info.ReplyCreator = rdr.GetString("ReplyCreator");
info.ReplyTime = rdr.GetNullableDateTime("ReplyTime");
info.Score = rdr.GetInt32("Score");
info.IsPublic = rdr.GetBoolean("IsPublic");
info.IsReply = rdr.GetBoolean("IsReply");
info.IsSolved = rdr.GetBoolean("IsSolved");
if (getAll)
{
info.AntiVirus = rdr.GetString("AntiVirus");
info.ErrorCode = rdr.GetString("ErrorCode");
info.ErrorText = rdr.GetString("ErrorText");
info.FireWall = rdr.GetString("FireWall");
info.IP = rdr.GetString("IP");
info.ProductDBType = rdr.GetString("ProductDBType");
info.ProductVersion = rdr.GetString("ProductVersion");
info.QuestionContent = rdr.GetString("QuestionContent");
info.SystemType = rdr.GetString("SystemType");
info.Url = rdr.GetString("Url");
}
return info;
}
public int GetMaxId()
{
return DBHelper.GetMaxId("PE_Question", "ID");
}
private static Parameters GetParameters(QuestionInfo info)
{
Parameters parameters = new Parameters();
parameters.AddInParameter("@ID", DbType.Int32, info.Id);
parameters.AddInParameter("@ProductVersion", DbType.String, info.ProductVersion);
parameters.AddInParameter("@ProductDBType", DbType.String, info.ProductDBType);
parameters.AddInParameter("@SystemType", DbType.String, info.SystemType);
parameters.AddInParameter("@TypeId", DbType.Int32, info.TypeId);
parameters.AddInParameter("@TypeName", DbType.String, info.TypeName);
parameters.AddInParameter("@QuestionTitle", DbType.String, info.QuestionTitle);
parameters.AddInParameter("@QuestionContent", DbType.String, info.QuestionContent);
parameters.AddInParameter("@QuestionCreateTime", DbType.DateTime, info.QuestionCreateTime);
parameters.AddInParameter("@QuestionCreator", DbType.String, info.QuestionCreator);
parameters.AddInParameter("@AntiVirus", DbType.String, info.AntiVirus);
parameters.AddInParameter("@FireWall", DbType.String, info.FireWall);
parameters.AddInParameter("@ErrorCode", DbType.String, info.ErrorCode);
parameters.AddInParameter("@ErrorText", DbType.String, info.ErrorText);
parameters.AddInParameter("@IP", DbType.String, info.IP);
parameters.AddInParameter("@ReplyCreator", DbType.String, info.ReplyCreator);
parameters.AddInParameter("@ReplyTime", DbType.DateTime, info.ReplyTime);
parameters.AddInParameter("@Url", DbType.String, info.Url);
parameters.AddInParameter("@Score", DbType.Int32, info.Score);
parameters.AddInParameter("@IsSolved", DbType.Boolean, info.IsSolved);
parameters.AddInParameter("@IsPublic", DbType.Boolean, info.IsPublic);
parameters.AddInParameter("@IsReply", DbType.Boolean, info.IsReply);
return parameters;
}
public IList<QuestionInfo> GetQuestion(int startRowIndex, int maximumRows, int searchType, string keyword)
{
StringBuilder builder = new StringBuilder(" 1=1 ");
string sortCloumn = "q.QuestionCreateTime";
switch (searchType)
{
case 1:
builder.Append(" and q.IsSolved=1 ");
break;
case 2:
builder.Append(" and q.IsSolved=0 ");
break;
case 3:
builder.Append(" and q.IsSolved=1 and q.ReplyCreator='").Append(PEContext.Current.Admin.AdminName).Append("' ");
break;
case 4:
builder.Append(" and q.IsSolved=0 and q.TypeId IN(Select TypeId from PE_QuestionType_Admin where AdminID=").Append(PEContext.Current.Admin.AdministratorInfo.AdminId).Append(") ");
break;
case 5:
builder.Append(" and q.IsReply=0 and q.IsSolved=0 ");
break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -