/// <summary> /// 删除模块或模块内容 /// </summary> /// <param name="contentId"></param> /// <param name="moduleId"></param> /// <param name="moduleType"></param> /// <returns></returns> public JsonResult DeleteMemberPageModule(long contentId, long moduleId, int moduleType) { bool flag = false; var channelManager = new MemberPageChannelManager(); var contentManager = new MemberPageModuleContentManager(); var moduleManager = new MemberPageModuleManager(); if (moduleType == 0)//模块内容 { channelManager.DeleteMemberPageChannel(contentId); flag = contentManager.DeleteMemberPageModuleContent(contentId); #region 日志记录 using (var client = new ConfigLogClient()) { var response = client.InsertDefaultLogQueue("CommonConfigLog", JsonConvert.SerializeObject(new { ObjectId = contentId, ObjectType = "MemberPageModuleContent", BeforeValue = "", AfterValue = "", Remark = "删除", Creator = User.Identity.Name, })); } #endregion } else//模块 { channelManager.DeleteMemberPageChannelByModuleID(moduleId); contentManager.DeleteMemberPageModuleContentByModuleID(moduleId); flag = moduleManager.DeleteMemberPageModule(moduleId); #region 日志记录 using (var client = new ConfigLogClient()) { var response = client.InsertDefaultLogQueue("CommonConfigLog", JsonConvert.SerializeObject(new { ObjectId = moduleId, ObjectType = "MemberPageModule", BeforeValue = "", AfterValue = "", Remark = "删除", Creator = User.Identity.Name, })); } #endregion } //等待1秒,写库同步到读库 Thread.Sleep(1000); moduleManager.RefreshMemberPageCache(); return(Json(flag, JsonRequestBehavior.AllowGet)); }
public JsonResult AddMemberPageModuleContent(MemberPageModuleContentModel model) { #region 数据验证 if (!string.IsNullOrEmpty(model.StartVersion)) { Version startVersion; if (!Version.TryParse(model.StartVersion, out startVersion)) { return(Json(new { status = false, msg = "APP开始版本的类型有误" }, JsonRequestBehavior.AllowGet)); } } if (!string.IsNullOrEmpty(model.EndVersion)) { Version endVersion; if (!Version.TryParse(model.EndVersion, out endVersion)) { return(Json(new { status = false, msg = "APP结束版本的类型有误" }, JsonRequestBehavior.AllowGet)); } } if (model.ChannelList != null) { foreach (var item in model.ChannelList) { if (string.IsNullOrWhiteSpace(item.Link)) { return(Json(new { status = false, msg = $"请输入{item.Channel}渠道的跳转链接" }, JsonRequestBehavior.AllowGet)); } } } #endregion bool flag = false; var memberPageManager = new MemberPageManager(); var moduleManager = new MemberPageModuleManager(); var contentManager = new MemberPageModuleContentManager(); var channelManager = new MemberPageChannelManager(); if (model.ImageUrl == "static/default.jpg") { model.ImageUrl = null; } if (model.PKID == 0)//新建 { var memberPageInfo = memberPageManager.GetMemberPageByPageCode(model.PageCode); if (memberPageInfo != null) { model.MemberPageID = memberPageInfo.PKID; } model.Creator = User.Identity.Name; flag = contentManager.AddMemberPageModuleContent(model); #region 日志记录 using (var client = new ConfigLogClient()) { var response = client.InsertDefaultLogQueue("CommonConfigLog", JsonConvert.SerializeObject(new { ObjectId = model.PKID, ObjectType = "MemberPageModuleContent", BeforeValue = "", AfterValue = JsonConvert.SerializeObject(model), Remark = "创建", Creator = User.Identity.Name, })); } #endregion } else//编辑 { var contentInfo = contentManager.GetMemberPageModuleContentInfo(model.PKID); flag = contentManager.UpdateMemberPageModuleContent(model); channelManager.DeleteMemberPageChannel(model.PKID); #region 日志记录 using (var client = new ConfigLogClient()) { var response = client.InsertDefaultLogQueue("CommonConfigLog", JsonConvert.SerializeObject(new { ObjectId = model.PKID, ObjectType = "MemberPageModuleContent", BeforeValue = JsonConvert.SerializeObject(contentInfo), AfterValue = JsonConvert.SerializeObject(model), Remark = "编辑", Creator = User.Identity.Name, })); } #endregion } //重新保存渠道信息 if (model.ChannelList != null) { foreach (var item in model.ChannelList) { if (item.MemberPageModuleContentID == 0) { item.MemberPageModuleContentID = model.PKID; } channelManager.AddMemberPageChannel(item); } } //等待1秒,写库同步到读库 Thread.Sleep(1000); moduleManager.RefreshMemberPageCache(); return(Json(new { status = flag, msg = "" }, JsonRequestBehavior.AllowGet)); }