예제 #1
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);
        }
예제 #2
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);
        }