⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ultipublish.cs

📁 最好用的站点内容管理系统 全部源代码都有
💻 CS
📖 第 1 页 / 共 5 页
字号:
                    if (!existFlag)
                    {
                        Template classTemplate = new Template(TempletPath, TempType.Class);
                        classTemplate.ClassID = classID;
                        classTemplate.GetHTML();
                        replaceTemp(classTemplate, existFlag, saveClassPath, classID, "class");
                    }
                }
                else
                {
                    Template classTemplate = new Template(TempletPath, TempType.Class);
                    classTemplate.ClassID = classID;
                    classTemplate.GetHTML();
                    replaceTemp(classTemplate, existFlag, saveClassPath, classID, "class");
                }
                succeedList.Add(classID);
                return true;
            }
            catch (Exception e)
            {
                failedList.Add(classID + "$" + e.Message);
                NetCMS.Common.Public.savePublicLogFiles("□□□发布栏目", "【ID】:" + classID + "\r\n【错误描述:】\r\n" + e.ToString(), "");
                return false;
            }
        }
        /// <summary>
        /// 发布一个专题
        /// </summary>
        /// <param name="specialID">专题ID</param>
        /// <returns>成功与否标志</returns>
        public bool publishSingleSpecial(string specialID)
        {
            try
            {
                TempletPath = SiteRootPath.Trim('\\') + TempletPath;
                bool existFlag = false;
                if (templateList.Count != 0)
                {
                    foreach (Template temp in templateList)
                    {
                        if (TempletPath == temp.TempFilePath)
                        {
                            existFlag = true;
                            temp.SpecialID = specialID;
                            replaceTemp(temp, existFlag, saveSpecialPath, specialID, "special");
                            break;
                        }
                    }
                    if (!existFlag)
                    {
                        Template specialTemplate = new Template(TempletPath, TempType.Special);
                        specialTemplate.SpecialID = specialID;
                        specialTemplate.GetHTML();
                        replaceTemp(specialTemplate, existFlag, saveSpecialPath, specialID, "special");
                    }
                }
                else
                {
                    Template specialTemplate = new Template(TempletPath, TempType.Special);
                    specialTemplate.SpecialID = specialID;
                    specialTemplate.GetHTML();
                    replaceTemp(specialTemplate, existFlag, saveSpecialPath, specialID, "special");
                }
                succeedList.Add(specialID);
                return true;
            }
            catch (Exception e)
            {
                failedList.Add(specialID + "$" + e.Message);
                return false;
            }
        }
        /// <summary>
        /// 处理模板
        /// </summary>
        /// <param name="tempRe">模板实例</param>
        /// <param name="existFlag">该模板是否存在于模板列表</param>
        protected void replaceTemp(Template tempRe, bool existFlag, string savePath, string id, string ContentType)
        {
            tempRe.ReplaceLabels();
            tempRe.ReplaceIMLabels();
            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 = SiteRootPath + savePath;
                string TmpPath = SiteRootPath + 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);
                    //类型$颜色$css
                    string pattern = @"\{\$NT\:P[01]\}\{Page\:\d\$[^\$]{0,6}\$[^\$]{0,50}\}";
                    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)
                            {
                                postResult_css1 = " class=\"" + postResult_css + "\"";
                            }
                            string[] ArrayCon = reg.Split(PageMid);
                            int n = ArrayCon.Length;
                            if (ArrayCon[n - 1] == null || ArrayCon[n - 1].Trim() == string.Empty)
                                n--;
                            for (int i = 0; i < n; i++)
                            {
                                string getPageStr = "";
                                if (i > 0)
                                {
                                    int laspot = TmpPath.LastIndexOf('.');
                                    filepath = TmpPath.Substring(0, laspot) + "_" + (i + 1) + TmpPath.Substring(laspot);
                                }
                                getPageStr = getPagelist(postResult_style, i, getFileName, getFileEXName, postResult_color, postResult_css1, n, id, ContentType, 0);
                                string PageContent = PageHead + ArrayCon[i] + getPageStr + PageEnd;

                                General.WriteHtml(PageContent, filepath);
                            }
                            if (n > 0)
                            {
                                if (!existFlag)
                                {
                                    templateList.Add(tempRe);
                                }
                                return;
                            }
                        }
                    }
                    #endregion
                }
            }
            string p1js = "<span style=\"text-align:center;\" id=\"gPtypenowdiv" + DateTime.Now.ToShortDateString() + "\">加载中...</span>";
            p1js += "<script language=\"javascript\" type=\"text/javascript\">";
            p1js += "pubajax('/configuration/system/public.aspx','NowStr=" + DateTime.Now.ToShortDateString() + "&ruleStr=1','gPtypenowdiv" + DateTime.Now.ToShortDateString() + "');";
            p1js += "</script>";
            General.WriteHtml(tempRe.FinallyContent.Replace("{NT:NewsLIST}", "").Replace("{/NT:NewsLIST}", "").Replace("{$NT:P1}", p1js), SiteRootPath + savePath);
            if (!existFlag)
            {
                templateList.Add(tempRe);
            }
        }

        /// <summary>
        /// 得到分页样式
        /// </summary>
        /// <param name="Input"></param>
        /// <param name="sColor"></param>
        /// <param name="Css"></param>
        /// <returns></returns>
        public static string getPageStyle(string Input, string sColor)
        {
            string colorstr = "";
            if (sColor.Trim() != string.Empty)
            {
                colorstr = " style=\"color:" + sColor + "\"";
            }
            return "<span" + colorstr + ">" + Input + "</span>";
        }

        public string getPageresult(string ID, string ReadType, string ContentType, int ConstStr, string getFileName, string getFileEXName, int isPop)
        {

            string getURL = string.Empty;
            string CHSTR = string.Empty;
            if (_ChID != 0)
            {
                CHSTR = "&ChID=" + _ChID.ToString() + "";
            }
            if (ReadType == "1")
            {
                if (ContentType == "class")
                {
                    if (ConstStr == 0)
                    {
                        getURL = "list.aspx?ClassID=" + ID + CHSTR;
                    }
                    else
                    {
                        getURL = "list.aspx?ClassID=" + ID + "&Page=" + ConstStr + CHSTR;
                    }
                }
                else
                {
                    if (ConstStr == 0)
                    {
                        getURL = "Special.aspx?SpecialID=" + ID + CHSTR;
                    }
                    else
                    {
                        getURL = "Special.aspx?SpecialID=" + ID + "&Page=" + ConstStr + CHSTR;
                    }
                }
            }
            else
            {
                if (isPop == 0)
                {
                    if (ConstStr == 0)
                    {
                        getURL = getFileName + getFileEXName;
                    }
                    else
                    {
                        getURL = getFileName + "_" + ConstStr + getFileEXName;
                    }
                }
                else
                {
                    if (ContentType == "class")
                    {
                        if (ConstStr == 0)
                        {
                            getURL = "list.aspx?ClassID=" + ID + CHSTR;
                        }
                        else
                        {
                            getURL = "list.aspx?ClassID=" + ID + "&Page=" + ConstStr + CHSTR;
                        }
                    }
                    else
                    {
                        if (ConstStr == 0)
                        {
                            getURL = "Special.aspx?SpecialID=" + ID + CHSTR;
                        }
                        else
                        {
                            getURL = "Special.aspx?SpecialID=" + ID + "&Page=" + ConstStr + CHSTR;
                        }
                    }
                }
            }
            return getURL;
        }

        /// <summary>
        /// 得到分页样式
        /// </summary>
        /// <param name="Numstr"></param>
        /// <param name="i"></param>
        /// <param name="getFileName"></param>
        /// <param name="getFileEXName"></param>
        /// <param name="postResult_color"></param>
        /// <param name="postResult_css"></param>
        /// <param name="n"></param>
        /// <returns></returns>
        public string getPagelist(string Numstr, int i, string getFileName, string getFileEXName, string postResult_color, string postResult_css, int n, string ID, string ContentType, int isPop)
        {
            string Pagestr = string.Empty;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -