Exemplo n.º 1
0
        /// <summary>
        /// 存储/更新实体对象是否成功
        /// </summary>
        public bool StoredSuccess(object Instance)
        {
            PageTemplet pageTpt = Instance as PageTemplet;

            if (pageTpt == null)
            {
                return(false);
            }

            string strOp = (pageTpt.TempletID == 0) ? "I" : "U@[TempletID=" + pageTpt.TempletID.ToString() + "]";
            string sql   = OleDbHelper.BuildSqlIU(OleDbHelper.DbDialect.MsAccess, "Tbl_Templets", strOp,
                                                  new string[] { "TempletName", "SiteBaseDir", "FileSaveUrl", "Content", "TimeFlag", "MixedSyntax", "Category" },
                                                  new object[] {
                OleDbHelper.EscapeSQL(pageTpt.TempletName),
                OleDbHelper.EscapeSQL(pageTpt.SiteBaseDir),
                OleDbHelper.EscapeSQL(pageTpt.FileSaveUrl),
                pageTpt.TempletRawContent,
                "N'Now()",
                Util.IsMatch(TagBase.TagDefinitionPattern, pageTpt.TempletRawContent),
                pageTpt.TptCategory.GetHashCode()
            });

            strOp = FanmaquerOleDbModule.GetOleDbInstance(FanmaquarConfig.ConnectionKey).ExecuteNonQuery(sql).ToString();
            return(strOp != "0");
        }
Exemplo n.º 2
0
        /// <summary>
        /// 存储/更新实体对象是否成功
        /// </summary>
        public bool StoredSuccess(object Instance)
        {
            AccessWebChannel aWebChannel = Instance as AccessWebChannel;

            if (aWebChannel == null)
            {
                return(false);
            }
            string strOp = (aWebChannel.ChannelID == 0) ? "I" : "U@[TypeID=" + aWebChannel.ChannelID.ToString() + "]";
            string sql   = OleDbHelper.BuildSqlIU(OleDbHelper.DbDialect.MsAccess, "Tbl_Type", strOp,
                                                  new string[] { "TypeName", "ParentTypeID", "Sort", "GroupID",
                                                                 "StaticFileDir", "ArchiveDays", "DisplayByPath", "OuterLinkUrl", "GenTempletRule" },
                                                  new object[] {
                OleDbHelper.EscapeSQL(aWebChannel.ChannelName),
                aWebChannel.ParentChannel.ChannelID,
                aWebChannel.Sort,
                Convert.ToInt32(aWebChannel.GetDefinition("GroupID")),
                OleDbHelper.EscapeSQL((aWebChannel.StaticFileGenDir + "/").Replace("//", "/")),
                aWebChannel.ArchiveDays,
                aWebChannel.IsOuterLink,
                OleDbHelper.EscapeSQL(aWebChannel.OuterLinkUrl),
                OleDbHelper.EscapeSQL(aWebChannel.GetTempletConfigStoreText(65535))
            });

            strOp = FanmaquerOleDbModule.GetOleDbInstance(FanmaquarConfig.ConnectionKey).ExecuteNonQuery(sql).ToString();
            return(strOp != "0");
        }
Exemplo n.º 3
0
        /// <summary>
        /// 存储/更新实体对象是否成功
        /// </summary>
        public bool StoredSuccess(object Instance)
        {
            AccessWebNews aWebNews = Instance as AccessWebNews;

            if (aWebNews == null)
            {
                return(false);
            }

            string strOp = (aWebNews.NewsID == 0) ? "I" : "U@[NewsID=" + aWebNews.NewsID.ToString() + "]";
            string sql   = OleDbHelper.BuildSqlIU(OleDbHelper.DbDialect.MsAccess, "Tbl_Articles", strOp,
                                                  new string[] { "TypeID", "VirtualPath", "Sort", "IsPrimary",
                                                                 "Title", "Author", "InnerUserName", "Summary", "Content", "Pubed", "PublishDate", "Hits" },
                                                  new object[] {
                aWebNews.Channel.ChannelID,
                OleDbHelper.EscapeSQL(aWebNews.VirtualPath),
                aWebNews.Sort,
                aWebNews.IsPrimary,
                OleDbHelper.EscapeSQL(aWebNews.Title),
                OleDbHelper.EscapeSQL(aWebNews.Author),
                OleDbHelper.EscapeSQL(aWebNews.InnerUserName),
                OleDbHelper.EscapeSQL(aWebNews.Summary),
                OleDbHelper.EscapeSQL(aWebNews.Content),
                aWebNews.IsPubed,
                "N'Now()", aWebNews.Hits
            });

            strOp = FanmaquerOleDbModule.GetOleDbInstance(FanmaquarConfig.ConnectionKey).ExecuteNonQuery(sql).ToString();
            return(strOp != "0");
        }
