📄 utipublishchannel.cs
字号:
try
{
TempletPath = SiteRootPath.Trim('\\') + TempletPath;
bool existFlag = false;
if (templateList.Count != 0)
{
foreach (Template temp in templateList)
{
if (TempletPath == temp.TempFilePath)
{
existFlag = true;
temp.CHSpecialID = specialID;
temp.ChID = _ChID;
replaceTemp(temp, existFlag, saveSpecialPath, specialID.ToString(), "special");
break;
}
}
if (!existFlag)
{
Template specialTemplate = new Template(TempletPath, TempType.Chspecial);
specialTemplate.CHSpecialID = specialID;
specialTemplate.ChID = _ChID;
specialTemplate.GetHTML();
replaceTemp(specialTemplate, existFlag, saveSpecialPath, specialID.ToString(), "special");
}
}
else
{
Template specialTemplate = new Template(TempletPath, TempType.Chspecial);
specialTemplate.CHSpecialID = specialID;
specialTemplate.ChID = _ChID;
specialTemplate.GetHTML();
replaceTemp(specialTemplate, existFlag, saveSpecialPath, specialID.ToString(), "special");
}
succeedList.Add(specialID.ToString());
return true;
}
catch (Exception e)
{
failedList.Add(specialID.ToString() + "$" + e.Message);
return false;
}
}
/// <summary>
/// 得到要发布的所有专题(频道)
/// </summary>
protected IDataReader getAllCHSpecials()
{
string spid = string.Empty;
switch (_CHspecialFlag)
{
case 0:
break;
case 1:
spid = getCHSpecialsSelect();
break;
default:
return null;
}
return CommonData.DalPublish.GetPublishCHSpecial(_ChID, spid, out nCHSpecialCount);
}
/// <summary>
/// 选择选择专题时,取得所有专题
/// </summary>
protected string getCHSpecialsSelect()
{
if (_strCHSpecialParams != null)
{
string reslt = "";
string[] spparam = _strCHSpecialParams.Split('$');
for (int i = 0; i < spparam.Length; i++)
{
if (i > 0)
reslt += ",";
reslt += "" + spparam[i] + "";
}
return reslt;
}
else
{
HProgressBar.Roll("请选择频道专题", 0);
return "";
}
}
/// <summary>
/// 得到要发布的频道新闻
/// </summary>
/// <param name="DTable"></param>
/// <returns></returns>
protected IDataReader getALLCHNews(string DTable)
{
switch (_CHnewsFlag)
{
case 0: return getCHNewsAll(DTable);
case 1: return getCHNewsLast(DTable);
case 2: return getCHNewsUnhtml(DTable);
case 3: return getCHNewsClasses(DTable);
case 4: return getCHNewsDate(DTable);
case 5: return getCHNewsId(DTable);
default: return null;
}
}
/// <summary>
/// 选择发布频道所有新闻时,取得所有新闻
/// </summary>
/// <param name="strParams">页面信息字符串</param>
/// <returns>取得符合条件的所有新闻的查询结果</returns>
protected IDataReader getCHNewsAll(string DTable)
{
return CommonData.DalPublish.GetPublishCHNewsAll(DTable, out nCHNewsCount);
}
/// <summary>
/// 选择发布频道最新时,取得所有新闻
/// </summary>
/// <param name="strParams">页面信息字符串</param>
/// <returns>取得符合条件的所有新闻的查询结果</returns>
protected IDataReader getCHNewsLast(string DTable)
{
int ncount;
IDataReader rd = CommonData.DalPublish.GetPublishCHNewsLast(DTable,Convert.ToInt32(_strNewsCHParams), false, out ncount);
nCHNewsCount = Convert.ToInt32(_strNewsCHParams);
if (ncount < nCHNewsCount)
{
nCHNewsCount = ncount;
}
return rd;
}
/// <summary>
/// 选择只发布频道未生成时,取得所有新闻
/// </summary>
/// <param name="strParams">页面信息字符串</param>
/// <returns>取得符合条件的所有新闻的查询结果</returns>
protected IDataReader getCHNewsUnhtml(string DTable)
{
int ncount;
IDataReader rd = CommonData.DalPublish.GetPublishCHNewsLast(DTable, Convert.ToInt32(_strNewsCHParams), true, out ncount);
nCHNewsCount = Convert.ToInt32(_strNewsCHParams);
if (ncount < nCHNewsCount)
{
nCHNewsCount = ncount;
}
return rd;
}
/// <summary>
/// 选择选择频道栏目时,取得所有新闻
/// </summary>
/// <param name="strParams">页面信息字符串</param>
/// <returns>取得符合条件的所有新闻的查询结果</returns>
protected IDataReader getCHNewsClasses(string DTable)
{
bool IsHtml = false;
if (_strNewsCHParams.IndexOf("#") >= 0)
{
//只发布未发布的
IsHtml = true;
_strNewsCHParams = _strNewsCHParams.Replace("#", "");
}
if (_strNewsCHParams.IndexOf("&") >= 0)
{
_strNewsCHParams = _strNewsCHParams.Replace("&", "");
}
string classid = "";
string[] PublishParam = _strNewsCHParams.Split('$');
int n = PublishParam.Length;
for (int i = 0; i < n - 1; i++)
{
if (i > 0)
classid += ",";
classid = "'" + PublishParam[i] + "'";
}
return CommonData.DalPublish.GetPublishCHNewsByClass(DTable,classid, IsHtml, false, PublishParam[n - 1], out nCHNewsCount);
}
/// <summary>
/// 选择按照频道日期发布时,取得所有新闻
/// </summary>
/// <param name="strParams">页面信息字符串</param>
/// <returns>取得符合条件的所有新闻的查询结果</returns>
protected IDataReader getCHNewsDate(string DTable)
{
DateTime StartTm = Convert.ToDateTime(_strNewsCHParams.Split('$')[0]);
DateTime EndTm = Convert.ToDateTime(_strNewsCHParams.Split('$')[1]);
return CommonData.DalPublish.GetPublishCHNewsByTime(DTable,StartTm, EndTm, out nCHNewsCount);
}
/// <summary>
/// 选择按照ID频道发布时,取得所有新闻
/// </summary>
/// <param name="strParams">页面信息字符串</param>
/// <returns>取得符合条件的所有新闻的查询结果</returns>
protected IDataReader getCHNewsId(string DTable)
{
int MinID = Convert.ToInt32(_strNewsCHParams.Split('$')[0]);
int MaxID = Convert.ToInt32(_strNewsCHParams.Split('$')[1]);
return CommonData.DalPublish.GetPublishCHNewsByID(DTable,MinID, MaxID, out nCHNewsCount);
}
/// <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 setSaveinfoPath(int classID, string SavePath, string FileName)
{
PubCHClassInfo info = CommonData.GetCHClassById(classID);
if (info != null)
{
string dirHTML = NetCMS.Common.Public.readCHparamConfig("htmldir", _ChID);
dirHTML = dirHTML.Replace("{@dirHTML}", NetCMS.Config.UIConfig.dirHtml);
saveinfoPath = "\\" + dirHTML.Trim('\\').Trim('/') + "\\" + info.SavePath.Trim('\\').Trim('/') + "\\" + SavePath.Trim('\\').Trim('/') + "\\" + FileName.Trim('\\').Trim('/');
}
}
/// <summary>
/// 处理频道模板
/// </summary>
/// <param name="tempRe">模板实例</param>
/// <param name="existFlag">该模板是否存在于模板列表</param>
protected void makeHtmlFile_channel(Template tempRe, bool existFlag, int classID, int infoID)
{
tempRe.ReplaceLabels();
tempRe.ReplaceIMLabels();
if (tempRe.MyTempType == TempType.ChNews)
{
string FinlContent = tempRe.FinallyContent;
int pos1 = FinlContent.IndexOf("<!-NT:STAR=");
int pos2 = FinlContent.IndexOf("NT:END->");
if (pos1 > -1)
{
saveinfoPath = saveinfoPath.Replace("\\\\", "\\");
int getFiledot = saveinfoPath.LastIndexOf(".");
int getFileg = saveinfoPath.LastIndexOf("\\");
string getFileName = saveinfoPath.Substring((getFileg + 1), ((getFiledot - getFileg) - 1));
string getFileEXName = saveinfoPath.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 (ArrayCon[n - 1] == null || ArrayCon[n - 1].Trim() == string.Empty)
// n--;
for (int i = 0; i < n; i++)
{
string filepath = SiteRootPath + saveinfoPath;
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 = General.ReplaceResultPage(infoID.ToString(), PageContent.Replace("[NT:PAGE]", "").Replace("NT:END->", "").Replace("<!-NT:STAR=", ""), getFileName, getFileEXName, n, (i + 1), 0);
General.WriteHtml(getFileContent, filepath);
}
//if (n > 0)
//{
// if (!existFlag)
// {
// templateList.Add(tempRe);
// }
// return;
//}
}
}
General.WriteHtml(tempRe.FinallyContent.Replace("NT:END->", "").Replace("<!-NT:STAR=", ""), SiteRootPath + saveinfoPath);
//if (!existFlag)
//{
// templateList.Add(tempRe);
//}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -