Пример #1
0
        /// <summary>
        /// 删除喷漆大客户套餐配置
        /// </summary>
        /// <param name="carNoPrefix"></param>
        /// <param name="surfaceCount"></param>
        /// <param name="servicePid"></param>
        /// <param name="user"></param>
        /// <returns></returns>
        public bool DeletePackageConfig(string packageName, string user)
        {
            var result = true;

            try
            {
                var oldValue = dbScopeManagerConfigurationRead.Execute(conn =>
                                                                       DalVipPaintPackage.GetPackageConfig(conn, packageName));
                if (oldValue != null)
                {
                    result = dbScopeManagerConfiguration.Execute(conn => DalVipPaintPackage.DeletePackageConfig(conn, oldValue.PKID, user));
                    if (result)
                    {
                        var log = new
                        {
                            ObjectId    = $"PackageConfig_{oldValue.PackageName}",
                            ObjectType  = "VipPaintPackage",
                            BeforeValue = JsonConvert.SerializeObject(oldValue),
                            AfterValue  = "",
                            Remark      = $"删除喷漆大客户套餐:{oldValue.PackageName}的配置",
                            Creator     = user,
                        };
                        LoggerManager.InsertLog("CommonConfigLog", log);
                    }
                }
            }
            catch (Exception ex)
            {
                result = false;
                Logger.Error("DeleteVipPaintPackageConfig", ex);
            }
            return(result);
        }
Пример #2
0
        /// <summary>
        /// 添加喷漆大客户套餐配置
        /// </summary>
        /// <param name="model"></param>
        /// <param name="user"></param>
        /// <returns></returns>
        public bool AddPackageConfig(VipPaintPackageConfigModel model)
        {
            var result = false;

            try
            {
                var oldValue = dbScopeManagerConfigurationRead.Execute(conn =>
                                                                       DalVipPaintPackage.GetPackageConfig(conn, model.PackageName));
                dbScopeManagerConfiguration.CreateTransaction
                    (conn =>
                {
                    var addResult = false;
                    if (oldValue == null)
                    {
                        var pkid   = DalVipPaintPackage.AddPackageConfig(conn, model);
                        addResult  = pkid > 0;
                        model.PKID = addResult ? pkid : 0;
                    }
                    if (addResult)
                    {
                        model.PackagePid = $"FU-PQXB-KAT|{model.PKID.ToString()}";
                        var pidResult    = DalVipPaintPackage.UpdatePackagePID(conn, model.PKID, model.PackagePid);
                        if (pidResult)
                        {
                            var packagePid = CreatePaintPackageProduct(model.PKID.ToString(), model.PackageName, model.Operator);
                            if (string.IsNullOrWhiteSpace(packagePid))
                            {
                                throw new Exception($"CreatePaintPackageProduct失败,待创建产品{JsonConvert.SerializeObject(model)}");
                            }
                            else if (!string.Equals(packagePid, model.PackagePid))
                            {
                                model.PackagePid = packagePid;
                                result           = DalVipPaintPackage.UpdatePackagePID(conn, model.PKID, model.PackagePid);
                            }
                            else
                            {
                                result = true;
                            }
                        }
                        else
                        {
                            throw new Exception($"AddVipPackageConfig失败,待插入配置{JsonConvert.SerializeObject(model)}");
                        }
                    }
                });
                if (result)
                {
                    model.CreateDateTime     = DateTime.Now;
                    model.LastUpdateDateTime = DateTime.Now;
                    var log = new
                    {
                        ObjectId    = $"PackageConfig_{model.PackageName}",
                        ObjectType  = "VipPaintPackage",
                        BeforeValue = "",
                        AfterValue  = JsonConvert.SerializeObject(model),
                        Remark      = $"添加喷漆大客户套餐:{model.PackageName}的配置",
                        Creator     = model.Operator
                    };
                    LoggerManager.InsertLog("CommonConfigLog", log);
                }
            }
            catch (Exception ex)
            {
                result = false;
                Logger.Error("AddVipPackageConfig", ex);
            }
            return(result);
        }