Exemplo n.º 4
0
        /// <summary>
        /// 通过ID初始化实例对象实现
        /// </summary>
        public object GetInstanceById(int InstanceID)
        {
            AccessWebChannel aWebChannel = new AccessWebChannel(InstanceID);
            DataRow          dRow        = FanmaquerOleDbModule.GetOleDbInstance(FanmaquarConfig.ConnectionKey).GetDataRow(string.Format("select top 1 * from Tbl_Type where TypeID={0}", InstanceID));

            if (dRow != null)
            {
                aWebChannel.ChannelName      = dRow["TypeName"].ToString();
                aWebChannel.Sort             = Convert.ToInt32(dRow["Sort"]);
                aWebChannel.IsOuterLink      = Convert.ToBoolean(dRow["DisplayByPath"]);
                aWebChannel.OuterLinkUrl     = dRow["OuterLinkUrl"].ToString();
                aWebChannel.StaticFileGenDir = dRow["StaticFileDir"].ToString();
                aWebChannel.ArchiveDays      = Convert.ToInt32(dRow["ArchiveDays"]);
                aWebChannel.ParentChannel    = new AccessWebChannel(Convert.ToInt32(dRow["ParentTypeID"]));

                aWebChannel.SetDefined("GroupID", dRow["GroupID"].ToString());
                #region Templet with file generate rules.
                string xmlTptRule = dRow["GenTempletRule"].ToString();
                if (xmlTptRule.Length > 10)
                {
                    StringReader sR = new StringReader(xmlTptRule);
                    //   OleDbHelper.AppendToFile(true, @"D:\wwwroot\newsign\chinaqmzxco29607\@docs\temp.xml",
                    //"\n\r\n**" + dRow["GenTempletRule"].ToString());
                    XmlSerializer xSer = new XmlSerializer(typeof(TempletSetting));
                    aWebChannel.TempletConfig = (TempletSetting)xSer.Deserialize(sR);
                }
                #endregion

                aWebChannel.IsExist = true;
            }
            aWebChannel.IsFilled = true;
            return(aWebChannel);
        }
Exemplo n.º 5
0
 /// <summary>
 /// 移除需要更新的记录
 /// </summary>
 /// <param name="SiteID">站点编号</param>
 /// <param name="trackPath">页面基于跟目录的路径</param>
 public static void RemoveUpdateRecord(int SiteID, string trackPath)
 {
     FanmaquerOleDbModule.GetOleDbInstance(FanmaquarConfig.ConnectionKey)
     .ExecuteNonQuery(string.Format("delete from [Tbl_TrackDat] where SiteID={0} and TrackPath='{1}'",
                                    SiteID,
                                    trackPath.Replace("'", "")));
 }
