Exemplo n.º 1
0
        /// <summary>
        /// 更新违章查询省份配置
        /// </summary>
        /// <param name="province"></param>
        /// <param name="user"></param>
        /// <returns></returns>
        public bool UpdatePeccancyProvinceConfig(PeccancyQueryProvinceModel province, string user)
        {
            var result = false;

            try
            {
                var oldValue = DalPeccancyQueryConfig.GetPeccancyProvinceConfigByProvinceId(province.ProvinceId);
                if (oldValue != null)
                {
                    using (var dbhelper = new Tuhu.Component.Common.SqlDbHelper(grconnectionString))
                    {
                        result = DalPeccancyQueryConfig.UpdatePeccancyProvinceConfig(dbhelper, province);
                    }
                    if (result)
                    {
                        var log = new PeccancyConfigOprLogModel
                        {
                            LogType       = "PeccancyProvinceConfig",
                            IdentityId    = $"{province.ProvinceId}",
                            OperationType = "Update",
                            OldValue      = JsonConvert.SerializeObject(oldValue),
                            NewValue      = JsonConvert.SerializeObject(province),
                            Remarks       = $"更新 违章查询省份:{province.ProvinceName} 的配置",
                            Operator      = user,
                        };
                        LoggerManager.InsertLog("PeccancyConfigOprLog", log);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error("UpdatePeccancyProvinceConfig", ex);
            }
            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 添加违章查询城市配置
        /// </summary>
        /// <param name="model"></param>
        /// <param name="user"></param>
        /// <returns></returns>
        public bool AddPeccancyCityConfig(PeccancyQueryCityModel model, string user)
        {
            var result = false;

            try
            {
                using (var dbhelper = new Tuhu.Component.Common.SqlDbHelper(grconnectionString))
                {
                    result = DalPeccancyQueryConfig.AddPeccancyCityConfig(dbhelper, model);
                    if (result)
                    {
                        var log = new PeccancyConfigOprLogModel
                        {
                            LogType       = "PeccancyCityConfig",
                            IdentityId    = $"{model.CityId}",
                            OperationType = "Add",
                            OldValue      = null,
                            NewValue      = JsonConvert.SerializeObject(model),
                            Remarks       = $"添加 违章查询城市:{model.CityName} 的配置",
                            Operator      = user,
                        };
                        LoggerManager.InsertLog("PeccancyConfigOprLog", log);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error("AddPeccancyCityConfig", ex);
            }
            return(result);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 删除违章查询城市配置
        /// </summary>
        /// <param name="cityId"></param>
        /// <returns></returns>
        public bool DeletePeccancyCityConfig(int cityId, string user)
        {
            var result = false;

            try
            {
                var oldValue = DalPeccancyQueryConfig.GetPeccancyCityConfigByCityId(cityId);
                if (oldValue != null)
                {
                    using (var dbhelper = new Tuhu.Component.Common.SqlDbHelper(grconnectionString))
                    {
                        result = DalPeccancyQueryConfig.DeletePeccancyCityConfigByCityId(dbhelper, cityId);
                    }
                    if (result)
                    {
                        var log = new PeccancyConfigOprLogModel
                        {
                            LogType       = "PeccancyCityConfig",
                            IdentityId    = $"{oldValue.CityId}",
                            OperationType = "Delete",
                            OldValue      = JsonConvert.SerializeObject(oldValue),
                            NewValue      = null,
                            Remarks       = $"删除 违章查询城市:{oldValue.CityName} 的配置",
                            Operator      = user,
                        };
                        LoggerManager.InsertLog("PeccancyConfigOprLog", log);
                    }
                }
                else
                {
                    result = true;
                }
            }
            catch (Exception ex)
            {
                Logger.Error("DeletePeccancyCityConfig", ex);
            }
            return(result);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 删除违章查询省份配置
        /// </summary>
        /// <param name="provinceId"></param>
        /// <returns></returns>
        public bool DeletePeccancyProvinceConfig(int provinceId, string user)
        {
            var result = false;

            try
            {
                using (var dbhelper = new Tuhu.Component.Common.SqlDbHelper(grconnectionString))
                {
                    var oldValue = DalPeccancyQueryConfig.GetPeccancyProvinceConfigByProvinceId(provinceId);
                    if (oldValue != null)
                    {
                        var cityConfigs = DalPeccancyQueryConfig.GetPeccancyCitiesByProvinceId(provinceId);
                        if (cityConfigs != null && cityConfigs.Any())
                        {
                            dbhelper.BeginTransaction();
                            var deleteProvince = DalPeccancyQueryConfig.DeletePeccancyCityConfigByProvinceId(dbhelper, provinceId);
                            var deleteCity     = DalPeccancyQueryConfig.DeletePeccancyProvinceConfig(dbhelper, provinceId);//同时删除该省份下的所有城市配置
                            if (deleteProvince && deleteCity)
                            {
                                dbhelper.Commit();
                                result = true;
                                #region  除的省份和城市记录日志
                                var logs        = new List <PeccancyConfigOprLogModel>();
                                var provinceLog = new PeccancyConfigOprLogModel
                                {
                                    LogType       = "PeccancyProvinceConfig",
                                    IdentityId    = $"{oldValue.ProvinceId}",
                                    OperationType = "Delete",
                                    OldValue      = JsonConvert.SerializeObject(oldValue),
                                    NewValue      = null,
                                    Remarks       = $"删除 违章查询省份:{oldValue.ProvinceName} 的配置",
                                    Operator      = user,
                                };
                                logs.Add(provinceLog);
                                foreach (var city in cityConfigs)
                                {
                                    var cityLog = new PeccancyConfigOprLogModel
                                    {
                                        LogType       = "PeccancyCityConfig",
                                        IdentityId    = $"{city.CityId}",
                                        OperationType = "Delete",
                                        OldValue      = JsonConvert.SerializeObject(city),
                                        NewValue      = null,
                                        Remarks       = $"删除 违章查询城市:{city.CityName} 的配置",
                                        Operator      = user,
                                    };
                                    logs.Add(cityLog);
                                }
                                if (logs.Any())
                                {
                                    logs.ForEach(s => LoggerManager.InsertLog("PeccancyConfigOprLog", s));
                                }
                                #endregion
                            }
                        }
                        else
                        {
                            result = DalPeccancyQueryConfig.DeletePeccancyProvinceConfig(dbhelper, provinceId);
                            if (result)
                            {
                                var log = new PeccancyConfigOprLogModel
                                {
                                    LogType       = "PeccancyProvinceConfig",
                                    IdentityId    = $"{oldValue.ProvinceId}",
                                    OperationType = "Delete",
                                    OldValue      = JsonConvert.SerializeObject(oldValue),
                                    NewValue      = null,
                                    Remarks       = $"删除 违章查询省份:{oldValue.ProvinceName} 的配置",
                                    Operator      = user,
                                };
                                LoggerManager.InsertLog("PeccancyConfigOprLog", log);
                            }
                        }
                    }
                    else
                    {
                        result = true;
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error("DeletePeccancyProvinceConfig", ex);
            }
            return(result);
        }