public bool UpdateTipBannerDetailConfig(TipBannerConfigDetailModel model, string user)
        {
            var result = false;

            try
            {
                var oldValue = dbScopeManagerConfigRead.Execute(conn => DalTipBannerConfig.GetTipBannerDetailConfigByPKID(conn, model.PKID));
                if (oldValue != null)
                {
                    result = dbScopeManagerConfig.Execute(conn => DalTipBannerConfig.UpdateTipBannerDetailConfig(conn, model));
                    if (result)
                    {
                        model.LastUpdateDateTime = DateTime.Now;
                        var log = new BaoYangOprLog
                        {
                            LogType     = "TipBannerDetailConfig",
                            IdentityID  = oldValue.TypeName,
                            OldValue    = JsonConvert.SerializeObject(oldValue),
                            NewValue    = JsonConvert.SerializeObject(model),
                            Remarks     = "Update",
                            OperateUser = user,
                        };
                        LoggerManager.InsertLog("BYOprLog", log);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error("UpdateTipBannerDetailConfig", ex);
            }
            return(result);
        }
        public bool AddTipBannerDetailConfig(TipBannerConfigDetailModel model, string user)
        {
            var result = false;

            try
            {
                var pkid = dbScopeManagerConfig.Execute(conn => DalTipBannerConfig.AddTipBannerDetailConfig(conn, model));
                if (pkid > 0)
                {
                    result                   = true;
                    model.PKID               = pkid;
                    model.CreateDateTime     = DateTime.Now;
                    model.LastUpdateDateTime = DateTime.Now;
                    var log = new BaoYangOprLog
                    {
                        LogType     = "TipBannerDetailConfig",
                        IdentityID  = model.TypeName,
                        OldValue    = null,
                        NewValue    = JsonConvert.SerializeObject(model),
                        Remarks     = "Add",
                        OperateUser = user,
                    };
                    LoggerManager.InsertLog("BYOprLog", log);
                }
            }
            catch (Exception ex)
            {
                Logger.Error("AddTipBannerDetailConfig", ex);
            }
            return(result);
        }
        public bool DeleteTipBannerDetailConfigByPKID(int pkid, string user)
        {
            var result = false;

            try
            {
                var oldValue = dbScopeManagerConfigRead.Execute(conn => DalTipBannerConfig.GetTipBannerDetailConfigByPKID(conn, pkid));
                if (oldValue != null)
                {
                    result = dbScopeManagerConfig.Execute(conn => DalTipBannerConfig.DeleteTipBannerDetailConfigByPKID(conn, pkid));
                    if (result)
                    {
                        var log = new BaoYangOprLog
                        {
                            LogType     = "TipBannerDetailConfigByPKID",
                            IdentityID  = oldValue.TypeName,
                            OldValue    = JsonConvert.SerializeObject(oldValue),
                            NewValue    = null,
                            Remarks     = "Delete",
                            OperateUser = user,
                        };
                        LoggerManager.InsertLog("BYOprLog", log);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error("DeleteTipBannerDetailConfigByPKID", ex);
            }
            return(result);
        }
Exemplo n.º 4
0
        public static bool UsertEnterpriseUserConfig(EnterpriseUserViewModel data, string user)
        {
            var result = false;

            try
            {
                using (var dbhelper = new SqlDbHelper(BeautyServicePackageDal.GetTuhuGrouponWriteConnstr()))
                {
                    dbhelper.BeginTransaction();
                    var userConfig   = BeautyServicePackageDal.SelectEnterpriseUserConfigByUserId(dbhelper, data.UserId);
                    var moduleConfig = BeautyServicePackageDal.SelectEnterpriseUserModuleConfigByUserId(dbhelper, data.UserId);
                    if (userConfig != null && userConfig.Any())
                    {
                        BeautyServicePackageDal.DeleteEnterpriseUserConfigByUserId(dbhelper, data.UserId);
                    }
                    if (moduleConfig != null && moduleConfig.Any())
                    {
                        BeautyServicePackageDal.DeleteEnterpriseModuleConfigByUserId(dbhelper, data.UserId);
                    }
                    if (data.PackageDetailIds != null && data.PackageDetailIds.Any())
                    {
                        foreach (var item in data.PackageDetailIds)
                        {
                            BeautyServicePackageDal.InsertEnterpriseUserConfig(dbhelper, data.UserId, item, data.Remark);
                        }
                    }
                    else
                    {
                        BeautyServicePackageDal.InsertEnterpriseUserConfig(dbhelper, data.UserId, 0, data.Remark);//允许不配服务模板
                    }
                    if (data.UserModuleDetails != null && data.UserModuleDetails.Any())
                    {
                        foreach (var item in data.UserModuleDetails)
                        {
                            BeautyServicePackageDal.InsertEnterpriseUserModuleConfig(dbhelper, data.UserId, item.ModuleType);
                        }
                    }
                    dbhelper.Commit();
                    result = true;
                    var log = new BaoYangOprLog
                    {
                        LogType     = "EnterpriseUserConfig",
                        IdentityID  = data.UserId.ToString(),
                        OldValue    = "[]",
                        NewValue    = JsonConvert.SerializeObject(data),
                        Remarks     = $"发码服务权限修改 {data.UserMobile}",
                        OperateUser = user,
                    };
                    LoggerManager.InsertLog("BeautyOprLog", log);
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message, ex);
            }

            return(result);
        }
Exemplo n.º 5
0
        /// <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));
        }
Exemplo n.º 6
0
        /// <summary>
        /// 批量删除机油粘度特殊地区配置
        /// </summary>
        /// <param name="regionIds"></param>
        /// <param name="user"></param>
        /// <returns></returns>
        public bool MultDeleteOilViscosityRegionConfig(List <int> regionIds, string user)
        {
            var result = 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 = GetOilViscosityRegionConfigByRegionId(regionId);
                                if (oldValue != null && !oldValue.IsDeleted)
                                {
                                    var delResult = DalBaoYangOilViscosityPriorityConfig.DeleteOilViscosityRegionConfig(conn, regionId);
                                    if (!delResult)
                                    {
                                        throw new Exception($"DeleteOilViscosityRegionConfig失败,{JsonConvert.SerializeObject(oldValue)}");
                                    }
                                    var log = new BaoYangOprLog
                                    {
                                        LogType     = "OilViscosityRegionConfig",
                                        IdentityID  = regionId.ToString(),
                                        OldValue    = JsonConvert.SerializeObject(oldValue),
                                        NewValue    = null,
                                        Remarks     = $"删除机油粘度配置:{oldValue.OilViscosity}",
                                        OperateUser = user,
                                    };
                                    logData.Add(log);
                                }
                            }
                        }
                        result = true;
                    });
                    foreach (var log in logData)
                    {
                        LoggerManager.InsertLog("BYOprLog", log);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error("MultDeleteOilViscosityRegionConfig", ex);
            }
            return(result);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 删除保养项目加价配置 --只做逻辑删除
        /// </summary>
        /// <param name="pkid"></param>
        /// <param name="user"></param>
        /// <returns></returns>
        public bool DeleteBaoYangInstallFeeConfig(string serviceId, string user)
        {
            var result = true;

            try
            {
                var logs      = new List <BaoYangOprLog>();
                var configs   = dbScopeManagerGungnirRead.Execute(conn => DalBaoYangInstallFeeConfig.SelectBaoYangInstallFeeConfig(conn, serviceId));
                var oldValues = configs.Where(s => s.PKID > 0).ToList();
                if (oldValues != null && oldValues.Any())
                {
                    dbScopeManagerGungnir.CreateTransaction(conn =>
                    {
                        foreach (var oldValue in oldValues)
                        {
                            var isDel = DalBaoYangInstallFeeConfig.DeleteBaoYangInstallFeeConfigByPKID(conn, oldValue.PKID);
                            if (!isDel)
                            {
                                throw new Exception($"DeleteBaoYangInstallFeeConfigByPKID失败,待删除数据{JsonConvert.SerializeObject(oldValue)}");
                            }
                            var log = new BaoYangOprLog
                            {
                                LogType     = "BaoYangInstallFeeConfig",
                                IdentityID  = oldValue.PKID.ToString(),
                                OldValue    = JsonConvert.SerializeObject(oldValues),
                                NewValue    = null,
                                Remarks     = $"删除保养项目:{oldValue.ServiceName}的加价配置",
                                OperateUser = user,
                            };
                            logs.Add(log);
                        }
                    });
                    foreach (var log in logs)
                    {
                        LoggerManager.InsertLog("BYOprLog", log);
                    }
                }
            }
            catch (Exception ex)
            {
                result = false;
                Logger.Error("DeleteBaoYangInstallFeeConfig", ex);
            }
            return(result);
        }
