private void SaveOrder(HttpContext context) { int value = base.GetIntParam(context, "Value", false).Value; if (value > 0) { int value2 = base.GetIntParam(context, "CategroyId", false).Value; try { ArticleHelper.SwapArticleCategorySequence(value2, value); base.ReturnSuccessResult(context, "保存排序成功!", 0, true); } catch (Exception) { throw new HidistroAshxException("修改排序失败!未知错误!"); } return; } throw new HidistroAshxException("错误的参数"); }
public override DataRow Get(PanelContext data) { DataRow row = null; if (data.DataKey["ID"] != null) { Article article = ArticleHelper.GetArticle(data.DataKey["ID"].ToString()); if (article != null && !String.IsNullOrEmpty(article.ModelXml)) { DataSet ds = CreateDataSet(data.Model); ReadXml(ds, article.ModelXml); row = ds.Tables[0].Rows.Count > 0 ? ds.Tables[0].Rows[0] : null; if (row != null) { row[OBJECTCOLUMN] = article; } } } return(row); }
/// <summary> /// 构建当前位置导航 /// </summary> /// <returns></returns> string BuildPagePath() { string pos = "<a href='/admin/' target='_parent'>开始</a> > <a href='../AddIns/Articlelist.aspx?notiframe=1'>文章</a> > <a href={0}>{1}</a> > {2}"; string channelName = ""; string article = "发布文章"; Channel ch = ChannelHelper.GetChannel(OwnerID, null); if (ch != null) { channelName = ch.Name; if (ArticleID != null) { string url = "#"; string title = ""; string editArticle = " 编辑信息“ <a href={0} target=_blank>{1}</a>”"; Article a = ArticleHelper.GetArticle(ArticleID); if (a != null) { if (a.Title.Length < 10) { title = a.Title; } else { title = a.Title.Substring(0, 5) + "…" + a.Title.Substring(a.Title.Length - 5); } url = a.GetFullUrlWithChannel(ch.FullUrl); article = string.Format(editArticle, url, title); } } string url2 = "../AddIns/ArticleList.aspx?oid=" + OwnerID; if (MasterPageIs == MasterPageMode.FullMenu) { url2 = "../AddIns/ArticleList.aspx?notiframe=1&oid=" + OwnerID; } return(string.Format(pos, url2, "[栏目]" + channelName, article)); } return(""); }
protected void Page_Load(object sender, EventArgs e) { string temTitle = "物理系"; if (Request.QueryString["type"] != "本科生教育") { Response.Redirect("index.aspx"); } if (Request.QueryString["item"] != null) { temTitle = Request.QueryString["item"]; } // 绑定院系名称标签 lbdepartment.Text = temTitle.Replace('<', ' ').Replace('>', ' ').Replace('"', ' '); lbenglishDepart.Text = ArticleHelper.GetEnglishItems(temTitle); // 显示所选院系对应的Panel switch (temTitle) { case "物理系": Panel1.Visible = true; break; case "电子工程系": Panel2.Visible = true; break; case "计算机科学与技术系": Panel3.Visible = true; break; case "海洋技术系": Panel4.Visible = true; break; default: Response.Redirect("index.aspx"); break; } }
/// <summary> /// 处理流转 /// </summary> void HandleProcessAction() { ProcessAction action = ProcessAction.Next; if (ActionTextBox.Text != "") { action = (ProcessAction)int.Parse(ActionTextBox.Text); } Object oldObject = null; bool dataSuccess = true; if (!IsAdivice) { oldObject = ArticleHelper.GetArticle(ObjectID); Article oa = new Article(); oa = (Article)oldObject; action = UpdateArticleProcessState(action, oa); Article a = ArticleHelper.GetArticle(ObjectID); dataSuccess = TransferSitesFlow(action, a); } else { oldObject = AdviceHelper.GetAdvice(ObjectID); Advice a = new Advice(); a = (Advice)oldObject; UpdateAdviceProcessState(action, a); dataSuccess = true; } if (!dataSuccess) { RollBackProcessState(oldObject); Messages.ShowError("无法完成操作!跨站数据传递时出现错误。"); } else { Messages.ShowMessage("您的操作已成功执行!"); SignPanelDiv.Visible = false; ProcessHistoryList1.Binding(); } }
public async Task <NewArticleResultSet> NewArticles(NewArticleRequestParameters requestParameters) { if (requestParameters == null) { throw new ArgumentNullException(nameof(requestParameters)); } if (requestParameters.Limit <= 0 || requestParameters.Limit > 100) { throw new ArgumentOutOfRangeException(nameof(requestParameters.Limit), "Minimum limit is 1 and maximum is 100."); } if (requestParameters.MinArticleQuality <= 0 || requestParameters.MinArticleQuality > 99) { throw new ArgumentOutOfRangeException(nameof(requestParameters.MinArticleQuality), "Minimal value of article quality. Ranges from 0 to 99."); } var json = await ArticleRequest(ArticleEndpoint.NewArticles, () => ArticleHelper.GetNewArticleParameters(requestParameters)); return(JsonHelper.Deserialize <NewArticleResultSet>(json)); }
protected void BindData() { Article article = ArticleHelper.GetArticle(ArticleID); if (!String.IsNullOrEmpty(article.Photos)) { string[] ss = article.Photos.Split('|'); for (int i = 0; i < ss.Length; i++) { string s = ss[i]; ss[i] = s.Substring(0, s.LastIndexOf(".")) + "_S" + s.Substring(s.LastIndexOf(".")); } dlstPhotos.DataSource = ss; dlstPhotos.DataBind(); } else { dlstPhotos.DataSource = null; } dlstPhotos.DataBind(); }
private void ShowArticleInfo(int nArticleID) { ArticleHelper ah = new ArticleHelper(); Article art = ah.getArticle(nArticleID); lblTitle.Text = art.Titles.OrderBy(t => t.Language).Select(t => t.Title1).FirstOrDefault(); lblAbstraction.Text = art.Abstractions.OrderBy(a => a.Language).Select(a => a.Abstract).FirstOrDefault(); ltrlKeyWords.Text = makeKeyWordLink(art.KeyWords.Select(k => k.KeyWord1).ToList <string>()); lblAuthors.Text = makeAuthorLink(art.Authors.Select(a => a).ToList <Author>()); ltrlCategory.Text = makeCategoryLink(art.Classification1); ah.addVisitCount(nArticleID); //test LibraryDataContext lib = new LibraryDataContext(); var rply = from r in lib.Replays where r.ArticleID == nArticleID select r; Response.Write(rply.Count().ToString()); }
void GetArticlesByOccurrenceAsyncTest_ReturnsListOfFilteredArticles(string title, string userName, string category) { var articles = ArticleHelper.GetTestArticles(); var article = new Article { UserName = "******", Title = "Car", Category = Categories.Amusement, Content = "Volvo", CreatedDate = DateTime.Now }; _mockRepository.Setup(rep => rep.GetAll()).ReturnsAsync(articles); var result = _articleService.GetArticlesByOccurrenceAsync(title, userName, category).Result.FirstOrDefault(); Assert.Equal(article.Category, result.Category); Assert.Equal(article.UserName, result.UserName); Assert.Equal(article.Content, result.Content); Assert.Equal(article.Title, result.Title); }
/// <summary> /// 初始化需要传递给编辑器的文件存放路径 /// </summary> void InitEditorParameter() { Session["ARTICLEDETAIL_CHANNELFILEPATH"] = ThisArticle.AttachmentUrlPath; Session["WorkPlace"] = "articleedit"; string path = Server.MapPath("~/Config/general.config"); if (!File.Exists(path)) { ArticleHelper.Write(path); //记录日志 string content = string.Format("创建了内容模型文件“{0}”", "general.config"); AddLog("创建内容模型文件", content); } GeneralConfigInfo config = GeneralConfigs.Deserialize(We7Utils.GetMapPath("~/Config/general.config")); if (config.CutToMaxWidthOfUploadedImg == 1) { Session["GENERALCONFIGINFO_CMAXWIDTHOFUPLOADEDIMG"] = config.MaxWidthOfUploadedImg; } }
private string GetProcessState(string id) { if (!ChannelProcess(id)) { return("[流转历程]"); } Article a = ArticleHelper.GetArticle(id); if (a != null && a.State != 2) { return("[流转历程]"); } Processing ap = ArticleProcessHelper.GetArticleProcess(a); string processText = "草稿"; if (ap != null) { processText = ap.ProcessDirectionText + ap.ProcessText; } return(processText); }
private void btnSubmitArticleCategory_Click(object sender, System.EventArgs e) { ArticleCategoryInfo articleCategory = ArticleHelper.GetArticleCategory(this.categoryId); if (articleCategory == null) { return; } if (this.fileUpload.HasFile) { try { ResourcesHelper.DeleteImage(articleCategory.IconUrl); articleCategory.IconUrl = ArticleHelper.UploadArticleImage(this.fileUpload.PostedFile); } catch { this.ShowMsg("图片上传失败,您选择的不是图片类型的文件,或者网站的虚拟目录没有写入文件的权限", false); return; } } articleCategory.Name = this.txtArticleCategoryiesName.Text.Trim(); articleCategory.Description = this.txtArticleCategoryiesDesc.Text.Trim(); ValidationResults validationResults = Validation.Validate <ArticleCategoryInfo>(articleCategory, new string[] { "ValArticleCategoryInfo" }); string text = string.Empty; if (validationResults.IsValid) { this.UpdateCategory(articleCategory); return; } foreach (ValidationResult current in (System.Collections.Generic.IEnumerable <ValidationResult>)validationResults) { text += Formatter.FormatErrorMessage(current.Message); } this.ShowMsg(text, false); }
private void btnSubmitHelpCategory_Click(object sender, System.EventArgs e) { string iconUrl = string.Empty; if (this.fileUpload.HasFile) { try { iconUrl = ArticleHelper.UploadHelpImage(this.fileUpload.PostedFile); } catch { this.ShowMsg("图片上传失败,您选择的不是图片类型的文件,或者网站的虚拟目录没有写入文件的权限", false); return; } } HelpCategoryInfo helpCategoryInfo = new HelpCategoryInfo(); helpCategoryInfo.Name = this.txtHelpCategoryName.Text.Trim(); helpCategoryInfo.IconUrl = iconUrl; helpCategoryInfo.Description = this.txtHelpCategoryDesc.Text.Trim(); helpCategoryInfo.IsShowFooter = this.radioShowFooter.SelectedValue; ValidationResults validationResults = Validation.Validate <HelpCategoryInfo>(helpCategoryInfo, new string[] { "ValHelpCategoryInfo" }); string text = string.Empty; if (validationResults.IsValid) { this.AddNewCategory(helpCategoryInfo); this.Reset(); return; } foreach (ValidationResult current in (System.Collections.Generic.IEnumerable <ValidationResult>)validationResults) { text += Formatter.FormatErrorMessage(current.Message); } this.ShowMsg(text, false); }
protected override void AttachChildControls() { this.itemID = Globals.RequestQueryNum("iid"); this.singleID = Globals.RequestQueryNum("sid"); this.imgUrl = (HiImage)this.FindControl("imgUrl"); this.litContent = (Literal)this.FindControl("litContent"); if (this.singleID > 0) { ArticleInfo articleInfo = ArticleHelper.GetArticleInfo(this.singleID); if (articleInfo != null) { this.htmlTitle = articleInfo.Title; this.imgUrl.ImageUrl = articleInfo.ImageUrl; this.litContent.Text = articleInfo.Content; } else { base.GotoResourceNotFound(""); } } else if (this.itemID > 0) { ArticleItemsInfo articleItemsInfo = ArticleHelper.GetArticleItemsInfo(this.itemID); if (articleItemsInfo != null) { this.htmlTitle = articleItemsInfo.Title; this.imgUrl.ImageUrl = articleItemsInfo.ImageUrl; this.litContent.Text = articleItemsInfo.Content; } else { base.GotoResourceNotFound(""); } } else { base.GotoResourceNotFound(""); } PageTitle.AddSiteNameTitle(this.htmlTitle); }
private void btnSubmitHelpCategory_Click(object sender, EventArgs e) { string str = string.Empty; if (fileUpload.HasFile) { try { str = ArticleHelper.UploadHelpImage(fileUpload.PostedFile); } catch { ShowMsg("图片上传失败,您选择的不是图片类型的文件,或者网站的虚拟目录没有写入文件的权限", false); return; } } HelpCategoryInfo info2 = new HelpCategoryInfo(); info2.Name = txtHelpCategoryName.Text.Trim(); info2.IconUrl = str; info2.Description = txtHelpCategoryDesc.Text.Trim(); info2.IsShowFooter = radioShowFooter.SelectedValue; HelpCategoryInfo target = info2; ValidationResults results = Hishop.Components.Validation.Validation.Validate <HelpCategoryInfo>(target, new string[] { "ValHelpCategoryInfo" }); string msg = string.Empty; if (results.IsValid) { AddNewCategory(target); Reset(); } else { foreach (ValidationResult result in (IEnumerable <ValidationResult>)results) { msg = msg + Formatter.FormatErrorMessage(result.Message); } ShowMsg(msg, false); } }
protected void Page_Load(object sender, EventArgs e) { string str = base.Request.QueryString["articletype"]; string str2 = base.Request.Form["posttype"]; string s = base.Request.Form["id"]; int.TryParse(s, out this.articleid); if ((str2 == "del") && (this.articleid > 0)) { base.Response.ContentType = "application/json"; string str4 = "{\"type\":\"0\",\"tips\":\"操作失败\"}"; DataSet set = ArticleHelper.ArticleIsInWeiXinReply(this.articleid); DataTable table = set.Tables[0]; DataTable table2 = set.Tables[1]; DataTable table3 = set.Tables[2]; if (Globals.ToNum(table.Rows[0][0]) > 0) { str4 = "{\"type\":\"0\",\"tips\":\"删除失败,该素材已在栏目“微信->自动回复”中使用。\"}"; } else if (Globals.ToNum(table2.Rows[0][0]) > 0) { str4 = "{\"type\":\"0\",\"tips\":\"删除失败,该素材已在栏目“微博->自动回复”中使用。\"}"; } else if (Globals.ToNum(table3.Rows[0][0]) > 0) { str4 = "{\"type\":\"0\",\"tips\":\"删除失败,该素材已在栏目“服务窗->自动回复”中使用。\"}"; } else if (ArticleHelper.DeleteArticle(this.articleid)) { str4 = "{\"type\":\"1\",\"tips\":\"删除成功\"}"; } base.Response.Write(str4); base.Response.End(); } else { this.LoadParameters(str); } }
protected void ChannelDropDownList_SelectedIndexChanged(object sender, EventArgs e) { string ownerId = OwnerID; if (ownerId == null) { ownerId = ChannelDropDownList.SelectedValue; } if (ChannelHelper.GetChannel(ownerId, null).Process == "1") { if (ArticleID != null && ArticleID != "") { Article a = ArticleHelper.GetArticle(ArticleID); if (a.ProcessState.Trim() != "99") { StateDropDownList.Enabled = false; } } StateDropDownList.Items[0].Selected = false; StateDropDownList.Items[1].Selected = true; } }
private void refriendscircle_ItemDataBound(object sender, RepeaterItemEventArgs e) { if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem)) { Repeater repeater = e.Item.Controls[0].FindControl("ItemInfo") as Repeater; Literal literal = e.Item.Controls[0].FindControl("ItemHtml") as Literal; DataRowView dataItem = (DataRowView)e.Item.DataItem; if (dataItem["ArticleType"].ToString() == "4") { IList <ArticleItemsInfo> articleItems = ArticleHelper.GetArticleItems(int.Parse(dataItem["ArticleId"].ToString())); if (articleItems != null) { repeater.DataSource = articleItems; repeater.DataBind(); } } else { literal.Text = "<div class='mate-ctx clear' >" + dataItem["Memo"].ToString() + "</div>"; } } }
/// <summary> /// 生成缩略图按钮点击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void GenarateButton_ServerClick(object sender, EventArgs e) { Article a = ArticleHelper.GetArticle(ArticleID); string fn = Server.MapPath(a.Thumbnail); string ext = Path.GetExtension(fn); string path = a.Thumbnail; if (String.IsNullOrEmpty(a.Thumbnail) || String.IsNullOrEmpty(a.Thumbnail.Trim())) { Messages.ShowError("请先上传原始图片"); } else { string fileName = Path.GetFileNameWithoutExtension(path); string ret = GenerateThumbImage(Server.MapPath(a.Thumbnail), ext, fileName); if (ret != "") { Response.Redirect(We7Helper.AddParamToUrl(Request.RawUrl, "generated", ret)); } } }
/// <summary> /// 获取父文章路径 /// </summary> /// <returns></returns> List <Article> GetParentArticlePath() { List <Article> list = new List <Article>(); if (!string.IsNullOrEmpty(ArticleID)) { Article a = ArticleHelper.GetArticle(ArticleID, null); while (a != null) { list.Insert(0, a); if (!We7Helper.IsEmptyID(a.ParentID)) { a = ArticleHelper.GetArticle(a.ParentID, null); } else { break; } } } return(list); }
private void grdArticleCategories_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e) { int rowIndex = ((System.Web.UI.WebControls.GridViewRow)((System.Web.UI.Control)e.CommandSource).NamingContainer).RowIndex; int categoryId = (int)this.grdArticleCategories.DataKeys[rowIndex].Value; int displaySequence = int.Parse((this.grdArticleCategories.Rows[rowIndex].FindControl("lblDisplaySequence") as System.Web.UI.WebControls.Literal).Text); int num = 0; int replaceDisplaySequence = 0; if (e.CommandName == "Fall") { if (rowIndex < this.grdArticleCategories.Rows.Count - 1) { num = (int)this.grdArticleCategories.DataKeys[rowIndex + 1].Value; replaceDisplaySequence = int.Parse((this.grdArticleCategories.Rows[rowIndex + 1].FindControl("lblDisplaySequence") as System.Web.UI.WebControls.Literal).Text); } } else { if (e.CommandName == "Rise" && rowIndex > 0) { num = (int)this.grdArticleCategories.DataKeys[rowIndex - 1].Value; replaceDisplaySequence = int.Parse((this.grdArticleCategories.Rows[rowIndex - 1].FindControl("lblDisplaySequence") as System.Web.UI.WebControls.Literal).Text); } } if (num > 0) { ArticleHelper.SwapArticleCategorySequence(categoryId, num, displaySequence, replaceDisplaySequence); } if (e.CommandName == "Delete") { ArticleCategoryInfo articleCategory = ArticleHelper.GetArticleCategory(categoryId); if (ArticleHelper.DeleteArticleCategory(categoryId)) { ResourcesHelper.DeleteImage(articleCategory.IconUrl); } } base.Response.Redirect(System.Web.HttpContext.Current.Request.Url.ToString(), true); }
/// <summary> /// 分页获取首页文章列表。 /// </summary> /// <param name="pageIndex">第几页,从 1 开始。</param> /// <param name="pageSize">每页条数。</param> /// <returns>文章列表。</returns> /// <exception cref="ArgumentOutOfRangeException">文章页数错误。</exception> /// <exception cref="ArgumentOutOfRangeException">文章条数错误。</exception> public static async Task <IEnumerable <Article> > RecentAsync(int pageIndex, int pageSize) { if (pageIndex < 1) { throw new ArgumentOutOfRangeException(nameof(pageIndex)); } if (pageSize < 1 || pageSize > 100) { throw new ArgumentOutOfRangeException(nameof(pageSize)); } var url = string.Format(CultureInfo.InvariantCulture, RecentUrlTemplate, pageIndex, pageSize); url = url.WithCache(); var uri = new Uri(url, UriKind.Absolute); var request = WebRequest.Create(uri); using (var response = await request.GetResponseAsync()) { var document = XDocument.Load(response.GetResponseStream()); return(ArticleHelper.Deserialize(document)); } }
/// <summary> /// 保存缩略图源文件名到数据库 /// </summary> /// <param name="thumbnailFile"></param> void SaveImageToDB(string thumbnailFile) { string rootPath = Server.MapPath("/"); thumbnailFile = thumbnailFile.Remove(0, rootPath.Length); thumbnailFile = string.Format("/{0}", thumbnailFile.Replace("\\", "/")); Article a = new Article(); a.ID = ArticleID; a.Thumbnail = thumbnailFile; a.IsImage = 1; if (a.ID == null) { Article article = ArticleHelper.AddArticles(a); } else { string[] fields = new string[] { "Thumbnail", "WapImage", "OriginalImage", "IsImage" }; ArticleHelper.UpdateArticle(a, fields); } }
protected void Page_Load(object sender, EventArgs e) { string str = base.Request.QueryString["articletype"]; string str2 = base.Request.Form["posttype"]; string s = base.Request.Form["id"]; int.TryParse(s, out this.articleid); if ((str2 == "del") && (this.articleid > 0)) { base.Response.ContentType = "application/json"; string str4 = "{\"type\":\"0\",\"tips\":\"操作失败\"}"; if (ArticleHelper.DeleteArticle(this.articleid)) { str4 = "{\"type\":\"1\",\"tips\":\"删除成功\"}"; } base.Response.Write(str4); base.Response.End(); } else { this.LoadParameters(str); } }
/// <summary> /// 获取最热的文章列表 /// </summary> /// <returns></returns> protected List<Article> GetHotArticles() { List<Article> list = null; ArticleQuery query = CreateHotQuery(); if (HotSize <= 0) { list = ArticleHelper.QueryArtilcesByAll(query, 0, HotRecordCount, null); } else { if (HotRecordCount > HotSize) { list = ArticleHelper.QueryArtilcesByAll(query, 0, HotSize, null); } else { list = ArticleHelper.QueryArtilcesByAll(query, 0, HotRecordCount, null); } } FormatArticlesData(list); return list; }
public void GetSortedArticlesTest_ReturnsListOfArticles() { var articles = ArticleHelper.GetRandomTestArticles(10); var expectedArticles = articles.Take(3).ToList(); string title = expectedArticles.ElementAt(0).Title; string userName = expectedArticles.ElementAt(1).UserName; string category = expectedArticles.ElementAt(2).Category.ToString(); _mockArticleService.Setup(ser => ser.GetArticlesByOccurrenceAsync(title, userName, category) ).ReturnsAsync(expectedArticles); var okObjectResult = (_controller.GetSortedArticles(title, userName, category).Result.Result as OkObjectResult)?.Value; var result = okObjectResult as IEnumerable <Article> ?? throw new InvalidOperationException(); Assert.Contains(result, article => articles.Any(a => a.Category == article.Category && a.UserName == article.UserName && a.Content == article.Content && a.CreatedDate == article.CreatedDate && a.Id == article.Id && a.Title == article.Title)); }
private DataGridViewModel <Dictionary <string, object> > GetDataList(ArticleQuery query) { DataGridViewModel <Dictionary <string, object> > dataGridViewModel = new DataGridViewModel <Dictionary <string, object> >(); if (query != null) { DbQueryResult articleList = ArticleHelper.GetArticleList(query); dataGridViewModel.rows = DataHelper.DataTableToDictionary(articleList.Data); dataGridViewModel.total = articleList.TotalRecords; foreach (Dictionary <string, object> row in dataGridViewModel.rows) { if (string.IsNullOrEmpty(row["IconUrl"].ToString())) { row.Add("IconUrls", HiContext.Current.SiteSettings.DefaultProductImage); } else { row.Add("IconUrls", row["IconUrl"]); } } } return(dataGridViewModel); }
protected void Page_Load(object sender, EventArgs e) { this.btnSubmitArticleCategory.Click += this.btnSubmitArticleCategory_Click; if (!int.TryParse(base.Request.QueryString["CategoryId"], out this.categoryId)) { base.GotoResourceNotFound(); } else if (!base.IsPostBack) { ArticleCategoryInfo articleCategory = ArticleHelper.GetArticleCategory(this.categoryId); if (articleCategory == null) { base.GotoResourceNotFound(); } else { Globals.EntityCoding(articleCategory, false); this.txtArticleCategoryiesName.Text = articleCategory.Name; this.txtArticleCategoryiesDesc.Text = articleCategory.Description; this.hidOldImages.Value = articleCategory.IconUrl; } } }
private void btnSubmitArticleCategory_Click(object sender, EventArgs e) { ArticleCategoryInfo articleCategory = ArticleHelper.GetArticleCategory(categoryId); if (articleCategory != null) { if (fileUpload.HasFile) { try { ResourcesHelper.DeleteImage(articleCategory.IconUrl); articleCategory.IconUrl = ArticleHelper.UploadArticleImage(fileUpload.PostedFile); } catch { ShowMsg("图片上传失败,您选择的不是图片类型的文件,或者网站的虚拟目录没有写入文件的权限", false); return; } } articleCategory.Name = txtArticleCategoryiesName.Text.Trim(); articleCategory.Description = txtArticleCategoryiesDesc.Text.Trim(); ValidationResults results = Hishop.Components.Validation.Validation.Validate <ArticleCategoryInfo>(articleCategory, new string[] { "ValArticleCategoryInfo" }); string msg = string.Empty; if (results.IsValid) { UpdateCategory(articleCategory); } else { foreach (ValidationResult result in (IEnumerable <ValidationResult>)results) { msg = msg + Formatter.FormatErrorMessage(result.Message); } ShowMsg(msg, false); } } }
protected void Page_Load(object sender, System.EventArgs e) { string stype = base.Request.QueryString["articletype"]; string a = base.Request.Form["posttype"]; string s = base.Request.Form["id"]; int.TryParse(s, out this.articleid); if (a == "del" && this.articleid > 0) { base.Response.ContentType = "application/json"; string s2 = "{\"type\":\"0\",\"tips\":\"操作失败\"}"; System.Data.DataSet dataSet = ArticleHelper.ArticleIsInWeiXinReply(this.articleid); System.Data.DataTable dataTable = dataSet.Tables[0]; System.Data.DataTable dataTable2 = dataSet.Tables[1]; System.Data.DataTable dataTable3 = dataSet.Tables[2]; if (Globals.ToNum(dataTable.Rows[0][0]) > 0) { s2 = "{\"type\":\"0\",\"tips\":\"删除失败,该素材已在栏目“微信->自动回复”中使用。\"}"; } else if (Globals.ToNum(dataTable2.Rows[0][0]) > 0) { s2 = "{\"type\":\"0\",\"tips\":\"删除失败,该素材已在栏目“微博->自动回复”中使用。\"}"; } else if (Globals.ToNum(dataTable3.Rows[0][0]) > 0) { s2 = "{\"type\":\"0\",\"tips\":\"删除失败,该素材已在栏目“服务窗->自动回复”中使用。\"}"; } else if (ArticleHelper.DeleteArticle(this.articleid)) { s2 = "{\"type\":\"1\",\"tips\":\"删除成功\"}"; } base.Response.Write(s2); base.Response.End(); return; } this.LoadParameters(stype); }