protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (((DataView)odsDieuTriHo.Select()).Count <= DataPager1.PageSize) { DataPager1.Visible = false; } string strTitle, strDescription, strMetaTitle, strMetaDescription; if (!string.IsNullOrEmpty(Request.QueryString["di"])) { var oArticle = new Article(); var oArticleCategory = new ArticleCategory(); var dv = oArticle.ArticleSelectOne(Request.QueryString["di"]).DefaultView; if (dv != null && dv.Count <= 0) return; var row = dv[0]; strTitle = Server.HtmlDecode(row["ArticleTitleEn"].ToString()); strDescription = Server.HtmlDecode(row["DescriptionEn"].ToString()); strMetaTitle = Server.HtmlDecode(row["MetaTittleEn"].ToString()); strMetaDescription = Server.HtmlDecode(row["MetaDescriptionEn"].ToString()); } else { strTitle = strMetaTitle = "Cough Treatment"; strDescription = ""; strMetaDescription = ""; } Page.Title = !string.IsNullOrEmpty(strMetaTitle) ? strMetaTitle : strTitle; var meta = new HtmlMeta() { Name = "description", Content = !string.IsNullOrEmpty(strMetaDescription) ? strMetaDescription : strDescription }; Header.Controls.Add(meta); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string strTitle, strDescription, strMetaTitle, strMetaDescription; if (!string.IsNullOrEmpty(Request.QueryString["tt"])) { var oArticle = new Article(); var oArticleCategory = new ArticleCategory(); var dv = oArticle.ArticleSelectOne(Request.QueryString["tt"]).DefaultView; if (dv != null && dv.Count <= 0) return; var row = dv[0]; var dv2 = oArticleCategory.ArticleCategorySelectOne(row["ArticleCategoryID"].ToString()).DefaultView; strTitle = Server.HtmlDecode(row["ArticleTitleEn"].ToString()); strDescription = Server.HtmlDecode(row["DescriptionEn"].ToString()); strMetaTitle = Server.HtmlDecode(row["MetaTittleEn"].ToString()); strMetaDescription = Server.HtmlDecode(row["MetaDescriptionEn"].ToString()); lblTitleNews.Text = dv2[0]["ArticleCategoryNameEn"].ToString(); } else { strTitle = strMetaTitle = "News"; strDescription = ""; strMetaDescription = ""; } Page.Title = !string.IsNullOrEmpty(strMetaTitle) ? strMetaTitle : strTitle; var meta = new HtmlMeta() { Name = "description", Content = !string.IsNullOrEmpty(strMetaDescription) ? strMetaDescription : strDescription }; Header.Controls.Add(meta); } }
public ActionResult EditArticle(ArticleCategory category, int articleID, string title, string content, bool isTop, Lang lang) { var cmd = new EditArticle(category, articleID, title, content, isTop, lang, this.CurrentUser.UserID); this.CommandBus.Send(cmd); return Json(JsonResult.Success); }
/******************************前台****************************************************/ public int CountCategoryArticleBySearch(ArticleCategory category) { var paramters = new object[] { (int)category }; return this.Context.Sql(countArticleCategory_sql) .Parameters(paramters) .QuerySingle<int>(); }
public ArticleCreated(ArticleCategory category, string title, string content, bool isTop, Lang lang, int createBy) { this.Category = category; this.Title = title; this.Content = content; this.Lang = lang; this.IsTop = isTop; this.CreateBy = createBy; }
public ActionResult Index(ArticleCategory category, int page) { var count = IoC.Resolve<IArticleQuery>().CountCategoryArticleBySearch(category); var articles = IoC.Resolve<IArticleQuery>().GetCategoryArticleBySearch(this.CurrentLang,category, page, Constants.DEFAULT_PAGE_COUNT); ViewBag.Count = count; ViewBag.Article = articles; return View(); }
public ArticleEdit(int articleID, ArticleCategory category, string title, string content, bool isTop, Lang lang, int editBy) { this.ArticleID = articleID; this.Category = category; this.Lang = lang; this.Title = title; this.Content = content; this.IsTop = isTop; this.EditBy = editBy; }
public ActionResult List(ArticleCategory category, int? page) { var _page = page.HasValue ? page.Value : 1; ViewBag.Category = category; var articles = IoC.Resolve<IArticleQuery>().GetCategoryArticleBySearch(this.CurrentLang, category, _page, Constants.DEFAULT_PAGE_COUNT); ViewBag.Articles = articles; ViewBag.HasPre = _page == 1 ? false : true; ViewBag.HasNext = articles.Count() == Constants.DEFAULT_PAGE_COUNT ? true : false; ViewBag.CurrentPage = _page; return View(); }
public CreateArticle(ArticleCategory category, string title, string content, bool isTop, Lang lang, int currentUserID) { Check.Argument.IsNotNegativeOrZero((int)category, "category"); Check.Argument.IsNotNegativeOrZero(currentUserID, "currentUserID"); Check.Argument.IsNotEmpty(title, "title"); Check.Argument.IsNotEmpty(content, "content"); Check.Argument.IsNotNull(isTop, "isTop"); this.Category = category; this.IsTop = isTop; this.Lang = lang; this.Title = title; this.Content = content; this.CreateBy = currentUserID; }
//Handle add new category public void Add_Category(Object s, EventArgs e) { //Instantiate article delete object ArticleCategory AddCat = new ArticleCategory(); AddCat.Category = Request.Form["CategoryName"]; Caching.PurgeCacheItems("ArticleCategory_SideMenu"); //Notify user if error occured. if (AddCat.Add() != 0) { JSLiteral.Text = "Error occured while processing your submit."; return; } Response.Redirect("confirmarticlecatedit.aspx?catname=" + AddCat.Category + "&mode=add"); }
private void BindDDL(ArticleCategory current) { List<ArticleCategory> mys = ResolveDDL<ArticleCategory>(ArticleCategoryHelper.ArticleCategorys, current.ID); // 绑定到下拉列表(启用模拟树功能和不可选择项功能) ddlBox.EnableSimulateTree = true; ddlBox.DataTextField = "Name"; ddlBox.DataValueField = "ID"; ddlBox.DataSimulateTreeLevelField = "TreeLevel"; ddlBox.DataEnableSelectField = "Enabled"; ddlBox.DataSource = mys; ddlBox.DataBind(); if (current.Parent != null) { // 选中当前节点的父节点 ddlBox.SelectedValue = current.Parent.ID.ToString(); } }
private void SaveItem() { ArticleCategory item = new ArticleCategory(); item.Name = tbxName.Text.Trim(); item.sort = Convert.ToInt32(tbxSortIndex.Text.Trim()); item.CreateTime = DateTime.Now; item.Remark = tbxRemark.Text.Trim(); int parentID = Convert.ToInt32(ddlParent.SelectedValue); if (parentID == -1) { item.Parent = null; } else { ArticleCategory articlecategory = Attach<ArticleCategory>(parentID); item.Parent = articlecategory; } DB.ArticleCategorys.Add(item); DB.SaveChanges(); }
public IActionResult EditArticleCategory(int id) { ArticleCategory entity = ArticleCategory.Find(ArticleCategory._.Id == id); if (entity == null) { return(EchoTipPage("系统找不到本记录!")); } //获取上级栏目 IList <ArticleCategory> list = ArticleCategory.GetListTree(0, -1, true, true); ViewBag.ListTree = list; //获取模板 模板规则,以Index_开头的,为栏目列表,以Detial_开头的为文章详情 List <string> listTpls = new List <string>(); var asms = AppDomain.CurrentDomain.GetAssemblies(); foreach (var asmItem in asms) { string fullName = asmItem.GetName().ToString(); if (fullName.IndexOf("COMCMS.Web.Views") > -1) { var types = asmItem.GetTypes().Where(e => e.Name.StartsWith("Views_Article")).ToList(); if (types.Count == 0) { continue; } foreach (var type in types) { string viewName = type.Name.Replace("Views_Article_", "") + ".cshtml"; listTpls.Add(viewName); } } } ViewBag.ListTpl = listTpls; Core.Admin.WriteLogActions("查看/编辑文章栏目(id:" + id + ")页面;"); return(View(entity)); }
public ActionResult Add(CategoryModels model) { if (ModelState.IsValid) { try { var m = new ArticleCategory { Name = model.Name, Description = model.Description, DisplayOrder = model.DisplayOrder, IncludeInTopMenu = model.IncludeInTopMenu, ParentCategoryId = model.ParentCategoryId ?? 0, Published = model.Published, ShowOnHomePage = model.ShowOnHomePage, MetaDescription = model.MetaDescription, MetaKeywords = model.MetaKeywords, MetaTitle = model.MetaTitle, CreatedOnUtc = DateTime.Now, UpdatedOnUtc = DateTime.Now }; _articleCategoryService.Add(m); if (m.Id > 0) { return(View("Add", model)); } } catch (Exception ex) { logger.Error(ex); } //return RedirectToAction("Index", "Home"); } // If we got this far, something failed, redisplay form return(View(model)); }
public List <HomeCategoryArticleViewModel> GetZazhiCategoryByFatherCategory(string fathercategory_code) { ArticleCategoryDao acDao = new ArticleCategoryDao(); int father_id = articleCategoryBll.GetCategoryIdByCode(fathercategory_code); ArticleCategory ac = new ArticleCategory(); ac.category_father_id = father_id; ac.category_state = 0; ac.category_type = 2; //1的时候小导航 2的时候首页5个 3的时候广告 IEnumerable <ArticleCategory> arList = acDao.Select(ac).Take(5); //获取该类别下所有子类别 小导航条 List <HomeCategoryArticleViewModel> articleViewModelList = new List <HomeCategoryArticleViewModel>(); //获取各类别下面的文章 foreach (ArticleCategory item in arList) { HomeCategoryArticleViewModel articleViewModel = new HomeCategoryArticleViewModel(); articleViewModel.category_name = item.category_name; articleViewModel.articleList = articleBll.GetZazhiArticleByCategory(item.category_code, 1).ToList(); //articleViewModel.adArticle = articleBll.GetArticleByCategory(item.category_code, 1).FirstOrDefault(); articleViewModelList.Add(articleViewModel); } return(articleViewModelList); }
public ActionResult Create([Bind(Include = "ArticleCategoryID,ArticleCategoryName,Description,Image,MetaTitle,ParentID,DisplayOrder,SeoTitle,MetaDescription,MetaKeywords,CreateDate,CreateUser,ModifiedDate,ModifiedUser,IsActive")] ArticleCategory articleCategory) { var UserSession = (UserLogin)Session[TechDeviShopVs002.Common.CommonConstants.USER_SESSION]; if (ModelState.IsValid) { var _dal = new ArticleCategoryDAL(); articleCategory.CreateUser = UserSession.UserID; int id = _dal.Insert(articleCategory); if (id > 0) { return(RedirectToAction("Index", "ArticleCategories")); } else { ModelState.AddModelError("", "Thêm danh muc bài viết ko thành công"); } } return(View(articleCategory)); }
private void PrepareAclModel(ArticleCategoryModel model, ArticleCategory category, bool excludeProperties) { if (model == null) { throw new ArgumentNullException("model"); } model.AvailableUserRoles = _userService .GetAllUserRoles(true) .Select(cr => cr.ToModel()) .ToList(); if (!excludeProperties) { if (category != null) { model.SelectedUserRoleIds = _aclService.GetUserRoleIdsWithAccess(category); } else { model.SelectedUserRoleIds = new int[0]; } } }
public int Add(ArticleCategory model) { string cmdText = "insert into ArticleCategory values(?,?,?,?,?,?);select last_insert_rowid() newid;"; object[] paramList = { model.CategoryId, model.ArticleId, model.CreateUser, model.CreateTime, model.UpdateTime, model.Enable }; object result = SQLiteHelper.ExecuteScalar(cmdText, paramList); int intResult; if (int.TryParse(result.ToString(), out intResult)) { return(intResult); } return(0); }
public bool Update(ArticleCategory category, int version) { var entity = _client.GetQueryable <ArticleCategoryEntity>().FirstOrDefault(e => e.Id == category.Id); if (entity == null) { entity = new ArticleCategoryEntity(category) { Version = ++version }; _client.Add(entity); return(true); } if (entity.Version != version) { return(false); } entity.Version++; _client.Update(entity); return(true); }
public void Register(RegisterArticleCommand command) { command.Validate(); if (AddNotifications(command)) { return; } ArticleCategory category = _categoryRepository.GetById(command.CategoryId); LedgerIdentityUser user = _identityResolver.GetUser(); if (NotifyNullCategory(category)) { return; } Article article = new Article(command.Slug, command.Title, command.Body, command.CategoryId, user.Id); _articleRepository.Register(article); Commit(); }
protected void UpdateLocales(ArticleCategory category, ArticleCategoryModel model) { foreach (var localized in model.Locales) { _localizedEntityService.SaveLocalizedValue(category, x => x.Name, localized.Name, localized.LanguageId); _localizedEntityService.SaveLocalizedValue(category, x => x.FullName, localized.FullName, localized.LanguageId); _localizedEntityService.SaveLocalizedValue(category, x => x.Description, localized.Description, localized.LanguageId); _localizedEntityService.SaveLocalizedValue(category, x => x.BottomDescription, localized.BottomDescription, localized.LanguageId); _localizedEntityService.SaveLocalizedValue(category, x => x.MetaKeywords, localized.MetaKeywords, localized.LanguageId); _localizedEntityService.SaveLocalizedValue(category, x => x.MetaDescription, localized.MetaDescription, localized.LanguageId); _localizedEntityService.SaveLocalizedValue(category, x => x.MetaTitle, localized.MetaTitle, localized.LanguageId); //search engine name var seName = category.ValidateSeName(localized.SeName, localized.Name, false, localized.LanguageId); _urlRecordService.SaveSlug(category, seName, localized.LanguageId); } }
/// <summary> /// /// </summary> /// <param name="ctype"></param> /// <param name="id"></param> /// <returns></returns> public static string EchoURL(Utils.CMSType ctype, int id) { string url = "/"; switch (ctype) { case Utils.CMSType.ArticleCategory: ArticleCategory ac = ArticleCategory.FindById(id); url = EchoURL(ac); break; case Utils.CMSType.ProductCategory: Category pc = Category.FindById(id); url = EchoURL(pc); break; default: url = "/"; break; } return(url); }
public OperationResult Create(CreateArticleCategory command) { var operation = new OperationResult(); if (_articleCategoryRepository.Exist(x => x.Name == command.Name)) { return(operation.Failed(ApplicationMessages.DuplicatedRecord)); } var slug = command.Slug.Slugify(); var path = $"{"Blog"}/{slug}"; var pictureName = _fileUploader.Upload(command.Picture, path); var articleCategory = new ArticleCategory(command.Name, pictureName, command.PictureAlt, command.PictureTitle, command.ShortDescription, command.Description, command.ShowOrder, slug, command.Keywords, command.MetaDescription, command.CanonicalAddress); _articleCategoryRepository.Create(articleCategory); _articleCategoryRepository.SaveChanges(); return(operation.Succedded()); }
public bool Update(ArticleCategory articleCategory, int version) { var entity = entities.FirstOrDefault(e => e.ArticleCategory.Id == articleCategory.Id); if (entity == null) { entities.Add( new ArticleCategoryEntity() { ArticleCategory = articleCategory, Version = ++version }); return(true); } if (entity.Version != version) { return(false); } entity.ArticleCategory = articleCategory; entity.Version++; return(true); }
/// <summary> /// Categories the articles index view. /// </summary> /// <returns></returns> public override ActionResult Index() { var category = _categoryRepository.Get(it => it.Code == ForCategoryCode); if (category == null) { category = new ArticleCategory() { Id = ForCategoryCode, Code = ForCategoryCode, Name = ForCategoryArticleName, }; _categoryRepository.Insert(category); } ViewBag.Title = $"{ForCategoryArticleName}管理"; return(View("_Article_ListForCategory", new YunKe.Commerce.Articles.Queries.GetArticlesListQuery() { CategoryCode = ForCategoryCode, CategoryId = category.Id, })); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string strTitle, strDescription, strMetaTitle, strMetaDescription; if (!string.IsNullOrEmpty(Request.QueryString["tci"])) { var oArticleCategory = new ArticleCategory(); var dv = oArticleCategory.ArticleCategorySelectOne(Request.QueryString["tci"]).DefaultView; if (dv != null && dv.Count <= 0) { return; } var row = dv[0]; strTitle = Server.HtmlDecode(row["ArticleCategoryNameEn"].ToString()); strDescription = Server.HtmlDecode(row["DescriptionEn"].ToString()); strMetaTitle = Server.HtmlDecode(row["MetaTitleEn"].ToString()); strMetaDescription = Server.HtmlDecode(row["MetaDescriptionEn"].ToString()); } else { strTitle = strMetaTitle = "News"; strDescription = ""; strMetaDescription = ""; } Page.Title = !string.IsNullOrEmpty(strMetaTitle) ? strMetaTitle : strTitle; var meta = new HtmlMeta() { Name = "description", Content = !string.IsNullOrEmpty(strMetaDescription) ? strMetaDescription : strDescription }; Header.Controls.Add(meta); lblTitle.Text = strTitle; } }
public object GetArticleCategory(int id, string random = "", string timeStamp = "", string signature = "") { ArticleCategory entity = ArticleCategory.FindById(id); if (entity == null) { reJson.message = "系统找不到本记录"; return(reJson); } //获取下属栏目 IList <ArticleCategory> listsub = ArticleCategory.FindAll(ArticleCategory._.PId == entity.Id & ArticleCategory._.IsHide == 0, ArticleCategory._.Rank.Asc(), null, 0, 0); List <object> reListSubs = new List <object>(); if (listsub != null && listsub.Count > 0) { foreach (var item in listsub) { reListSubs.Add(new { kindName = item.KindName, id = item.Id }); } } dynamic detail = new { category = entity, sublist = reListSubs }; reJson.code = 0; reJson.message = "获取成功!"; reJson.detail = detail; return(reJson); }
public async Task <IActionResult> PutCategory([FromBody] CategoryViewModel categoryVm) { if (!ModelState.IsValid) { throw new Exception(string.Join("\n", ModelState.Keys.SelectMany(k => ModelState[k].Errors).Select(m => m.ErrorMessage).ToArray())); } else { var artic = new ArticleCategory(); var _article = await _articleCategoryRepository.GetCategory(categoryVm.Id); if (_article == null) { throw new Exception("Invalid article."); } else { try { artic.CategoryName = categoryVm.CategoryName; artic.ID = categoryVm.Id; //_article.UpdateToArticle(articleVm); await _articleCategoryRepository.UpdateCategory(artic); return(Ok()); } catch (AppException ex) { return(BadRequest(new { message = ex.Message })); } } } }
/// <summary> /// 添加/修改类型 /// </summary> /// <param name="context"></param> /// <returns></returns> private string addCate(HttpContext context) { int autoId = int.Parse(context.Request["autoId"]); string type = "OpenClass"; int preId = int.Parse(context.Request["preId"]); string name = context.Request["name"]; int sort = int.Parse(context.Request["sort"]); ZentCloud.BLLJIMP.Enums.ArticleCategoryType ntype = new ZentCloud.BLLJIMP.Enums.ArticleCategoryType(); if (!Enum.TryParse(type, out ntype)) { resp.Status = (int)APIErrCode.OperateFail; resp.Msg = "类型错误"; return(Common.JSONHelper.ObjectToJson(resp)); } ArticleCategory cate = new ArticleCategory(); cate.AutoID = autoId; cate.CategoryType = type; cate.PreID = preId; cate.CategoryName = name; cate.Sort = sort; cate.WebsiteOwner = bllArticleCategory.WebsiteOwner; if (bllArticleCategory.PutArticleCategory(cate)) { resp.Status = 1; resp.Msg = "提交成功"; } else { resp.Status = -1; resp.Msg = "提交失败"; } return(Common.JSONHelper.ObjectToJson(resp)); }
private void PrepareSitesMappingModel(ArticleCategoryModel model, ArticleCategory category, bool excludeProperties) { if (model == null) { throw new ArgumentNullException("model"); } model.AvailableSites = _siteService .GetAllSites() .Select(s => s.ToModel()) .ToList(); if (!excludeProperties) { if (category != null) { model.SelectedSiteIds = _siteMappingService.GetSitesIdsWithAccess(category); } else { model.SelectedSiteIds = new int[0]; } } model.SiteContentShare = _siteSettings.SiteContentShare; }
public async Task <IActionResult> Edit(int id, [Bind("Id,Title,CallIndex,SeoTitle,SeoKeyword,SeoDescription,Description")] ArticleCategory articleCategory) { if (id != articleCategory.Id) { return(NotFound()); } if (ModelState.IsValid) { try { if (id == 0) { context.Add(articleCategory); } else { context.Update(articleCategory); } await context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ArticleCategoryExists(articleCategory.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(articleCategory)); }
public SelectList GetSelectListCategories(ArticleModel article) { List <SelectListItem> _categoryList = new List <SelectListItem>(); var _categories = _unitOfWorkAsync.Repository <ArticleCategory>().Query().Select().OrderBy(m => m.Name); ArticleCategory _default = new ArticleCategory(); if (article.CategoryId != null) { _default = _articleCategoryManager.GetById(article.CategoryId.Value); } foreach (var item in _categories) { _categoryList.Add(new SelectListItem() { Text = item.Name, Value = item.Id.ToString(), Selected = (item == _default ? true : false) }); } return(new SelectList(_categoryList, "Value", "Text")); }
private void PrepareCategoryModel(ArticleCategoryModel model, ArticleCategory category) { if (model == null) { throw new ArgumentNullException("model"); } if (category != null) { model.CreatedOnUtc = _dateTimeHelper.ConvertToUserTime(category.CreatedOnUtc, DateTimeKind.Utc); model.ModifiedOnUtc = (category.ModifiedOnUtc.HasValue ? _dateTimeHelper.ConvertToUserTime(category.ModifiedOnUtc.Value, DateTimeKind.Utc) : category.ModifiedOnUtc); } model.AvailableDefaultViewModes.Add( new SelectListItem { Value = "grid", Text = _localizationService.GetResource("Common.Grid"), Selected = model.DefaultViewMode.IsCaseInsensitiveEqual("grid") } ); model.AvailableDefaultViewModes.Add( new SelectListItem { Value = "list", Text = _localizationService.GetResource("Common.List"), Selected = model.DefaultViewMode.IsCaseInsensitiveEqual("list") } ); }
public async Task <IActionResult> Create([Bind("Id,Title,Row,Content")] Article article, int CategoryId, IFormFile files) { var userId = Guid.Parse(HttpContext.User.FindFirstValue(ClaimTypes.NameIdentifier)); List <ArticleCategory> articleCategory = new List <ArticleCategory>() { }; var category = await _unitService.Category.GetByIdAsync(CategoryId); ArticleCategory cat = new ArticleCategory { Category = category }; articleCategory.Add(cat); article.ArticleCategory = articleCategory; article.PostCategory = PostCategory.Tutorial; article.CreatedDate = DateTime.Now; article.UpdateDate = DateTime.Now; article.BrainStormUser = await _unitService.User.GetUsersByIdAsync(userId); article.Row = _context.Articles.Any() == false ? 1 : _context.Articles.Max(item => item.Row + 1); if (ModelState.IsValid) { _unitService.Article.Create(article); _unitService.SaveChanges(); if (files != null && files.Length > 0) { ImageHelper imageHelper = new ImageHelper(_context); imageHelper.UpdateImage(article.Id, files, "article", article); } return(RedirectToAction(nameof(Index))); } return(View(article)); }
/// <summary> /// 按分类名称获取文章信息 /// </summary> /// <param name="name">分类名称</param> /// <returns>文章分类信息</returns> public ArticleCategoryDetailsModel GetArticleCategoryByName(string name) { IRepository <ArticleCategory> categoryRep = Factory.Factory <IRepository <ArticleCategory> > .GetConcrete <ArticleCategory>(); ArticleCategory tmp = null; ArticleCategoryDetailsModel target = new ArticleCategoryDetailsModel(); try { tmp = categoryRep.Find(new Specification <ArticleCategory>(c => c.Name == name)); target.CategoryID = tmp.Id; target.CategoryName = tmp.Name; target.Deepth = tmp.Deepth; target.Description = tmp.Description; target.Icon = tmp.Icon; target.ParentID = tmp.ParentID; target.Priority = tmp.Priority; } catch { } return(target); }
partial void InsertArticleCategory(ArticleCategory instance);
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e) { if (e.CommandName == "QuickUpdate") { string ArticleCategoryID, IsShowOnMenu, IsShowOnHomePage, IsAvailable; var oArticleCategory = new ArticleCategory(); foreach (GridDataItem item in RadGrid1.Items) { ArticleCategoryID = item.GetDataKeyValue("ArticleCategoryID").ToString(); IsShowOnMenu = ((CheckBox)item.FindControl("chkIsShowOnMenu")).Checked.ToString(); IsShowOnHomePage = ((CheckBox)item.FindControl("chkIsShowOnHomePage")).Checked.ToString(); IsAvailable = ((CheckBox)item.FindControl("chkIsAvailable")).Checked.ToString(); oArticleCategory.ArticleCategoryQuickUpdate( ArticleCategoryID, IsShowOnMenu, IsShowOnHomePage, IsAvailable ); } } else if (e.CommandName == "DeleteSelected") { var oArticleCategory = new ArticleCategory(); var errorList = ""; foreach (GridDataItem item in RadGrid1.SelectedItems) { var isChildCategoryExist = oArticleCategory.ArticleCategoryIsChildrenExist(item.GetDataKeyValue("ArticleCategoryID").ToString()); var ArticleCategoryName = ((Label)item.FindControl("lblArticleCategoryName")).Text; var ArticleCategoryNameEn = ((Label)item.FindControl("lblArticleCategoryNameEn")).Text; if (isChildCategoryExist) { errorList += ", " + ArticleCategoryName; } else { string strImageName = ((HiddenField)item.FindControl("hdnImageName")).Value; if (!string.IsNullOrEmpty(strImageName)) { string strSavePath = Server.MapPath("~/res/articlecategory/" + strImageName); if (File.Exists(strSavePath)) { File.Delete(strSavePath); } } } } if (!string.IsNullOrEmpty(errorList)) { e.Canceled = true; string strAlertMessage = "Danh mục <b>\"" + errorList.Remove(0, 1).Trim() + "\"</b> đang có danh mục con hoặc sản phẩm.<br /> Xin xóa danh mục con hoặc sản phẩm trong danh mục này hoặc thiết lập hiển thị = \"không\"."; lblError.Text = strAlertMessage; } } else if (e.CommandName == "PerformInsert" || e.CommandName == "Update") { var command = e.CommandName; var row = command == "PerformInsert" ? (GridEditFormInsertItem)e.Item : (GridEditFormItem)e.Item; var FileImageName = (RadUpload)row.FindControl("FileImageName"); string strArticleCategoryName = ((RadTextBox)row.FindControl("txtArticleCategoryName")).Text.Trim(); string strArticleCategoryNameEn = ((RadTextBox)row.FindControl("txtArticleCategoryNameEn")).Text.Trim(); string strConvertedArticleCategoryName = Common.ConvertTitle(strArticleCategoryName); string strDescription = HttpUtility.HtmlDecode(FCKEditorFix.Fix(((RadEditor)row.FindControl("txtDescription")).Content.Trim())); string strDescriptionEn = HttpUtility.HtmlDecode(FCKEditorFix.Fix(((RadEditor)row.FindControl("txtDescriptionEn")).Content.Trim())); string strContent = HttpUtility.HtmlDecode(FCKEditorFix.Fix(((RadEditor)row.FindControl("txtContent")).Content.Trim())); string strContentEn = HttpUtility.HtmlDecode(FCKEditorFix.Fix(((RadEditor)row.FindControl("txtContentEn")).Content.Trim())); string strMetaTitle = ((RadTextBox)row.FindControl("txtMetaTitle")).Text.Trim(); string strMetaTitleEn = ((RadTextBox)row.FindControl("txtMetaTitleEn")).Text.Trim(); string strMetaDescription = ((RadTextBox)row.FindControl("txtMetaDescription")).Text.Trim(); string strMetaDescriptionEn = ((RadTextBox)row.FindControl("txtMetaDescriptionEn")).Text.Trim(); string strImageName = FileImageName.UploadedFiles.Count > 0 ? FileImageName.UploadedFiles[0].GetName() : ""; string strParentID = ((RadComboBox)row.FindControl("ddlParent")).SelectedValue; string strIsAvailable = ((CheckBox)row.FindControl("chkIsAvailable")).Checked.ToString(); string strIsShowOnMenu = ((CheckBox)row.FindControl("chkIsShowOnMenu")).Checked.ToString(); string strIsShowOnHomePage = ((CheckBox)row.FindControl("chkIsShowOnHomePage")).Checked.ToString(); var oArticleCategory = new ArticleCategory(); if (e.CommandName == "PerformInsert") { strImageName = oArticleCategory.ArticleCategoryInsert( strArticleCategoryName, strArticleCategoryNameEn, strConvertedArticleCategoryName, strDescription, strDescriptionEn, strContent, strContentEn, strMetaTitle, strMetaTitleEn, strMetaDescription, strMetaDescriptionEn, strImageName, strParentID, strIsShowOnMenu, strIsShowOnHomePage, strIsAvailable ); string strFullPath = "~/res/articlecategory/" + strImageName; if (!string.IsNullOrEmpty(strImageName)) { FileImageName.UploadedFiles[0].SaveAs(Server.MapPath(strFullPath)); ResizeCropImage.ResizeByCondition(strFullPath, 40, 40); } RadGrid1.Rebind(); } else { var dsUpdateParam = ObjectDataSource1.UpdateParameters; var strArticleCategoryID = row.GetDataKeyValue("ArticleCategoryID").ToString(); var strOldImageName = ((HiddenField)row.FindControl("hdnImageName")).Value; var strOldImagePath = Server.MapPath("~/res/articlecategory/" + strOldImageName); dsUpdateParam["ArticleCategoryName"].DefaultValue = strArticleCategoryName; dsUpdateParam["ArticleCategoryNameEn"].DefaultValue = strArticleCategoryNameEn; dsUpdateParam["ConvertedArticleCategoryName"].DefaultValue = strConvertedArticleCategoryName; dsUpdateParam["Description"].DefaultValue = strDescription; dsUpdateParam["DescriptionEn"].DefaultValue = strDescriptionEn; dsUpdateParam["Content"].DefaultValue = strContent; dsUpdateParam["ContentEn"].DefaultValue = strContentEn; dsUpdateParam["ImageName"].DefaultValue = strImageName; dsUpdateParam["ParentID"].DefaultValue = strParentID; dsUpdateParam["IsShowOnMenu"].DefaultValue = strIsShowOnMenu; dsUpdateParam["IsShowOnHomePage"].DefaultValue = strIsShowOnHomePage; dsUpdateParam["IsAvailable"].DefaultValue = strIsAvailable; if (!string.IsNullOrEmpty(strImageName)) { var strFullPath = "~/res/articlecategory/" + strConvertedArticleCategoryName + "-" + strArticleCategoryID + strImageName.Substring(strImageName.LastIndexOf('.')); if (File.Exists(strOldImagePath)) { File.Delete(strOldImagePath); } FileImageName.UploadedFiles[0].SaveAs(Server.MapPath(strFullPath)); ResizeCropImage.ResizeByCondition(strFullPath, 40, 40); } } } if (e.CommandName == "DeleteImage") { var oArticleCategory = new ArticleCategory(); var lnkDeleteImage = (LinkButton)e.CommandSource; var s = lnkDeleteImage.Attributes["rel"].ToString().Split('#'); var strArticleCategoryID = s[0]; var strImageName = s[1]; oArticleCategory.ArticleCategoryImageDelete(strArticleCategoryID); DeleteImage(strImageName); RadGrid1.Rebind(); } }
private async void ShowGallery(ArticleCategory category) { Core.Track.Telemetry.Instance.Action("Filter", new Dictionary<string, string>() { { "filter", category.ToString() } }); PageDataContext.CurrentArticleGallery = category; var parameters = new OverviewParameter() { StartOver = true, Category = category, Paging = 0 }; await Task.Factory.StartNew(() => Searcher.ExecuteGaleryScrape(this, context, parameters), source.Token); }
public IActionResult AddArticle(Article model) { if (model.KId <= 0) { tip.Message = "请选择一个文章栏目"; return(Json(tip)); } if (string.IsNullOrWhiteSpace(model.Title)) { tip.Message = "请填写文章标题"; return(Json(tip)); } if (string.IsNullOrWhiteSpace(model.Content)) { tip.Message = "请填写文章内容"; return(Json(tip)); } if (!string.IsNullOrEmpty(model.Pic) && !Utils.IsImgFilename(model.Pic)) { tip.Message = "文章图片填写的不是图片格式!"; return(Json(tip)); } if (!string.IsNullOrEmpty(model.FileName) && !Utils.ChekHTMLFileNameIsOK(model.FileName)) { tip.Message = "静态化文件名错误,请填写正确的,或者留空!"; return(Json(tip)); } Admin my = Admin.GetMyInfo(); List <int> aclist = new List <int>(); if (my.Roles.IsSuperAdmin != 1) { aclist = JsonConvert.DeserializeObject <List <int> >(string.IsNullOrEmpty(my.Roles.AuthorizedArticleCagegory) ? "[]" : my.Roles.AuthorizedArticleCagegory); if (aclist == null) { aclist = new List <int>(); } if (aclist.Count > 0) { if (aclist.FindIndex(x => x == model.KId) == -1) { tip.Message = "当前选择栏目不存在,或者您没这个栏目的权限!"; return(Json(tip)); } } } //处理文章更多图片 string[] moreImgSrc = Request.Form["nImgUrl"]; string morIMG = string.Empty;//更多图片的时候用到 if (moreImgSrc != null && moreImgSrc.Length > 0) { foreach (string s in moreImgSrc) { if (Utils.IsImgFilename(s)) { morIMG += s + "|||";//使用“|||”分隔图片 } } } string content = model.Content; if (Request.Form["autoSaveRemoteImg"] == "1" && !string.IsNullOrEmpty(content)) { content = ThumbnailHelper.SaveRemoteImgForContent(content); model.Content = content; } model.ItemImg = morIMG; model.AuthorId = my.Id; model.Insert(); ArticleCategory.UpdateDetailCount(model.KId); SessionHelper.WriteSession("com_add_article_kid", model.KId); //添加TAG //Tag.InsertTags(model.Tags, RTType.RatuoModule.Article, model.Id, model.Title); Core.Admin.WriteLogActions("添加文章(id:" + model.Id + ");"); tip.Status = JsonTip.SUCCESS; tip.Message = "添加文章成功"; tip.ReturnUrl = "close"; return(Json(tip)); }
public IActionResult GetArticleList(string keyword, int page = 1, int limit = 20) { int numPerPage, currentPage, startRowIndex; numPerPage = limit; currentPage = page; startRowIndex = (currentPage - 1) * numPerPage; Expression ex = new Expression();; Admin my = Admin.GetMyInfo(); List <int> aclist = new List <int>(); if (my.Roles.IsSuperAdmin != 1) { aclist = Newtonsoft.Json.JsonConvert.DeserializeObject <List <int> >(string.IsNullOrEmpty(my.Roles.AuthorizedArticleCagegory)?"[]": my.Roles.AuthorizedArticleCagegory); if (aclist == null) { aclist = new List <int>(); } if (aclist.Count > 0) { ex &= Article._.KId.In(aclist); } //仅显示有权限内容 if (my.Roles.OnlyEditMyselfArticle == 1) { ex &= Article._.AuthorId == my.Id; } } if (!string.IsNullOrWhiteSpace(keyword)) { if (Utils.IsInt(keyword)) { ex &= (Article._.Id == int.Parse(keyword) | Article._.Title.Contains(keyword)); } else { ex &= Article._.Title.Contains(keyword); } } string kid = Request.Query["kid"]; string isshowsub = Request.Query["isshowsub"]; if (Utils.IsInt(kid) && int.Parse(kid) > 0) { //获取栏目 if (isshowsub == "1") { List <int> kids = new List <int>(); kids.Add(int.Parse(kid)); IList <ArticleCategory> subkinds = ArticleCategory.FindByParentID(int.Parse(kid)); if (subkinds != null && subkinds.Count > 0) { foreach (var item in subkinds) { kids.Add(item.Id); } ex &= Article._.KId.In(kids); } } else { ex &= Article._.KId == int.Parse(kid); } } IList <Article> list = Article.FindAll(ex, Article._.Sequence.Asc().And(Article._.Id.Desc()), null, startRowIndex, numPerPage); long totalCount = Article.FindCount(ex, Article._.Sequence.Asc().And(Article._.Id.Desc()), null, startRowIndex, numPerPage); //return Content(Newtonsoft.Json.JsonConvert.SerializeObject(new { total = totalCount, rows = list }), "text/plain"); return(Json(new { total = totalCount, rows = list })); }
//Handle the delete button click event public void Delete_Category(Object sender, RepeaterCommandEventArgs e) { if ((e.CommandName == "Delete")) { //Instantiate article delete object ArticleCategory DelCat = new ArticleCategory(); DelCat.CatID = Convert.ToInt32(e.CommandArgument); Caching.PurgeCacheItems("ArticleCategory_SideMenu"); //Perform delete DelCat.Delete(); //Redirect to confirm delete page Response.Redirect("confirmarticlecatedit.aspx?catname=ArticleCategoryID" + DelCat.CatID + "&mode=del"); } }
public bool AddCategory(ArticleCategory categoryModel) { return(dbManager.Execute(conn => DalArticle.AddCategory(conn, categoryModel))); }
// Add sample data private void AddSampleData() { var user1 = new UserProfile() { DisplayName = "jlaw21", FirstName = "Cindy", LastName = "Stone", Email = "*****@*****.**", CreateDateTime = DateTime.Now - TimeSpan.FromDays(150), FirebaseUserId = "TEST_FIREBASE_UID_2", ImageLocation = null, }; var user2 = new UserProfile() { DisplayName = "jlaw21", FirstName = "Jonny", LastName = "Law", Email = "*****@*****.**", CreateDateTime = DateTime.Now - TimeSpan.FromDays(400), FirebaseUserId = "TEST_FIREBASE_UID_2", ImageLocation = null, }; var article1 = new Article() { UserProfileId = 1, Author = "@rogervincent", Publisher = "latimes", CurrentsId = "553abec9-6f64-4787-8244-46788b4d195c", Title = "Motels are having a moment. It's a coronavirus thing", Description = "Motels, long the orphans of the hospitality industry, stand to gain popularity as people hit the road again and seek to avoid interior spaces....", Url = "https://www.latimes.com/business/story/2020-07-24/motels-coronavirus-design", UserTitle = "Dune Ipsum", Content = "Beneath hostility proverb creates about Paul, whenever tends. Wife grasps legendary around sand. Purpose seeks the imperium stops the unique Rautha. Over native so Harah, beside Lisan al-Gaib and the reflection. For thinking where assassination above the trained Ichwan Bedwine. Self-control reaches the deep-sand Tleilax.", CreateDateTime = DateTime.Now - TimeSpan.FromDays(10), Image = "https://ca-times.brightspotcdn.com/dims4/default/8eb9564/2147483647/strip/true/crop/5760x3240+0+300/resize/1200x675!/quality/90/?url=https%3A%2F%2Fcalifornia-times-brightspot.s3.amazonaws.com%2F1d%2F58%2F6cab4fd8479d94bb8f1892ca19fe%2Fap18290829832389.jpg", Language = "en", Published = Convert.ToDateTime("2020-07-24 18:03:42 +0000"), Objectivity = 0.50, Sentimentality = 0.50 }; var article2 = new Article() { UserProfileId = 2, Author = "The Bon Appétit Staff", Publisher = "bonappetit", CurrentsId = "f624f638-ac4a-4577-a312-a647e36f3b7d", Title = "93 Grilling Recipes So You Don’t Have to Cook Anything Inside", Description = "From ribs to shrimp, chicken to veggies, fish to ... so much more, get grilling with these recipes!...", Url = "https://www.bonappetit.com/recipes/slideshow/60-favorite-grilling-recipes-almost-everything", UserTitle = "Dune Ipsum User 2", Content = "The breeding program passes for question, against spannungsbogen yet enemy threatens instinctual. The water burden stops near exploitation. Nothing sinks superior out Water of Life. Awakening uses for the kiswa ridge beside the Jamis chooses extreme. The Leto manipulates, the Wellington clouds. Spacing Guild disobeys the superior the Way. Between the prompt guilt disturbs the scorched conditioning yet the weirding homeworld nor terrifies Hasimir.", CreateDateTime = DateTime.Now - TimeSpan.FromDays(20), Image = "https://assets.bonappetit.com/photos/5cdf092b56f182a9a3eb2e97/16:9/w_1600,c_limit/grilled-scallops-with-nori-ginger-lime.jpg", Language = "en", Published = Convert.ToDateTime("2020-07-24 13:00:00 +0000"), Objectivity = 0.50, Sentimentality = 0.50 }; var referenceArticle1 = new Article() { UserProfileId = 1, Author = "The Associated Press", Publisher = "seattletimes", CurrentsId = "774bc577-f284-41a8-ad58-cd99e252332c", Title = "FAA orders emergency engine checks of parked Boeing 737s", Description = "Airlines parked hundreds of planes when the coronavirus pandemic triggered a collapse in air travel and are slowly bringing some of those planes....", Url = "https://www.seattletimes.com/business/faa-orders-emergency-engine-checks-of-parked-boeing-737s/", CreateDateTime = DateTime.Now - TimeSpan.FromDays(1), Language = "en", Published = Convert.ToDateTime("2020-07-24 16:25:16 +0000"), Objectivity = 0.50, Sentimentality = 0.50 }; var referenceArticle2 = new Article() { UserProfileId = 2, Author = "Tyler Durden", Publisher = "google", CurrentsId = "a9fa3cca-e0e7-4ce2-95d3-12ffd7e9d97b", Title = "Some Optimism From Goldman: The Number Of New COVID Cases Is Starting To Flatten", Description = "Some Optimism From Goldman: The Number Of New COVID Cases Is Starting To Flatten \n\nTyler Durden\n\nFri, 07/24/2020 - 12:05\nAs the US reports more than 1k deaths for the third straight day, reporters are mostly focusing on this milestone, along with the US surmounting the 4 million-case mark, as the bi...", Url = "http://feedproxy.google.com/~r/zerohedge/feed/~3/97bxxwviQ-Q/some-optimism-goldman-number-new-covid-cases-starting-flatten", CreateDateTime = DateTime.Now - TimeSpan.FromDays(1), Language = "en", Published = Convert.ToDateTime("2020-07-24 16:05:00 +0000"), Objectivity = 0.50, Sentimentality = 0.50 }; var articleCategory1 = new ArticleCategory() { ArticleId = 1, CategoryId = 4 }; var articleCategory2 = new ArticleCategory() { ArticleId = 2, CategoryId = 18 }; var articleCategory3 = new ArticleCategory() { ArticleId = 3, CategoryId = 4 }; var articleCategory4 = new ArticleCategory() { ArticleId = 4, CategoryId = 18 }; var articleReference1 = new ArticleReference() { ArticleId = 1, ReferenceArticleId = 3 }; var articleReference2 = new ArticleReference() { ArticleId = 2, ReferenceArticleId = 4 }; _context.Add(user1); _context.Add(user2); _context.Add(article1); _context.Add(article2); _context.Add(referenceArticle1); _context.Add(referenceArticle2); _context.Add(articleCategory1); _context.Add(articleCategory2); _context.Add(articleCategory3); _context.Add(articleCategory4); _context.Add(articleReference1); _context.Add(articleReference2); _context.SaveChanges(); }
public IActionResult EditArticleCategory(ArticleCategory model) { if (model.Id <= 0) { tip.Message = "错误参数传递!"; Json(tip); } if (string.IsNullOrWhiteSpace(model.KindName)) { tip.Message = "文章栏目标题不能为空!"; return(Json(tip)); } ArticleCategory entity = ArticleCategory.Find(ArticleCategory._.Id == model.Id); if (entity == null) { tip.Message = "系统找不到本记录!"; Json(tip); } if (entity.PId != model.PId) { if (entity.Id == model.PId) { tip.Message = "上级栏目不能选择本身!"; return(Json(tip)); } entity.PId = model.PId; entity.Location = ArticleCategory.GetNewLocation(model.PId); entity.Level = ArticleCategory.GetNewLevel(model.PId); //修改文章的location IList <Article> alist = Article.FindAll(Article._.KId == model.Id, null, null, 0, 0); if (alist != null && alist.Count > 0) { foreach (var a in alist) { a.Location = entity.Location + "," + entity.Id; //a.FilePath = entity.FilePath; } alist.Save(); } } //赋值 entity.PId = model.PId; entity.KindName = model.KindName; entity.SubTitle = model.SubTitle; entity.KindTitle = model.KindTitle; entity.Keyword = model.Keyword; entity.Description = model.Description; entity.LinkURL = model.LinkURL; entity.TitleColor = model.TitleColor; entity.TemplateFile = model.TemplateFile; entity.DetailTemplateFile = model.DetailTemplateFile; entity.IsList = model.IsList; entity.PageSize = model.PageSize <= 0 ? 15 : model.PageSize; entity.IsLock = model.IsLock; entity.IsHide = model.IsHide; entity.IsShowSubDetail = model.IsShowSubDetail; entity.BannerImg = model.BannerImg; entity.Pic = model.Pic; entity.KindInfo = model.KindInfo; entity.KindDomain = model.KindDomain; entity.Rank = model.Rank; entity.Pic = model.Pic; entity.Save(); Core.Admin.WriteLogActions("修改文章栏目(id:" + entity.Id + ");"); tip.Status = JsonTip.SUCCESS; tip.Message = "修改文章栏目成功"; tip.ReturnUrl = "close"; return(Json(tip)); }
protected void lnkDownOrder_Click(object sender, EventArgs e) { var lnkDownOrder = (LinkButton)sender; var strArticleCategoryID = lnkDownOrder.Attributes["rel"]; var oArticleCategory = new ArticleCategory(); oArticleCategory.ArticleCategoryDownOrder(strArticleCategoryID); RadGrid1.Rebind(); }
public ArticleInListModel GetFristArticleByCategory(ArticleCategory category) { Check.Argument.IsNotNegativeOrZero((int)category, "category"); var article= this.Context.Sql(getFirstArticleByCategory) .Parameter("@category", category) .QuerySingle<ArticleInListModel>(); return article; }
public IEnumerable<DotPay.ViewModel.ArticleInListModel> GetCategoryArticleBySearch(Lang lang, ArticleCategory category, int page, int pageCount) { var paramters = new object[] { (int)category, (int)lang, (page - 1) * pageCount, pageCount }; return this.Context.Sql(categoryArticle_Sql) .Parameters(paramters) .QueryMany<ArticleInListModel>(); }
partial void UpdateArticleCategory(ArticleCategory instance);
private async void ShowGallery(ArticleCategory category) { PageDataContext.CurrentArticleGallery = category; var parameters = new OverviewParameter() { StartOver = true, Category = category, Paging = -1 }; await Task.Factory.StartNew(() => Searcher.ExecuteGaleryScrape(this, context, parameters), source.Token); }
partial void DeleteArticleCategory(ArticleCategory instance);
public IActionResult EditArticleCategory(ArticleCategory model) { if (model.Id <= 0) { tip.Message = "错误参数传递!"; Json(tip); } if (string.IsNullOrWhiteSpace(model.KindName)) { tip.Message = "文章栏目标题不能为空!"; return(Json(tip)); } ArticleCategory entity = ArticleCategory.Find(ArticleCategory._.Id == model.Id); if (entity == null) { tip.Message = "系统找不到本记录!"; Json(tip); } if (!string.IsNullOrEmpty(model.FilePath)) { if (!model.FilePath.StartsWith("/")) { tip.Message = "栏目路径请以/开头!"; return(Json(tip)); } if (model.FilePath.EndsWith("/")) { tip.Message = "栏目路径结尾不用加上/"; return(Json(tip)); } if (model.FilePath.Count(x => x == '/') > 4) { tip.Message = "最多只能四级路径!"; return(Json(tip)); } } if (!string.IsNullOrEmpty(model.FilePath) && !AdminUtils.CheckFilePathIsOK(model.FilePath, entity.Id, 0)) { tip.Message = "栏目路径不可用,请重新填写!"; return(Json(tip)); } if (entity.PId != model.PId) { if (entity.Id == model.PId) { tip.Message = "上级栏目不能选择本身!"; return(Json(tip)); } entity.PId = model.PId; entity.Location = ArticleCategory.GetNewLocation(model.PId); entity.Level = ArticleCategory.GetNewLevel(model.PId); //修改文章的location IList <Article> alist = Article.FindAll(Article._.KId == model.Id, null, null, 0, 0); if (alist != null && alist.Count > 0) { foreach (var a in alist) { a.Location = entity.Location + "," + entity.Id; //a.FilePath = entity.FilePath; } alist.Save(); } } bool idNeedUpdateAllArticleFilePath = entity.FilePath == model.FilePath; //赋值 entity.PId = model.PId; entity.KindName = model.KindName; entity.SubTitle = model.SubTitle; entity.KindTitle = model.KindTitle; entity.Keyword = model.Keyword; entity.Description = model.Description; entity.LinkURL = model.LinkURL; entity.TitleColor = model.TitleColor; entity.TemplateFile = model.TemplateFile; entity.DetailTemplateFile = model.DetailTemplateFile; entity.IsList = model.IsList; entity.PageSize = model.PageSize <= 0 ? 15 : model.PageSize; entity.IsLock = model.IsLock; entity.IsHide = model.IsHide; entity.IsShowSubDetail = model.IsShowSubDetail; entity.BannerImg = model.BannerImg; entity.Pic = model.Pic; entity.KindInfo = model.KindInfo; entity.KindDomain = model.KindDomain; entity.Rank = model.Rank; entity.Pic = model.Pic; entity.FilePath = model.FilePath; entity.Save(); //修改所有文章的路径 if (idNeedUpdateAllArticleFilePath) { IList <Article> listArticles = Article.FindAll(Article._.KId == entity.Id, null, null, 0, 0); if (listArticles != null && listArticles.Count > 0) { foreach (var item in listArticles) { item.FilePath = entity.FilePath; } listArticles.Update(); } } Core.Admin.WriteLogActions("修改文章栏目(id:" + entity.Id + ");"); tip.Status = JsonTip.SUCCESS; tip.Message = "修改文章栏目成功"; tip.ReturnUrl = "close"; return(Json(tip)); }
public static void SetArticleCategory(ArticleCategory category) { var description = category.ID == 0 ? "添加文章分类" : "修改文章分类"; if (category.ID == 0) // 新文章分类 { dc.ArticleCategory.InsertOnSubmit(category); } dc.SubmitChanges(); AddLog(category.ID, "ArticleCategory", description); }
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e) { if (e.CommandName == "QuickUpdate") { string ArticleCategoryID, IsShowOnMenu, IsShowOnHomePage, IsAvailable; var oArticleCategory = new ArticleCategory(); foreach (GridDataItem item in RadGrid1.Items) { ArticleCategoryID = item.GetDataKeyValue("ArticleCategoryID").ToString(); IsShowOnMenu = ((CheckBox)item.FindControl("chkIsShowOnMenu")).Checked.ToString(); IsShowOnHomePage = ((CheckBox)item.FindControl("chkIsShowOnHomePage")).Checked.ToString(); IsAvailable = ((CheckBox)item.FindControl("chkIsAvailable")).Checked.ToString(); oArticleCategory.ArticleCategoryQuickUpdate( ArticleCategoryID, IsShowOnMenu, IsShowOnHomePage, IsAvailable ); } } else if (e.CommandName == "DeleteSelected") { var oArticleCategory = new ArticleCategory(); var errorList = ""; foreach (GridDataItem item in RadGrid1.SelectedItems) { var isChildCategoryExist = oArticleCategory.ArticleCategoryIsChildrenExist(item.GetDataKeyValue("ArticleCategoryID").ToString()); var ArticleCategoryName = ((Label)item.FindControl("lblArticleCategoryName")).Text; var ArticleCategoryNameEn = ((Label)item.FindControl("lblArticleCategoryNameEn")).Text; if (isChildCategoryExist) { errorList += ", " + ArticleCategoryName; } else { string strImageName = ((HiddenField)item.FindControl("hdnImageName")).Value; if (!string.IsNullOrEmpty(strImageName)) { string strSavePath = Server.MapPath("~/res/articlecategory/" + strImageName); if (File.Exists(strSavePath)) File.Delete(strSavePath); } } } if (!string.IsNullOrEmpty(errorList)) { e.Canceled = true; string strAlertMessage = "Danh mục <b>\"" + errorList.Remove(0, 1).Trim() + "\"</b> đang có danh mục con hoặc sản phẩm.<br /> Xin xóa danh mục con hoặc sản phẩm trong danh mục này hoặc thiết lập hiển thị = \"không\"."; lblError.Text = strAlertMessage; } } else if (e.CommandName == "PerformInsert" || e.CommandName == "Update") { var command = e.CommandName; var row = command == "PerformInsert" ? (GridEditFormInsertItem)e.Item : (GridEditFormItem)e.Item; var FileImageName = (RadUpload)row.FindControl("FileImageName"); string strArticleCategoryName = ((RadTextBox)row.FindControl("txtArticleCategoryName")).Text.Trim(); string strArticleCategoryNameEn = ((RadTextBox)row.FindControl("txtArticleCategoryNameEn")).Text.Trim(); string strConvertedArticleCategoryName = Common.ConvertTitle(strArticleCategoryName); string strDescription = HttpUtility.HtmlDecode(FCKEditorFix.Fix(((RadEditor)row.FindControl("txtDescription")).Content.Trim())); string strDescriptionEn = HttpUtility.HtmlDecode(FCKEditorFix.Fix(((RadEditor)row.FindControl("txtDescriptionEn")).Content.Trim())); string strContent = HttpUtility.HtmlDecode(FCKEditorFix.Fix(((RadEditor)row.FindControl("txtContent")).Content.Trim())); string strContentEn = HttpUtility.HtmlDecode(FCKEditorFix.Fix(((RadEditor)row.FindControl("txtContentEn")).Content.Trim())); string strMetaTitle = ((RadTextBox)row.FindControl("txtMetaTitle")).Text.Trim(); string strMetaTitleEn = ((RadTextBox)row.FindControl("txtMetaTitleEn")).Text.Trim(); string strMetaDescription = ((RadTextBox)row.FindControl("txtMetaDescription")).Text.Trim(); string strMetaDescriptionEn = ((RadTextBox)row.FindControl("txtMetaDescriptionEn")).Text.Trim(); string strImageName = FileImageName.UploadedFiles.Count > 0 ? FileImageName.UploadedFiles[0].GetName() : ""; string strParentID = ((RadComboBox)row.FindControl("ddlParent")).SelectedValue; if ("".Equals(strParentID)) strParentID = "3"; string strIsAvailable = ((CheckBox)row.FindControl("chkIsAvailable")).Checked.ToString(); string strIsShowOnMenu = ((CheckBox)row.FindControl("chkIsShowOnMenu")).Checked.ToString(); string strIsShowOnHomePage = ((CheckBox)row.FindControl("chkIsShowOnHomePage")).Checked.ToString(); var oArticleCategory = new ArticleCategory(); if (e.CommandName == "PerformInsert") { strImageName = oArticleCategory.ArticleCategoryInsert( strArticleCategoryName, strArticleCategoryNameEn, strConvertedArticleCategoryName, strDescription, strDescriptionEn, strContent, strContentEn, strMetaTitle, strMetaTitleEn, strMetaDescription, strMetaDescriptionEn, strImageName, strParentID, strIsShowOnMenu, strIsShowOnHomePage, strIsAvailable ); string strFullPath = "~/res/articlecategory/" + strImageName; if (!string.IsNullOrEmpty(strImageName)) { FileImageName.UploadedFiles[0].SaveAs(Server.MapPath(strFullPath)); ResizeCropImage.ResizeByCondition(strFullPath, 40, 40); } RadGrid1.Rebind(); } else { var dsUpdateParam = ObjectDataSource1.UpdateParameters; var strArticleCategoryID = row.GetDataKeyValue("ArticleCategoryID").ToString(); var strOldImageName = ((HiddenField)row.FindControl("hdnImageName")).Value; var strOldImagePath = Server.MapPath("~/res/articlecategory/" + strOldImageName); dsUpdateParam["ArticleCategoryName"].DefaultValue = strArticleCategoryName; dsUpdateParam["ArticleCategoryNameEn"].DefaultValue = strArticleCategoryNameEn; dsUpdateParam["ConvertedArticleCategoryName"].DefaultValue = strConvertedArticleCategoryName; dsUpdateParam["Description"].DefaultValue = strDescription; dsUpdateParam["DescriptionEn"].DefaultValue = strDescriptionEn; dsUpdateParam["Content"].DefaultValue = strContent; dsUpdateParam["ContentEn"].DefaultValue = strContentEn; dsUpdateParam["ImageName"].DefaultValue = strImageName; dsUpdateParam["ParentID"].DefaultValue = strParentID; dsUpdateParam["IsShowOnMenu"].DefaultValue = strIsShowOnMenu; dsUpdateParam["IsShowOnHomePage"].DefaultValue = strIsShowOnHomePage; dsUpdateParam["IsAvailable"].DefaultValue = strIsAvailable; if (!string.IsNullOrEmpty(strImageName)) { var strFullPath = "~/res/articlecategory/" + strConvertedArticleCategoryName + "-" + strArticleCategoryID + strImageName.Substring(strImageName.LastIndexOf('.')); if (File.Exists(strOldImagePath)) File.Delete(strOldImagePath); FileImageName.UploadedFiles[0].SaveAs(Server.MapPath(strFullPath)); ResizeCropImage.ResizeByCondition(strFullPath, 40, 40); } } } if (e.CommandName == "DeleteImage") { var oArticleCategory = new ArticleCategory(); var lnkDeleteImage = (LinkButton)e.CommandSource; var s = lnkDeleteImage.Attributes["rel"].ToString().Split('#'); var strArticleCategoryID = s[0]; var strImageName = s[1]; oArticleCategory.ArticleCategoryImageDelete(strArticleCategoryID); DeleteImage(strImageName); RadGrid1.Rebind(); } }