Exemplo n.º 8
0
        /// <summary>
        /// 添加日志
        /// </summary>
        /// <param name="model"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public BaoYangResultEntity <bool> SaveBatteryLevelUpLog(BatteryLevelUpEntity oldbatteryLevelUp, BatteryLevelUpEntity newbatteryLevelUp, string name)
        {
            BaoYangResultEntity <bool> result = new BaoYangResultEntity <bool>()
            {
                Status = true
            };
            var log = new BaoYangOprLog()
            {
                CreateTime  = DateTime.Now,
                LogType     = "BaoYangProductBatteryLevelUpSetting",
                Remarks     = oldbatteryLevelUp == null ? "添加" : (newbatteryLevelUp == null ? "删除" : "修改"),
                IdentityID  = newbatteryLevelUp == null ? oldbatteryLevelUp.OriginalPID : newbatteryLevelUp.OriginalPID,
                NewValue    = JsonConvert.SerializeObject(newbatteryLevelUp ?? new BatteryLevelUpEntity()),
                OldValue    = JsonConvert.SerializeObject(oldbatteryLevelUp ?? new BatteryLevelUpEntity()),
                OperateUser = name
            };

            LoggerManager.InsertLog("BYOprLog", log);
            return(result);
        }
Exemplo n.º 9
0
        /// <summary>
        /// 添加日志
        /// </summary>
        /// <param name="model"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public BaoYangResultEntity <bool> SaveCouponActivityConfigLog(CouponActivityConfigV2Model oldModel, CouponActivityConfigV2Model newmodel, string name)
        {
            BaoYangResultEntity <bool> result = new BaoYangResultEntity <bool>()
            {
                Status = true
            };
            var log = new BaoYangOprLog()
            {
                CreateTime = DateTime.Now,
                LogType    = "BaoYangCouponActivityConfigSetting",
                Remarks    = oldModel == null ? "添加" : (newmodel == null ? "删除" : "修改"),
                IdentityID = newmodel == null?oldModel.Id.ToString() : newmodel.Id.ToString(),
                                 NewValue    = JsonConvert.SerializeObject(newmodel ?? new CouponActivityConfigV2Model()),
                                 OldValue    = JsonConvert.SerializeObject(oldModel ?? new CouponActivityConfigV2Model()),
                                 OperateUser = name
            };

            LoggerManager.InsertLog("BYOprLog", log);
            return(result);
        }
