예제 #1
0
        /// <summary>
        /// 删除相册
        /// </summary>
        /// <param name="m_where"></param>
        /// <returns></returns>
        public static Result DeleteImageAlbum(string m_where)
        {
            Result r = new Result();

            try
            {
                var imgas = ImageAlbumView.GetModelList(m_where);
                foreach (var imga in imgas)
                {
                    try
                    {
                        Voodoo.IO.File.Delete(HttpContext.Current.Server.MapPath(BasePage.GetImageUrl(imga, imga.GetClass())));//删除相册HTML页面
                        DeleteImage(string.Format("AlbumID={0}", imga.ID));
                    }
                    catch { }
                }
                r.Success = true;
                r.Text    = string.Format("成功删除{0}条记录", imgas.Count);
            }
            catch (Exception ex)
            {
                r.Success = false;
                r.Text    = ex.Message;
            }

            ImageAlbumView.Del(m_where);

            return(r);
        }
예제 #2
0
        /// <summary>
        /// 获取下一个相册
        /// </summary>
        /// <param name="img"></param>
        /// <param name="cls"></param>
        /// <returns></returns>
        public static ImageAlbum GetNextImages(ImageAlbum img, Class cls)
        {
            List <ImageAlbum> lresult = ImageAlbumView.GetModelList(string.Format("classID={0} and ID>{1} order by ID Asc", cls.ID, img.ID), 1);

            if (lresult.Count == 0)
            {
                return(null);
            }
            else
            {
                return(lresult.First());
            }
        }
예제 #3
0
        /// <summary>
        /// 加载信息
        /// </summary>
        protected void LoadInfo()
        {
            ddl_Class.DataSource     = NewsAction.NewsClass.Where(p => p.IsLeafClass && p.ModelID == 2);
            ddl_Class.DataTextField  = "ClassName";
            ddl_Class.DataValueField = "ID";
            ddl_Class.DataBind();

            ddl_Class.SelectedValue = cls.ToS();

            ddl_Author.DataSource     = SysUserView.GetModelList();
            ddl_Author.DataTextField  = "UserName";
            ddl_Author.DataValueField = "ID";
            ddl_Author.DataBind();

            ImageAlbum imga = ImageAlbumView.GetModelByID(id.ToS());

            //txt_Title.Text = imga.Title;
            //ddl_Author.SelectedValue = imga.AuthorID.ToS();
            //txt_Folder.Text = imga.Folder;
            //txt_Keyword.Text=imga.

            if (id > 0)
            {
                ddl_Class.SelectedValue = imga.ClassID.ToS();
                txt_Title.Text          = imga.Title;
                ddl_Author.Text         = imga.AuthorID.ToS();
                //txt_Folder.Text = imga.Folder;
                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 = ImagesView.GetModelList(string.Format("AlbumID={0} order by id", imga.ID));
                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));
            }
        }
예제 #4
0
        /// <summary>
        /// 获取列表页面的页数
        /// </summary>
        /// <param name="id"></param>
        protected void GetClassPageCount(int id)
        {
            Class c = ClassView.GetModelByID(id.ToS());
            TemplateList t = TemplateListView.Find(string.Format("SysModel={0}", c.ModelID.ToS()));

            int pagecount = 0;
            switch (c.ModelID)
            {
                case 1:
                    //新闻
                    pagecount = NewsView.Count(string.Format("classid in(select {0} union select id from Class where parentID={0})", id)).GetPageCount(t.ShowRecordCount);
                    break;
                case 2:
                    //图片
                    pagecount = ImageAlbumView.Count(string.Format("classid in(select {0} union select id from Class where parentID={0})", id)).GetPageCount(t.ShowRecordCount);
                    break;
                case 3:
                    //问答
                    pagecount = QuestionView.Count(string.Format("classid in(select {0} union select id from Class where parentID={0})", id)).GetPageCount(t.ShowRecordCount);
                    break;
                case 4:
                    //小说
                    pagecount = BookView.Count(string.Format("classid in(select {0} union select id from Class where parentID={0})", id)).GetPageCount(t.ShowRecordCount);
                    break;
                case 5:
                    //分类
                    pagecount = InfoView.Count(string.Format("classid in(select {0} union select id from Class where parentID={0})", id)).GetPageCount(t.ShowRecordCount);
                    break;
                case 6:
                    //影视
                    pagecount = MovieInfoView.Count(string.Format("classid in(select {0} union select id from Class where parentID={0})", id)).GetPageCount(t.ShowRecordCount);
                    break;
                default:
                    pagecount = 0;
                    break;
            }

            Response.Clear();
            Response.Write(pagecount);
        }
