public async Task <ActionResult> AddExport() { var file = Request.Files[0]; if (file.ContentType != "application/vnd.ms-excel" && file.ContentType != "application/x-xls") { return(Content(JsonConvert.SerializeObject(new { Status = -1, Error = "请上传.xlsx文件或者.xls文件" }), "text/html")); } var excel = new Controls.ExcelHelper(file.InputStream, file.FileName); var dt = excel.ExcelToDataTable("问答题库", true); if (dt != null && dt?.Rows?.Count > 0) { if (dt.Columns.Count != 8) { return(Content(JsonConvert.SerializeObject(new { Status = -1, Error = "请确认文档的列是否只有【编码】【标签】【题目】【选项A】【选项B】【选项B】【选项C】【选项D】【正确选项】这几列" }), "text/html")); } RepositoryManager manager = new RepositoryManager(); using (var db = manager.BeginTrans()) { foreach (DataRow dr in dt.Rows) { if (string.IsNullOrWhiteSpace(dr[2].ToString().Trim()))//过滤 答题 为空的 行 { continue; } AnswerInfoListEntity entity = new AnswerInfoListEntity() { Tip = dr[1].ToString(), Answer = dr[2].ToString(), OptionsA = dr[3].ToString(), OptionsB = dr[4].ToString(), OptionsC = dr[5].ToString(), OptionsD = dr[6].ToString(), OptionsReal = dr[7].ToString(), CreateDateTime = DateTime.Now, LastUpdateDateTime = DateTime.Now, IsEnabled = true }; db.Insert <AnswerInfoListEntity>(entity); } db.Commit(); } //读写分离 做延时 await Task.Delay(2000); #region 更新问答题库缓存 RefreshQuestionInfoListCache(); #endregion return(Content(JsonConvert.SerializeObject(new { Status = 1, Error = "导入成功" }), "text/html")); } else { return(Content(JsonConvert.SerializeObject(new { Status = -1, Error = "请确认xls的sheet名称是否为:问答题库;是否有内容" }), "text/html")); } }
public ActionResult Delete(string group, int pkid) { if (string.IsNullOrWhiteSpace(group) || pkid == 0) { return(Content("null")); } try { RepositoryManager repository = new RepositoryManager(); using (var db = repository.BeginTrans()) { Expression <Func <ActivePageContentEntity, bool> > expression = _ => _.GROUP == group; db.Delete <ActivePageContentEntity>(expression); Expression <Func <ActivePageMenuEntity, bool> > expre = _ => _.FKActiveContentID == pkid; db.Delete <ActivePageMenuEntity>(expre); db.Commit(); } return(Content(JsonConvert.SerializeObject(new { state = "success", message = "操作成功" }))); } catch (Exception em) { return(Content(JsonConvert.SerializeObject(new { state = "error", message = em.Message }))); } }
public ActionResult SetBackgroundColor(int keyValue, string color) { try { Expression <Func <ActivePageHomeEntity, bool> > expression = _ => _.FKActiveID == keyValue; RepositoryManager repository = new RepositoryManager(); var list = repository.GetEntityList <ActivePageHomeEntity>(expression); if (list != null && list.Any()) { using (var db = repository.BeginTrans()) { foreach (var item in list) { item.BackgroundColor = color; db.Update(item); } db.Commit(); } } return(Content("1")); } catch (System.Exception ex) { return(Content(ex.Message)); } }
public ActionResult SubmitFormCopy(int?keyValue) { RepositoryManager manager = new RepositoryManager(); var entity = manager.GetEntity <BusniessListEntity>(keyValue); if (entity != null) { Expression <Func <BusniessListDeatilEntity, bool> > exp = _ => _.FKID == entity.PKID; var list = manager.GetEntityList <BusniessListDeatilEntity>(exp); manager.Add <BusniessListEntity>(entity); if (list != null) { using (var db = manager.BeginTrans()) { foreach (var i in list) { i.FKID = entity.PKID; db.Insert <BusniessListDeatilEntity>(i); } db.Commit(); } } } return(Content(JsonConvert.SerializeObject(new { state = "success", message = "操作成功", data = "" }))); }
public ActionResult SubmitAnswer(BigBrandAnsQuesEntity model) { if (model.BigBrandPKID == 0) { return(Content(JsonConvert.SerializeObject(new { state = "error", message = "抽奖PKID不能为空", data = "参数没有实例化" }))); } RepositoryManager manager = new RepositoryManager(); using (var db = manager.BeginTrans()) { Expression <Func <BigBrandAnsQuesEntity, bool> > exp = _ => _.BigBrandPKID == model.BigBrandPKID; db.Delete <BigBrandAnsQuesEntity>(exp); model.CreateDateTime = DateTime.Now; model.LastUpdateDateTime = DateTime.Now; db.Insert <BigBrandAnsQuesEntity>(model); db.Commit(); LoggerManager.InsertOplog(new ConfigHistory() { AfterValue = JsonConvert.SerializeObject(model), Author = User.Identity.Name, Operation = "抽奖问答配置", ObjectType = "BigBrand" }); } return(Content(JsonConvert.SerializeObject(new { state = "success", message = "操作成功", data = "" }))); }
/// <summary> /// 保存 摇奖机的 配置 /// </summary> /// <param name="model"></param> /// <returns></returns> public ActionResult SubmitPageConfige(BigBrandPageConfigeEntity model, List <BigBrandPageStyleEntity> pageStyles) { model.DrawMachineImgUri = model.DrawMachineImgUri ?? ""; model.HomeBgImgUri = model.HomeBgImgUri ?? ""; model.HomeBgImgUri2 = model.HomeBgImgUri2 ?? ""; model.ResultImgUri = model.ResultImgUri ?? ""; if (model.FKPKID == 0) { return(Content(JsonConvert.SerializeObject(new { state = "error", message = "抽奖PKID不能为空", data = "参数没有实例化" }))); } RepositoryManager manager = new RepositoryManager(); using (var db = manager.BeginTrans()) { Expression <Func <BigBrandPageConfigeEntity, bool> > exp = _ => _.FKPKID == model.FKPKID && _.ActivityType == model.ActivityType; db.Delete <BigBrandPageConfigeEntity>(exp); model.CreateDateTime = DateTime.Now; model.LastUpdateDateTime = DateTime.Now; db.Insert <BigBrandPageConfigeEntity>(model); foreach (var item in pageStyles) { item.ImageUri = item.ImageUri ?? ""; if (item.PKID == 0) { item.CreateDateTime = DateTime.Now; item.LastUpdateDateTime = DateTime.Now; db.Insert(item); } else { var original = db.FindEntity <BigBrandPageStyleEntity>(item.PKID); if (item.ImageUri != original.ImageUri) { original.ImageUri = item.ImageUri; original.LastUpdateDateTime = DateTime.Now; db.Update(original); } } } db.Commit(); LoggerManager.InsertOplog(new ConfigHistory() { AfterValue = JsonConvert.SerializeObject(model), Author = User.Identity.Name, Operation = "活动页面 配置", ObjectType = "BigBrandPageConfig" }); } return(Content(JsonConvert.SerializeObject(new { state = "success", message = "操作成功", data = "" }))); }
public ActionResult SubmitHomeDeatil(string json, int fkActivePage) { if (string.IsNullOrWhiteSpace(json)) { return(Content(JsonConvert.SerializeObject(new { state = "error", message = "信息为空" }))); } var list = JsonConvert.DeserializeObject <IEnumerable <ActivePageHomeDeatilEntity> >(json.Replace("\" \"", "null")); if (list == null || list?.Count() == 0) { return(Content(JsonConvert.SerializeObject(new { state = "error", message = "信息为空" }))); } try { RepositoryManager repository = new RepositoryManager(); IEnumerable <ActivePageHomeDeatilEntity> beforeList = null; using (var db = repository.BeginTrans()) { Expression <Func <ActivePageHomeDeatilEntity, bool> > expression = _ => _.FKActiveHome == fkActivePage; beforeList = repository.GetEntityList <ActivePageHomeDeatilEntity>(expression); db.Delete <ActivePageHomeDeatilEntity>(expression); foreach (var item in list) { item.CreateDateTime = DateTime.Now; item.FKActiveHome = fkActivePage; db.Insert <ActivePageHomeDeatilEntity>(item); } db.Commit(); LoggerManager.InsertOplog(new ConfigHistory() { BeforeValue = JsonConvert.SerializeObject(beforeList), AfterValue = JsonConvert.SerializeObject(list), Author = User.Identity.Name, Operation = "会场明细", ObjectType = "AUCAct" }); } return(Content(JsonConvert.SerializeObject(new { state = "success", message = "操作成功" }))); } catch (Exception em) { return(Content(JsonConvert.SerializeObject(new { state = "error", message = em.Message }))); } }
public ActionResult AddExport() { var file = Request.Files[0]; if (file.ContentType != "application/vnd.ms-excel" && file.ContentType != "application/x-xls") { return(Content(JsonConvert.SerializeObject(new { Status = -1, Error = "请上传.xlsx文件或者.xls文件" }), "text/html")); } var excel = new Tuhu.Provisioning.Controls.ExcelHelper(file.InputStream, file.FileName); var dt = excel.ExcelToDataTable("问答题库", true); if (dt != null && dt?.Rows?.Count > 0) { if (dt.Columns.Count != 8) { return(Content(JsonConvert.SerializeObject(new { Status = -1, Error = "请确认文档的列是否只有【编码】【标签】【题目】【选项A】【选项B】【选项B】【选项C】【选项D】【正确选项】这几列" }), "text/html")); } RepositoryManager manager = new RepositoryManager(); using (var db = manager.BeginTrans()) { foreach (DataRow dr in dt.Rows) { AnswerInfoListEntity entity = new AnswerInfoListEntity() { Tip = dr[1].ToString(), Answer = dr[2].ToString(), OptionsA = dr[3].ToString(), OptionsB = dr[4].ToString(), OptionsC = dr[5].ToString(), OptionsD = dr[6].ToString(), OptionsReal = dr[7].ToString(), CreateDateTime = DateTime.Now, LastUpdateDateTime = DateTime.Now, IsEnabled = true }; db.Insert <AnswerInfoListEntity>(entity); } db.Commit(); } return(Content(JsonConvert.SerializeObject(new { Status = 1, Error = "导入成功" }), "text/html")); } else { return(Content(JsonConvert.SerializeObject(new { Status = -1, Error = "请确认xls的sheet名称是否为:问答题库;是否有内容" }), "text/html")); } }
public JsonResult UpdateIsEnabled(string ids, bool enabled) { RepositoryManager manager = new RepositoryManager(); using (var db = manager.BeginTrans()) { var list = db.FindList <AnswerInfoListEntity>($"SELECT * FROM Configuration.dbo.AnswerInfoList WITH(NOLOCK) WHERE PKID IN ({ids})"); foreach (var item in list) { item.IsEnabled = enabled; db.Update(item); } db.Commit(); } return(Json(new { code = 1 })); }
public async Task <JsonResult> UpdateIsEnabled(string ids, bool enabled) { RepositoryManager manager = new RepositoryManager(); using (var db = manager.BeginTrans()) { var list = db.FindList <AnswerInfoListEntity>($"SELECT * FROM Configuration.dbo.AnswerInfoList WITH(NOLOCK) WHERE PKID IN ({ids}) AND Is_Deleted=0"); foreach (var item in list) { item.IsEnabled = enabled; db.Update(item); } db.Commit(); } //读写分离 做延时 await Task.Delay(2000); #region 更新问答题库缓存 RefreshQuestionInfoListCache(); #endregion return(Json(new { code = 1 })); }
public ActionResult DeleteForm(int?keyValue) { RepositoryManager manager = new RepositoryManager(); using (var db = manager.BeginTrans()) { var entity = manager.GetEntity <BusniessListEntity>(keyValue); Expression <Func <BusniessListEntity, bool> > exp = _ => _.PKID == keyValue; db.Delete <BusniessListEntity>(exp); Expression <Func <BusniessListDeatilEntity, bool> > expre = _ => _.FKID == keyValue; db.Delete <BusniessListDeatilEntity>(expre); db.Commit(); LoggerManager.InsertOplog(new ConfigHistory() { BeforeValue = JsonConvert.SerializeObject(entity), Author = User.Identity.Name, Operation = "删除业务", ObjectType = "OWNBCON" }); return(Content(JsonConvert.SerializeObject(new { state = "success", message = "操作成功", data = "" }))); } }
public ActionResult Submit(string json, string group, int?fkActivityID, int pkid = 0, int?MenuType = 0) { if (string.IsNullOrWhiteSpace(json) || string.IsNullOrWhiteSpace(group) || fkActivityID == null || fkActivityID == 0) { return(Content("null")); } try { RepositoryManager repository = new RepositoryManager(); ActivePageContentEntity content = new ActivePageContentEntity(); try { using (var db = repository.BeginTrans()) { var activityEntity = db.FindEntity <ActivePageListEntity>(fkActivityID); activityEntity.MenuType = MenuType; db.Update <ActivePageListEntity>(activityEntity); IEnumerable <ActivePageMenuEntity> beforeList = null; if (pkid != 0) { Expression <Func <ActivePageMenuEntity, bool> > expression = _ => _.FKActiveContentID == pkid; beforeList = repository.GetEntityList <ActivePageMenuEntity>(expression); db.Delete <ActivePageMenuEntity>(expression); } else { content.FKActiveID = fkActivityID; content.GROUP = group; content.CreateDateTime = DateTime.Now; content.Type = -2; content.RowType = 0; content.OrderBy = 1; content.IsUploading = false; content.Channel = "wap"; repository.Add <ActivePageContentEntity>(content); } var list = JsonConvert.DeserializeObject <IEnumerable <ActivePageMenuEntity> >(json); foreach (var item in list) { item.FKActiveContentID = content.PKID == 0 ? pkid : content.PKID; item.CreateDateTime = DateTime.Now; item.UpdateDateTime = DateTime.Now; db.Insert <ActivePageMenuEntity>(item); } db.Commit(); LoggerManager.InsertOplog(new ConfigHistory() { BeforeValue = JsonConvert.SerializeObject(beforeList), AfterValue = JsonConvert.SerializeObject(list), Author = User.Identity.Name, Operation = "菜单配置", ObjectType = "AUCAct" }); } } catch (Exception em) { Expression <Func <ActivePageContentEntity, bool> > expre = _ => _.PKID == content.PKID; repository.Delete <ActivePageContentEntity>(expre); throw new Exception("保存菜单明细错误"); } ActivityUnityController activity = new ActivityUnityController(); activity.RefreshSource(fkActivityID); //刷新活动页缓存 return(Content(JsonConvert.SerializeObject(new { state = "success", message = "操作成功" }))); } catch (Exception em) { return(Content(JsonConvert.SerializeObject(new { state = "error", message = em.Message }))); } }
//提交 活动页面 public ActionResult SubmitPageStyle(string json) { IEnumerable <BigBrandPageStyleEntity> list = JsonConvert.DeserializeObject <IEnumerable <BigBrandPageStyleEntity> >(json); if (list != null) { RepositoryManager manager = new RepositoryManager(); var exitGroup = list?.FirstOrDefault().GroupGuid; var fkpkid = list?.FirstOrDefault().FKPKID; Expression <Func <BigBrandPageStyleEntity, bool> > exp = _ => _.GroupGuid == exitGroup && _.FKPKID == fkpkid; var data = manager.GetEntityList <BigBrandPageStyleEntity>(exp); if (data != null && data.Count() > 0) { data.ForEach(_ => { _.LastUpdateDateTime = DateTime.Now; _.UpdateUserName = User.Identity.Name; var item = list.Where(o => o.Position == _.Position)?.FirstOrDefault(); _.ImageUri = item.ImageUri; _.BImageUri = item.BImageUri; _.PromptStyle = item.PromptStyle; _.IsShare = item.IsShare; }); using (var db = manager.BeginTrans()) { foreach (var item in data) { db.Update <BigBrandPageStyleEntity>(item); } db.Commit(); } } else { using (var db = manager.BeginTrans()) { list.ForEach(_ => { _.CreateDateTime = DateTime.Now; _.LastUpdateDateTime = DateTime.Now; _.CreateUserName = User.Identity.Name; _.UpdateUserName = User.Identity.Name; }); foreach (var item in list) { db.Insert <BigBrandPageStyleEntity>(item); } db.Commit(); } } LoggerManager.InsertOplog(new ConfigHistory() { AfterValue = JsonConvert.SerializeObject(list), Author = User.Identity.Name, Operation = "大翻牌页面配置", ObjectType = "BigBrand" }); return(Content(JsonConvert.SerializeObject(new { state = "success", message = "操作成功", data = "" }))); } else { return(Content(JsonConvert.SerializeObject(new { state = "error", message = "操作失败", data = "参数没有实例化" }))); } }
public ActionResult SubmitFormPackage(string entityString, string data) { data = data.Replace("\" \"", "null"); entityString = entityString.Replace("\" \"", "null"); IEnumerable <BigBrandRewardPoolEntity> list = JsonConvert.DeserializeObject <IEnumerable <BigBrandRewardPoolEntity> >(data); RepositoryManager manager = new RepositoryManager(); var entity = JsonConvert.DeserializeObject <BigBrandRewardPoolEntity>(entityString); if (entity.PKID == 0) { entity.CreateDateTime = DateTime.Now; entity.LastUpdateDateTime = DateTime.Now; entity.CreateUserName = User.Identity.Name; entity.UpdateUserName = User.Identity.Name; entity.Status = true; manager.Add <BigBrandRewardPoolEntity>(entity); using (var db = manager.BeginTrans()) { if (list != null) { foreach (var item in list) { item.FKPKID = entity.FKPKID; item.ParentPKID = entity.PKID; item.CreateDateTime = DateTime.Now; item.UpdateUserName = User.Identity.Name; item.LastUpdateDateTime = DateTime.Now; item.CreateUserName = User.Identity.Name; item.Status = true; if (item.CouponGuid != null) { System.Data.DataTable dt = DataAccess.DAO.DALActivity.CouponVlidate(item.CouponGuid.Value.ToString()); if (dt == null || dt.Rows.Count == 0) { return(Content(JsonConvert.SerializeObject(new { state = "error", message = "配置的优惠券:" + item.CouponGuid.Value + "不存在,请重新配置", data = "" }))); } item.Name = dt.Rows[0]["PromtionName"].ToString(); } else if (item.WxRedBagAmount > 0) { item.Name = "微信红包"; } else if (item.Integral > 0) { item.Name = "积分"; } db.Insert <BigBrandRewardPoolEntity>(item); } db.Commit(); } } LoggerManager.InsertOplog(new ConfigHistory() { AfterValue = JsonConvert.SerializeObject(entity), Author = User.Identity.Name, Operation = "新增大翻牌礼包信息", ObjectType = "BigBrand" }); LoggerManager.InsertOplog(new ConfigHistory() { AfterValue = JsonConvert.SerializeObject(list), Author = User.Identity.Name, Operation = "新增大翻牌礼包明细", ObjectType = "BigBrand" }); } else { var before = manager.GetEntity <BigBrandRewardPoolEntity>(entity.PKID); entity.LastUpdateDateTime = DateTime.Now; entity.UpdateUserName = User.Identity.Name; manager.Update <BigBrandRewardPoolEntity>(entity); Expression <Func <BigBrandRewardPoolEntity, bool> > exp = _ => _.ParentPKID == entity.PKID; using (var db = manager.BeginTrans()) { var contentList = db.FindList <BigBrandRewardPoolEntity>(exp); if (contentList != null) { foreach (var i in contentList) { i.Status = false; db.Update <BigBrandRewardPoolEntity>(i); } } if (list != null) { foreach (var item in list) { item.FKPKID = entity.FKPKID; item.ParentPKID = entity.PKID; item.CreateDateTime = DateTime.Now; item.UpdateUserName = User.Identity.Name; item.LastUpdateDateTime = DateTime.Now; item.CreateUserName = User.Identity.Name; item.Status = true; if (item.CouponGuid != null) { System.Data.DataTable dt = DataAccess.DAO.DALActivity.CouponVlidate(item.CouponGuid.Value.ToString()); if (dt == null || dt.Rows.Count == 0) { return(Content(JsonConvert.SerializeObject(new { state = "error", message = "配置的优惠券:" + item.CouponGuid.Value + "不存在,请重新配置", data = "" }))); } item.Name = dt.Rows[0]["PromtionName"].ToString(); } else if (item.WxRedBagAmount > 0) { item.Name = "微信红包"; } else if (item.Integral > 0) { item.Name = "积分"; } db.Insert <BigBrandRewardPoolEntity>(item); } db.Commit(); } } LoggerManager.InsertOplog(new ConfigHistory() { BeforeValue = JsonConvert.SerializeObject(before), AfterValue = JsonConvert.SerializeObject(entity), Author = User.Identity.Name, Operation = "更新大翻牌礼包信息", ObjectType = "BigBrand" }); LoggerManager.InsertOplog(new ConfigHistory() { AfterValue = JsonConvert.SerializeObject(list), Author = User.Identity.Name, Operation = "更新大翻牌礼包明细", ObjectType = "BigBrand" }); } return(Content(JsonConvert.SerializeObject(new { state = "success", message = "操作成功", data = "" }))); }
/// <summary> /// 提交大翻盘的配置 /// </summary> /// <param name="modeljson"></param> /// <param name="wheeljson"></param> /// <returns></returns> public async Task <ActionResult> SubmitForm(string modeljson, string wheeljson) { modeljson = modeljson.Replace("\" \"", "null"); wheeljson = wheeljson.Replace("\" \"", "null"); try { BigBrandRewardListEntity entity = JsonConvert.DeserializeObject <BigBrandRewardListEntity>(modeljson); IEnumerable <BigBrandWheelEntity> wheel = null; if (!string.IsNullOrWhiteSpace(wheeljson)) { wheel = JsonConvert.DeserializeObject <IEnumerable <BigBrandWheelEntity> >(wheeljson); } RepositoryManager manager = new RepositoryManager(); //获取修改前旧数据 var oldEntity = new BigBrandRewardListEntity(); var oldWheel = new List <BigBrandWheelEntity>(); if (entity.PKID > 0) { try { oldEntity = manager.GetEntity <BigBrandRewardListEntity>(p => p.PKID == entity.PKID && p.Is_Deleted == false); Expression <Func <BigBrandWheelEntity, bool> > wheelExp = _ => _.FKBigBrand == entity.PKID && _.Is_Deleted == false; oldWheel = manager.GetEntityList <BigBrandWheelEntity>(wheelExp)?.ToList(); } catch (Exception ex) { Logger.Log(Level.Error, $"ex:{ex}"); } } using (var db = manager.BeginTrans()) { string errorMsg = string.Empty; var newWheelList = new List <BigBrandWheelEntity>(); //判断FKBigBrand,TimeNumber,FKPoolPKID(奖池ID) 是否唯一 if (wheel != null) { foreach (var item in wheel) { item.CreateDateTime = DateTime.Now; item.CreateUserName = User.Identity.Name; item.LastUpdateDateTime = DateTime.Now; item.UpdateUserName = User.Identity.Name; item.FKBigBrand = entity.PKID; var array = item.FKPoolPKIDText.TrimEnd(',').Split(','); if (array != null && array.Length > 0) { foreach (var s in array) { int poolPKID = 0; if (int.TryParse(s, out poolPKID)) { if (poolPKID != 0) { item.FKPoolPKID = poolPKID; var wheelPkidList = manager.GetEntityList <BigBrandWheelEntity>(_ => _.FKBigBrand == item.FKBigBrand && _.TimeNumber == item.TimeNumber && _.FKPoolPKID == item.FKPoolPKID && _.Is_Deleted == false).ToList().Select(p => p.PKID).ToList(); var existWheelList = manager.GetEntityList <BigBrandWheelEntity>(_ => _.FKBigBrand == item.FKBigBrand && _.TimeNumber == item.TimeNumber && _.FKPoolPKID == item.FKPoolPKID && _.Is_Deleted == false && !wheelPkidList.Contains(_.PKID)); if (existWheelList != null && existWheelList.ToList().Count > 0) { if (!errorMsg.Contains("第" + item.TimeNumber + "轮")) { errorMsg = errorMsg + "第" + item.TimeNumber + "轮奖池ID,"; } } else { string json = JsonConvert.SerializeObject(item); var tempModel = JsonConvert.DeserializeObject <BigBrandWheelEntity>(json); newWheelList.Add(tempModel); } } } } } } } if (errorMsg.Length > 0) { errorMsg = errorMsg.TrimEnd(',') + "的值重复了!"; return(Content(JsonConvert.SerializeObject(new { state = "false", message = errorMsg, data = "" }))); } if (entity.PKID == 0) { entity.HashKeyValue = Tuhu.Provisioning.Common.SecurityHelper.Sha1Encrypt(Guid.NewGuid().ToString(), System.Text.Encoding.UTF8).Substring(0, 8); entity.CreateDateTime = DateTime.Now; entity.LastUpdateDateTime = DateTime.Now; entity.UpdateUserName = User.Identity.Name; entity.CreateUserName = User.Identity.Name; manager.Add <BigBrandRewardListEntity>(entity); // LoggerManager.InsertOplog(new ConfigHistory() { AfterValue = JsonConvert.SerializeObject(entity), Author = User.Identity.Name, Operation = "新增大翻牌活动", ObjectType = "BigBrand" }); } else { entity.LastUpdateDateTime = DateTime.Now; entity.UpdateUserName = User.Identity.Name; manager.Update <BigBrandRewardListEntity>(entity); // LoggerManager.InsertOplog(new ConfigHistory() { AfterValue = JsonConvert.SerializeObject(entity), Author = User.Identity.Name, Operation = "更新大翻牌活动", ObjectType = "BigBrand" }); } Expression <Func <BigBrandWheelEntity, bool> > exp = _ => _.FKBigBrand == entity.PKID && _.Is_Deleted == false; var bigBrandWheelList = manager.GetEntityList <BigBrandWheelEntity>(exp); foreach (var item in bigBrandWheelList) { item.Is_Deleted = true; item.LastUpdateDateTime = DateTime.Now; item.UpdateUserName = User.Identity.Name; manager.Update <BigBrandWheelEntity>(item); } if (wheel != null) { foreach (var item in newWheelList) { db.Insert <BigBrandWheelEntity>(item); } } db.Commit(); // LoggerManager.InsertOplog(new ConfigHistory() { AfterValue = JsonConvert.SerializeObject(wheel), Author = User.Identity.Name, Operation = "大翻牌明细", ObjectType = "BigBrand" }); } entity = manager.GetEntity <BigBrandRewardListEntity>(p => p.PKID == entity.PKID && p.Is_Deleted == false); //操作日志 SubmitFormLog(oldEntity, entity, oldWheel, wheel); //读写分离 做延时 await Task.Delay(3000); #region 更新大翻盘缓存 using (var client = new Tuhu.Service.Activity.BigBrandClient()) { var result = client.UpdateBigBrand(entity.HashKeyValue); result.ThrowIfException(true); } #endregion #region 更新 活动页的 缓存 //筛选 出大翻盘相关的 活动页 配置 List <ActivePageContentEntity> activeEntityList = manager.GetEntityList <ActivePageContentEntity>(p => p.HashKey == entity.HashKeyValue && p.Type == 20).ToList(); foreach (var activeEntity in activeEntityList) { var activePageList = manager.GetEntity <ActivePageListEntity>(activeEntity.FKActiveID); using (var client = new Tuhu.Service.Activity.ActivityClient()) { var result1 = await client.RefreshActivePageListModelCacheAsync(new Service.Activity.Models.Requests.ActivtyPageRequest() { Channel = "wap", HashKey = activePageList.HashKey, }); result1.ThrowIfException(true); var result2 = await client.RefreshActivePageListModelCacheAsync(new Service.Activity.Models.Requests.ActivtyPageRequest() { ActivityId = activePageList.PKGuid.Value, Channel = "website", HashKey = activePageList.HashKey, }); result2.ThrowIfException(true); } var list = manager.GetEntityList <ActivePageContentEntity>(_ => _.FKActiveID == activeEntity.FKActiveID); var lucy = list?.Where(_ => _.Type == 13)?.FirstOrDefault(); if (lucy != null) { using (var client = new Tuhu.Service.Activity.ActivityClient()) { var result = await client.RefreshLuckWheelCacheAsync(lucy.ActivityID.ToString()); result.ThrowIfException(true); } } } #endregion return(Content(JsonConvert.SerializeObject(new { state = "success", message = "操作成功", data = "" }))); } catch (Exception em) { throw em; } }
public ActionResult SubmitForm(string modeljson, string wheeljson) { modeljson = modeljson.Replace("\" \"", "null"); wheeljson = wheeljson.Replace("\" \"", "null"); try { BigBrandRewardListEntity entity = JsonConvert.DeserializeObject <BigBrandRewardListEntity>(modeljson); IEnumerable <BigBrandWheelEntity> wheel = null; if (!string.IsNullOrWhiteSpace(wheeljson)) { wheel = JsonConvert.DeserializeObject <IEnumerable <BigBrandWheelEntity> >(wheeljson); } RepositoryManager manager = new RepositoryManager(); using (var db = manager.BeginTrans()) { if (entity.PKID == 0) { entity.HashKeyValue = Tuhu.Provisioning.Common.SecurityHelper.Sha1Encrypt(Guid.NewGuid().ToString(), System.Text.Encoding.UTF8).Substring(0, 8); entity.CreateDateTime = DateTime.Now; entity.LastUpdateDateTime = DateTime.Now; entity.UpdateUserName = User.Identity.Name; entity.CreateUserName = User.Identity.Name; manager.Add <BigBrandRewardListEntity>(entity); LoggerManager.InsertOplog(new ConfigHistory() { AfterValue = JsonConvert.SerializeObject(entity), Author = User.Identity.Name, Operation = "新增大翻牌活动", ObjectType = "BigBrand" }); } else { entity.LastUpdateDateTime = DateTime.Now; entity.UpdateUserName = User.Identity.Name; manager.Update <BigBrandRewardListEntity>(entity); LoggerManager.InsertOplog(new ConfigHistory() { AfterValue = JsonConvert.SerializeObject(entity), Author = User.Identity.Name, Operation = "更新大翻牌活动", ObjectType = "BigBrand" }); } Expression <Func <BigBrandWheelEntity, bool> > exp = _ => _.FKBigBrand == entity.PKID; db.Delete <BigBrandWheelEntity>(exp); if (wheel != null) { foreach (var item in wheel) { item.CreateDateTime = DateTime.Now; item.CreateUserName = User.Identity.Name; item.LastUpdateDateTime = DateTime.Now; item.UpdateUserName = User.Identity.Name; item.FKBigBrand = entity.PKID; var array = item.FKPoolPKIDText.TrimEnd(',').Split(','); if (array != null && array.Length > 0) { foreach (var s in array) { int poolPKID = 0; if (int.TryParse(s, out poolPKID)) { if (poolPKID != 0) { item.FKPoolPKID = poolPKID; string json = JsonConvert.SerializeObject(item); var tempModel = JsonConvert.DeserializeObject <BigBrandWheelEntity>(json); db.Insert <BigBrandWheelEntity>(tempModel); } } } } } } db.Commit(); LoggerManager.InsertOplog(new ConfigHistory() { AfterValue = JsonConvert.SerializeObject(wheel), Author = User.Identity.Name, Operation = "大翻牌明细", ObjectType = "BigBrand" }); } return(Content(JsonConvert.SerializeObject(new { state = "success", message = "操作成功", data = "" }))); } catch (Exception em) { throw em; } }