Пример #1
0
        /// <summary>
        /// 为文章表创建静态HTML页面
        /// </summary>
        /// <param name="book">书对像</param>
        /// <param name="html">要生成页面的HTML</param>
        /// <returns>页面路径</returns>
        public static string CreateStaticHTMLFile(this 文章表 doc, string html)
        {
            //susucong
            //string path = AppDomain.CurrentDomain.BaseDirectory + virtualPath + "/" + "HTML/" + doc.书名表.分类标识.Trim().ToPingYing() + "/" + doc.书名表.书名.Trim().ToPingYing() + "/";
            string path = AppDomain.CurrentDomain.BaseDirectory + "../" + "HTML/" + doc.书名表.分类标识.Trim().ToPingYing() + "/" + doc.书名表.书名.Trim().ToPingYing() + "/";

            //创建目录
            if (!System.IO.Directory.Exists(path))
            {
                System.IO.Directory.CreateDirectory(path);
            }

            path = path + +doc.ID + ".html";

            //写入文件
            try
            {
                System.IO.File.WriteAllText(path, html, System.Text.Encoding.UTF8);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message + (ex.StackTrace == null ? " " : ex.StackTrace));
            }

            return(path);
        }
Пример #2
0
        /// <summary>
        /// 返回文章文件的文件名
        /// </summary>
        /// <param name="doc"></param>
        /// <returns></returns>
        public static string GetHTMLFilePath(this 文章表 doc)
        {
            string path = virtualPath + "/HTML/" + doc.书名表.分类标识.Trim().ToPingYing() + "/" + doc.书名表.书名.Trim().ToPingYing() + "/";

            path = path + +doc.ID + ".html";


            return(path);
        }
Пример #3
0
        /// <summary>
        /// 传入一个页索引 返回对应的页对象,并对对象的同步状态进行比较 如果不同步,则同步记录状态
        /// </summary>
        /// <param name="keys"></param>
        /// <param name="book"></param>
        /// <param name="key"></param>
        /// <returns></returns>
        public static TabPageEntity GetPage(this System.Collections.Concurrent.ConcurrentBag <string> keys, TabBookEntity book, string key)
        {
            //得到指定key 的记录
            var records = tygDb.文章表.Where(p => p.GUID == Guid.Parse(key));

            if (records.Count() > 0)
            {
                文章表 record = records.FirstOrDefault();



                return(new TabPageEntity()
                {
                    Record = record,
                    Book = book,
                    Issync = true,
                    Modifyd = false
                });
            }
            else
            {
                throw new IndexOutOfRangeException("没有找到指定索引的记录");
            }
        }
Пример #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        List <文章表> list  = new List <文章表>();
        string     guid  = Request.QueryString["guid"];
        string     idstr = guid;

        bool.TryParse(Request.QueryString["html"], out IsCresteHTMLPage);
        if (!string.IsNullOrEmpty(guid))
        {
            decimal id = 0;
            if (decimal.TryParse(idstr, out id))
            {
                list = Tygdb.文章表.Where(p => p.ID == id).ToList();
            }
            else
            {
                Guid guidx = Guid.Parse(guid);

                list = Tygdb.文章表.Where(p => p.本记录GUID == guidx).ToList();
            }
            if (list.Count > 0)
            {
                BookName = list[0].书名;
                Creater  = list[0].书名表.作者名称;
                DocName  = list[0].章节名;
                Content  = list[0].内容;

                书id = list[0].GUID.ToString();

                //替换86zw url
                Content = Content.Replace("<img src=\"http://", "<img src=\"/Site/PicProxy.ashx?guid=" + list[0].本记录GUID + "&u=" + Server.UrlEncode(list[0].采集用的URL1) + "&url=http://");

                //上一章节
                var perRecords = GetDocByGuid(list[0].一章.Value);
                一章 = list[0].一章.Value.ToString();
                //下一章节
                var nextRecords = GetDocByGuid(list[0].一章.Value);
                一章 = list[0].一章.Value.ToString();
                一页 = perRecords.Count() == 0 ? "" : string.Format(href, list[0].一章, "上一章 " + perRecords.ElementAt(0).章节名);

                一页             = nextRecords.Count() == 0 ? "" : string.Format(href, list[0].一章, "下一章 " + nextRecords.ElementAt(0).章节名);
                list[0].最后访问时间 = DateTime.Now;
                list[0].总访问次数++;
                currentDoc  = list[0];
                currentBook = currentDoc.书名表;

                //生成静态页面
                if (IsCresteHTMLPage)
                {
                    href = "<a href='{0}'>{1}</a>";
                    if (perRecords.Count() > 0)
                    {
                        var per = perRecords.ElementAt(0);
                        一页 = perRecords.Count() == 0 ? "" : string.Format(href, per.GetHTMLFilePath(), "上一章 " + per.章节名);
                        一章 = per.ID + ".html";
                    }
                    else
                    {
                        一章 = "?";
                        一页 = string.Empty;
                    }
                    if (nextRecords.Count() > 0)
                    {
                        var next = nextRecords.ElementAt(0);
                        一页 = nextRecords.Count() == 0 ? "" : string.Format(href, next.GetHTMLFilePath(), "下一章 " + next.章节名);
                        一章 = next.ID + ".html";
                    }
                    else
                    {
                        一页 = "?";
                        一章 = string.Empty;
                    }
                }
            }
        }
    }