예제 #5
0
        protected void btn_Content_Click(object sender, EventArgs e)
        {
            Response.Buffer = false;
            Js.ScrollEnd();
            var newses = NewsView.GetModelList();

            newses = newses.Where(p => p.Audit).ToList();
            foreach (var n in newses)
            {
                Response.Write(string.Format("正在生成内容页:{0}<br/>", n.Title));
                try
                {
                    CreatePage.CreateContentPage(n, NewsView.GetNewsClass(n));
                }
                catch (Exception ex)
                {
                    Response.Write(string.Format("{0}<br/>", ex.Message));
                }
            }

            var imgs = ImageAlbumView.GetModelList();

            foreach (var img in imgs)
            {
                try
                {
                    Response.Write(string.Format("正在生成内容页:{0}<br/>", img.Title));
                    CreatePage.CreateContentPage(img, img.GetClass());
                }
                catch (Exception ex)
                {
                    Response.Write(string.Format("{0}<br/>", ex.Message));
                }
            }

            var ques = QuestionView.GetModelList();

            foreach (var q in ques)
            {
                try
                {
                    Response.Write(string.Format("正在生成内容页:{0}<br/>", q.Title));
                    CreatePage.CreateContentPage(q, q.GetClass());
                }
                catch (Exception ex)
                {
                    Response.Write(string.Format("{0}<br/>", ex.Message));
                }
            }

            var books = BookView.GetModelList();

            foreach (var b in books)
            {
                try
                {
                    Response.Write(string.Format("正在生成内容页:{0}<br/>", b.Title));
                    CreatePage.CreateContentPage(b, BookView.GetClass(b));
                    Js.ScrollEndStart();
                }
                catch (Exception ex)
                {
                    Response.Write(string.Format("{0}<br/>", ex.Message));
                }
            }

            //try
            //{
            //    var movies = MovieInfoView.GetModelList();
            //    foreach (var m in movies)
            //    {
            //        try
            //        {
            //            Response.Write(string.Format("正在生成内容页:{0}<br/>", m.Title));
            //            CreatePage.CreateContentPage(m, MovieInfoView.GetClass(m));
            //            Js.ScrollEnd();
            //        }
            //        catch (Exception ex)
            //        {
            //            Response.Write(string.Format("{0}<br/>", ex.Message));
            //        }
            //    }
            //}
            //catch { }

            Js.AlertAndGoback("成功!");
        }
예제 #6
0
        /// <summary>
        /// 上传图片
        /// </summary>
        /// <param name="file"></param>
        /// <param name="ClassID"></param>
        /// <returns></returns>
        public static Result UpLoadImage(HttpPostedFile file, int ImageAlbumID)
        {
            Result     r  = new Result();
            SysSetting ss = BasePage.SystemSetting;

            string FileName = file.FileName.GetFileNameFromPath().ToLower();    //文件名
            string ExtName  = file.FileName.GetFileExtNameFromPath().ToLower(); //扩展名
            string NewName  = @string.GetGuid() + ExtName;                      //新文件名

            if (!ExtName.Replace(".", "").IsInArray(ss.FileExtNameFilter.Split(',')))
            {
                r.Success = false;
                r.Text    = "不允许上传此类文件";
                return(r);
            }
            if (file.ContentLength > ss.MaxPostFileSize)
            {
                r.Success = false;
                r.Text    = "文件太大";
                return(r);
            }

            string Folder        = ss.FileDir + "/" + DateTime.Now.ToString("yyyy-MM-dd") + "/"; //文件目录
            string FolderShotCut = Folder + "ShortCut/";                                         //缩略图目录

            string FilePath          = Folder + NewName;                                         //文件路径
            string FilePath_ShortCut = FolderShotCut + NewName;                                  //缩略图路径

            file.SaveAs(System.Web.HttpContext.Current.Server.MapPath(FilePath), true);


            if (ExtName.ToLower().Replace(".", "").IsInArray("jpg,jpeg,png,gif,bmp".Split(',')))
            {
                ImageHelper.MakeThumbnail(System.Web.HttpContext.Current.Server.MapPath(FilePath), System.Web.HttpContext.Current.Server.MapPath(FilePath_ShortCut), 105, 118, "Cut");
            }

            ImageAlbum album = ImageAlbumView.GetModelByID(ImageAlbumID.ToS());

            Images img = new Images();

            img.AlbumID    = album.ID;
            img.ClickCount = 0;
            img.ExtName    = ExtName;
            img.FilePath   = FilePath;
            img.FileSize   = file.ContentLength;
            img.Intro      = "";
            img.ReplyCount = 0;
            img.SmallPath  = FilePath_ShortCut;
            img.Title      = "";
            img.UploadTime = DateTime.Now;
            ImagesView.Insert(img);

            ImageAlbum imga = ImageAlbumView.GetModelByID(ImageAlbumID.ToString());

            imga.Size = ImagesView.Count(string.Format("AlbumID={0}", imga.ID));
            ImageAlbumView.Update(imga);

            r.Success = true;
            r.Text    = FilePath;
            return(r);
        }
예제 #7
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btn_Save_Click(object sender, EventArgs e)
        {
            Class cls = ClassView.GetModelByID(ddl_Class.SelectedValue);

            ImageAlbum imga = ImageAlbumView.GetModelByID(WS.RequestString("id"));

            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 (imga.ID > 0)
            {
                ImageAlbumView.Update(imga);
            }
            else
            {
                ImageAlbumView.Insert(imga);
            }

            //保存单个图片设置
            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));

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

            //生成页面

            CreatePage.CreateContentPage(imga, cls);

            ImageAlbum pre = GetPreImage(imga, cls);

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


            Js.AlertAndChangUrl("保存成功!", url);
        }