Exemplo n.º 10
0
        /// <summary>
        /// 添加保养关联项目配置
        /// </summary>
        /// <param name="model"></param>
        /// <param name="user"></param>
        /// <returns></returns>
        public bool AddBaoYangPackageTypeRelation(BaoYangPackageTypeRelationViewModel model, string user)
        {
            var result = false;

            try
            {
                var oldValue = GetBaoYangPackageTypeRelation(model.MainPackageType);
                if (oldValue == null)
                {
                    var pkid = dbScopeManagerBaoYang.Execute
                                   (conn => DalBaoYangPackageTypeRelation.AddBaoYangPackageTypeRelation(conn, model));
                    result     = pkid > 0;
                    model.PKID = pkid;
                }
                else if (oldValue.IsDeleted)
                {
                    model.PKID = oldValue.PKID;
                    result     = dbScopeManagerBaoYang.Execute
                                     (conn => DalBaoYangPackageTypeRelation.UpdateBaoYangPackageTypeRelation(conn, model));
                }
                model.CreateDateTime     = DateTime.Now;
                model.LastUpdateDateTime = DateTime.Now;
                var log = new BaoYangOprLog
                {
                    LogType     = "BaoYangPackageTypeRelation",
                    IdentityID  = $"{model.MainPackageType}",
                    OldValue    = null,
                    NewValue    = JsonConvert.SerializeObject(model),
                    Remarks     = $"添加主项目为{model.MainPackageType}的保养关联项目配置",
                    OperateUser = user,
                };
                LoggerManager.InsertLog("BYOprLog", log);
            }
            catch (Exception ex)
            {
                result = false;
                Logger.Error("AddBaoYangPackageTypeRelation", ex);
            }
            return(result);
        }
Exemplo n.º 11
0
        /// <summary>
        /// 删除保养关联项目配置
        /// </summary>
        /// <param name="carNoPrefix"></param>
        /// <param name="surfaceCount"></param>
        /// <param name="servicePid"></param>
        /// <param name="user"></param>
        /// <returns></returns>
        public bool DeleteBaoYangPackageTypeRelation(string mainPackageType, string user)
        {
            var result = false;

            try
            {
                var oldValue = GetBaoYangPackageTypeRelation(mainPackageType);
                if (oldValue != null && !oldValue.IsDeleted)
                {
                    result = dbScopeManagerBaoYang.Execute(conn => DalBaoYangPackageTypeRelation.DeleteBaoYangPackageTypeRelation(conn, oldValue.PKID));
                    if (!result)
                    {
                        throw new Exception($"DeleteBaoYangPackageTypeRelation失败,待删除数据{JsonConvert.SerializeObject(oldValue)}");
                    }
                    var log = new BaoYangOprLog
                    {
                        LogType     = "BaoYangPackageTypeRelation",
                        IdentityID  = mainPackageType,
                        OldValue    = JsonConvert.SerializeObject(oldValue),
                        NewValue    = null,
                        Remarks     = $"删除主项目为{mainPackageType}的保养关联项目配置",
                        OperateUser = user,
                    };
                    LoggerManager.InsertLog("BYOprLog", log);
                }
                else
                {
                    result = true;
                }
            }
            catch (Exception ex)
            {
                result = false;
                Logger.Error("DeleteBaoYangPackageTypeRelation", ex);
            }
            return(result);
        }
Exemplo n.º 12
0
        /// <summary>
        /// 更新保养关联项目配置
        /// </summary>
        /// <param name="model"></param>
        /// <param name="user"></param>
        /// <returns></returns>
        public bool UpdateBaoYangPackageTypeRelation(BaoYangPackageTypeRelationViewModel model, string user)
        {
            var result = false;

            try
            {
                var oldValue = GetBaoYangPackageTypeRelation(model.MainPackageType);
                if (oldValue != null)
                {
                    model.PKID = oldValue.PKID;
                    result     = dbScopeManagerBaoYang.Execute(conn =>
                                                               DalBaoYangPackageTypeRelation.UpdateBaoYangPackageTypeRelation(conn, model));
                    if (!result)
                    {
                        throw new Exception($"UpdateBaoYangPackageTypeRelation失败,待更新数据{JsonConvert.SerializeObject(model)}");
                    }
                    model.CreateDateTime     = oldValue.CreateDateTime;
                    model.LastUpdateDateTime = DateTime.Now;
                    var log = new BaoYangOprLog
                    {
                        LogType     = "BaoYangPackageTypeRelation",
                        IdentityID  = model.MainPackageType,
                        OldValue    = JsonConvert.SerializeObject(oldValue),
                        NewValue    = JsonConvert.SerializeObject(model),
                        Remarks     = $"更新主项目为{model.MainPackageType}的保养关联项目配置",
                        OperateUser = user,
                    };
                    LoggerManager.InsertLog("BYOprLog", log);
                }
            }
            catch (Exception ex)
            {
                result = false;
                Logger.Error("UpdateBaoYangPackageTypeRelation", ex);
            }
            return(result);
        }
Exemplo n.º 13
0
        /// <summary>
        /// 删除保养项目加价配置 --只做逻辑删除
        /// </summary>
        /// <param name="pkid"></param>
        /// <param name="user"></param>
        /// <returns></returns>
        public bool DeleteBaoYangOilViscosityPriorityConfig(string originViscosity, string configType, string user)
        {
            var result = false;

            try
            {
                var oldValue = dbScopeManagerGungnirRead.Execute(conn => DalBaoYangOilViscosityPriorityConfig.GetBaoYangOilViscosityPriorityConfig(conn, originViscosity, configType));
                if (oldValue != null && !oldValue.IsDeleted)
                {
                    result = dbScopeManagerGungnir.Execute(conn => DalBaoYangOilViscosityPriorityConfig.DeleteBaoYangOilViscosityPriorityConfig(conn, oldValue.PKID));
                    if (!result)
                    {
                        throw new Exception($"DeleteBaoYangOilViscosityPriorityConfig失败,待删除数据{JsonConvert.SerializeObject(oldValue)}");
                    }
                    var log = new BaoYangOprLog
                    {
                        LogType     = "BaoYangOilViscosityPriorityConfig",
                        IdentityID  = oldValue.OriginViscosity,
                        OldValue    = JsonConvert.SerializeObject(oldValue),
                        NewValue    = null,
                        Remarks     = $"删除{oldValue.ConfigType}类原厂机油粘度{oldValue.OriginViscosity}推荐优先级:{oldValue.ViscosityPriority}",
                        OperateUser = user,
                    };
                    LoggerManager.InsertLog("BYOprLog", log);
                }
                else
                {
                    result = true;
                }
            }
            catch (Exception ex)
            {
                result = false;
                Logger.Error("DeleteBaoYangOilViscosityPriorityConfig", ex);
            }
            return(result);
        }
 /// <summary>
 /// 记录操作日志
 /// </summary>
 /// <param name="log"></param>
 /// <returns></returns>
 private bool RecordOperationLog(BaoYangOprLog log) => Business.Logger.LoggerManager.InsertLog("BYOprLog", log);
