public List <RegionMarketingModel> GetRegionMarketingConfig(Guid?activityId, string activityName, DateTime?startTime, DateTime?endTime, int pageIndex, int pageSize) { List <RegionMarketingModel> result = new List <RegionMarketingModel>(); try { result = dbScopeReadManager.Execute(conn => DALRegionMarketing.SelectRegionMarketingConfig(conn, activityId, activityName, startTime, endTime, pageIndex, pageSize)); } catch (Exception ex) { logger.Log(Level.Error, ex, "GetRegionMarketingConfig"); } return(result); }
public bool SaveRegionarketingConfig(RegionMarketingModel data, string user) { var result = false; var flag = false; string msg = string.Empty; var isAdd = false; var startTime = data.StartTime.GetValueOrDefault(); var endTime = data.EndTime.GetValueOrDefault(); try { if (data != null) { data.StartTime = data.EndTime = null; dbScopeManager.CreateTransaction(conn => { var info = DALRegionMarketing.SelectRegionMarketingConfig(conn, data.ActivityId, string.Empty, null, null, 1, 10); if (info == null || info.Count == 0) { isAdd = true; msg = "添加活动配置"; flag = DALRegionMarketing.InsertRegionMarketingConfig(conn, data) > 0; } else { msg = "修改活动配置"; flag = DALRegionMarketing.UpdateRegionMarketingConfig(conn, data) > 0; } if (flag) { foreach (var item in data.ImgList) { var imgInfo = DALRegionMarketing.SelectActivityImgByIdAndType(conn, item.ActivityId, item.Type); if (imgInfo != null) { result = DALRegionMarketing.UpdateActivityImgByIdAnType(conn, item.ActivityId, item.ImgUrl, item.Type, item.Position) > 0; } else { result = DALRegionMarketing.InsertActivityImg(conn, item.ActivityId, item.ImgUrl, item.Type, item.Position) > 0; } } foreach (var item in data.ProductList) { var proInfo = DALRegionMarketing.SelectRegionProductsByPID(conn, item.ActivityId, item.ProductId); if (proInfo != null) { result = DALRegionMarketing.UpdateRegionProductInfo(conn, item.ActivityId, item.ProductId, item.AdvertiseTitle, item.SpecialCondition) > 0; } else { result = DALRegionMarketing.InsertRegionProductInfo(conn, item.ActivityId, item.ProductId, item.AdvertiseTitle, item.SpecialCondition) > 0; } } } }); } } catch (Exception ex) { result = false; logger.Log(Level.Error, ex, "SaveRegionarketingConfig"); } if (result) { data.ProductList = new List <RegionMarketingProductConfig>(); data.ImgList = new List <DataAccess.Entity.RegionMarketing.ActivityImageConfig>(); InsertLog("RegionMarketingLog", data.ActivityId, JsonConvert.SerializeObject(data), msg, user, LogType); if (isAdd) { CallCRMService.NewAddActivity(data.ActivityName, startTime, endTime, "", data.ActivityRules, data.ActivityId.ToString(), CRMSourceType.TiresActivityOne, user); } else { CallCRMService.NewUpdateActivity(data.ActivityName, startTime, endTime, "", data.ActivityRules, data.ActivityId.ToString(), CRMSourceType.TiresActivityOne, user); } } return(result); }