Ejemplo n.º 1
0
        protected void loadarticle(string id)
        {
            SiteGroupCms.Dal.ArticleDal artdal = new SiteGroupCms.Dal.ArticleDal();
            SiteGroupCms.Entity.Article art    = new SiteGroupCms.Entity.Article();
            art = artdal.GetEntity(id);
            SiteGroupCms.Dal.ArticlepicDal         artpicdal  = new SiteGroupCms.Dal.ArticlepicDal();
            SiteGroupCms.Dal.ArticleattsDal        artattsdal = new SiteGroupCms.Dal.ArticleattsDal();
            SiteGroupCms.Entity.Articlepic         artpic     = new SiteGroupCms.Entity.Articlepic();
            SiteGroupCms.Entity.Articleatts        artatts    = new SiteGroupCms.Entity.Articleatts();
            List <SiteGroupCms.Entity.Articlepic>  piclist    = artpicdal.getEntityList(id);
            List <SiteGroupCms.Entity.Articleatts> attslists  = artattsdal.getEntityList(id);
            //获取imglist和imgtitlelist
            string imglist       = "";
            string imgtitlelist  = "";
            string attslist      = "";
            string attstitlelist = "";

            for (int i = 0; i < piclist.Count; i++)
            {
                imglist      += piclist[i].Url + ",";
                imgtitlelist += piclist[i].Title + ",";
            }
            for (int i = 0; i < attslists.Count; i++)
            {
                attslist      += attslists[i].Url + ",";
                attstitlelist += attslists[i].Title + ",";
            }
            string _response = "";

            if (art != null)
            {
                string isppt       = art.Isppt == 1 ? "true" : "false";
                string isrecommend = art.Isrecommend == 1 ? "true" : "false";
                string isroll      = art.Isroll == 1 ? "true" : "false";
                string isshart     = art.Isshare == 1 ? "true" : "false";
                _response += "{\"IsError\":false,\"Message\":\"加载成功\",\"Data\":{";
                _response += "\"artid\":" + art.Id + ",\"catalogid\":" + art.Catalogid + ",\"title\":" + SiteGroupCms.Utils.fastJSON.JSON.WriteString(art.Title);
                _response += ",\"abstract\":" + SiteGroupCms.Utils.fastJSON.JSON.WriteString(art.Abstract) + ",\"addtime\":\"" + art.Addtime.ToString("yyyy-MM-dd") + "\",\"color\":\"" + art.Color + "\"";
                _response += ",\"isppt\":" + isppt + ",\"isrecommend\":" + isrecommend + ",\"isshare\":" + isshart + ",\"   isroll\":" + isroll;
                _response += ",\"keywords\":" + SiteGroupCms.Utils.fastJSON.JSON.WriteString(art.Keywords) + ",\"linkurl\":" + SiteGroupCms.Utils.fastJSON.JSON.WriteString(art.Linkurl) + ",\"source\":" + SiteGroupCms.Utils.fastJSON.JSON.WriteString(art.Source) + ",\"subtitle\":" + SiteGroupCms.Utils.fastJSON.JSON.WriteString(art.Subtitle);
                _response += ",\"imglist\":\"" + imglist + "\",\"imgtitlelist\":\"" + imgtitlelist + "\"";
                _response += ",\"attslist\":\"" + attslist + "\",\"attstitlelist\":\"" + attstitlelist + "\",\"clickcount\":" + art.Clickcount;
                _response += "}}";
            }
            Response.Write(_response);
        }
Ejemplo n.º 2
0
        public void updatearicle()
        {
            //更新article
            article.Id        = Str2Int(artid);
            article.Abstract  = abstraction;
            article.Addtime   = SiteGroupCms.Utils.Validator.StrToDate(addtime, DateTime.Now);
            article.Catalogid = Str2Int(catalogid);
            article.Siteid    = _admin.CurrentSite;
            //article.Author = _admin.UserName;
            article.Color       = color;
            article.Content     = content;
            article.Isppt       = isppt == "true" ? 1 : 0;
            article.Isrecommend = isrecommend == "true" ? 1 : 0;
            article.Isshare     = isshare == "true" ? 1 : 0;
            article.Isroll      = isroll == "true" ? 1 : 0;
            article.Keywords    = keywords;
            article.Linkurl     = linkurl;
            article.Source      = source;
            article.Subtitle    = subtitle;
            article.Title       = title;
            article.Clickcount  = clickcount;
            if (artobj.UpdateArticle(article))
            {
                _response = "{\"IsError\":false,\"Message\":\"保存成功\",\"Data\":0}";
                new SiteGroupCms.Dal.LogDal().SaveLog(28);
            }
            else
            {
                _response = "{\"IsError\":true,\"Message\":\"保存失败\",\"Data\":0}";
            }

            //插入图片库 暂时不用

            if (imglist != "")
            {
                SiteGroupCms.Dal.ArticlepicDal        picdal  = new SiteGroupCms.Dal.ArticlepicDal();
                SiteGroupCms.Entity.Articlepic        pic     = new SiteGroupCms.Entity.Articlepic();
                List <SiteGroupCms.Entity.Articlepic> piclist = picdal.getEntityList(article.Id.ToString());
                string[] imgl  = imglist.Split(',');
                string[] imgtl = imgtitlelist.Split(',');
                int[]    flag0 = new int[piclist.Count]; //用来标记是否有更改
                for (int k = 0; k < flag0.Length; k++)
                {
                    flag0[k] = 0;
                }

                for (int i = 0; i < imgl.Length - 1; i++)
                {
                    if (piclist.Count > 0)                      //包含图片时
                    {
                        for (int j = 0; j < piclist.Count; j++) //将插入的pic一一与数据库里面的对比,若存在则不改动,若不存在则插入
                        {
                            if (imgl[i] == piclist[j].Url)      //存在则直接跳出这层for语句,检查下一个需要插入的
                            {
                                flag0[j] = 1;                   //表示没有改变
                                break;
                            }
                            else   //不存在则插入
                            {
                                pic.Title = imgtl[i];
                                pic.Artid = article.Id;
                                pic.Url   = imgl[i];
                                pic.Istop = i == 1 ? 1 : 0;
                                picdal.InsertEntity(pic);
                            }
                        }
                    }
                    else//不含图片集则直接插入进去
                    {
                        pic.Title = imgtl[i];
                        pic.Artid = article.Id;
                        pic.Url   = imgl[i];
                        pic.Istop = i == 1 ? 1 : 0;
                        picdal.InsertEntity(pic);
                    }
                    //对改变了的做处理 即删除就可以了
                    for (int l = 0; l < flag0.Length; l++)
                    {
                        if (flag0[l] == 0)
                        {
                            picdal.DelEntity(piclist[l].ID);
                        }
                    }
                }
            }
            else  //如果传递进来的是空 则判断数据库是否含有 如果含有则全部删除
            {
                SiteGroupCms.Dal.ArticlepicDal        picdal  = new SiteGroupCms.Dal.ArticlepicDal();
                List <SiteGroupCms.Entity.Articlepic> piclist = picdal.getEntityList(article.Id.ToString());
                if (piclist.Count > 0)
                {
                    picdal.DelEntityByartid(article.Id);
                }
            }

            //插入附件库    对于删除附件不行  本来有 现在要全部删除 就不起作用了
            if (attslist != "")
            {
                SiteGroupCms.Dal.ArticleattsDal        attdal   = new SiteGroupCms.Dal.ArticleattsDal();
                SiteGroupCms.Entity.Articleatts        att      = new SiteGroupCms.Entity.Articleatts();
                List <SiteGroupCms.Entity.Articleatts> attlists = attdal.getEntityList(article.Id.ToString());
                string[] attl  = attslist.Split(',');
                string[] atttl = attstitlelist.Split(',');
                int[]    flag  = new int[attlists.Count]; //用来标记是否有更改
                for (int k = 0; k < flag.Length; k++)
                {
                    flag[k] = 0;
                }
                for (int i = 0; i < attl.Length - 1; i++)
                {
                    if (attlists.Count > 0)
                    {
                        for (int j = 0; j < attlists.Count; j++)
                        {
                            if (attlists[j].Url == attl[i]) //如果存在则继续
                            {
                                flag[j] = 1;                //表示没有改变
                                break;
                            }
                            else
                            {
                                att.Artid = article.Id;
                                att.Title = atttl[i];
                                att.Url   = attl[i];
                                attdal.InsertEntity(att);
                            }
                        }
                    }
                    else
                    {
                        att.Artid = article.Id;
                        att.Title = atttl[i];
                        att.Url   = attl[i];
                        attdal.InsertEntity(att);
                    }
                    //对改变了的做处理 即删除就可以了
                    for (int l = 0; l < flag.Length; l++)
                    {
                        if (flag[l] == 0)
                        {
                            attdal.DelEntity(attlists[l].ID);
                        }
                    }
                }
            }
            else  //如果传递进来的是空 则判断数据库是否含有 如果含有则全部删除
            {
                SiteGroupCms.Dal.ArticleattsDal        attdal  = new SiteGroupCms.Dal.ArticleattsDal();
                List <SiteGroupCms.Entity.Articleatts> attlist = attdal.getEntityList(article.Id.ToString());
                if (attlist.Count > 0)
                {
                    attdal.DelEntityByartid(article.Id);
                }
            }
        }