Exemplo n.º 6
0
        /// <summary>
        /// 获取该频道的导航菜单
        /// </summary>
        /// <param name="ChannelID">频道编号</param>
        /// <param name="IDAndNameFormat">一个频道的完整链接格式化字符,0参为频道ID,1参为频道名称。</param>
        /// <param name="sperator">频道与上级频道之间的分隔字符</param>
        /// <example>
        ///     AccessWebChanel.DrawHtmlNavPath(58, "<a href=/{0}/list.html>{1}</a>", " &gt;&gt; ")
        /// </example>
        public static string DrawHtmlNavPath(int ChannelID, string IDAndNameFormat, string sperator)
        {
            // "{"及"}"为关键标签字符
            IDAndNameFormat = Regex.Replace(IDAndNameFormat, @"\[(\d+)\]", "{$1}");
            string    sql  = string.Format("select ParentTypeID,TypeID,TypeName,OuterLinkUrl,DisplayByPath from Tbl_Type where TypeID={0}", ChannelID);
            ArrayList list = new ArrayList();

            DataRow dRow         = null;
            int     ParentTypeID = 1;

            OleDbHelper hp = FanmaquerOleDbModule.GetOleDbInstance(FanmaquarConfig.ConnectionKey);

            while (ParentTypeID > 0)
            {
                dRow = hp.GetDataRow(sql);
                if (dRow != null)
                {
                    sql = dRow["OuterLinkUrl"].ToString();
                    if (Convert.ToBoolean(dRow["DisplayByPath"]) == true && sql.Length > 0)
                    {
                        list.Add(string.Format(Regex.Replace(IDAndNameFormat, "(href=)(\\'|\\\"?)([^\\s\\>]+)(\\2)", "$1$2{0}$4", RegexOptions.IgnoreCase),
                                               sql, dRow["TypeName"].ToString()));
                    }
                    else
                    {
                        list.Add(string.Format(IDAndNameFormat, dRow["TypeID"].ToString(), dRow["TypeName"].ToString()));
                    }
                    ParentTypeID = Convert.ToInt32(dRow["ParentTypeID"]);
                    if (ParentTypeID > 0)
                    {
                        sql = string.Format("select ParentTypeID,TypeID,TypeName,OuterLinkUrl,DisplayByPath from Tbl_Type where TypeID={0}", ParentTypeID);
                    }
                    else
                    {
                        break;
                    }
                }
                else
                {
                    break;
                }
            }

            if (list.Count > 0)
            {
                list.Reverse();
                string[] objChNav = (string[])list.ToArray(typeof(string));
                return(string.Join(sperator, objChNav));
            }
            else
            {
                return("");
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// 通过模板名称获取模板内容
        /// </summary>
        /// <param name="TptName">模板名称</param>
        public object GetInstanceByName(string TptName)
        {
            int     tid  = 0;
            DataRow dRow = FanmaquerOleDbModule.GetOleDbInstance(FanmaquarConfig.ConnectionKey)
                           .GetDataRow(string.Format("select top 1 TempletID from Tbl_Templets where TempletName='{0}'", TptName));

            if (dRow != null)
            {
                tid = Convert.ToInt32(dRow["TempletID"]);
            }
            return(GetInstanceById(tid));
        }
Exemplo n.º 8
0
        /// <summary>
        /// 通过ID初始化实例对象实现
        /// </summary>
        public object GetInstanceById(int InstanceID)
        {
            AccessWebNews aWebNews = new AccessWebNews(InstanceID);
            DataRow       dRow     = FanmaquerOleDbModule.GetOleDbInstance(FanmaquarConfig.ConnectionKey)
                                     .GetDataRow(string.Format("select top 1 * from Tbl_Articles where NewsID={0}", InstanceID));

            if (dRow != null)
            {
                aWebNews         = AccessWebNews.LoadFromDataRow(dRow);
                aWebNews.IsExist = true;
            }
            aWebNews.IsFilled = true;
            return(aWebNews);
        }
Exemplo n.º 9
0
        /// <summary>
        /// 频道默认新闻
        /// </summary>
        public IWebNews GetPrimaryNews()
        {
            DataRow dRow = FanmaquerOleDbModule.GetOleDbInstance(FanmaquarConfig.ConnectionKey)
                           .GetDataRow(string.Format("select top 1 * from Tbl_Articles where IsPrimary=true and Pubed=true and TypeID={0} order by NewsID desc",
                                                     this.ChannelID));

            if (dRow != null)
            {
                AccessWebNews aWebNews = AccessWebNews.LoadFromDataRow(dRow);
                aWebNews.IsExist  = true;
                aWebNews.IsFilled = true;
                return(aWebNews);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// 登录控制
        /// </summary>
        public static string TryLogin(string username, string password, string verifyCode, string domain)
        {
            if (verifyCode != GetVeifyCode())
            {
                return("验证码不正确");
            }
            OleDbHelper hp  = FanmaquerOleDbModule.GetOleDbInstance(FanmaquarConfig.ConnectionKey);
            string      sql = "select top 1 UserName,IsManager,LoginTimes,LastLogon,LastLoginIP from Tbl_Users where Disabled=false and UserName='******' and Pwd='" + Util.Md5(password) + "'";
            //Util.Debug(sql);
            DataRow mRow = hp.GetDataRow(sql);

            if (mRow == null)
            {
                return("登录名或密码不正确,或者该帐号被系统禁止登录。");
            }
            else
            {
                sql = string.Format("update Tbl_Users set LoginTimes=LoginTimes+1,LastLogon=Now(),LastLoginIP='{1}' where Username='******'",
                                    OleDbHelper.EscapeSQL(username),
                                    Util.GetIP());
                hp.ExecuteNonQuery(sql);

                LoginUserData uDat = new LoginUserData
                {
                    UserName  = username,
                    IsLogon   = true,
                    IsManager = Convert.ToBoolean(mRow["IsManager"])
                };

                FormsAuthenticationTicket tkt = new FormsAuthenticationTicket(1,
                                                                              username, DateTime.Now, DateTime.Now.AddDays(1.00), false,
                                                                              ToJSON(uDat));
                HttpCookie mCookie = new HttpCookie(FormsAuthentication.FormsCookieName);
                mCookie.Value   = FormsAuthentication.Encrypt(tkt);
                mCookie.Expires = System.DateTime.Now.AddDays(1.00);
                if (domain != null)
                {
                    mCookie.Domain = domain;
                }
                HttpContext.Current.Response.Cookies.Add(mCookie);
                return("0");
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// 根据网站页面完整相对地址自动更新页面内容
        /// </summary>
        /// <param name="fileRelatviePath">页面完整相对地址</param>
        public static void GeneratorByPath(string fileRelatviePath)
        {
            string trackPath = fileRelatviePath.Replace("'", "");
            //先找新闻表,再找频道表
            OleDbHelper hp  = FanmaquerOleDbModule.GetOleDbInstance(FanmaquarConfig.ConnectionKey);
            object      tid = hp.ExecuteScalar("select top 1 NewsID from Tbl_Articles where VirtualPath='" + trackPath + "'");

            if (tid != null)
            {
                AccessWebNews news = new AccessWebNews(Convert.ToInt32(tid));
                (new PageGenerator()).Generate(news);
            }
            else
            {
                tid = hp.ExecuteScalar("select top 1 TypeID from Tbl_Type where OuterLinkUrl='" + trackPath + "'");
                if (tid != null)
                {
                    AccessWebChannel channel = new AccessWebChannel(Convert.ToInt32(tid));
                    (new PageGenerator()).Generate(channel);
                }
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// 通过ID获取实例
        /// </summary>
        public object GetInstanceById(int InstanceID)
        {
            PageTemplet tpt  = new PageTemplet(InstanceID);
            DataRow     dRow = FanmaquerOleDbModule.GetOleDbInstance(FanmaquarConfig.ConnectionKey)
                               .GetDataRow(string.Format("select top 1 * from Tbl_Templets where TempletID={0}",
                                                         InstanceID));

            if (dRow != null)
            {
                tpt.IsExist = true;

                tpt.TempletName       = dRow["TempletName"].ToString();
                tpt.Property          = dRow["Property"].ToString();
                tpt.SiteBaseDir       = dRow["SiteBaseDir"].ToString();
                tpt.FileSaveUrl       = dRow["FileSaveUrl"].ToString();
                tpt.IsSystemBuild     = Convert.ToBoolean(dRow["IsSysBuild"]);
                tpt.IsMixedSyntax     = Convert.ToBoolean(dRow["MixedSyntax"]);
                tpt.ModifiedTime      = Convert.ToDateTime(dRow["TimeFlag"]);
                tpt.TempletRawContent = dRow["Content"].ToString();
                //tpt.ResDependency = (byte[])dRow["ResDependence"];

                int tptCate = Convert.ToInt32(dRow["Category"]);
                if (tptCate == 1)
                {
                    tpt.TptCategory = TempletCategory.OnListPage;
                }
                else if (tptCate == 2)
                {
                    tpt.TptCategory = TempletCategory.OnDetailPage;
                }
                else
                {
                    tpt.TptCategory = TempletCategory.MixedSingle;
                }
            }
            tpt.IsFilled = true;

            return(tpt);
        }
Exemplo n.º 13
0
        /// <summary>
        /// 生成网站栏目/频道静态文件
        /// </summary>
        /// <param name="aWebChannel">指定了ChannelID的实体</param>
        public void Generate(AccessWebChannel aWebChannel, ChannelGeneratorOptions options)
        {
            if (aWebChannel.IsFilled == false)
            {
                aWebChannel = (new AccessWebChannel()).GetInstanceById(aWebChannel.ChannelID) as AccessWebChannel;
            }

            if (aWebChannel != null && aWebChannel.IsExist == true && aWebChannel.IsFilled == true)
            {
                if (aWebChannel.StaticFileGenDir.IndexOf("/") == -1)
                {
                    ShowMessage("生成文件目录设置有错误,系统终止!");
                    return;
                }

                TempletSetting tptConfig = aWebChannel.TempletConfig;
                if (tptConfig == null)
                {
                    ShowMessage("该频道没有配置模板,不能生成相关文件!");
                }
                else
                {
                    string strGenFilePath, strFileName, strFileExt, strGenResult = "";
                    if (aWebChannel.StaticFileGenDir.IndexOf("{#$ChannelID$#}") != -1)
                    {
                        aWebChannel.StaticFileGenDir = aWebChannel.StaticFileGenDir.Replace("{#$ChannelID$#}", aWebChannel.ChannelID.ToString());
                    }
                    strGenFilePath = Util.ParseAppPath(aWebChannel.StaticFileGenDir);
                    //ShowMessage(strGenFilePath);
                    if (!strGenFilePath.EndsWith("\\"))
                    {
                        strGenFilePath += "\\";
                    }

                    //最终页面内容
                    string strGenFileContent = "";
                    string trackPath         = "";

                    this.UTCDateBegin = DateTime.Now.ToUniversalTime();

                    if (options != null && options.GenerateSinglePage == false)
                    {
                        ShowMessage("* 已禁止单页综合内容页生成!");
                    }
                    else
                    {
                        #region 单页综合生成
                        if (tptConfig.GenerateSinglePage == true)
                        {
                            strFileName = tptConfig.MixedSingleTemplet.FileNameConfig.FileNameTag.GetTagValue().ToString();
                            strFileExt  = tptConfig.MixedSingleTemplet.FileNameConfig.FileExtentionName;

                            PageTemplet pageTpt = (new PageTemplet()).GetInstanceById(tptConfig.MixedSingleTemplet.TempletID) as PageTemplet;
                            if (pageTpt != null && pageTpt.IsExist == true && pageTpt.IsFilled == true)
                            {
                                if (pageTpt.IsMixedSyntax == false)
                                {
                                    if (!pageTpt.SiteBaseDir.EndsWith("/"))
                                    {
                                        pageTpt.SiteBaseDir += "/";
                                    }
                                    strGenResult = OleDbHelper.SetTextFileContent(strGenFilePath + strFileName + strFileExt,
                                                                                  "utf-8",
                                                                                  HtmlTextGenerator.GetRightHtmlText(pageTpt.SiteBaseDir, pageTpt.TempletRawContent));

                                    if (strGenResult == "0")
                                    {
                                        FireGeneratorFileFinished(strGenFilePath + strFileName + strFileExt);
                                    }
                                }
                                else
                                {
                                    TempletParse tpp = new TempletParse();
                                    tpp.Caller = this;
                                    tpp.SetResourceDependency(aWebChannel);
                                    tpp.TagTrack = new System.Collections.Generic.Dictionary <string, string>();
                                    tpp.TagTrack.Add("T" + pageTpt.TempletID.ToString(), pageTpt.ModifiedTime.ToString("yyyyMMddHHmmss"));
                                    tpp.SetTaggedObjectCollection(pageTpt.TempletRawContent);

                                    strGenFileContent = HtmlTextGenerator.GetRightHtmlText(pageTpt.SiteBaseDir, tpp.ParsedResult);
                                    //插入Track代码
                                    trackPath = GetSiteRelativeUrl(strGenFilePath + strFileName + strFileExt);
                                    GetTrackHtmlInSertCode(tpp.TagTrack, trackPath, "</body>", ref strGenFileContent);

                                    strGenResult = OleDbHelper.SetTextFileContent(trackPath, "utf-8", strGenFileContent);

                                    if (strGenResult == "0")
                                    {
                                        FireGeneratorFileFinished(trackPath);
                                    }
                                }

                                if (strGenResult == "0")
                                {
                                    TrackUnit.RemoveUpdateRecord(0, trackPath);
                                    ShowMessage(string.Format("单页内容生成成功!<a href=\"{0}\" target=\"_blank\">{0}</a>", GetSiteRelativeUrl(strGenFilePath + strFileName + strFileExt)));
                                }
                            }
                            else
                            {
                                ShowMessage("页面模板实体还原失败,请检查配置是否正确!");
                            }
                        }
                        #endregion
                    }

                    if (options != null && options.GenerateListPage == false)
                    {
                        ShowMessage("* 已禁止列表页生成!");
                    }
                    else
                    {
                        #region 列表页面生成
                        if (tptConfig.GenerateListPage == true)
                        {
                            strFileExt = tptConfig.ListPageTemplet.FileNameConfig.FileExtentionName;
                            tptConfig.ListPageTemplet.FileNameConfig.FileNameTag.SetResourceDependency(aWebChannel);
                            strFileName = tptConfig.ListPageTemplet.FileNameConfig.FileNameTag.GetTagValue().ToString();

                            PageTemplet pageTpt = (new PageTemplet()).GetInstanceById(tptConfig.ListPageTemplet.TempletID) as PageTemplet;
                            if (pageTpt != null && pageTpt.IsExist == true && pageTpt.IsFilled == true)
                            {
                                strGenResult = "";
                                #region 根据模板内的列表动态生成多个页
                                if (pageTpt.IsMixedSyntax == false)
                                {
                                    if (!pageTpt.SiteBaseDir.EndsWith("/"))
                                    {
                                        pageTpt.SiteBaseDir += "/";
                                    }
                                    strGenResult = OleDbHelper.SetTextFileContent(strGenFilePath + strFileName + strFileExt,
                                                                                  "utf-8",
                                                                                  HtmlTextGenerator.GetRightHtmlText(pageTpt.SiteBaseDir, pageTpt.TempletRawContent));

                                    if (strGenResult == "0")
                                    {
                                        FireGeneratorFileFinished(strGenFilePath + strFileName + strFileExt);
                                        ShowMessage(string.Format("文件生成成功!<a href=\"{0}\" target=\"_blank\">{0}</a>", GetSiteRelativeUrl(strGenFilePath + strFileName + strFileExt)));
                                    }
                                }
                                else
                                {
                                    string       realContent = "", myPageHtml = "";
                                    TempletParse tpp = new TempletParse();

                                    //获取要分页变化的模块内容(含Pager)
                                    //替换分页变化的内容 + 生成多页

                                    tpp.Caller = this;
                                    tpp.SetResourceDependency(aWebChannel);

                                    tpp.TagTrack = new System.Collections.Generic.Dictionary <string, string>();
                                    tpp.TagTrack.Add("T" + pageTpt.TempletID.ToString(), pageTpt.ModifiedTime.ToString("yyyyMMddHHmmss"));
                                    tpp.SetTaggedObjectCollection(pageTpt.TempletRawContent);

                                    if (this.PagedObject == null)
                                    {
                                        myPageHtml = tpp.ParsedResult;
                                        //处理分页导航内容
                                        if (this.PagerDic.Count > 0)
                                        {
                                            foreach (string pagerKey in PagerDic.Keys)
                                            {
                                                myPageHtml = myPageHtml.Replace(pagerKey, "");
                                            }
                                        }

                                        strGenFileContent = HtmlTextGenerator.GetRightHtmlText(pageTpt.SiteBaseDir, myPageHtml);
                                        //插入Track代码
                                        trackPath = GetSiteRelativeUrl(strGenFilePath + TagBase.TrimTagDefine(strFileName, '_', '-') + strFileExt);
                                        GetTrackHtmlInSertCode(tpp.TagTrack, trackPath, "</body>", ref strGenFileContent);
                                        strGenResult = OleDbHelper.SetTextFileContent(trackPath, "utf-8", strGenFileContent);
                                        if (strGenResult == "0")
                                        {
                                            FireGeneratorFileFinished(trackPath);
                                        }
                                        TrackUnit.RemoveUpdateRecord(0, trackPath);
                                    }
                                    else
                                    {
                                        string dynTpt = tpp.ParsedResult;
                                        PagedObject.SetResourceDependency(aWebChannel);
                                        while (PagedObject.CurrentPageIndex <= PagedObject.GetPageCount())
                                        {
                                            #region 处理分页内容
                                            realContent = PagedObject.GetCurrentPageContent();
                                            //处理当前页内容
                                            myPageHtml = dynTpt.Replace(PagedContentAlia, realContent);

                                            //处理分页导航内容
                                            if (this.PagerDic.Count > 0)
                                            {
                                                foreach (string pagerKey in PagerDic.Keys)
                                                {
                                                    PagerTag Pager = PagerDic[pagerKey];
                                                    Pager.TotalRecordCount  = PagedObject.GetTotalRecordCount();
                                                    Pager.CurrentPage       = PagedObject.CurrentPageIndex;
                                                    Pager.StartIndex        = PagedObject.StartIndex;
                                                    Pager.EndIndex          = PagedObject.EndIndex;
                                                    Pager.PageSize          = PagedObject.PageSize;
                                                    Pager.DefaultPageFormat = aWebChannel.StaticFileGenDir + strFileName.Replace("{#$CIDX$#}", "{0}") + strFileExt;

                                                    //Util.Debug(false, Pager.ToString());
                                                    myPageHtml = myPageHtml.Replace(pagerKey, Pager.ToString());
                                                    //Util.Debug(false, this.PagerDic[pagerKey].OuterDefineText);
                                                }
                                            }
                                            int    currentPage     = PagedObject.CurrentPageIndex;
                                            string currentFileName = strFileName.Replace("{#$CIDX$#}", currentPage.ToString());

                                            strGenFileContent = HtmlTextGenerator.GetRightHtmlText(pageTpt.SiteBaseDir, myPageHtml);
                                            //插入Track代码
                                            trackPath = GetSiteRelativeUrl(strGenFilePath + currentFileName + strFileExt);
                                            GetTrackHtmlInSertCode(tpp.TagTrack, trackPath, "</body>", ref strGenFileContent);
                                            strGenResult = OleDbHelper.SetTextFileContent(trackPath, "utf-8", strGenFileContent);
                                            //清除更新请求
                                            TrackUnit.RemoveUpdateRecord(0, trackPath);

                                            if (strGenResult == "0")
                                            {
                                                FireGeneratorFileFinished(trackPath);
                                                ShowMessage(string.Format("列表页文件生成成功!<a href=\"{0}\" target=\"_blank\">{0}</a>", trackPath));
                                            }

                                            if (currentPage == 1)
                                            {
                                                trackPath = strGenFilePath + currentFileName.Trim('1', '-', '_') + strFileExt;
                                                OleDbHelper.SetTextFileContent(trackPath, "utf-8", strGenFileContent);
                                                FireGeneratorFileFinished(trackPath);
                                                TrackUnit.RemoveUpdateRecord(0, trackPath);
                                            }
                                            PagedObject.MoveNextPage();
                                            #endregion
                                        }
                                    }
                                    tpp.Dispose();
                                }
                                #endregion
                                if (strGenResult == "0")
                                {
                                    ShowMessage("列表页内容生成成功完成。");
                                }
                            }
                            else
                            {
                                ShowMessage("页面模板实体还原失败,请检查配置是否正确!");
                            }
                        }
                        #endregion
                    }

                    if (options != null && options.GenerateDetailPage == false)
                    {
                        ShowMessage("* 已禁止详细内容页生成!");
                    }
                    else
                    {
                        #region 详细页面生成
                        if (tptConfig.GenerateDetailPage == true)
                        {
                            strFileExt = tptConfig.DetailPageTemplet.FileNameConfig.FileExtentionName;
                            PageTemplet pageTpt = (new PageTemplet()).GetInstanceById(tptConfig.DetailPageTemplet.TempletID) as PageTemplet;
                            if (pageTpt != null && pageTpt.IsExist == true && pageTpt.IsFilled == true)
                            {
                                if (pageTpt.IsMixedSyntax == false)
                                {
                                    strFileName = tptConfig.DetailPageTemplet.FileNameConfig.FileNameTag.GetTagValue().ToString();
                                    if (!pageTpt.SiteBaseDir.EndsWith("/"))
                                    {
                                        pageTpt.SiteBaseDir += "/";
                                    }
                                    strGenResult = OleDbHelper.SetTextFileContent(strGenFilePath + strFileName + strFileExt,
                                                                                  "utf-8",
                                                                                  HtmlTextGenerator.GetRightHtmlText(pageTpt.SiteBaseDir, pageTpt.TempletRawContent));

                                    if (strGenResult == "0")
                                    {
                                        FireGeneratorFileFinished(strGenFilePath + strFileName + strFileExt);
                                    }
                                }
                                else
                                {
                                    TempletParse tpp = new TempletParse();
                                    OleDbHelper  hp  = FanmaquerOleDbModule.GetOleDbInstance(FanmaquarConfig.ConnectionKey);

                                    DataTable dTab = hp.GetDataTable(string.Format("select * from Tbl_Articles where Pubed=True and Archived=false and TypeID={0} order by Sort asc,NewsID desc",
                                                                                   aWebChannel.ChannelID));

                                    if (dTab != null && dTab.Rows.Count > 0)
                                    {
                                        for (int i = 0; i < dTab.Rows.Count; i++)
                                        {
                                            AccessWebNews news = AccessWebNews.LoadFromDataRow(dTab.Rows[i]);
                                            tptConfig.DetailPageTemplet.FileNameConfig.FileNameTag.SetResourceDependency(news);
                                            strFileName = tptConfig.DetailPageTemplet.FileNameConfig.FileNameTag.GetTagValue().ToString();

                                            MultiResDependency newsRes = new MultiResDependency(aWebChannel, news);
                                            tpp.SetResourceDependency(newsRes);
                                            tpp.TagTrack = new System.Collections.Generic.Dictionary <string, string>();
                                            tpp.TagTrack.Add("T" + pageTpt.TempletID.ToString(), pageTpt.ModifiedTime.ToString("yyyyMMddHHmmss"));
                                            tpp.SetTaggedObjectCollection(pageTpt.TempletRawContent);

                                            string newsfileWithFullPath = strGenFilePath + strFileName + strFileExt;
                                            if (news.VirtualPath.Length > 5)
                                            {
                                                newsfileWithFullPath = Util.ParseAppPath(news.VirtualPath);
                                            }
                                            else
                                            {
                                                news.VirtualPath = aWebChannel.StaticFileGenDir + strFileName + strFileExt;
                                                news.RefreshVirtualPath();
                                            }

                                            strGenFileContent = HtmlTextGenerator.GetRightHtmlText(pageTpt.SiteBaseDir, tpp.ParsedResult);
                                            //插入Track代码
                                            trackPath = GetSiteRelativeUrl(newsfileWithFullPath);
                                            GetTrackHtmlInSertCode(tpp.TagTrack, trackPath, "</body>", ref strGenFileContent);

                                            strGenResult = OleDbHelper.SetTextFileContent(newsfileWithFullPath, "utf-8", strGenFileContent);
                                            if (strGenResult == "0")
                                            {
                                                TrackUnit.RemoveUpdateRecord(0, trackPath);
                                                FireGeneratorFileFinished(trackPath);
                                                ShowMessage(string.Format("内容页文件生成成功!<a href=\"{0}\" target=\"_blank\">{0}</a>", trackPath));
                                            }
                                        }
                                    }

                                    tpp.Dispose();
                                }

                                if (strGenResult == "0")
                                {
                                    ShowMessage("详细页面内容生成成功完成。");
                                }
                            }
                            else
                            {
                                ShowMessage("页面模板实体还原失败,请检查配置是否正确!");
                            }
                        }
                        #endregion
                    }
                }

                ShowMessage("已完成所有处理,如没有任何消息显示,这可能是该栏目没有内容或配置错误!");
                ShowMessage("$end$");
            }
        }
Exemplo n.º 14
0
 /// <summary>
 /// 通过连接字符串键值获取数据操作辅助对象
 /// </summary>
 /// <param name="connKey">The conn key.</param>
 /// <returns></returns>
 protected OleDbHelper getStoreHelper(string connKey)
 {
     return(FanmaquerOleDbModule.GetOleDbInstance(connKey));
 }
Exemplo n.º 15
0
 /// <summary>
 /// 更新虚拟文件路径
 /// </summary>
 public void RefreshVirtualPath()
 {
     FanmaquerOleDbModule.GetOleDbInstance(FanmaquarConfig.ConnectionKey)
     .ExecuteNonQuery(string.Format("update Tbl_Articles set VirtualPath='{1}' where NewsID={0}",
                                    this.NewsID, this.VirtualPath));
 }