public bool DeleteUpkeepActivitySetting(int id, string activityNum) { try { if (DalBaoYangActivitySetting.DeleteUpkeepActivitySetting(id)) { using (var client = new CacheClient()) { client.UpdateBaoYangActivityAsync(activityNum); } CleanBaoYangActivitySettingCache(activityNum); return(true); } else { return(false); } } catch (TuhuBizException) { throw; } catch (Exception ex) { Logger.Error("DeleteUpkeepActivitySetting", ex); throw ex; } }
public bool UpdateUpkeepActivitySetting(BaoYangActivitySetting model) { try { if (DalBaoYangActivitySetting.UpdateUpkeepActivitySetting(model)) { using (var client = new CacheClient()) { client.UpdateBaoYangActivityAsync(model.ActivityNum); } CleanBaoYangActivitySettingCache(model.ActivityNum); return(true); } else { return(false); } } catch (TuhuBizException) { throw; } catch (Exception ex) { Logger.Error("UpdateUpkeepActivitySetting", ex); throw ex; } }
public bool InsertUpkeepActivitySetting(BaoYangActivitySetting model) { try { int id = 0; string activityNum = ""; if (DalBaoYangActivitySetting.InsertUpkeepActivitySetting(model, out id, out activityNum)) { using (var client = new CacheClient()) { client.UpdateBaoYangActivityAsync(activityNum); } return(true); } else { return(false); } } catch (TuhuBizException) { throw; } catch (Exception ex) { Logger.Error("InsertUpkeepActivitySetting", ex); throw ex; } }
public bool InsertBaoYangActivitySettingItem(BaoYangActivitySettingItem model, string actId) { try { if (DalBaoYangActivitySetting.InsertBaoYangActivitySettingItem(model)) { using (var client = new CacheClient()) { client.UpdateBaoYangActivityAsync(actId); } return(true); } else { return(false); } } catch (TuhuBizException) { throw; } catch (Exception ex) { Logger.Error("InsertBaoYangActivitySettingItem", ex); throw ex; } }
public bool DeleteBaoYangActivitySettingItem(int id, int baoYangActivityId) { try { if (DalBaoYangActivitySetting.DeleteBaoYangActivitySettingItem(id)) { using (var client = new CacheClient()) { client.UpdateBaoYangActivityAsync(DalBaoYangActivitySetting.GetUpkeepActivitySettingById(baoYangActivityId).ActivityNum); } return(true); } else { return(false); } } catch (TuhuBizException) { throw; } catch (Exception ex) { Logger.Error("DeleteBaoYangActivitySettingItem", ex); throw ex; } }
/// <summary> /// 批量删除保养活动地区配置 /// </summary> /// <param name="regionIds"></param> /// <param name="user"></param> /// <returns></returns> public Tuple <bool, bool> MultDeleteBaoYangActivityRegion(List <int> regionIds, string user) { var result = false; var cacheResult = false; try { var logData = new List <BaoYangOprLog>(); if (regionIds != null && regionIds.Any()) { dbScopeManagerGungnir.CreateTransaction(conn => { foreach (var regionId in regionIds) { if (regionId > 0) { var oldValue = GetBaoYangActivityRegionByRegionId(regionId); if (oldValue != null) { var delResult = DalBaoYangActivitySetting.DeleteBaoYangActivityRegion(conn, regionId); if (!delResult) { throw new Exception($"DeleteBaoYangActivityRegion失败,{JsonConvert.SerializeObject(oldValue)}"); } var log = new BaoYangOprLog { LogType = "BaoYangActivityRegion", IdentityID = regionId.ToString(), OldValue = JsonConvert.SerializeObject(oldValue), NewValue = null, Remarks = "Delete", OperateUser = user, }; logData.Add(log); } } } result = true; }); foreach (var log in logData) { LoggerManager.InsertLog("BYOprLog", log); } cacheResult = CleanBaoYangActivityRegionCache(regionIds); } } catch (Exception ex) { Logger.Error("MultDeleteBaoYangActivityRegion", ex); } return(Tuple.Create(result, cacheResult)); }
/// <summary> /// 获取保养活动关联配置 /// </summary> /// <param name="id"></param> /// <returns></returns> public BaoYangActivitySettingItem GetBaoYangActivitySettingItemById(int id) { var result = null as BaoYangActivitySettingItem; try { result = DalBaoYangActivitySetting.GetBaoYangActivitySettingItemById(id); } catch (Exception ex) { Logger.Error("GetBaoYangActivitySettingItemById", ex); } return(result); }
/// <summary> /// 获取所有机油粘度 /// </summary> /// <returns></returns> public List <string> GetAllOilViscosity() { var result = null as List <string>; try { result = dbScopeManagerGungnirRead.Execute(conn => DalBaoYangActivitySetting.GetAllOilViscosity(conn)); } catch (Exception ex) { Logger.Error("GetAllOilViscosity", ex); } return(result); }
/// <summary> /// 根据保养活动Id获取保养活动名称 /// </summary> /// <param name="activityId"></param> /// <returns></returns> public string GetBaoYangActivityNameByActivityId(string activityId) { var result = string.Empty; try { result = dbScopeManagerGungnirRead.Execute(conn => DalBaoYangActivitySetting.GetBaoYangActivityNameByActivityId(conn, activityId)); } catch (Exception ex) { Logger.Error("GetBaoYangActivityNameByActivityId", ex); } return(result); }
/// <summary> /// 获取所有机油等级 /// </summary> /// <returns></returns> public List <OilLevelModel> GetAllOilLevel() { var result = null as List <OilLevelModel>; try { result = dbScopeManagerGungnirRead.Execute(conn => DalBaoYangActivitySetting.GetAllOilLevel(conn)); } catch (Exception ex) { Logger.Error("GetAllOilLevel", ex); } return(result); }
/// <summary> /// 查询保养活动地区配置 /// </summary> /// <param name="regionIds"></param> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <returns></returns> public List <BaoYangActivityRegionViewModel> SelectBaoYangActivityRegion(List <int> regionIds, int pageIndex, int pageSize) { var result = null as List <BaoYangActivityRegionViewModel>; try { result = dbScopeManagerGungnirRead.Execute(conn => DalBaoYangActivitySetting.SelectBaoYangActivityRegion(conn, regionIds, pageIndex, pageSize)); var regions = GetAllRegion(); if (result != null && result.Any() && regions.Any()) { var directRegion = new int[4] { 1, 2, 19, 20 }; result.ForEach(s => { if (directRegion.Contains(s.RegionId)) { var region = regions.Where(r => r.RegionId == s.RegionId)?.FirstOrDefault(); if (region != null) { s.ProvinceName = region.RegionName; s.CityName = region.RegionName; } } else { regions.ForEach(r => { if (r.ChildRegions != null) { var region = r.ChildRegions.Where(c => c.RegionId == s.RegionId)?.FirstOrDefault(); if (region != null) { s.ProvinceName = r.RegionName; s.CityName = region.RegionName; return; } } }); } }); } } catch (Exception ex) { Logger.Error("SelectBaoYangActivityRegion", ex); } return(result); }
public List <BaoYangOprLog> GetBaoYangOprLogByIdentityIdAndType(string identityId, string type) { var list = null as List <BaoYangOprLog>; try { list = dbScopeManagerTuhuLog.Execute(conn => DalBaoYangActivitySetting.GetBaoYangOprLogByIdentityIdAndType(conn, identityId, type)); } catch (Exception ex) { Logger.Error("GetBaoYangOprLogByIdentityIdAndType", ex); } return(list); }
public bool UpdateServiceTypeSetting(ServiceTypeSetting model) { try { return(DalBaoYangActivitySetting.UpdateServiceTypeSetting(model)); } catch (TuhuBizException) { throw; } catch (Exception ex) { Logger.Error("UpdateServiceTypeSetting", ex); throw ex; } }
public List <IGrouping <int, BaoYangActivitySetting> > GetUpkeepActivitySetting(string sqlStr, int pageSize, int pageIndex, out int recordCount) { try { return(DalBaoYangActivitySetting.GetUpkeepActivitySetting(sqlStr, pageSize, pageIndex, out recordCount)); } catch (TuhuBizException) { throw; } catch (Exception ex) { Logger.Error("GetUpkeepActivitySetting", ex); throw ex; } }
public bool DeleteServiceTypeSetting(int id) { try { return(DalBaoYangActivitySetting.DeleteServiceTypeSetting(id)); } catch (TuhuBizException) { throw; } catch (Exception ex) { Logger.Error("DeleteServiceTypeSetting", ex); throw ex; } }
public List <ServiceTypeSetting> GetServiceTypeSetting() { try { return(DalBaoYangActivitySetting.GetServiceTypeSetting()); } catch (TuhuBizException) { throw; } catch (Exception ex) { Logger.Error("GetServiceTypeSetting", ex); throw ex; } }
public List <BaoYangActivityRelevance> GetStoreAuthentication() { try { return(DalBaoYangActivitySetting.GetStoreAuthentication()); } catch (TuhuBizException) { throw; } catch (Exception ex) { Logger.Error("GetStoreAuthentication", ex); throw ex; } }
public List <BaoYangActivityRelevance> GetRelevanceSeries(string catalogName) { try { return(DalBaoYangActivitySetting.GetRelevanceSeries(catalogName)); } catch (TuhuBizException) { throw; } catch (Exception ex) { Logger.Error("GetRelevanceSeries", ex); throw ex; } }
public BaoYangActivitySettingItem GetBaoYangActivitySettingItemById(int id) { try { return(DalBaoYangActivitySetting.GetBaoYangActivitySettingItemById(id)); } catch (TuhuBizException) { throw; } catch (Exception ex) { Logger.Error("GetBaoYangActivitySettingItem", ex); throw ex; } }
public ServiceTypeSetting GetServiceTypeSettingById(int id) { try { return(DalBaoYangActivitySetting.GetServiceTypeSettingById(id)); } catch (TuhuBizException) { throw; } catch (Exception ex) { Logger.Error("GetServiceTypeSettingById", ex); throw ex; } }
/// <summary> /// 根据地区Id获取保养活动地区配置 /// </summary> /// <param name="regionId"></param> /// <returns></returns> public BaoYangActivityVehicleAndRegionModel GetBaoYangActivityRegionByRegionId(int regionId) { var result = null as BaoYangActivityVehicleAndRegionModel; try { if (regionId > 0) { result = dbScopeManagerGungnirRead.Execute(conn => DalBaoYangActivitySetting.GetBaoYangActivityRegionByRegionId(conn, regionId)); } } catch (Exception ex) { Logger.Error("GetBaoYangActivityRegionByRegionId", ex); } return(result); }
/// <summary> /// 根据二级车型获取保养活动车型配置 /// </summary> /// <param name="vehicleId"></param> /// <returns></returns> public BaoYangActivityVehicleAndRegionModel GetBaoYangActivityVehicleByVehicleId(string vehicleId) { var result = null as BaoYangActivityVehicleAndRegionModel; try { if (!string.IsNullOrWhiteSpace(vehicleId)) { result = dbScopeManagerGungnirRead.Execute(conn => DalBaoYangActivitySetting.GetBaoYangActivityVehicleByVehicleId(conn, vehicleId)); } } catch (Exception ex) { Logger.Error("GetBaoYangActivityVehicleByVehicleId", ex); } return(result); }
/// <summary> /// 获取所有车型品牌 /// </summary> /// <returns></returns> public Dictionary <string, List <string> > GetAllVehicleBrand() { var result = null as Dictionary <string, List <string> >; try { var brands = dbScopeManagerGungnirRead.Execute(conn => DalBaoYangActivitySetting.GetAllVehicleBrand(conn)); if (brands != null && brands.Any()) { result = brands.Where(v => !string.IsNullOrWhiteSpace(v)).GroupBy(v => v.Substring(0, 1)).OrderBy(g => g.Key).ToDictionary(c => c.Key, c => c.ToList()); } } catch (Exception ex) { Logger.Error("GetAllVehicleBrand", ex); } return(result); }
/// <summary> /// 查询保养活动车型配置 /// </summary> /// <param name="model"></param> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <returns></returns> public Tuple <List <BaoYangActivityVehicleViewModel>, int> SelectBaoYangActivityVehicle(BaoYangActivityVehicleSearchModel model, int pageIndex, int pageSize) { var result = null as Tuple <List <BaoYangActivityVehicleViewModel>, int>; try { result = dbScopeManagerGungnirRead.Execute(conn => DalBaoYangActivitySetting.SelectBaoYangActivityVehicle(conn, model, pageIndex, pageSize)); var oilLevels = GetAllOilLevel(); if (oilLevels != null && oilLevels.Any() && result != null && result.Item1 != null && result.Item1.Any()) { result.Item1.ForEach(s => s.OilLevel = (string.Join(",", oilLevels.Where(o => s.OilLevel.Split(',').ToList().Contains(o.OilLevel)).Select(r => r.OilType).Distinct().ToList()))); } } catch (Exception ex) { Logger.Error("SelectBaoYangActivityVehicle", ex); } return(result ?? Tuple.Create(null as List <BaoYangActivityVehicleViewModel>, 0)); }
/// <summary> /// 批量新增或更新保养活动地区配置 /// </summary> /// <param name="regionIds"></param> /// <param name="activityId"></param> /// <param name="user"></param> /// <returns></returns> public Tuple <bool, bool> MultiAddOrEditBaoYangActivityRegion(List <int> regionIds, string activityId, string user) { var result = false; var cacheResult = false; try { if (regionIds != null && regionIds.Any() && !string.IsNullOrWhiteSpace(activityId)) { var insertModels = new List <BaoYangActivityVehicleAndRegionModel>(); var updateModels = new List <BaoYangActivityVehicleAndRegionModel>(); var logData = new List <BaoYangOprLog>(); foreach (var regionId in regionIds) { var oldValue = GetBaoYangActivityRegionByRegionId(regionId); if (oldValue == null) { var insertModel = new BaoYangActivityVehicleAndRegionModel { VehicleId = null, ActivityId = activityId, RegionId = regionId, Type = "Region", CreateDateTime = DateTime.Now, LastUpdateDateTime = DateTime.Now }; insertModels.Add(insertModel); } else { updateModels.Add(oldValue); } } dbScopeManagerGungnir.CreateTransaction(conn => { foreach (var insertModel in insertModels) { var pkid = DalBaoYangActivitySetting.AddBaoYangActivityRegion(conn, insertModel); if (pkid < 1) { throw new Exception($"AddBaoYangActivityRegion失败,{JsonConvert.SerializeObject(insertModel)}"); } insertModel.PKID = pkid; var log = new BaoYangOprLog { LogType = "BaoYangActivityRegion", IdentityID = insertModel.RegionId.ToString(), OldValue = null, NewValue = JsonConvert.SerializeObject(insertModel), Remarks = "Add", OperateUser = user, }; logData.Add(log); } foreach (var oldValue in updateModels) { var updateModel = new BaoYangActivityVehicleAndRegionModel { PKID = oldValue.PKID, VehicleId = oldValue.VehicleId, ActivityId = activityId, RegionId = oldValue.RegionId, Type = oldValue.Type, CreateDateTime = oldValue.CreateDateTime, LastUpdateDateTime = DateTime.Now }; var updateResult = DalBaoYangActivitySetting.UpdateBaoYangActivityRegion(conn, updateModel); if (!updateResult) { throw new Exception($"UpdateBaoYangActivityRegion失败,{JsonConvert.SerializeObject(updateModel)}"); } var log = new BaoYangOprLog { LogType = "BaoYangActivityRegion", IdentityID = updateModel.RegionId.ToString(), OldValue = JsonConvert.SerializeObject(oldValue), NewValue = JsonConvert.SerializeObject(updateModel), Remarks = "Update", OperateUser = user, }; logData.Add(log); } result = true; }); foreach (var log in logData) { LoggerManager.InsertLog("BYOprLog", log); } cacheResult = CleanBaoYangActivityRegionCache(regionIds); } } catch (Exception ex) { Logger.Error("MultiAddOrEditBaoYangActivityRegion", ex); } return(Tuple.Create(result, cacheResult)); }