📄 contentmanage.cs
字号:
return info;
}
public IList<CommonModelInfo> CreateAll(string nodeIdArray)
{
IList<CommonModelInfo> commonModelInfoList = new List<CommonModelInfo>();
Parameters parms = new Parameters();
string strSql = "SELECT M.* FROM PE_CommonModel M LEFT JOIN PE_ContentCharge C ON C.GeneralId IS NULL WHERE M.Status=99 ";
strSql = GetNodeBound(nodeIdArray, parms, strSql) + " ORDER BY M.GeneralId DESC";
GetCommonModelInfo(commonModelInfoList, parms, strSql);
return commonModelInfoList;
}
public IList<CommonModelInfo> CreateByNotCreate(string nodeIdArray)
{
IList<CommonModelInfo> commonModelInfoList = new List<CommonModelInfo>();
Parameters parms = new Parameters();
string strSql = "SELECT M.* FROM PE_CommonModel M LEFT JOIN PE_ContentCharge C ON C.GeneralId IS NULL \r\n WHERE M.Status=99 ";
strSql = GetNodeBound(nodeIdArray, parms, strSql) + " AND (M.CreateTime IS NULL OR M.CreateTime<= M.UpdateTime) ORDER BY M.GeneralId DESC";
GetCommonModelInfo(commonModelInfoList, parms, strSql);
return commonModelInfoList;
}
public bool Delete(string generalId)
{
string[] strArray = generalId.Split(new char[] { ',' });
Parameters cmdParams = new Parameters();
cmdParams.AddInParameter("@TableName", DbType.String, string.Empty);
cmdParams.AddInParameter("@ProductID", DbType.Int32, 0);
for (int i = 0; i < strArray.Length; i++)
{
CommonModelInfo commonModelInfoById = this.GetCommonModelInfoById(DataConverter.CLng(strArray[i]));
if (!commonModelInfoById.IsNull && (commonModelInfoById.LinkType == 0))
{
if (commonModelInfoById.IsEshop)
{
cmdParams.Entries[0].Value = commonModelInfoById.TableName;
cmdParams.Entries[1].Value = commonModelInfoById.GeneralId;
DBHelper.ExistsProc("PR_Shop_Product_DeleteAll", cmdParams);
}
this.DeleteVirtualContent(DataConverter.CLng(strArray[i]));
DBHelper.ExecuteSql(string.Concat(new object[] { "DELETE FROM ", commonModelInfoById.TableName, " WHERE ID=", commonModelInfoById.GeneralId }));
}
}
return DBHelper.ExecuteSql("DELETE FROM PE_CommonModel WHERE GeneralId IN(" + generalId + ")");
}
public void DeleteByNodeId(string nodeIds, int status)
{
string strSql = "DELETE FROM PE_CommonModel WHERE NodeId IN(" + nodeIds + ")";
if (status >= -3)
{
strSql = strSql + "Status=" + status.ToString();
}
DBHelper.ExecuteNonQuerySql(strSql);
}
private static bool DeleteSpecialContent(int generalId)
{
Parameters cmdParams = new Parameters();
cmdParams.AddInParameter("@GeneralId", DbType.Int32, generalId);
return DBHelper.ExecuteSql("DELETE FROM PE_SpecialInfos WHERE GeneralId=@GeneralId", cmdParams);
}
public bool DeleteVirtualContent(int generalId)
{
CommonModelInfo commonModelInfoById = this.GetCommonModelInfoById(generalId);
Parameters cmdParams = new Parameters();
cmdParams.AddInParameter("@ItemId", DbType.Int32, commonModelInfoById.GeneralId);
cmdParams.AddInParameter("@TableName", DbType.String, commonModelInfoById.TableName);
return DBHelper.ExecuteSql("DELETE FROM PE_CommonModel WHERE ItemId=@ItemId and TableName=@TableName and LinkType=1", cmdParams);
}
public bool ExistSameTitle(int nodeId, string title)
{
Parameters cmdParams = new Parameters();
cmdParams.AddInParameter("@NodeID", DbType.Int32, nodeId);
cmdParams.AddInParameter("@Title", DbType.String, title);
return DBHelper.ExistsSql("SELECT COUNT(*) FROM PE_CommonModel WHERE NodeID=@NodeID AND Title=@Title", cmdParams);
}
public IList<CommonModelInfo> GetCommentedCommonModelInfoListByNodeId(int startRowIndexId, int maxNumberRows, string nodeIds, int type)
{
Database database = DatabaseFactory.CreateDatabase();
List<CommonModelInfo> list = new List<CommonModelInfo>();
DbCommand storedProcCommand = database.GetStoredProcCommand("PR_Common_GetList");
StringBuilder builder = new StringBuilder(" CommentAudited + CommentUnAudited > 0 ");
switch (type)
{
case 1:
builder.Append(" AND CommentUnAudited >0");
break;
case 2:
builder.Append(" AND CommentUnAudited =0");
break;
}
if (!string.IsNullOrEmpty(nodeIds))
{
builder.Append(" AND NodeId IN (" + nodeIds.ToString() + ") ");
}
database.AddInParameter(storedProcCommand, "@StartRows", DbType.Int32, startRowIndexId);
database.AddInParameter(storedProcCommand, "@PageSize", DbType.Int32, maxNumberRows);
database.AddInParameter(storedProcCommand, "@SortColumn", DbType.String, "GeneralId");
database.AddInParameter(storedProcCommand, "@StrColumn", DbType.String, "*");
database.AddInParameter(storedProcCommand, "@Sorts", DbType.String, "DESC");
database.AddInParameter(storedProcCommand, "@TableName", DbType.String, "PE_CommonModel");
database.AddInParameter(storedProcCommand, "@Filter", DbType.String, builder.ToString());
database.AddOutParameter(storedProcCommand, "@Total", DbType.Int32, maxNumberRows);
using (NullableDataReader reader = new NullableDataReader(database.ExecuteReader(storedProcCommand)))
{
while (reader.Read())
{
CommonModelInfo item = CommonModelInfoFromDataReader(reader);
list.Add(item);
}
}
this.m_TotalOfCommonModelInfo = (int) database.GetParameterValue(storedProcCommand, "@Total");
return list;
}
public IList<CommonModelInfo> GetCommentedCommonModelInfoListByUserName(int startRowIndexId, int maxNumberRows, string nodeIds, int type, string userName)
{
Database database = DatabaseFactory.CreateDatabase();
List<CommonModelInfo> list = new List<CommonModelInfo>();
DbCommand storedProcCommand = database.GetStoredProcCommand("PR_Common_GetList");
StringBuilder builder = new StringBuilder(" CommentAudited + CommentUnAudited > 0 ");
switch (type)
{
case 1:
builder.Append(" AND CommentUnAudited >0");
break;
case 2:
builder.Append(" AND CommentUnAudited =0");
break;
}
if (!string.IsNullOrEmpty(nodeIds))
{
builder.Append(" AND NodeId IN (" + nodeIds.ToString() + ") ");
}
if (!string.IsNullOrEmpty(userName))
{
builder.Append(" AND ((SELECT COUNT(*) FROM PE_Comment Comment WHERE Comment.UserName='" + userName + "' AND Comment.GeneralId = CM.GeneralId)>0)");
}
database.AddInParameter(storedProcCommand, "@StartRows", DbType.Int32, startRowIndexId);
database.AddInParameter(storedProcCommand, "@PageSize", DbType.Int32, maxNumberRows);
database.AddInParameter(storedProcCommand, "@SortColumn", DbType.String, "GeneralId");
database.AddInParameter(storedProcCommand, "@StrColumn", DbType.String, "*");
database.AddInParameter(storedProcCommand, "@Sorts", DbType.String, "DESC");
database.AddInParameter(storedProcCommand, "@TableName", DbType.String, "PE_CommonModel CM");
database.AddInParameter(storedProcCommand, "@Filter", DbType.String, builder.ToString());
database.AddOutParameter(storedProcCommand, "@Total", DbType.Int32, maxNumberRows);
using (NullableDataReader reader = new NullableDataReader(database.ExecuteReader(storedProcCommand)))
{
while (reader.Read())
{
CommonModelInfo item = CommonModelInfoFromDataReader(reader);
list.Add(item);
}
}
this.m_TotalOfCommonModelInfo = (int) database.GetParameterValue(storedProcCommand, "@Total");
return list;
}
public IList<CommonModelInfo> GetCommonInfoListByGeneralId(string generalId)
{
string strSqlText = "SELECT * FROM PE_CommonModel WHERE GeneralId IN(" + generalId + ")";
IList<CommonModelInfo> commonModelInfoList = new List<CommonModelInfo>();
GetCommonModelInfo(commonModelInfoList, null, strSqlText);
return commonModelInfoList;
}
private static void GetCommonModelDataTable(string[] filedNames, string[] filedValues, FieldType[] fieldType, DataTable contentData)
{
int length = filedNames.Length;
for (int i = 0; i < length; i++)
{
DataRow[] rowArray = contentData.Select("FieldName='" + filedNames[i] + "'");
if (rowArray.Length == 0)
{
DataRow row = contentData.NewRow();
row["FieldName"] = filedNames[i];
row["FieldValue"] = filedValues[i];
row["FieldType"] = fieldType[i];
row["FieldLevel"] = 0;
contentData.Rows.Add(row);
}
else
{
rowArray[0][1] = filedValues[i];
}
}
}
public CommonModelInfo GetCommonModelInfo(int itemId, string tableName)
{
Parameters cmdParams = new Parameters();
cmdParams.AddInParameter("@ItemID", DbType.Int32, itemId);
cmdParams.AddInParameter("@TableName", DbType.String, tableName);
using (NullableDataReader reader = DBHelper.ExecuteReaderSql("select * from PE_CommonModel where ItemID = @ItemID and TableName = @TableName", cmdParams))
{
if (reader.Read())
{
return CommonModelInfoFromDataReader(reader);
}
return new CommonModelInfo(true);
}
}
private static void GetCommonModelInfo(IList<CommonModelInfo> commonModelInfoList, Parameters parms, string strSqlText)
{
using (NullableDataReader reader = DBHelper.ExecuteReader(CommandType.Text, strSqlText, parms))
{
while (reader.Read())
{
CommonModelInfo item = CommonModelInfoFromDataReader(reader);
commonModelInfoList.Add(item);
}
}
}
public CommonModelInfo GetCommonModelInfoById(int generalId)
{
Parameters cmdParams = new Parameters();
cmdParams.AddInParameter("@GeneralId", DbType.Int32, generalId);
using (NullableDataReader reader = DBHelper.ExecuteReaderSql("select C.IsEshop , M.* from PE_CommonModel M inner Join PE_Model C on C.ModelID=M.ModelID where M.generalID=@GeneralId", cmdParams))
{
if (reader.Read())
{
CommonModelInfo info = CommonModelInfoFromDataReader(reader);
info.IsEshop = reader.GetBoolean("IsEshop");
return info;
}
return new CommonModelInfo(true);
}
}
public IList<CommonModelInfo> GetCommonModelInfoList()
{
IList<CommonModelInfo> commonModelInfoList = new List<CommonModelInfo>();
Parameters parms = new Parameters();
string strSqlText = "SELECT * FROM PE_CommonModel ORDER BY GeneralId DESC";
GetCommonModelInfo(commonModelInfoList, parms, strSqlText);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -