📄 general.cs
字号:
newsTemplate.CHNewsID = newsID;
newsTemplate.CHClassID = classID;
newsTemplate.ChID = ChID;
newsTemplate.GetHTML();
newsTemplate.ReplaceLabels();
newsTemplate.ReplaceIMLabels();
string FinlContent = newsTemplate.FinallyContent;
if (newsTemplate.MyTempType == TempType.ChNews)
{
int pos1 = FinlContent.IndexOf("<!-NT:STAR=");
int pos2 = FinlContent.IndexOf("NT:END->");
if (pos1 > -1)
{
int getFiledot = saveNewsPath.LastIndexOf(".");
int getFileg = saveNewsPath.LastIndexOf("\\");
string getFileName = saveNewsPath.Substring((getFileg + 1), ((getFiledot - getFileg) - 1));
string getFileEXName = saveNewsPath.Substring(getFiledot);
string PageHead = FinlContent.Substring(0, pos1);
string PageEnd = FinlContent.Substring(pos2 + 8);
string PageMid = FinlContent.Substring(pos1 + 11, pos2 - pos1 - 11);
string[] ArrayCon = PageMid.Split(new string[] { "[NT:PAGE]" }, StringSplitOptions.RemoveEmptyEntries);
int n = ArrayCon.Length;
if (n > 0)
{
for (int i = 0; i < n; i++)
{
string filepath = SiteRootPath + saveNewsPath;
if (i > 0)
{
int laspot = filepath.LastIndexOf('.');
filepath = filepath.Substring(0, laspot) + "_" + (i + 1) + filepath.Substring(laspot);
}
string PageContent = PageHead + ArrayCon[i] + PageEnd;
string getFileContent = ReplaceResultPage(rd["id"].ToString(), PageContent.Replace("[NT:PAGE]", "").Replace("NT:END->", "").Replace("<!-NT:STAR=", ""), getFileName, getFileEXName, n, (i + 1), 0);
WriteHtml(getFileContent, filepath);
}
}
else
{
WriteHtml(FinlContent.Replace("NT:END->", "").Replace("<!-NT:STAR=", ""), SiteRootPath + saveNewsPath);
}
}
else
{
WriteHtml(FinlContent.Replace("NT:END->", "").Replace("<!-NT:STAR=", ""), SiteRootPath + saveNewsPath);
}
}
state = true;
}
else
{
state = false;
}
}
rd.Close();
}
catch (Exception e)
{
NetCMS.Common.Public.savePublicLogFiles("□□□ 生成新闻(频道ID" + ChID + ")", "【ID】:" + newsID.ToString() + "\r\n【错误描述:】\r\n" + e.ToString(), "");
state = false;
}
return state;
}
/// <summary>
/// 发布单个栏目
/// </summary>
/// <param name="classID">个栏目的ID</param>
/// <returns>成功与否标志</returns>
public bool publishSingleClass(string classID)
{
bool state = false;
try
{
CommonData.Initialize();
string saveClassPath = string.Empty;
string TempletPath = string.Empty;
string SiteRootPath = NetCMS.Common.ServerInfo.GetRootPath();
string strTempletDir = strgTemplet;
PubClassInfo info = CommonData.GetClassById(classID);
if (info != null)
{
if (info.isDelPoint == 0)
{
TempletPath = info.ClassTemplet;
TempletPath = TempletPath.Replace("/", "\\");
TempletPath = TempletPath.ToLower().Replace("{@dirtemplet}", strTempletDir);
TempletPath = SiteRootPath.Trim('\\') + TempletPath;
string TMPSavePath = info.SavePath.Trim();
if (TMPSavePath.Substring(0, 1) != "/")
{
TMPSavePath = "\\" + TMPSavePath;
}
saveClassPath = (TMPSavePath + "\\" + info.SaveClassframe + '\\' + info.ClassSaveRule.Trim()).Replace("/", @"\\");
Template classTemplate = new Template(TempletPath, TempType.Class);
classTemplate.ClassID = classID;
classTemplate.GetHTML();
string TmpPath = SiteRootPath + saveClassPath;
replaceTempg(classTemplate, TmpPath, classID, "class");
state = true;
}
}
}
catch (Exception e)
{
NetCMS.Common.Public.savePublicLogFiles("□□□ 生成栏目", "【classID】:" + classID + "\r\n【错误描述:】\r\n" + e.ToString(), "");
}
return state;
}
/// <summary>
/// 发布单个栏目(频道)
/// </summary>
public bool publishCHSingleClass(int classID, int ChID)
{
bool state = false;
try
{
CommonData.Initialize();
string saveClassPath = string.Empty;
string TempletPath = string.Empty;
string SiteRootPath = NetCMS.Common.ServerInfo.GetRootPath();
string strTempletDir = strgTemplet;
PubCHClassInfo info = CommonData.GetCHClassById(classID);
if (info != null)
{
if (info.isDelPoint == 0)
{
TempletPath = info.Templet;
TempletPath = TempletPath.Replace("/", "\\");
TempletPath = TempletPath.ToLower().Replace("{@dirtemplet}", strTempletDir);
TempletPath = SiteRootPath.Trim('\\') + TempletPath;
string TMPSavePath = info.SavePath.Trim();
string dirHTML = NetCMS.Common.Public.readCHparamConfig("htmldir", ChID);
dirHTML = dirHTML.Replace("{@dirHTML}", NetCMS.Config.UIConfig.dirHtml);
TMPSavePath = dirHTML + "/" + TMPSavePath;
TMPSavePath = TMPSavePath.Replace("//", "/");
if (TMPSavePath.Substring(0, 1) != "/")
{
TMPSavePath = "\\" + TMPSavePath;
}
saveClassPath = (TMPSavePath + "\\" + info.FileName.Trim()).Replace("/", @"\\");
Template classTemplate = new Template(TempletPath, TempType.ChClass);
classTemplate.CHClassID = classID;
classTemplate.ChID = ChID;
classTemplate.GetHTML();
string TmpPath = SiteRootPath + saveClassPath;
replaceTempg(classTemplate, TmpPath, classID.ToString(), "class");
state = true;
}
}
}
catch (Exception e)
{
NetCMS.Common.Public.savePublicLogFiles("□□□ 生成栏目,频道ID:" + ChID + "", "【classID】:" + classID.ToString() + "\r\n【错误描述:】\r\n" + e.ToString(), "");
}
return state;
}
/// <summary>
/// 发布单个专题
/// </summary>
/// <param name="specialID">单个专题ID</param>
/// <returns>成功与否标志</returns>
public bool publishSingleSpecial(string specialID)
{
bool state = false;
try
{
CommonData.Initialize();
string saveSpecialPath = string.Empty;
string TempletPath = string.Empty;
string SiteRootPath = NetCMS.Common.ServerInfo.GetRootPath() + "\\";
string strTempletDir = strgTemplet;
PubSpecialInfo info = CommonData.GetSpecial(specialID);
if (info != null)
{
if (info.isDelPoint == 0)
{
TempletPath = info.Templet;
TempletPath = TempletPath.Replace("/", "\\");
TempletPath = TempletPath.ToLower().Replace("{@dirtemplet}", strTempletDir);
TempletPath = SiteRootPath.Trim('\\') + TempletPath;
saveSpecialPath = "\\" + info.SavePath.Trim('\\').Trim('/') + "\\" + info.saveDirPath.Trim('\\').Trim('/') + '\\' + info.FileName + info.FileEXName;
Template specialTemplate = new Template(TempletPath, TempType.Special);
specialTemplate.SpecialID = specialID;
specialTemplate.GetHTML();
specialTemplate.ReplaceLabels();
specialTemplate.ReplaceIMLabels();
replaceTempg(specialTemplate, SiteRootPath + saveSpecialPath, specialID, "special");
state = true;
}
}
}
catch (Exception e)
{
NetCMS.Common.Public.savePublicLogFiles("□□□ 生成专题", "【specialID】:" + specialID + "\r\n【错误描述:】\r\n" + e.ToString(), "");
}
return state;
}
/// <summary>
/// 发布单个专题(频道)
/// </summary>
public bool publishCHSingleSpecial(int specialID, int ChID)
{
bool state = false;
try
{
CommonData.Initialize();
string saveSpecialPath = string.Empty;
string TempletPath = string.Empty;
string SiteRootPath = NetCMS.Common.ServerInfo.GetRootPath() + "\\";
string strTempletDir = strgTemplet;
PubCHSpecialInfo info = CommonData.GetCHSpecial(specialID);
if (info != null)
{
TempletPath = info.templet;
TempletPath = TempletPath.Replace("/", "\\");
TempletPath = TempletPath.ToLower().Replace("{@dirtemplet}", strTempletDir);
string dirHTML = NetCMS.Common.Public.readCHparamConfig("htmldir", ChID);
dirHTML = dirHTML.Replace("{@dirHTML}", NetCMS.Config.UIConfig.dirHtml);
TempletPath = SiteRootPath.Trim('\\') + TempletPath;
saveSpecialPath = dirHTML.Trim('\\').Trim('/') + "\\" + info.savePath.Trim('\\').Trim('/') + '\\' + info.filename;
Template specialTemplate = new Template(TempletPath, TempType.Chspecial);
specialTemplate.CHSpecialID = specialID;
specialTemplate.ChID = ChID;
specialTemplate.GetHTML();
specialTemplate.ReplaceLabels();
specialTemplate.ReplaceIMLabels();
replaceTempg(specialTemplate, SiteRootPath + saveSpecialPath, specialID.ToString(), "special");
state = true;
}
}
catch (Exception e)
{
NetCMS.Common.Public.savePublicLogFiles("□□□ 生成专题,频道ID:" + ChID + "", "【specialID】:" + specialID + "\r\n【错误描述:】\r\n" + e.ToString(), "");
}
return state;
}
/// <summary>
/// 处理模板
/// </summary>
/// <param name="tempRe">模板实例</param>
public void replaceTempg(Template tempRe, string savePath, string id, string ContentType)
{
tempRe.ReplaceLabels();
tempRe.ReplaceIMLabels();
savePath = savePath.Replace("/", @"\\");
savePath = savePath.Replace(@"\\\\", @"\\");
if (tempRe.MyTempType == TempType.Class || tempRe.MyTempType == TempType.Special || tempRe.MyTempType == TempType.ChClass || tempRe.MyTempType == TempType.Chspecial)
{
string FinlContent = tempRe.FinallyContent;
int pos1 = FinlContent.IndexOf("{NT:NewsLIST}");
int pos2 = FinlContent.IndexOf("{/NT:NewsLIST}");
string filepath = savePath;
string TmpPath = savePath;
if (pos2 > pos1 && pos1 > -1)
{
int getFiledot = savePath.LastIndexOf(".");
int getFileg = savePath.LastIndexOf("\\");
string getFileName = savePath.Substring((getFileg + 1), ((getFiledot - getFileg) - 1));
string getFileEXName = savePath.Substring(getFiledot);
#region 处理分页
string PageHead = FinlContent.Substring(0, pos1);
string PageEnd = FinlContent.Substring(pos2 + 14);
string PageMid = FinlContent.Substring(pos1 + 13, pos2 - pos1 - 13);
string pattern = @"\{\$NT\:P[01]\}\{Page\:\d\$[^\$]{0,6}\$\}";
Regex reg = new Regex(pattern, RegexOptions.Compiled);
Match match = reg.Match(PageMid);
if (match.Success)
{
if (NetCMS.Config.verConfig.PublicType == "0" || tempRe.MyTempType == TempType.ChClass || tempRe.MyTempType == TempType.Chspecial)
{
string PageStr = match.Value;
int posPage = PageStr.IndexOf("}{Page:");
string postResult = PageStr.Substring(posPage + 7);
postResult = postResult.TrimEnd('}');
string[] postResultARR = postResult.Split('$');
string postResult_style = postResultARR[0];
string postResult_color = postResultARR[1];
string postResult_css = postResultARR[2];
string postResult_css1 = "";
if (postResult_css.Trim() != string.Empty)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -