protected void Page_Load(object sender, EventArgs e) { wid = GetCurWebId(); if (string.IsNullOrEmpty(wid)) { return; } this.ReUrl = Globals.RequestQueryStr("reurl"); if (string.IsNullOrEmpty(this.ReUrl)) { this.ReUrl = "articles.aspx"; } int.TryParse(Globals.RequestQueryStr("id"), out this.MaterialID); if (!(Globals.RequestQueryStr("cmd") == "add")) { if (this.MaterialID > 0) { this.htmlOperName = "编辑"; ArticleInfo articleInfo = ArticleHelper.GetArticleInfo(this.MaterialID); if (articleInfo != null) { if (articleInfo.ArticleType == ArticleType.News) { base.Response.Redirect("articlesedit.aspx?id=" + this.MaterialID); base.Response.End(); } else { IList <ArticleItemsInfo> itemsInfo = articleInfo.ItemsInfo; ArticleItemsInfo item = new ArticleItemsInfo { ArticleId = this.MaterialID, Title = articleInfo.Title, ImageUrl = articleInfo.ImageUrl, Url = articleInfo.Url, Content = articleInfo.Content, LinkType = articleInfo.LinkType, Id = 0 }; itemsInfo.Insert(0, item); this.htmlLinkType = ((int)articleInfo.LinkType).ToString(); if (this.htmlLinkType != "1") { this.htmlAddJs = "$('#divContent').hide();$('#urlData').show();"; } this.htmlLinkTypeName = articleInfo.LinkType.ToShowText(); List <ArticleList> list5 = new List <ArticleList>(); int num3 = 1; foreach (ArticleItemsInfo info5 in itemsInfo) { ArticleList list6 = new ArticleList { Id = info5.Id, Title = info5.Title, Url = info5.Url, ImageUrl = info5.ImageUrl, Content = info5.Content }; list6.BoxId = num3++.ToString(); list6.LinkType = info5.LinkType; list6.Status = ""; list5.Add(list6); } this.articleJson = JsonConvert.SerializeObject(list5); } } } else { this.articleJson = "''"; } } else { base.Response.ContentType = "application/json"; string str2 = Globals.RequestFormStr("MultiArticle"); string s = "{\"type\":\"0\",\"tips\":\"操作失败\"}"; List <ArticleList> list = JsonConvert.DeserializeObject <List <ArticleList> >(str2); if ((list != null) && (list.Count > 0)) { int num = 0; ArticleInfo article = new ArticleInfo(); List <ArticleItemsInfo> list2 = new List <ArticleItemsInfo>(); DateTime now = DateTime.Now; string str4 = string.Empty; foreach (ArticleList list3 in list) { if (list3.Title == "") { str4 = "标题不能为空!"; break; } if (list3.ImageUrl == "") { str4 = "请选择一张封面!"; break; } if ((list3.LinkType == LinkType.ArticleDetail) && (list3.Content == "")) { str4 = "请输入内容!"; break; } if ((list3.LinkType != LinkType.ArticleDetail) && (list3.Url == "")) { str4 = "请选择或输入自定义链接!"; break; } if (list3.Status != "del") { if (num == 0) { article.Title = list3.Title; article.ArticleType = ArticleType.List; article.Content = list3.Content; article.ImageUrl = list3.ImageUrl; article.Url = list3.Url; article.LinkType = list3.LinkType; article.Memo = ""; article.ArticleId = this.MaterialID; article.PubTime = now; article.wid = this.wid; num++; } else { ArticleItemsInfo info2 = list3; info2.PubTime = now; list2.Add(info2); num++; } } } if (!string.IsNullOrEmpty(str4)) { s = "{\"type\":\"0\",\"tips\":\"" + str4 + "\"}"; base.Response.Write(s); base.Response.End(); } article.ItemsInfo = list2; if (article.ArticleId > 0) { if (ArticleHelper.UpdateMultiArticle(article)) { s = "{\"type\":\"1\",\"id\":\"" + article.ArticleId + "\",\"tips\":\"多图素材修改成功!\"}"; } } else { int num2 = ArticleHelper.AddMultiArticle(article); if (num2 > 0) { s = "{\"type\":\"1\",\"id\":\"" + num2 + "\",\"tips\":\"多图素材新增成功!\"}"; } } base.Response.Write(s); base.Response.End(); } } }
protected void Page_Load(object sender, System.EventArgs e) { this.ReUrl = Globals.RequestQueryStr("reurl"); if (string.IsNullOrEmpty(this.ReUrl)) { this.ReUrl = "articles.aspx"; } int.TryParse(Globals.RequestQueryStr("id"), out this.MaterialID); string a = Globals.RequestQueryStr("cmd"); if (a == "add") { base.Response.ContentType = "application/json"; string value = Globals.RequestFormStr("MultiArticle"); string s = "{\"type\":\"0\",\"tips\":\"操作失败\"}"; System.Collections.Generic.List <ArticleList> list = JsonConvert.DeserializeObject <System.Collections.Generic.List <ArticleList> >(value); if (list != null && list.Count > 0) { int num = 0; ArticleInfo articleInfo = new ArticleInfo(); System.Collections.Generic.List <ArticleItemsInfo> list2 = new System.Collections.Generic.List <ArticleItemsInfo>(); System.DateTime now = System.DateTime.Now; string text = string.Empty; foreach (ArticleList current in list) { if (current.Title == "") { text = "标题不能为空!"; break; } if (current.ImageUrl == "") { text = "请选择一张封面!"; break; } if (current.LinkType == LinkType.ArticleDetail && current.Content == "") { text = "请输入内容!"; break; } if (current.LinkType != LinkType.ArticleDetail && current.Url == "") { text = "请选择或输入自定义链接!"; break; } if (current.Status != "del") { if (num == 0) { articleInfo.Title = current.Title; articleInfo.ArticleType = ArticleType.List; articleInfo.Content = current.Content; articleInfo.ImageUrl = current.ImageUrl; articleInfo.Url = current.Url; articleInfo.LinkType = current.LinkType; articleInfo.Memo = ""; articleInfo.ArticleId = this.MaterialID; articleInfo.PubTime = now; articleInfo.IsShare = current.IsShare; num++; } else { ArticleItemsInfo articleItemsInfo = current; articleItemsInfo.PubTime = now; list2.Add(articleItemsInfo); num++; } } } if (!string.IsNullOrEmpty(text)) { s = "{\"type\":\"0\",\"tips\":\"" + text + "\"}"; base.Response.Write(s); base.Response.End(); } articleInfo.ItemsInfo = list2; if (articleInfo.ArticleId > 0) { bool flag = ArticleHelper.UpdateMultiArticle(articleInfo); if (flag) { s = "{\"type\":\"1\",\"id\":\"" + articleInfo.ArticleId + "\",\"tips\":\"多图素材修改成功!\"}"; } } else { int num2 = ArticleHelper.AddMultiArticle(articleInfo); if (num2 > 0) { s = "{\"type\":\"1\",\"id\":\"" + num2 + "\",\"tips\":\"多图素材新增成功!\"}"; } } base.Response.Write(s); base.Response.End(); return; } } else if (this.MaterialID > 0) { this.htmlOperName = "编辑"; ArticleInfo articleInfo2 = ArticleHelper.GetArticleInfo(this.MaterialID); if (articleInfo2 != null) { if (articleInfo2.ArticleType == ArticleType.News) { base.Response.Redirect("articlesedit.aspx?id=" + this.MaterialID); base.Response.End(); return; } System.Collections.Generic.IList <ArticleItemsInfo> itemsInfo = articleInfo2.ItemsInfo; itemsInfo.Insert(0, new ArticleItemsInfo { ArticleId = this.MaterialID, Title = articleInfo2.Title, ImageUrl = articleInfo2.ImageUrl, Url = articleInfo2.Url, Content = articleInfo2.Content, LinkType = articleInfo2.LinkType, Id = 0, IsShare = articleInfo2.IsShare }); this.IsShare.Checked = articleInfo2.IsShare; this.htmlLinkType = ((int)articleInfo2.LinkType).ToString(); if (this.htmlLinkType != "1") { this.htmlAddJs = "$('#urlData').show();"; } this.htmlLinkTypeName = articleInfo2.LinkType.ToShowText(); System.Collections.Generic.List <ArticleList> list3 = new System.Collections.Generic.List <ArticleList>(); int num3 = 1; foreach (ArticleItemsInfo current2 in itemsInfo) { list3.Add(new ArticleList { Id = current2.Id, Title = current2.Title, Url = current2.Url, ImageUrl = current2.ImageUrl, Content = current2.Content, BoxId = num3++.ToString(), LinkType = current2.LinkType, Status = "", IsShare = current2.IsShare }); } this.articleJson = JsonConvert.SerializeObject(list3); return; } } else { this.articleJson = "''"; } }