📄 ultipublish.cs
字号:
{
string msg = string.Format(MsgFormat, "新闻", nNewsCount.ToString(), ((int)num).ToString(), succeedNum.ToString(), failedNum.ToString(), "发布新闻成功。 <a class=\"list_link\" href=\"javascript:history.back();\">返 回</a> <a class=\"list_link\" href=\"../../index.html\" target=\"_blank\">浏览首页</a>");
if (nNewsCount > 0)
{
HProgressBar.Roll(msg, (num * 100 / nNewsCount));
}
else
{
HProgressBar.Roll("没有新闻", 0);
}
}
}
if (templateList.Count != 0)
{
templateList.Clear();
}
if (failedList.Count != 0)
{
for (int i = 0; i < failedList.Count; i++)
{
NetCMS.Common.Public.savePublicLogFiles("□□□发布新闻", "【ID】:" + failedList[i].Split('$')[0] + "\r\n【错误描述:】\r\n" + failedList[i].Split('$')[1], "");
}
failedList.Clear();
}
if (succeedList.Count != 0)
{
updateNewsIsHtml(DBConfig.TableNamePrefix + "news", "isHtml", "newsID");
}
}
/// <summary>
/// 为saveNewsPath赋值
/// </summary>
/// <param name="classID">新闻所属栏目的ID</param>
/// <param name="SavePath">新闻表中SavePath字段的值</param>
/// <param name="FileName">新闻表中FileName字段的值</param>
/// <param name="FileName">新闻表中FileName字段的值</param>
private void setSaveNewsPath(string classID, string SavePath, string FileName, string FileEXName)
{
PubClassInfo info = CommonData.GetClassById(classID);
if (info != null)
{
saveNewsPath = "\\" + info.SavePath.Trim('\\').Trim('/') + "\\" + info.SaveClassframe.Trim('\\').Trim('/') + "\\" + SavePath.Trim('\\').Trim('/') + "\\" + FileName.Trim('\\').Trim('/') + FileEXName.Trim('\\').Trim('/');
}
}
/// <summary>
/// 设置已发布新闻、栏目的IsHtml
/// </summary>
private void updateNewsIsHtml(string tableName, string isHtml, string idField)
{
try
{
CommonData.DalPublish.UpdateNewsIsHtml(tableName, isHtml, idField, succeedList);
}
catch
{
//写日志
}
finally
{
succeedList.Clear();
}
}
/// <summary>
/// 生成所有栏目
/// </summary>
public void ultiPublishClass()
{
using (IDataReader rd = getAllClass())
{
int num = 0;
int succeedNum = 0;
int failedNum = 0;
bool HasRows = false;
if (nClassCount > 0)
{
while (rd.Read())
{
HasRows = true;
TempletPath = rd["classtemplet"].ToString();
TempletPath = TempletPath.Replace("/", "\\");
TempletPath = TempletPath.ToLower().Replace("{@dirtemplet}", strTempletDir);
string TmpsaveClassPath = "\\" + rd["savePath"].ToString().Trim('\\').Trim('/') + "\\" + rd["SaveClassframe"].ToString().Trim('\\').Trim('/') + '\\' + rd["ClassSaveRule"].ToString().Trim('\\').Trim('/');
saveClassPath = TmpsaveClassPath.Replace("/", "\\");
string strClassId = rd["classid"].ToString();
bool state = publishSingleClass(strClassId, rd["Datalib"].ToString());
if (_isClassIndex)
{
General.publishClassIndex(strClassId);
}
num += 1;
if (state)
{
succeedNum++;
}
else
{
failedNum++;
}
string msg = string.Format(MsgFormat, "栏目", nClassCount.ToString(), ((int)num).ToString(), succeedNum.ToString(), failedNum.ToString(), "发布栏目成功 <a class=\"list_link\" href=\"javascript:history.back();\">返 回</a> <a class=\"list_link\" href=\"../../index.html\" target=\"_blank\">浏览首页</a>");
HProgressBar.Roll(msg, (num * 100 / nClassCount));
}
}
else
{
HProgressBar.Roll("没有栏目", 0);
}
if (!HasRows)
{
string msg = string.Format(MsgFormat, "栏目", nClassCount.ToString(), ((int)num).ToString(), succeedNum.ToString(), failedNum.ToString(), "发布栏目成功 <a class=\"list_link\" href=\"javascript:history.back();\">返 回</a> <a class=\"list_link\" href=\"../../index.html\" target=\"_blank\">浏览首页</a>");
if (nClassCount > 0)
{
HProgressBar.Roll(msg, (num * 100 / nClassCount));
}
else
{
HProgressBar.Roll("没有栏目", 0);
}
}
}
if (templateList.Count != 0)
{
templateList.Clear();
}
if (failedList.Count != 0)
{
for (int i = 0; i < failedList.Count; i++)
{
NetCMS.Common.Public.savePublicLogFiles("□□□发布栏目", "【ID】:" + failedList[i].Split('$')[0] + "\r\n【错误描述:】\r\n" + failedList[i].Split('$')[1], "");
}
failedList.Clear();
}
if (succeedList.Count != 0)
{
updateNewsIsHtml(DBConfig.TableNamePrefix + "news_class", "isunHtml", "cLassID");
}
}
/// <summary>
/// 生成所有专题
/// </summary>
public void ultiPublishSpecial()
{
float num = 0;
int succeedNum = 0;
int failedNum = 0;
bool HasRows = false;
IDataReader rd = getAllSpecials();
{
if (nSpecialCount > 0)
{
while (rd.Read())
{
HasRows = true;
TempletPath = rd["Templet"].ToString();
TempletPath = TempletPath.Replace("/", "\\");
TempletPath = TempletPath.ToLower().Replace("{@dirtemplet}", strTempletDir);
string TmpsaveSpecialPath = "\\" + rd["SavePath"].ToString().Trim('\\').Trim('/') + "\\" + rd["saveDirPath"].ToString().Trim('\\').Trim('/') + '\\' + rd["FileName"].ToString().Trim('\\').Trim('/') + rd["FileEXName"].ToString().Trim('\\').Trim('/');
saveSpecialPath = TmpsaveSpecialPath.Replace("{@dirHtml}", NetCMS.Config.UIConfig.dirHtml).Replace("/", "\\"); ;
bool state = publishSingleSpecial(rd["specialID"].ToString());
if (state)
{
num += 1;
succeedNum++;
}
else
{
failedNum++;
}
string msg = string.Format(MsgFormat, "专题", nSpecialCount.ToString(), ((int)num).ToString(), succeedNum.ToString(), failedNum.ToString(), "发布栏目成功。 <a class=\"list_link\" href=\"javascript:history.back();\">返 回</a> <a class=\"list_link\" href=\"../../index.html\" target=\"_blank\">浏览首页</a>");
HProgressBar.Roll(msg, (int)(num / nSpecialCount) * 100);
}
}
else
{
HProgressBar.Roll("没有专题", 0);
}
rd.Close();
if (!HasRows)
{
string msg = string.Format(MsgFormat, "专题", nSpecialCount.ToString(), ((int)num).ToString(), succeedNum.ToString(), failedNum.ToString(), "发布栏目成功。 <a class=\"list_link\" href=\"javascript:history.back();\">返 回</a> <a class=\"list_link\" href=\"../../index.html\" target=\"_blank\">浏览首页</a>");
HProgressBar.Roll(msg, (int)(num / nSpecialCount) * 100);
}
}
if (templateList.Count != 0)
{
templateList.Clear();
}
if (failedList.Count != 0)
{
for (int i = 0; i < failedList.Count; i++)
{
NetCMS.Common.Public.savePublicLogFiles("□□□发布专题", "【ID】:" + failedList[i].Split('$')[0] + "\r\n【错误描述:】\r\n" + failedList[i].Split('$')[1], "");
}
failedList.Clear();
}
}
/// <summary>
/// 发布一条新闻
/// </summary>
/// <param name="newsID">单条新闻的ID</param>
/// <param name="datalib">该条新闻所在的表</param>
/// <returns>成功与否标志</returns>
public bool publishSingleNews(string newsID, string datalib, string classID)
{
try
{
TempletPath = SiteRootPath.Trim('\\') + TempletPath;
bool existFlag = false;
if (templateList.Count != 0)
{
foreach (Template temp in templateList)
{
if (TempletPath == temp.TempFilePath)
{
existFlag = true;
temp.NewsID = newsID;
makeHtmlFile(temp, existFlag, classID, newsID);
break;
}
}
if (!existFlag)
{
Template newsTemplate = new Template(TempletPath, TempType.News);
newsTemplate.NewsID = newsID;
newsTemplate.GetHTML();
makeHtmlFile(newsTemplate, existFlag, classID, newsID);
}
}
else
{
Template newsTemplate = new Template(TempletPath, TempType.News);
newsTemplate.NewsID = newsID;
newsTemplate.GetHTML();
makeHtmlFile(newsTemplate, existFlag, classID, newsID);
}
succeedList.Add(newsID);
return true;
}
catch (Exception e)
{
failedList.Add(newsID + "$" + e.Message);
NetCMS.Common.Public.savePublicLogFiles("□□□发布新闻", "【ID】:" + classID + "\r\n【错误描述:】\r\n" + e.ToString(), "");
return false;
}
}
/// <summary>
/// 发布一个栏目
/// </summary>
/// <param name="classID">单个栏目的ID</param>
/// <param name="datalib">该栏目所在的表</param>
/// <returns>成功与否标志</returns>
public bool publishSingleClass(string classID, string datalib)
{
try
{
TempletPath = SiteRootPath.Trim('\\') + TempletPath;
bool existFlag = false;
if (templateList.Count != 0)
{
foreach (Template temp in templateList)
{
if (TempletPath == temp.TempFilePath)
{
existFlag = true;
temp.ClassID = classID;
replaceTemp(temp, existFlag, saveClassPath, classID, "class");
break;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -