Exemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PagerTag"/> class.
 /// </summary>
 /// <param name="tagdef">The tagdef.</param>
 public PagerTag(string tagdef)
     : base(tagdef)
 {
     TagBase tag = new TagBase(tagdef);
     InheriteFromBase(tag);
     FilledInTagList(tagdef, tagList, this);
 }
Exemplo n.º 2
0
Arquivo: ListTag.cs Projeto: vbyte/fmq
 /// <summary>
 /// 初始化一个列表实例对象
 /// </summary>
 public ListTag(string tagdef)
     : base(tagdef)
 {
     TagBase tag = new TagBase(tagdef);
     InheriteFromBase(tag);
     SetListTemplet(tagdef);
 }
Exemplo n.º 3
0
        /// <summary>
        ///  转化为分页标签
        /// </summary>
        public static PagerTag Parse(TagBase tag)
        {
            PagerTag pager = new PagerTag(tag.OuterDefineText);

            pager.InheriteFromBase(tag);
            return(pager);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 初始化一个列表实例对象
        /// </summary>
        public ListTag(string tagdef)
            : base(tagdef)
        {
            TagBase tag = new TagBase(tagdef);

            InheriteFromBase(tag);
            SetListTemplet(tagdef);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PagerTag"/> class.
        /// </summary>
        /// <param name="tagdef">The tagdef.</param>
        public PagerTag(string tagdef)
            : base(tagdef)
        {
            TagBase tag = new TagBase(tagdef);

            InheriteFromBase(tag);
            FilledInTagList(tagdef, tagList, this);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 转化为列表标签,并传递资源依赖对象
        /// </summary>
        public static ListTag Parse(TagBase tag, IResourceDependency res)
        {
            ListTag listTag = new ListTag();

            listTag.SetResourceDependency(res);
            listTag.InheriteFromBase(tag);
            listTag.SetListTemplet(tag.OuterDefineText);
            return(listTag);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 获取标签的最终输出值
        /// </summary>
        public override object GetTagValue()
        {
            if (this.IsExist == true)
            {
                //OleDbHelper.AppendToFile("~/debug.log", this.Category.ToString() + Environment.NewLine + Environment.NewLine);
                //OleDbHelper.AppendToFile("~/debug.log", this.OuterDefineText + Environment.NewLine + Environment.NewLine);
                //OleDbHelper.AppendToFile("~/debug.log", this.Content + Environment.NewLine + Environment.NewLine);

                if (!ContainTags())
                {
                    return(this.GetHtmlOutPut());
                }
                else
                {
                    TagBase tag = new TagBase(this.Content);
                    if (tag.Category == TagCategory.DataListTag)
                    {
                        ListTag list = ListTag.Parse(tag, this.GetResourceDependency());
                        if (list.PageSize > 0)
                        {
                            string pagedAliaContent = (string.IsNullOrEmpty(list.IDentity)) ? Guid.NewGuid().ToString() : list.IDentity;
                            SetDynamicPagedAlia(pagedAliaContent, list);
                            return(pagedAliaContent);
                        }
                        else
                        {
                            return(list.GetTagValue());
                        }
                    }
                    else if (tag.Category == TagCategory.PagerTag)
                    {
                        PagerTag pager     = PagerTag.Parse(tag);
                        string   pagerAlia = (string.IsNullOrEmpty(pager.IDentity)) ? Guid.NewGuid().ToString() : pager.IDentity;
                        SetDynamicPagerDependency(pagerAlia, pager);
                        return(pagerAlia);
                    }
                    else
                    {
                        //Util.Debug(false, GetResourceDependency());
                        return(TagBase.InterpretContentWithTags(GetHtmlOutPut(), GetResourceDependency()));
                    }
                }
            }
            else
            {
                //OleDbHelper.AppendToFile("~/debug.log", "NULL:" + this.OuterDefineText + Environment.NewLine + Environment.NewLine);
                return(null);
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// 获取标签定义的内部文本
        /// </summary>
        public static string GetTagDefineInnerText(string tagdef)
        {
            TagBase tag = new TagBase(tagdef);

            if (!tag.IsDependencyTag)
            {
                return(tag.TagDefinition);
            }
            else
            {
                if (tag.IsContainer)
                {
                    int idxBegin = 0, idxEnd = 0;
                    idxBegin = tagdef.IndexOf("#}");
                    idxEnd   = tagdef.LastIndexOf("{#");
                    return(tagdef.Substring(idxBegin + 2, idxEnd - idxBegin - 2).Trim());
                }
                else
                {
                    return(tagdef.Trim('{', '#', '}'));
                }
            }
        }
Exemplo n.º 9
0
        internal void InheriteFromBase(TagBase tag)
        {
            string strTemp = tag.GetAttribute("ID");

            //标志
            if (strTemp != null)
            {
                this.IDentity = strTemp;
            }

            //是否总是显示
            strTemp = tag.GetAttribute("AlwaysShow");
            if (strTemp != null)
            {
                this.AlwaysShow = (strTemp.ToLower() == "true");
            }

            //分页格式定义
            strTemp = tag.GetAttribute("PageFormat");
            if (strTemp != null)
            {
                this.PageFormat = strTemp;
            }
        }
Exemplo n.º 10
0
 public static AutoItem Parse(TagBase tag)
 {
     return(new AutoItem(tag.OuterDefineText));
 }
Exemplo n.º 11
0
        /// <summary>
        /// 从基础标签转换为数据存储标签
        /// </summary>
        /// <returns></returns>
        public static DbStoredCustomTag Parse(TagBase tag)
        {
            DbStoredCustomTag dbTag = new DbStoredCustomTag(tag.OuterDefineText);

            return(dbTag);
        }
Exemplo n.º 12
0
        internal void InheriteFromBase(TagBase tag)
        {
            string strTemp = tag.GetAttribute("ID");

            //标志
            if (!string.IsNullOrEmpty(strTemp))
            {
                this.IDentity = strTemp;
            }

            //指定另外的Access数据库
            strTemp = tag.GetAttribute("ConnKey");
            if (!string.IsNullOrEmpty(strTemp))
            {
                this.BindConnKey = strTemp;
            }

            //指定前几条
            strTemp = tag.GetAttribute("Top");
            if (!string.IsNullOrEmpty(strTemp))
            {
                this.TopCount = int.Parse(strTemp);
            }

            //指定每行显示的项数
            strTemp = tag.GetAttribute("RowSize");
            if (!string.IsNullOrEmpty(strTemp))
            {
                this.RowSize = int.Parse(strTemp);
            }

            strTemp = tag.GetAttribute("PageSize");
            if (!string.IsNullOrEmpty(strTemp))
            {
                this.PageSize = int.Parse(strTemp);
            }

            //指定绑定表格
            strTemp = tag.GetAttribute("Table");
            if (!string.IsNullOrEmpty(strTemp))
            {
                this.BindTableName = strTemp;
            }

            //指定选取字段列表
            strTemp = tag.GetAttribute("Fields");
            if (!string.IsNullOrEmpty(strTemp))
            {
                this.Fields = strTemp.Trim('"', '\'');
            }

            //指定选取字段列表
            strTemp = tag.GetAttribute("OrderBy");
            if (!string.IsNullOrEmpty(strTemp))
            {
                this.OrderBy = strTemp;
            }

            //自定义查询条件
            strTemp = tag.GetAttribute("Query");
            if (!string.IsNullOrEmpty(strTemp))
            {
                this.Query = strTemp; return;
            }

            object objTemp = null;

            #region sql查询条件
            foreach (string s in tag.GetObjAttributes())
            {
                string value = tag.GetAttribute(s);

                //OleDbHelper.AppendToFile("~/debug.log", System.Environment.NewLine + " Value:" + value);

                if ((s[0] == '%' && s[s.Length - 1] == '%') ||
                    (s[0] == '(' && value[value.Length - 1] == ')'))
                {
                    strTemp = (s[1] != '@') ? ((s[1] == '~') ? " like " : "=") : "";
                    string newCondition = s.Trim('%', '(', '~', '@')
                                          + strTemp
                                          + value.Replace('"', '\'').Trim(')');

                    #region 处理值中的系统标签或函数
                    if (value.StartsWith("$") && value.EndsWith("$"))
                    {
                        //OleDbHelper.AppendToFile("~/debug.log", System.Environment.NewLine + " Value:" + value);
                        if (this.GetResourceDependency() != null)
                        {
                            //OleDbHelper.AppendToFile("~/debug.log", System.Environment.NewLine + " Res:" + this.GetResourceDependency().ToString());

                            objTemp = this.GetResourceDependency().GetDefinition("{#" + value + "#}");

                            if (string.IsNullOrEmpty(objTemp.ToString()))
                            {
                                newCondition = "";
                            }
                            else
                            {
                                newCondition = s.Trim('%', '(', '~', '@') + strTemp + objTemp.ToString();
                            }
                        }
                        else
                        {
                            newCondition = "";
                        }
                    }
                    #endregion

                    if (newCondition.Length > 0)
                    {
                        if (this._filterCondition != "")
                        {
                            this._filterCondition += " And " + newCondition;
                        }
                        else
                        {
                            this._filterCondition = newCondition;
                        }
                    }
                }
            }
            //Util.Debug(false, this.FilterCondition);
            #endregion
        }
Exemplo n.º 13
0
Arquivo: ListTag.cs Projeto: vbyte/fmq
        internal void InheriteFromBase(TagBase tag)
        {
            string strTemp = tag.GetAttribute("ID");
            //标志
            if (!string.IsNullOrEmpty(strTemp)) { this.IDentity = strTemp; }

            //指定另外的Access数据库
            strTemp = tag.GetAttribute("ConnKey");
            if (!string.IsNullOrEmpty(strTemp)) { this.BindConnKey = strTemp; }

            //指定前几条
            strTemp = tag.GetAttribute("Top");
            if (!string.IsNullOrEmpty(strTemp)) { this.TopCount = int.Parse(strTemp); }

            //指定每行显示的项数
            strTemp = tag.GetAttribute("RowSize");
            if (!string.IsNullOrEmpty(strTemp)) { this.RowSize = int.Parse(strTemp); }

            strTemp = tag.GetAttribute("PageSize");
            if (!string.IsNullOrEmpty(strTemp)) { this.PageSize = int.Parse(strTemp); }

            //指定绑定表格
            strTemp = tag.GetAttribute("Table");
            if (!string.IsNullOrEmpty(strTemp)) { this.BindTableName = strTemp; }

            //指定选取字段列表
            strTemp = tag.GetAttribute("Fields");
            if (!string.IsNullOrEmpty(strTemp)) { this.Fields = strTemp.Trim('"', '\''); }

            //指定选取字段列表
            strTemp = tag.GetAttribute("OrderBy");
            if (!string.IsNullOrEmpty(strTemp)) { this.OrderBy = strTemp; }

            //自定义查询条件
            strTemp = tag.GetAttribute("Query");
            if (!string.IsNullOrEmpty(strTemp)) { this.Query = strTemp; return; }

            object objTemp = null;
            #region sql查询条件
            foreach (string s in tag.GetObjAttributes())
            {
                string value = tag.GetAttribute(s);

                //OleDbHelper.AppendToFile("~/debug.log", System.Environment.NewLine + " Value:" + value);

                if ((s[0] == '%' && s[s.Length - 1] == '%') ||
                    (s[0] == '(' && value[value.Length - 1] == ')'))
                {
                    strTemp = (s[1] != '@') ? ((s[1] == '~') ? " like " : "=") : "";
                    string newCondition = s.Trim('%', '(', '~', '@')
                        + strTemp
                        + value.Replace('"', '\'').Trim(')');

                    #region 处理值中的系统标签或函数
                    if (value.StartsWith("$") && value.EndsWith("$"))
                    {
                        //OleDbHelper.AppendToFile("~/debug.log", System.Environment.NewLine + " Value:" + value);
                        if (this.GetResourceDependency() != null)
                        {
                            //OleDbHelper.AppendToFile("~/debug.log", System.Environment.NewLine + " Res:" + this.GetResourceDependency().ToString());

                            objTemp = this.GetResourceDependency().GetDefinition("{#" + value + "#}");

                            if (string.IsNullOrEmpty(objTemp.ToString()))
                            {
                                newCondition = "";
                            }
                            else
                            {
                                newCondition = s.Trim('%', '(', '~', '@') + strTemp + objTemp.ToString();
                            }

                        }
                        else
                        {
                            newCondition = "";
                        }
                    }
                    #endregion

                    if (newCondition.Length > 0)
                    {
                        if (this._filterCondition != "")
                        {
                            this._filterCondition += " And " + newCondition;
                        }
                        else
                        {
                            this._filterCondition = newCondition;
                        }
                    }
                }
            }
            //Util.Debug(false, this.FilterCondition);
            #endregion
        }
Exemplo n.º 14
0
Arquivo: ListTag.cs Projeto: vbyte/fmq
 /// <summary>
 /// 转化为列表标签,并传递资源依赖对象
 /// </summary>
 public static ListTag Parse(TagBase tag, IResourceDependency res)
 {
     ListTag listTag = new ListTag();
     listTag.SetResourceDependency(res);
     listTag.InheriteFromBase(tag);
     listTag.SetListTemplet(tag.OuterDefineText);
     return listTag;
 }
Exemplo n.º 15
0
        /// <summary>
        /// 获取该标签的HTML输出
        /// </summary>
        public override object GetTagValue()
        {
            SetDataSource();
            StringBuilder sb = new StringBuilder();

            sb.Append(TagBase.InterpretContentWithTags(this.HeaderTemplet, this));
            if (this.DataSource != null && this.DataSource.Rows.Count > 0)
            {
                int rowCount = 0, rowIndex = 0;

                #region 设置开始结束索引
                this.StartIndex = 1 + (PageSize * (CurrentPageIndex - 1));
                this.EndIndex   = (this.StartIndex + this.DataSource.Rows.Count - 1);
                #endregion

                for (int i = 0; i < this.DataSource.Rows.Count; i++)
                {
                    ++rowCount;
                    //行在整个数据源中的索引
                    rowIndex = rowCount + (PageSize * (CurrentPageIndex - 1));

                    #region 单元项
                    if (rowCount % 2 == 0 && this.AlterItemTemplet != "")
                    {
                        sb.Append(TagBase.GetDataEscapedValue(rowIndex, this.AlterItemTemplet, this.DataSource.Rows[i], new MultiResDependency(this, GetResourceDependency())));
                    }
                    else
                    {
                        sb.Append(TagBase.GetDataEscapedValue(rowIndex, this.ItemTemplet, this.DataSource.Rows[i], new MultiResDependency(this, GetResourceDependency())));
                    }
                    #endregion

                    #region 单元项间隔
                    if (this.RowSize > 1 && (rowCount % this.RowSize != 0))
                    {
                        //多项分行间隔
                        sb.Append(this.SeparatorTemplet);
                    }
                    else
                    {
                        //单项间隔
                        if (rowCount < this.DataSource.Rows.Count)
                        {
                            sb.Append(this.SeparatorTemplet);
                        }
                    }
                    #endregion

                    #region 行分隔
                    if (this.RowSize > 1 && rowCount % this.RowSize == 0 &&
                        rowCount < this.DataSource.Rows.Count)
                    {
                        sb.Append(this.RowBreakTemplet);
                    }
                    #endregion
                }
            }
            else
            {
                sb.Append(this.EmptyTemplet);
            }
            sb.Append(TagBase.InterpretContentWithTags(this.FooterTemplet, this));
            return(sb.ToString());
        }
Exemplo n.º 16
0
        internal void InheriteFromBase(TagBase tag)
        {
            string strTemp = tag.GetAttribute("ID");
            //标志
            if (strTemp != null) { this.IDentity = strTemp; }

            //是否总是显示
            strTemp = tag.GetAttribute("AlwaysShow");
            if (strTemp != null) { this.AlwaysShow = (strTemp.ToLower()=="true"); }

            //分页格式定义
            strTemp = tag.GetAttribute("PageFormat");
            if (strTemp != null) { this.PageFormat = strTemp; }
        }
Exemplo n.º 17
0
 /// <summary>
 ///  转化为分页标签
 /// </summary>
 public static PagerTag Parse(TagBase tag)
 {
     PagerTag pager = new PagerTag(tag.OuterDefineText);
     pager.InheriteFromBase(tag);
     return pager;
 }
Exemplo n.º 18
0
        /// <summary>
        /// 解析模板内容
        /// </summary>
        public void SetTaggedObjectCollection(string tptContent)
        {
            StringBuilder sb = new StringBuilder(tptContent.Length);
            Regex regEx = new Regex(TagBase.TagDefinitionPattern, RegexOptions.IgnoreCase | RegexOptions.Compiled);
            int idxBegin = 0, idxEnd = 0;

            //Util.Debug(false, "------------------------begin---------------");
            MatchCollection mc = regEx.Matches(tptContent, idxBegin);
            while (mc.Count > 0)
            {
                Match m = mc[0];
                idxEnd = m.Index;

                if (idxEnd > idxBegin)
                {
                    //Util.Debug(false, tptContent.Substring(idxBegin, idxEnd - idxBegin));
                    sb.Append(tptContent.Substring(idxBegin, idxEnd - idxBegin));
                }

                TagBase tag = new TagBase(m.Value, m.Index, ref tptContent);
                //Util.Debug(false, "#####\n" + tag.OuterDefineText + " " + tag.Category.ToString() + "\n#####");
                //OleDbHelper.AppendToFile("~/debug.log", "parse Tag..." + tag.OuterDefineText + " \r\n " + tag.Category.ToString() + Environment.NewLine + Environment.NewLine);
                #region 处理标签内容
                if (tag.Category == TagCategory.CustomTag)
                {
                    DbStoredCustomTag dbTag = DbStoredCustomTag.Parse(tag);
                    dbTag.SetResourceDependency(this.GetResourceDependency());
                    //Util.Debug(false, "tpp: " + this.GetResourceDependency() + dbTag.OuterDefineText);
                    if (dbTag.IsExist == true)
                    {
                        dbTag.Caller = this;
                        sb.Append(dbTag.GetTagValue());
                        if (!this.TagTrack.ContainsKey("B" + dbTag.IDentity))
                        {
                            this.TagTrack.Add("B" + dbTag.IDentity, dbTag.PublishDate.ToString("yyyyMMddHHmmss"));
                        }
                    }
                }
                else if (tag.Category == TagCategory.DataListTag)
                {
                    //{#List:Repeater#}
                    ListTag list = ListTag.Parse(tag, this.GetResourceDependency());
                    //OleDbHelper.AppendToFile("~/debug.log", System.Environment.NewLine + " Res:"
                    //    + this.GetResourceDependency().ToString());
                    if (this.GeneratorListContent == true)
                    {
                        #region 直接获取列表标签内容
                        if (list.GetPageCount() < 2)
                        {
                            sb.Append(list.GetTagValue());
                        }
                        else
                        {
                            string pagedAliaContent = (string.IsNullOrEmpty(list.IDentity)) ? new Guid().ToString() : list.IDentity;
                            SetDynamicPagedAlia(pagedAliaContent, list);
                            sb.Append(pagedAliaContent);
                        }
                        #endregion
                    }
                    else
                    {
                        //设置列表标签占位符号
                        string pagedAliaContent = (string.IsNullOrEmpty(list.IDentity)) ? new Guid().ToString() : list.IDentity;
                        SetDynamicPagedAlia(pagedAliaContent, list);
                        sb.Append(pagedAliaContent);
                    }
                }
                else if (tag.Category == TagCategory.PagerTag)
                {
                    //{#Pager#}
                    PagerTag pager = PagerTag.Parse(tag);
                    string pagerAlia = (string.IsNullOrEmpty(pager.IDentity)) ? new Guid().ToString() : pager.IDentity;
                    SetDynamicPagerDependency(pagerAlia, pager);
                    sb.Append(pagerAlia);
                }
                else if (tag.Category == TagCategory.ServerTag)
                {
                    //服务端标签定义格式为
                }
                else if (tag.Category == TagCategory.SystemTag)
                {
                    //系统标签(函数)定义格式为 {#$ $#} {# ... () ... #}
                    // 系统标签: {#$this.PrimaryNews["Content"]$#}
                    if (tag.OuterDefineText.StartsWith("{#$this.") && this._resDependency != null)
                    {
                        sb.Append(this.GetResourceDependency().GetDefinition(tag.OuterDefineText));
                    }
                    else
                    {
                        SystemTag sysTag = new SystemTag(tag.TagDefinition);
                        sysTag.SetResourceDependency(GetResourceDependency());
                        sb.Append(sysTag.ToString());
                    }
                    //Util.Debug(false, tag.OuterDefineText);
                    //OleDbHelper.AppendToFile("~/log.txt", tag.OuterDefineText);
                }
                else if (tag.Category == TagCategory.DefineTag)
                {
                    //数据库标签定义格式为 {#%FieldName%#}
                    if (this._resDependency != null)
                    {
                        //Util.Debug(false, tag.OuterDefineText);
                        sb.Append(this.GetResourceDependency().GetDefinition(tag.OuterDefineText));
                    }
                }

                #endregion

                idxBegin = tag.DefinedIndexEnd;
                //Util.Debug(false, tptContent.Substring(idxBegin, 5));
                //Util.Debug(m.Value);
                mc = regEx.Matches(tptContent, idxBegin);
            }
            if (idxBegin < tptContent.Length)
            {
                sb.Append(tptContent.Substring(idxBegin));
                //Util.Debug(false, tptContent.Substring(idxBegin));
            }
            this.ParsedResult = sb.ToString();
            //Util.Debug(false, "------------------------End---------------");
            //OleDbHelper.SetTextFileContent(@"~/@docs/temp.html", "utf-8",
            //    HtmlTextGenerator.GetRightHtmlText("/templet/1/", sb.ToString()));
        }
Exemplo n.º 19
0
        internal static void FilledInTagList(string tagdef, ArrayList tagList, IResourceDependency res)
        {
            int idxBegin = 0, idxEnd = 0;

            idxBegin = tagdef.IndexOf("#}");
            idxEnd   = tagdef.LastIndexOf("{#");
            tagdef   = tagdef.Substring(idxBegin + 2, idxEnd - idxBegin - 2).Trim();

            Regex regEx = new Regex(TagBase.TagDefinitionPattern, RegexOptions.IgnoreCase | RegexOptions.Compiled);

            idxBegin = idxEnd = 0;
            MatchCollection mc      = regEx.Matches(tagdef, idxBegin);
            HtmlTextTag     htmlTag = null;

            while (mc.Count > 0)
            {
                Match m = mc[0];
                idxEnd = m.Index;

                if (idxEnd > idxBegin)
                {
                    htmlTag = new HtmlTextTag(tagdef.Substring(idxBegin, idxEnd - idxBegin));
                    tagList.Add(htmlTag);
                }

                TagBase tag = new TagBase(m.Value, m.Index, ref tagdef);
                //Util.Debug(tag.Category);
                if (tag.Category == TagCategory.AutoTag)
                {
                    AutoItem item = AutoItem.Parse(tag);
                    if (res.GetType() == typeof(PagerTag))
                    {
                        item.CallerTag = (PagerTag)res;
                    }
                    tagList.Add(item);
                }
                else if (tag.Category == TagCategory.DefineTag)
                {
                    //数据库标签定义格式为 {#%FieldName%#}
                    if (res != null)
                    {
                        htmlTag = new HtmlTextTag(res.GetDefinition(tag.OuterDefineText).ToString());
                        tagList.Add(htmlTag);
                    }
                }
                else if (tag.Category == TagCategory.CustomTag)
                {
                    #region 数据定义标签内包含数据定义标签
                    DbStoredCustomTag dbTag = DbStoredCustomTag.Parse(tag);
                    dbTag.SetResourceDependency(res);
                    if (dbTag.IsExist == true)
                    {
                        htmlTag = new HtmlTextTag(dbTag.GetTagValue().ToString());
                        tagList.Add(htmlTag);
                    }
                    #endregion
                }
                else if (tag.Category == TagCategory.SystemTag)
                {
                    string pageURLKey = ",FirstUrl,PreUrl,NextUrl,LastUrl,CurUrl,";
                    string tagName    = tag.TagName.Trim('$');
                    if (pageURLKey.IndexOf("," + tagName + ",", StringComparison.InvariantCultureIgnoreCase) != -1)
                    {
                        tagName = tagName.ToLower();
                        PageUrl url = new PageUrl(tag.OuterDefineText);
                        url.IsAutoItem = (res != null && res.GetType() == typeof(AutoItem));
                        url.SetResourceDependency(res);
                        switch (tagName)
                        {
                        case "firsturl": url.UrlCategory = PageUrlCategory.FirstPage; break;

                        case "preurl": url.UrlCategory = PageUrlCategory.PrePage; break;

                        case "nexturl": url.UrlCategory = PageUrlCategory.NextPage; break;

                        case "lasturl": url.UrlCategory = PageUrlCategory.LastPage; break;

                        case "cururl": url.UrlCategory = PageUrlCategory.ThisPage; break;

                        default:
                            url.UrlCategory = PageUrlCategory.ThisPage;
                            break;
                        }
                        tagList.Add(url);
                    }
                    else
                    {
                        SystemTag sys = new SystemTag(tag.OuterDefineText);
                        //Util.Debug(false, res.GetType().ToString());
                        sys.SetResourceDependency(res);
                        tagList.Add(sys);
                    }
                }
                else
                {
                    tagList.Add(tag);
                }
                //Util.Debug(false, "#####\n" + tag.OuterDefineText + "\n#####");
                //TagList.Add(tag);

                idxBegin = tag.DefinedIndexEnd;
                mc       = regEx.Matches(tagdef, idxBegin);
            }

            if (idxBegin < tagdef.Length)
            {
                htmlTag = new HtmlTextTag(tagdef.Substring(idxBegin));
                tagList.Add(htmlTag);
            }
        }
Exemplo n.º 20
0
        /// <summary>
        /// 解析模板内容
        /// </summary>
        public void SetTaggedObjectCollection(string tptContent)
        {
            StringBuilder sb = new StringBuilder(tptContent.Length);
            Regex         regEx = new Regex(TagBase.TagDefinitionPattern, RegexOptions.IgnoreCase | RegexOptions.Compiled);
            int           idxBegin = 0, idxEnd = 0;

            //Util.Debug(false, "------------------------begin---------------");
            MatchCollection mc = regEx.Matches(tptContent, idxBegin);

            while (mc.Count > 0)
            {
                Match m = mc[0];
                idxEnd = m.Index;

                if (idxEnd > idxBegin)
                {
                    //Util.Debug(false, tptContent.Substring(idxBegin, idxEnd - idxBegin));
                    sb.Append(tptContent.Substring(idxBegin, idxEnd - idxBegin));
                }

                TagBase tag = new TagBase(m.Value, m.Index, ref tptContent);
                //Util.Debug(false, "#####\n" + tag.OuterDefineText + " " + tag.Category.ToString() + "\n#####");
                //OleDbHelper.AppendToFile("~/debug.log", "parse Tag..." + tag.OuterDefineText + " \r\n " + tag.Category.ToString() + Environment.NewLine + Environment.NewLine);
                #region 处理标签内容
                if (tag.Category == TagCategory.CustomTag)
                {
                    DbStoredCustomTag dbTag = DbStoredCustomTag.Parse(tag);
                    dbTag.SetResourceDependency(this.GetResourceDependency());
                    //Util.Debug(false, "tpp: " + this.GetResourceDependency() + dbTag.OuterDefineText);
                    if (dbTag.IsExist == true)
                    {
                        dbTag.Caller = this;
                        sb.Append(dbTag.GetTagValue());
                        if (!this.TagTrack.ContainsKey("B" + dbTag.IDentity))
                        {
                            this.TagTrack.Add("B" + dbTag.IDentity, dbTag.PublishDate.ToString("yyyyMMddHHmmss"));
                        }
                    }
                }
                else if (tag.Category == TagCategory.DataListTag)
                {
                    //{#List:Repeater#}
                    ListTag list = ListTag.Parse(tag, this.GetResourceDependency());
                    //OleDbHelper.AppendToFile("~/debug.log", System.Environment.NewLine + " Res:"
                    //    + this.GetResourceDependency().ToString());
                    if (this.GeneratorListContent == true)
                    {
                        #region 直接获取列表标签内容
                        if (list.GetPageCount() < 2)
                        {
                            sb.Append(list.GetTagValue());
                        }
                        else
                        {
                            string pagedAliaContent = (string.IsNullOrEmpty(list.IDentity)) ? new Guid().ToString() : list.IDentity;
                            SetDynamicPagedAlia(pagedAliaContent, list);
                            sb.Append(pagedAliaContent);
                        }
                        #endregion
                    }
                    else
                    {
                        //设置列表标签占位符号
                        string pagedAliaContent = (string.IsNullOrEmpty(list.IDentity)) ? new Guid().ToString() : list.IDentity;
                        SetDynamicPagedAlia(pagedAliaContent, list);
                        sb.Append(pagedAliaContent);
                    }
                }
                else if (tag.Category == TagCategory.PagerTag)
                {
                    //{#Pager#}
                    PagerTag pager     = PagerTag.Parse(tag);
                    string   pagerAlia = (string.IsNullOrEmpty(pager.IDentity)) ? new Guid().ToString() : pager.IDentity;
                    SetDynamicPagerDependency(pagerAlia, pager);
                    sb.Append(pagerAlia);
                }
                else if (tag.Category == TagCategory.ServerTag)
                {
                    //服务端标签定义格式为
                }
                else if (tag.Category == TagCategory.SystemTag)
                {
                    //系统标签(函数)定义格式为 {#$ $#} {# ... () ... #}
                    // 系统标签: {#$this.PrimaryNews["Content"]$#}
                    if (tag.OuterDefineText.StartsWith("{#$this.") && this._resDependency != null)
                    {
                        sb.Append(this.GetResourceDependency().GetDefinition(tag.OuterDefineText));
                    }
                    else
                    {
                        SystemTag sysTag = new SystemTag(tag.TagDefinition);
                        sysTag.SetResourceDependency(GetResourceDependency());
                        sb.Append(sysTag.ToString());
                    }
                    //Util.Debug(false, tag.OuterDefineText);
                    //OleDbHelper.AppendToFile("~/log.txt", tag.OuterDefineText);
                }
                else if (tag.Category == TagCategory.DefineTag)
                {
                    //数据库标签定义格式为 {#%FieldName%#}
                    if (this._resDependency != null)
                    {
                        //Util.Debug(false, tag.OuterDefineText);
                        sb.Append(this.GetResourceDependency().GetDefinition(tag.OuterDefineText));
                    }
                }

                #endregion

                idxBegin = tag.DefinedIndexEnd;
                //Util.Debug(false, tptContent.Substring(idxBegin, 5));
                //Util.Debug(m.Value);
                mc = regEx.Matches(tptContent, idxBegin);
            }
            if (idxBegin < tptContent.Length)
            {
                sb.Append(tptContent.Substring(idxBegin));
                //Util.Debug(false, tptContent.Substring(idxBegin));
            }
            this.ParsedResult = sb.ToString();
            //Util.Debug(false, "------------------------End---------------");
            //OleDbHelper.SetTextFileContent(@"~/@docs/temp.html", "utf-8",
            //    HtmlTextGenerator.GetRightHtmlText("/templet/1/", sb.ToString()));
        }
Exemplo n.º 21
0
Arquivo: TagBase.cs Projeto: vbyte/fmq
 /// <summary>
 /// 获取标签定义的内部文本
 /// </summary>
 public static string GetTagDefineInnerText(string tagdef)
 {
     TagBase tag = new TagBase(tagdef);
     if (!tag.IsDependencyTag)
     {
         return tag.TagDefinition;
     }
     else
     {
         if (tag.IsContainer)
         {
             int idxBegin = 0, idxEnd = 0;
             idxBegin = tagdef.IndexOf("#}");
             idxEnd = tagdef.LastIndexOf("{#");
             return tagdef.Substring(idxBegin + 2, idxEnd - idxBegin - 2).Trim();
         }
         else
         {
             return tagdef.Trim('{', '#', '}');
         }
     }
 }
Exemplo n.º 22
0
 /// <summary>
 /// 从基础标签转换为数据存储标签
 /// </summary>
 /// <returns></returns>
 public static DbStoredCustomTag Parse(TagBase tag)
 {
     DbStoredCustomTag dbTag = new DbStoredCustomTag(tag.OuterDefineText);
     return dbTag;
 }
Exemplo n.º 23
0
        internal static void FilledInTagList(string tagdef, ArrayList tagList, IResourceDependency res)
        {
            int idxBegin = 0, idxEnd = 0;
            idxBegin = tagdef.IndexOf("#}");
            idxEnd = tagdef.LastIndexOf("{#");
            tagdef = tagdef.Substring(idxBegin+2, idxEnd - idxBegin-2).Trim();

            Regex regEx = new Regex(TagBase.TagDefinitionPattern, RegexOptions.IgnoreCase | RegexOptions.Compiled);
            idxBegin = idxEnd = 0;
            MatchCollection mc = regEx.Matches(tagdef, idxBegin);
            HtmlTextTag htmlTag = null;
            while (mc.Count > 0)
            {
                Match m = mc[0];
                idxEnd = m.Index;

                if (idxEnd > idxBegin)
                {
                    htmlTag = new HtmlTextTag(tagdef.Substring(idxBegin, idxEnd - idxBegin));
                    tagList.Add(htmlTag);
                }

                TagBase tag = new TagBase(m.Value, m.Index, ref tagdef);
                //Util.Debug(tag.Category);
                if (tag.Category == TagCategory.AutoTag)
                {
                    AutoItem item = AutoItem.Parse(tag);
                    if (res.GetType() == typeof(PagerTag))
                    {
                        item.CallerTag = (PagerTag)res;
                    }
                    tagList.Add(item);
                }
                else if (tag.Category == TagCategory.DefineTag)
                {
                    //数据库标签定义格式为 {#%FieldName%#}
                    if (res != null)
                    {
                        htmlTag = new HtmlTextTag(res.GetDefinition(tag.OuterDefineText).ToString());
                        tagList.Add(htmlTag);
                    }
                }
                else if (tag.Category == TagCategory.CustomTag)
                {
                    #region 数据定义标签内包含数据定义标签
                    DbStoredCustomTag dbTag = DbStoredCustomTag.Parse(tag);
                    dbTag.SetResourceDependency(res);
                    if (dbTag.IsExist == true)
                    {
                        htmlTag = new HtmlTextTag(dbTag.GetTagValue().ToString());
                        tagList.Add(htmlTag);
                    }
                    #endregion
                }
                else if (tag.Category == TagCategory.SystemTag)
                {
                    string pageURLKey = ",FirstUrl,PreUrl,NextUrl,LastUrl,CurUrl,";
                    string tagName = tag.TagName.Trim('$');
                    if (pageURLKey.IndexOf("," + tagName + ",", StringComparison.InvariantCultureIgnoreCase) != -1)
                    {
                        tagName = tagName.ToLower();
                        PageUrl url = new PageUrl(tag.OuterDefineText);
                        url.IsAutoItem = (res != null && res.GetType() == typeof(AutoItem));
                        url.SetResourceDependency(res);
                        switch (tagName)
                        {
                            case "firsturl": url.UrlCategory = PageUrlCategory.FirstPage; break;
                            case "preurl": url.UrlCategory = PageUrlCategory.PrePage; break;
                            case "nexturl": url.UrlCategory = PageUrlCategory.NextPage; break;
                            case "lasturl": url.UrlCategory = PageUrlCategory.LastPage; break;
                            case "cururl": url.UrlCategory = PageUrlCategory.ThisPage; break;
                            default:
                                url.UrlCategory = PageUrlCategory.ThisPage;
                                break;
                        }
                        tagList.Add(url);
                    }
                    else
                    {
                        SystemTag sys = new SystemTag(tag.OuterDefineText);
                        //Util.Debug(false, res.GetType().ToString());
                        sys.SetResourceDependency(res);
                        tagList.Add(sys);
                    }
                }
                else
                {
                    tagList.Add(tag);
                }
                //Util.Debug(false, "#####\n" + tag.OuterDefineText + "\n#####");
                //TagList.Add(tag);

                idxBegin = tag.DefinedIndexEnd;
                mc = regEx.Matches(tagdef, idxBegin);
            }

            if (idxBegin < tagdef.Length)
            {
                htmlTag = new HtmlTextTag(tagdef.Substring(idxBegin));
                tagList.Add(htmlTag);
            }
        }
Exemplo n.º 24
0
        /// <summary>
        /// 获取标签的最终输出值
        /// </summary>
        public override object GetTagValue()
        {
            if (this.IsExist == true)
            {
                //OleDbHelper.AppendToFile("~/debug.log", this.Category.ToString() + Environment.NewLine + Environment.NewLine);
                //OleDbHelper.AppendToFile("~/debug.log", this.OuterDefineText + Environment.NewLine + Environment.NewLine);
                //OleDbHelper.AppendToFile("~/debug.log", this.Content + Environment.NewLine + Environment.NewLine);

                if (!ContainTags())
                {
                    return this.GetHtmlOutPut();
                }
                else
                {
                    TagBase tag = new TagBase(this.Content);
                    if (tag.Category == TagCategory.DataListTag)
                    {
                        ListTag list = ListTag.Parse(tag, this.GetResourceDependency());
                        if (list.PageSize > 0)
                        {
                            string pagedAliaContent = (string.IsNullOrEmpty(list.IDentity)) ? Guid.NewGuid().ToString() : list.IDentity;
                            SetDynamicPagedAlia(pagedAliaContent, list);
                            return pagedAliaContent;
                        }
                        else
                        {
                            return list.GetTagValue();
                        }
                    }
                    else if (tag.Category == TagCategory.PagerTag)
                    {
                        PagerTag pager = PagerTag.Parse(tag);
                        string pagerAlia = (string.IsNullOrEmpty(pager.IDentity)) ? Guid.NewGuid().ToString() : pager.IDentity;
                        SetDynamicPagerDependency(pagerAlia, pager);
                        return pagerAlia;
                    }
                    else
                    {
                        //Util.Debug(false, GetResourceDependency());
                        return TagBase.InterpretContentWithTags(GetHtmlOutPut(), GetResourceDependency());
                    }
                }
            }
            else
            {
                //OleDbHelper.AppendToFile("~/debug.log", "NULL:" + this.OuterDefineText + Environment.NewLine + Environment.NewLine);
                return null;
            }
        }
Exemplo n.º 25
0
 public static AutoItem Parse(TagBase tag)
 {
     return new AutoItem(tag.OuterDefineText);
 }
Exemplo n.º 26
0
Arquivo: ListTag.cs Projeto: vbyte/fmq
 /// <summary>
 /// 转化为列表标签
 /// </summary>
 public static ListTag Parse(TagBase tag)
 {
     return Parse(tag, null);
 }
Exemplo n.º 27
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.º 28
0
 /// <summary>
 /// 转化为列表标签
 /// </summary>
 public static ListTag Parse(TagBase tag)
 {
     return(Parse(tag, null));
 }