protected override void PublishByRole(int appid, Article article, ArticleInfoView articleInfoView) { List <TagItem> tagList = WeChatCommonService.lstTag; switch (articleInfoView.ArticleCateSub) { case "SM_SALES_VEEVA": case "SM_SALES_RAPID": case "SM_SALES_OTHER": WechatCommon.PublishMessage(appid, new List <Article>() { article }, "", "", GetTagIdByTagName(tagList, "SF_REP|SF_DM|SF_NSD|SF_Trainer")); break; case "SM_MARKET_HCP": case "SM_MARKET_SPEAKER": case "SM_MARKET_VEEVA": case "SM_MARKET_FAQ": WechatCommon.PublishMessage(appid, new List <Article>() { article }, "", "", GetTagIdByTagName(tagList, "SPP_MKT")); break; default: WechatCommon.PublishMessage(appid, new List <Article>() { article }, "@all", "", ""); break; } }
/// <summary> /// /// </summary> /// <typeparam name="T"></typeparam> /// <param name="predicate"></param> /// <returns></returns> public List <T> GetList <T>(Expression <Func <ArticleInfo, bool> > predicate) where T : IViewModel, new() { var lst = Repository.Entities.Where(predicate).ToList().Select(n => (T)(new ArticleInfoView().ConvertAPIModelList(n))).ToList(); //更新CategoryCode //var lstCate = CommonService.GetCategory(CategoryType.ArticleInfoCate); lst.ForEach(d => { ArticleInfoView a = (ArticleInfoView)(IViewModel)d; //var cate = lstCate.FirstOrDefault(b => b.CategoryCode == a.ArticleCateSub); var cate = CommonService.GetCategory(a.AppId.Value, false).FirstOrDefault(b => b.Id == a.CategoryId); if (cate != null) { a.ArticleCateName = cate.CategoryName; } else { a.ArticleCateName = "其他"; } }); return(lst); }
private int AddOrUpdate <T>(T objModalSrc, bool bolAdd, List <string> lst) { ArticleInfoView objView = objModalSrc as ArticleInfoView; if (objView == null) { return(-1); } int iRet; BaseService <ArticleImages> ser = new BaseService <ArticleImages>("CAAdmin"); foreach (var a in objView.ArticleContentViews) { if (a.objImage != null) { ser.Repository.Insert(a.objImage); a.ImageID = a.objImage.Id; } } var article = objView.MapTo <ArticleInfo>(); // 处理article.content article.ArticleContentEdit = JsonHelper.ToJson(objView.ArticleContentViews); if (bolAdd) { article.ArticleStatus = ConstData.STATUS_NEW; article.ReadCount = 0; article.ThumbsUpCount = 0; iRet = Repository.Insert(article); objView.Id = article.Id; } else { if (lst == null || lst.Count == 0) { iRet = Repository.Update(article); } else { iRet = Repository.Update(article, lst); } } foreach (var a in objView.ArticleContentViews) { if (a.objImage != null) { a.objImage.ArticleID = article.Id; ser.Repository.Update(a.objImage, new List <string>() { "ArticleID" }); } } return(iRet); }
public override JsonResult Post(ArticleInfoView objModal, string Id) { if (!objModal.AppId.HasValue) { ModelState.AddModelError("Empty APP", "Please Select APP.<br/>"); } else { AppId = objModal.AppId.Value; } return(base.Post(objModal, Id)); }
public override JsonResult WxPreview(ArticleInfoView objModal) { if (!objModal.AppId.HasValue) { ModelState.AddModelError("Empty APP", "Please Select APP.<br/>"); } else { AppId = objModal.AppId.Value; } return(base.WxPreview(objModal)); }
private int AddOrUpdate <T>(T objModalSrc, bool bolAdd) { ArticleInfoView objView = objModalSrc as ArticleInfoView; if (objView == null) { return(-1); } int iRet; BaseService <ArticleImages> ser = new BaseService <ArticleImages>(); // article = new ArticleInfo(); foreach (var a in objView.ArticleContentViews) { if (a.objImage != null) { ser.Insert(a.objImage); a.ImageID = a.objImage.Id; } } var article = objView.MapTo <ArticleInfo>(); // 处理article.content article.ArticleContentEdit = JsonHelper.ToJson(objView.ArticleContentViews); if (bolAdd) { iRet = base.Insert(article); } else { iRet = base.Update(article); } foreach (var a in objView.ArticleContentViews) { if (a.objImage != null) { a.objImage.ArticleID = article.Id; ser.Update(a.objImage, new List <string>() { "ArticleID" }); } } return(iRet); }
public override JsonResult WxPreview(ArticleInfoView objModal) { var appId = GetAppID(int.Parse(objModal.ArticleCateSub)); if (appId == null) { ModelState.AddModelError("ArticleCateSub", @"The app of under you selected category does not exist!"); } else { objModal.AppId = appId; } return(base.WxPreview(objModal)); }
public override int InsertView <T>(T objModalSrc) { ArticleInfoView objView = objModalSrc as ArticleInfoView; if (objView == null) { return(-1); } int iRet; var article = new ImageInfo(); article = objView.MapTo <ImageInfo>(); iRet = Repository.Insert(article); return(iRet); }
public override int UpdateView <T>(T objModalSrc) { int iRet = 0; ArticleInfoView objView = objModalSrc as ArticleInfoView; if (objView == null) { return(-1); } var image = new ImageInfo(); image = objView.MapTo <ImageInfo>(); iRet = Repository.Update(image); return(iRet); }
public JsonResult GetItem(int id) { ArticleInfoView firstArticle = null; var item = this._objService.Repository.GetByKey(id); if (item != null && !string.IsNullOrEmpty(item.NewsIdList)) { var newsIdList = item.NewsIdList.Split(',').ToList().Select(x => int.Parse(x)).ToList(); if (newsIdList != null) { List <NewsInfoView> newsInfoList = new List <NewsInfoView>(); bool isArticle = false; List <dynamic> temp = typeof(WechatMessageLogType).GetAllItems(); var currentMsgContentType = temp.FirstOrDefault(w => item.MsgContentType.Value.Equals(w.Value)); for (int i = 0; i < newsIdList.Count; i++) { //包含被删除的图文 var article = this._articleInfoService.Repository.GetByKey(newsIdList[i]); if (article != null) { var articleView = (ArticleInfoView) new ArticleInfoView().ConvertAPIModel(article); if (i == 0) { firstArticle = articleView; } var newsInfo = (NewsInfoView)articleView.ConvertToNewsInfoView(article); if (currentMsgContentType != null) { newsInfo.NewsCate = currentMsgContentType.Text; isArticle = newsInfo.NewsCate.Equals("news"); } newsInfoList.Add(newsInfo); } } if (null != firstArticle) { firstArticle.ArticleCode = null; if (isArticle) { firstArticle.ArticleContentEdit = JsonConvert.SerializeObject(newsInfoList); } } } } return(Json(firstArticle, JsonRequestBehavior.AllowGet)); }
protected override void PublishByRole(int appid, Article article, ArticleInfoView articleInfoView) { List <TagItem> tagList = this.PrepareEditData(appid); switch (articleInfoView.ArticleCateSub) { case "ST_RCOUR_VIEW": case "ST_RTRA_BAA": case "ST_RMICRO_FORUM": case "ST_RMICRO_SHARE": case "ST_RLEARN_TYRANT": WechatCommon.PublishMessage(appid, new List <Article>() { article }, "", "", GetTagIdByTagName(tagList, "SF_REP|SF_DM|SF_RSD|SF_NSD|SF_Trainer")); break; case "ST_ECOUR_VIEW": case "ST_ETRA_BAA": case "ST_EMICRO_FORUM": case "ST_EMICRO_SHARE": WechatCommon.PublishMessage(appid, new List <Article>() { article }, "", "", GetTagIdByTagName(tagList, "SF_DM|SF_RSD|SF_NSD|SF_Trainer")); break; case "ST_TRAIN_CALA": case "ST_RDPAC_GUIDE": case "ST_LEARN_GUIDE": case "ST_CONNECT_US": WechatCommon.PublishMessage(appid, new List <Article>() { article }, "@all", "", ""); break; default: WechatCommon.PublishMessage(appid, new List <Article>() { article }, "@all", "", ""); break; } }
public override void InsertOrUpdate(ArticleInfoView objModal, string Id) { objModal.AppId = AppId; if (string.IsNullOrEmpty(Id) || Id == "0") { _BaseService.InsertView(objModal); } else { var lst = new List <string>() { "Title", "Content", "Comment", "URL", "AppId", "Previewers", "toDepartment", "toTag", "toUser" }; _BaseService.UpdateView(objModal, lst); } }