Exemple #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //每次页面回发触发
            if (navid != "")
            {
                nav = service.GetDetail(navid);
                if (nav != null)
                {
                    var children = service.GetSortedListByParentId(nav.NavId.ToString());
                    if (children.Count > 0)
                    {
                        //第一个子栏目--媒体报道
                        firstChild = children[0];
                    }
                    if (children.Count > 1)
                    {
                        //第二个子栏目--公司动态
                        secondChild = children[1];
                    }
                }

                var list = tagService.GetInformationsByTagCode(news_joyvio);
                joyVio = list.ElementAtOrDefault(0);
            }

            if (!IsPostBack)
            {
                bindInformation();
            }
        }
Exemple #2
0
 protected string GetCoverImage(Information info)
 {
     var attach = infoService.GetDetailIncludeAll(info.InfoId.ToString()).Attachments.ElementAtOrDefault(0);
     if (attach != null)
     {
         return infoService.GetCoverPath(attach.SourceUrl);
     }
     return "";
 }
Exemple #3
0
        public int AddInformation(
            string title,
            string subtitle,
            string source,
            string author,
            string adder,
            string summary,
            string content,
            string referenceUrl,
            bool isTop,
            IList<string> keywords,
            IList<string> navidlist,
            DateTime publishTime,
            string resourcePath
            )
        {
            using (var context = new WSI.DataAccess.WSICmsContext())
            {
                Information info = new Information();

                info.Title = title;
                info.SubTitle = subtitle;
                info.Source = source;
                info.Author = author;
                info.Adder = adder;
                info.Summary = summary;
                info.Content = content;
                info.ReferenceUrl = referenceUrl;
                info.IsTop = isTop;
                info.PublishTime = publishTime;
                info.ResourcePath = resourcePath;

                //默认字段
                info.CreateTime = DateTime.Now;
                info.UpdateTime = DateTime.Now;
                info.State = (int)EnumHelper.State.Disable;//默认禁用,因为还要在列表页添加附件和预览

                //关键字
                setKeyWords(context, info, keywords);

                //所属栏目
                setNavigation(context, info, navidlist);

                context.Informations.Add(info);

                context.LogChangesDuringSave = true;
                return context.SaveChanges();
            }
        }
Exemple #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (infoid != "")
            {
                info = service.GetDetailIncludeAll(infoid);
            }
            if (navid != null)
            {
                nav = navService.GetDetail(navid);
                prev = service.GetPrevRecord(infoid, navid);
                next = service.GetNextRecord(infoid, navid);
            }
            if (!IsPostBack)
            {

            }
        }
Exemple #5
0
 protected FrontendNavigation GetDefaultNavigation(Information info)
 {
     return info.NavigationList.ElementAtOrDefault(0);
 }
Exemple #6
0
 //设置新闻的所属栏目
 private void setNavigation(WSI.DataAccess.WSICmsContext context, Information info, IList<string> idlist)
 {
     //初始化
     info.NavigationList = new List<FrontendNavigation>();
     foreach (var navid in idlist)
     {
         Guid id;
         if (Guid.TryParse(navid, out id))
         {
             FrontendNavigation nav = context.FrontendNavigations.Find(id);
             if (nav != null)
             {
                 info.NavigationList.Add(nav);
             }
         }
     }
 }
Exemple #7
0
 //设置新闻的关键字
 private void setKeyWords(WSI.DataAccess.WSICmsContext context, Information info, IList<string> keywords)
 {
     //添加时初始化列表,修改时删除所有关键字关联重新添加
     info.KeyWords = new List<KeyWord>();
     foreach (var key in keywords)
     {
         if (key != "")
         {
             KeyWord keyword = context.KeyWords.SingleOrDefault(k => k.Content == key);
             //如果关键字已存在
             if (keyword != null)
             {
                 info.KeyWords.Add(keyword);
             }
             else
             {
                 //只需要直接将关键字添加到新闻的关键字字段中
                 info.KeyWords.Add(new KeyWord()
                 {
                     Content = key,
                     CreateTime = DateTime.Now
                 });
             }
         }
     }
 }
Exemple #8
0
        public int ChageState(Information info, int state)
        {
            using (var context = new WSI.DataAccess.WSICmsContext())
            {
                context.Informations.Attach(info);
                info.State = state;

                context.LogChangesDuringSave = true;
                return context.SaveChanges();
            }
        }