Exemplo n.º 15
0
        /// <summary>
        /// 修改大客户美容服务码
        /// </summary>
        /// <param name="model"></param>
        /// <param name="pkids"></param>
        /// <returns></returns>
        public static bool UpdateBeautyServicePackageDetailCodes(ServiceCodeDetail model, string user, ServiceCodeDetail oldCode)
        {
            var result = false;

            try
            {
                if (model.StartTime != null && model.EndTime != null)
                {
                    using (var dbhelper = new Tuhu.Component.Common.SqlDbHelper(writeConnStr))
                    {
                        dbhelper.BeginTransaction();
                        var upResult = true;
                        if (model.PackageDetailCodeId > 0)
                        {
                            var oldValue = BeautyServicePackageDal.GetBeautyServicePackageDetailCodeByPKID(model.PackageDetailCodeId);
                            if (oldValue != null)
                            {
                                #region 只更新服务码起止时间 其余数据保持不变
                                var newValue = new BeautyServicePackageDetailCode
                                {
                                    PKID            = model.PackageDetailCodeId,
                                    UserId          = oldValue.UserId,
                                    PackageDetailId = oldValue.PackageDetailId,
                                    ServiceCode     = oldValue.ServiceCode,
                                    IsActive        = oldValue.IsActive,
                                    StartTime       = model.StartTime,
                                    EndTime         = model.EndTime,
                                    PackageCode     = oldValue.PackageCode,
                                    VipUserId       = oldValue.VipUserId
                                };
                                #endregion
                                upResult = BeautyServicePackageDal.UpdateBeautyServicePackageDetailCodes(dbhelper, newValue);
                            }
                            else
                            {
                                upResult = false;
                            }
                        }
                        if (upResult)
                        {
                            using (var client = new ServiceCodeClient())
                            {
                                var kxChangeCodeTimeModel = new ChangeCodeTimeRequest
                                {
                                    ServiceCodes = new List <string>()
                                    {
                                        model.ServiceCode
                                    },
                                    OverdueTime = model.EndTime
                                };
                                var kxChangeResult = client.ChangeOverdueTime(kxChangeCodeTimeModel);
                                kxChangeResult.ThrowIfException(true);
                                if (kxChangeResult.Success && kxChangeResult.Result != null && kxChangeResult.Result.SuccessServiceCode.Count() > 0 &&
                                    string.Equals(kxChangeResult.Result.SuccessServiceCode.FirstOrDefault(), model.ServiceCode))
                                {
                                    result = true;
                                    dbhelper.Commit();

                                    var log = new BaoYangOprLog
                                    {
                                        LogType     = "修改大客户美容服务码",
                                        IdentityID  = oldCode.ServiceCode,
                                        OldValue    = JsonConvert.SerializeObject(oldCode),
                                        NewValue    = JsonConvert.SerializeObject(model),
                                        Remarks     = $"修改服务码有效期:服务码开始时间从{oldCode.StartTime}变更为{model.StartTime},结束时间从{oldCode.EndTime}变更为{model.EndTime}",
                                        OperateUser = user,
                                    };
                                    LoggerManager.InsertLog("BeautyOprLog", log);
                                }
                                else
                                {
                                    throw new Exception($"快修服务修改服务码有效期失败,请求信息:{JsonConvert.SerializeObject(kxChangeCodeTimeModel)},返回信息:{JsonConvert.SerializeObject(kxChangeResult)}");
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message, ex);
            }
            return(result);
        }
Exemplo n.º 16
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));
        }
Exemplo n.º 17
0
 private bool InsertBaoYangOprLog(BaoYangOprLog log) => LoggerManager.InsertLog("BYOprLog", log);
Exemplo n.º 18
0
        /// <summary>
        /// 添加或编辑保养项目加价配置
        /// </summary>
        /// <param name="models"></param>
        /// <param name="user"></param>
        /// <returns></returns>
        public bool AddOrEditBaoYangInstallFeeConfig(List <BaoYangInstallFeeConfigModel> models, string user)
        {
            var result = false;

            try
            {
                var delList     = new List <BaoYangInstallFeeConfigModel>();
                var logs        = new List <BaoYangOprLog>();
                var serviceId   = models.Select(s => s.ServiceId).FirstOrDefault();
                var configs     = dbScopeManagerGungnirRead.Execute(conn => DalBaoYangInstallFeeConfig.SelectBaoYangInstallFeeConfig(conn, serviceId));
                var existConfig = configs.Where(s => s.PKID > 0).ToList();
                foreach (var oldValue in existConfig)
                {
                    var sameValue = models.Where(model =>
                                                 (string.Equals(model.ServiceId, oldValue.ServiceId) && model.CarMinPrice.Equals(oldValue.CarMinPrice) &&
                                                  model.CarMaxPrice.Equals(oldValue.CarMaxPrice) && model.AddInstallFee.Equals(oldValue.AddInstallFee))).FirstOrDefault();
                    if (sameValue == null)
                    {
                        delList.Add(oldValue);//删除旧数据
                    }
                    else
                    {
                        models.Remove(sameValue);//数据没变的不做任何操作
                    }
                }
                dbScopeManagerGungnir.CreateTransaction(conn =>
                {
                    #region  除旧数据
                    foreach (var oldValue in delList)
                    {
                        var log = new BaoYangOprLog
                        {
                            LogType     = "BaoYangInstallFeeConfig",
                            IdentityID  = oldValue.PKID.ToString(),
                            OldValue    = JsonConvert.SerializeObject(oldValue),
                            NewValue    = null,
                            Remarks     = $"删除保养项目:{oldValue.ServiceName}的加价配置",
                            OperateUser = user,
                        };
                        logs.Add(log);
                        DalBaoYangInstallFeeConfig.DeleteBaoYangInstallFeeConfigByPKID(conn, oldValue.PKID);
                    }
                    #endregion

                    #region 插入新数据
                    foreach (var model in models)
                    {
                        var deletedModel = dbScopeManagerGungnirRead.Execute(co => DalBaoYangInstallFeeConfig.GetDeletedBaoYangInstallFeeConfig(co, model));
                        if (deletedModel != null)
                        {
                            var backUpResult = DalBaoYangInstallFeeConfig.BackUpBaoYangInstallFeeConfigByPKID(conn, deletedModel.PKID);
                            if (!backUpResult)
                            {
                                throw new Exception($"BackUpBaoYangInstallFeeConfigByPKID失败,待插入数据{JsonConvert.SerializeObject(deletedModel)}");
                            }
                            var log = new BaoYangOprLog
                            {
                                LogType     = "BaoYangInstallFeeConfig",
                                IdentityID  = deletedModel.PKID.ToString(),
                                OldValue    = null,
                                NewValue    = JsonConvert.SerializeObject(deletedModel),
                                Remarks     = $"添加保养项目:{model.ServiceName}的加价配置",
                                OperateUser = user,
                            };
                            logs.Add(log);
                        }
                        else
                        {
                            var pkid = DalBaoYangInstallFeeConfig.AddBaoYangInstallFeeConfig(conn, model);
                            if (pkid < 1)
                            {
                                throw new Exception($"AddBaoYangInstallFeeConfig失败,待插入数据{JsonConvert.SerializeObject(model)}");
                            }
                            model.PKID               = pkid;
                            model.CreateDateTime     = DateTime.Now;
                            model.LastUpdateDateTime = DateTime.Now;
                            var log = new BaoYangOprLog
                            {
                                LogType     = "BaoYangInstallFeeConfig",
                                IdentityID  = model.PKID.ToString(),
                                OldValue    = null,
                                NewValue    = JsonConvert.SerializeObject(model),
                                Remarks     = $"添加保养项目:{model.ServiceName}的加价配置",
                                OperateUser = user,
                            };
                            logs.Add(log);
                        }
                    }
                    #endregion
                    result = true;
                });
                foreach (var log in logs)
                {
                    LoggerManager.InsertLog("BYOprLog", log);
                }
            }
            catch (Exception ex)
            {
                Logger.Error("AddOrEditBaoYangInstallFeeConfig", ex);
            }
            return(result);
        }
Exemplo n.º 19
0
        /// <summary>
        /// 添加或编辑机油粘度优先级配置
        /// </summary>
        /// <param name="model"></param>
        /// <param name="user"></param>
        /// <returns></returns>
        public bool AddOrEditBaoYangOilViscosityPriorityConfig(BaoYangOilViscosityPriorityConfigModel model, string user)
        {
            var result = false;
            var log    = null as BaoYangOprLog;

            try
            {
                var oldValue = dbScopeManagerGungnirRead.Execute(conn => DalBaoYangOilViscosityPriorityConfig.GetBaoYangOilViscosityPriorityConfig(conn, model.OriginViscosity, model.ConfigType));
                #region 添加 判断是否存在该原厂粘度被逻辑删除的记录 存在则更新 不存在则插入
                if (oldValue == null)
                {
                    #region 插入记录
                    var pkid = dbScopeManagerGungnir.Execute(conn => DalBaoYangOilViscosityPriorityConfig.AddBaoYangOilViscosityPriorityConfig(conn, model));
                    if (pkid > 0)
                    {
                        result     = true;
                        model.PKID = pkid;
                        log        = new BaoYangOprLog
                        {
                            LogType     = "BaoYangOilViscosityPriorityConfig",
                            IdentityID  = model.OriginViscosity,
                            OldValue    = null,
                            NewValue    = JsonConvert.SerializeObject(model),
                            Remarks     = $"添加{model.ConfigType}类原厂机油粘度{model.OriginViscosity}推荐优先级:{model.ViscosityPriority}",
                            OperateUser = user,
                        };
                    }
                    #endregion
                }
                else if (oldValue.IsDeleted)
                {
                    #region 更新逻辑删除的记录
                    result = dbScopeManagerGungnir.Execute(conn => DalBaoYangOilViscosityPriorityConfig.UpdateBaoYangOilViscosityPriorityConfig(conn, model));
                    log    = new BaoYangOprLog
                    {
                        LogType     = "BaoYangOilViscosityPriorityConfig",
                        IdentityID  = model.OriginViscosity,
                        OldValue    = null,
                        NewValue    = JsonConvert.SerializeObject(model),
                        Remarks     = $"添加{model.ConfigType}类原厂机油粘度{model.OriginViscosity}推荐优先级:{model.ViscosityPriority}",
                        OperateUser = user,
                    };
                    #endregion
                }
                #endregion
                #region 更新
                else
                {
                    result = dbScopeManagerGungnir.Execute(conn => DalBaoYangOilViscosityPriorityConfig.UpdateBaoYangOilViscosityPriorityConfig(conn, model));
                    log    = new BaoYangOprLog
                    {
                        LogType     = "BaoYangOilViscosityPriorityConfig",
                        IdentityID  = model.OriginViscosity,
                        OldValue    = JsonConvert.SerializeObject(oldValue),
                        NewValue    = JsonConvert.SerializeObject(model),
                        Remarks     = $"更新{model.ConfigType}类原厂机油粘度{model.OriginViscosity}推荐优先级:{model.ViscosityPriority}",
                        OperateUser = user,
                    };
                }
                #endregion
                if (result && log != null)
                {
                    LoggerManager.InsertLog("BYOprLog", log);
                }
            }
            catch (Exception ex)
            {
                Logger.Error("AddOrEditBaoYangOilViscosityPriorityConfig", ex);
            }
            return(result);
        }
Exemplo n.º 20
0
        /// <summary>
        /// 批量新增或更新机油粘度特殊地区配置
        /// </summary>
        /// <param name="regionIds"></param>
        /// <param name="oilViscosity"></param>
        /// <param name="user"></param>
        /// <returns></returns>
        public bool MultAddOrEditOilViscosityRegionConfig(List <int> regionIds, string oilViscosity, string user)
        {
            var result = false;

            try
            {
                if (regionIds != null && regionIds.Any() && !string.IsNullOrWhiteSpace(oilViscosity))
                {
                    var insertModels = new List <OilViscosityRegionModel>();
                    var backupModels = new List <OilViscosityRegionModel>();
                    var updateModels = new List <OilViscosityRegionModel>();
                    var logData      = new List <BaoYangOprLog>();
                    foreach (var regionId in regionIds)
                    {
                        var oldValue = GetOilViscosityRegionConfigByRegionId(regionId);
                        if (oldValue == null)
                        {
                            var insertModel = new OilViscosityRegionModel
                            {
                                RegionId           = regionId,
                                OilViscosity       = oilViscosity,
                                CreateDateTime     = DateTime.Now,
                                LastUpdateDateTime = DateTime.Now
                            };
                            insertModels.Add(insertModel);
                        }
                        else
                        {
                            if (oldValue.IsDeleted)
                            {
                                backupModels.Add(oldValue);
                            }
                            else
                            {
                                updateModels.Add(oldValue);
                            }
                        }
                    }
                    dbScopeManagerGungnir.CreateTransaction(conn =>
                    {
                        foreach (var insertModel in insertModels)
                        {
                            var pkid = DalBaoYangOilViscosityPriorityConfig.AddOilViscosityRegionConfig(conn, insertModel);
                            if (pkid < 1)
                            {
                                throw new Exception($"AddOilViscosityRegionConfig失败,{JsonConvert.SerializeObject(insertModel)}");
                            }
                            insertModel.PKID = pkid;
                            var log          = new BaoYangOprLog
                            {
                                LogType     = "OilViscosityRegionConfig",
                                IdentityID  = insertModel.RegionId.ToString(),
                                OldValue    = null,
                                NewValue    = JsonConvert.SerializeObject(insertModel),
                                Remarks     = $"添加机油粘度配置:{oilViscosity}",
                                OperateUser = user,
                            };
                            logData.Add(log);
                        }
                        foreach (var oldValue in updateModels)
                        {
                            var updateModel = new OilViscosityRegionModel
                            {
                                PKID               = oldValue.PKID,
                                RegionId           = oldValue.RegionId,
                                OilViscosity       = oilViscosity,
                                CreateDateTime     = oldValue.CreateDateTime,
                                LastUpdateDateTime = DateTime.Now,
                                IsDeleted          = false
                            };
                            var updateResult = DalBaoYangOilViscosityPriorityConfig.UpdateOilViscosityRegionConfig(conn, updateModel);
                            if (!updateResult)
                            {
                                throw new Exception($"UpdateOilViscosityRegionConfig失败,{JsonConvert.SerializeObject(updateModel)}");
                            }

                            var log = new BaoYangOprLog
                            {
                                LogType     = "OilViscosityRegionConfig",
                                IdentityID  = updateModel.RegionId.ToString(),
                                OldValue    = JsonConvert.SerializeObject(oldValue),
                                NewValue    = JsonConvert.SerializeObject(updateModel),
                                Remarks     = $"更新机油粘度配置:{oilViscosity}",
                                OperateUser = user,
                            };
                            logData.Add(log);
                        }
                        foreach (var backupModel in backupModels)
                        {
                            var updateModel = new OilViscosityRegionModel
                            {
                                PKID               = backupModel.PKID,
                                RegionId           = backupModel.RegionId,
                                OilViscosity       = oilViscosity,
                                CreateDateTime     = backupModel.CreateDateTime,
                                LastUpdateDateTime = DateTime.Now,
                                IsDeleted          = false
                            };
                            var updateResult = DalBaoYangOilViscosityPriorityConfig.UpdateOilViscosityRegionConfig(conn, updateModel);
                            if (!updateResult)
                            {
                                throw new Exception($"UpdateOilViscosityRegionConfig失败,{JsonConvert.SerializeObject(updateModel)}");
                            }

                            var log = new BaoYangOprLog
                            {
                                LogType     = "OilViscosityRegionConfig",
                                IdentityID  = updateModel.RegionId.ToString(),
                                OldValue    = JsonConvert.SerializeObject(backupModel),
                                NewValue    = JsonConvert.SerializeObject(updateModel),
                                Remarks     = $"添加机油粘度配置:{oilViscosity}",
                                OperateUser = user,
                            };
                            logData.Add(log);
                        }
                        result = true;
                    });
                    foreach (var log in logData)
                    {
                        LoggerManager.InsertLog("BYOprLog", log);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error("MultiAddOrEditOilViscosityRegionConfig", ex);
            }
            return(result);
        }