Beispiel #1
0
        /// <summary>
        /// 生成内容页--图片
        /// </summary>
        /// <param name="album"></param>
        /// <param name="cls"></param>
        public string CreateContentPage(ImageAlbum album, Class cls)
        {
            DataEntities ent = new DataEntities();

            TemplateContent temp = GetContentTemplate(cls);
            string Content = temp.Content;

            Content = ReplacePublicTemplate(Content);
            Content = ReplacePublicTemplate(Content);
            Content = ReplacePublicTemplate(Content);

            Content = ReplaceSystemSetting(Content);

            #region 替换内容

            Content = Content.Replace("[!--class.id--]", cls.ID.ToString());
            Content = Content.Replace("[!--class.name--]", cls.ClassName);

            Content = ReplaceContent(Content, album, cls);

            List<Images> imgs = (from l in ent.Images where l.AlbumID == album.ID select l).ToList();
            StringBuilder sb = new StringBuilder();
            sb.AppendLine("<ul>");
            foreach (Images img in imgs)
            {
                string Description = img.Intro;
                if (Description.IsNullOrEmpty())
                {
                    Description = album.Intro;
                }
                if (Description.IsNullOrEmpty())
                {
                    Description = img.Title;
                }
                if (Description.IsNullOrEmpty())
                {
                    Description = album.Title;
                }
                sb.AppendLine(string.Format("<li><a rel=\"example_group\" href=\"{0}\" title=\"{1}\"><img src=\"{2}\" /><br/>{3}</a></li>",
                    img.FilePath,
                    Description,
                    img.SmallPath,
                    img.Title.IsNullOrEmpty() ? album.Title.CutString(6) : img.Title.CutString(6)
                    ));
            }
            sb.AppendLine("</ul>");

            Content = Content.Replace("[!--image.content--]", sb.ToS());
            #endregion

            Content = ReplaceTagContent(Content);

            #region 上一篇  下一篇 链接
            ImageAlbum news_pre = BasePage.GetPreImage(album, cls);
            ImageAlbum news_next = BasePage.GetNextImages(album, cls);

            //上一篇
            string pre_link = "<a href=\"javascript:void(0)\">没有了</a>";
            if (news_pre != null)
            {
                pre_link = string.Format("<a href=\"{0}\">{1}</a>", BasePage.GetImageUrl(news_pre, cls), news_pre.Title);
            }
            Content = Content.Replace("[!--news.prelink--]", pre_link);

            //下一篇
            string next_link = "<a href=\"javascript:void(0)\">没有了</a>";
            if (news_next != null)
            {
                next_link = string.Format("<a href=\"{0}\">{1}</a>", BasePage.GetImageUrl(news_next, cls), news_next.Title);
            }
            Content = Content.Replace("[!--news.nextlink--]", next_link);

            #endregion

            //替换导航条
            Content = Content.Replace("[!--newsnav--]", BuildClassNavString(cls));

            ent.Dispose();
            return Content;
        }
Beispiel #2
0
 public string ReplaceContent(string TempString, ImageAlbum n, Class c)
 {
     return ReplaceContent(new TemplateList() { TimeFormat = "yyyy-MM-dd HH:mm:ss", CutTitle = 0 }, TempString, n, c);
 }
Beispiel #3
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btn_Save_Click(object sender, EventArgs e)
        {
            Class cls = ClassAction.Classes.Where(p => p.ID.ToString() == ddl_Class.SelectedValue).FirstOrDefault();
            DataEntities ent = new DataEntities();

            int id=WS.RequestInt("id");
            var images = from l in ent.ImageAlbum where l.ID == id select l;
            ImageAlbum imga =new ImageAlbum();
            if(images.Count()>0)
            {
                imga=images.FirstOrDefault();
            }
            imga.ClassID = ddl_Class.SelectedValue.ToInt32();
            imga.Title = txt_Title.Text.TrimDbDangerousChar();
            imga.AuthorID = ddl_Author.SelectedValue.ToInt32();
            imga.Author = ddl_Author.SelectedItem.Text;
            imga.ClickCount = txt_ClickCount.Text.ToInt32(0);
            if (imga.ID <= 0)
            {
                imga.CreateTime = DateTime.Now;
                imga.Folder = DateTime.Now.ToString("yyyy-MM-dd");
            }
            imga.Intro = txt_Intro.Text.TrimDbDangerousChar();
            imga.KeyWords = txt_Keyword.Text.TrimDbDangerousChar();
            imga.ReplyCount = txt_ReplyCount.Text.ToInt32(0);
            imga.SetTop = false;
            //imga.ShotCut = "";
            //imga.Size = 0;
            imga.Title = txt_Title.Text;
            imga.UpdateTime = DateTime.Now;
            imga.ZtID = 0;

            if (images.Count()==0)
            {
                ent.AddToImageAlbum(imga);
                ent.SaveChanges();
            }

            //保存单个图片设置
            string[] t**s = WS.RequestString("tit[]").Split(',');
            string[] intrs = WS.RequestString("intro[]").Split(',');

            var imgs = //ImagesView.GetModelList(string.Format("AlbumID={0} order by id", imga.ID));
                (from l in ent.Images where l.AlbumID==imga.ID select l).ToList();

            for (int i = 0; i < imgs.Count; i++)
            {
                try
                {
                    imgs[i].Title = t**s[i].ToS();
                    imgs[i].Intro = intrs[i].ToS();
                }
                catch { }

            }

            ent.SaveChanges();

            //生成页面

            CreatePage.CreateContentPage(imga, cls);

            ImageAlbum pre = GetPreImage(imga, cls);
            if (pre != null)
            {
                CreatePage.CreateContentPage(pre, cls);
            }
            CreatePage.CreateListPage(cls, 1);

            Js.AlertAndChangUrl("保存成功!", url);
        }
Beispiel #4
0
        /// <summary>
        /// 替换图片
        /// </summary>
        /// <param name="TempString"></param>
        /// <param name="n"></param>
        /// <param name="c"></param>
        /// <returns></returns>
        public string ReplaceContent(TemplateList temp, string TempString, ImageAlbum n, Class c)
        {
            string r = TempString;

            r = r.Replace("[!--image.author--]", n.Author);
            r = r.Replace("[!--image.authorid--]", n.AuthorID.ToS());
            r = r.Replace("[!--image.classid--]", n.ClassID.ToS());
            r = r.Replace("[!--image.clickcount--]", n.ClickCount.ToS());
            r = r.Replace("[!--image.createtime--]", n.CreateTime.ToDateTime().ToString(temp.TimeFormat));
            r = r.Replace("[!--image.folder--]", n.Folder);
            r = r.Replace("[!--image.id--]", n.ID.ToS());
            r = r.Replace("[!--image.intro--]", n.Intro);
            r = r.Replace("[!--image.replycount--]", n.ReplyCount.ToS());
            r = r.Replace("[!--image.size--]", n.Size.ToS());
            r = r.Replace("[!--image.title--]", n.Title);
            r = r.Replace("[!--image.updatetime--]", n.UpdateTime.ToDateTime().ToString(temp.TimeFormat));
            r = r.Replace("[!--image.ztid--]", n.ZtID.ToS());
            r = r.Replace("[!--image.url--]", BasePage.GetImageUrl(n, c));

            return r;
        }
Beispiel #5
0
        /// <summary>
        /// 加载信息
        /// </summary>
        protected void LoadInfo()
        {
            using (DataEntities ent = new DataEntities())
            {

                ddl_Class.DataSource = ClassAction.Classes.Where(p => p.IsLeafClass == true && p.ModelID == 2);
                ddl_Class.DataTextField = "ClassName";
                ddl_Class.DataValueField = "ID";
                ddl_Class.DataBind();

                ddl_Class.SelectedValue = cls.ToS();

                ddl_Author.DataSource = from l in ent.SysUser select l;
                ddl_Author.DataTextField = "UserName";
                ddl_Author.DataValueField = "ID";
                ddl_Author.DataBind();

                var images=(from l in ent.ImageAlbum where l.ID==id select l).ToList();
                ImageAlbum imga = new ImageAlbum();
                if (images.Count > 0)
                {
                    imga = images.FirstOrDefault();
                }

                if (images.Count  > 0)
                {

                    ddl_Class.SelectedValue = imga.ClassID.ToS();
                    txt_Title.Text = imga.Title;
                    ddl_Author.Text = imga.AuthorID.ToS();
                    txt_Keyword.Text = imga.KeyWords;
                    txt_ClickCount.Text = imga.ClickCount.ToS();
                    txt_ReplyCount.Text = imga.ClickCount.ToS();
                    txt_Intro.Text = imga.Intro;

                    rp_list.DataSource = from l in ent.Images where l.AlbumID == id select l;
                    rp_list.DataBind();
                }
                else
                {
                    //ImageAlbumView.Del("AuthorID=0 and CreateTime<'" + DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd") + "'");
                    //imga = new ImageAlbum() { ClassID = cls, ClickCount = 0, ReplyCount = 0, ZtID = 0, CreateTime = DateTime.Now, AuthorID = 0, UpdateTime = DateTime.Now };
                    //ImageAlbumView.Insert(imga);
                    Response.Redirect(string.Format("ImageEdit.aspx?class={0}&id={1}", cls, imga.ID));

                }
            }
        }