Ejemplo n.º 1
0
        /// <summary>
        ///  增加一条数据
        ///  注:如果functionIdList为空,则添加model.FK_SysFunctionID,否则,则添加functionIdList
        /// </summary>
        public bool Add(XCLCMS.Data.Model.SysRoleFunction model, List <long> functionIdList = null)
        {
            if (null == functionIdList || functionIdList.Count == 0)
            {
                if (model.FK_SysFunctionID > 0)
                {
                    functionIdList = new List <long>()
                    {
                        model.FK_SysFunctionID
                    };
                }
            }

            Database  db        = base.CreateDatabase();
            DbCommand dbCommand = db.GetStoredProcCommand("sp_SysRoleFunction_ADD");

            db.AddInParameter(dbCommand, "FK_SysRoleID", DbType.Int64, model.FK_SysRoleID);
            db.AddInParameter(dbCommand, "RecordState", DbType.AnsiString, model.RecordState);
            db.AddInParameter(dbCommand, "CreateTime", DbType.DateTime, model.CreateTime);
            db.AddInParameter(dbCommand, "CreaterID", DbType.Int64, model.CreaterID);
            db.AddInParameter(dbCommand, "CreaterName", DbType.String, model.CreaterName);
            db.AddInParameter(dbCommand, "UpdateTime", DbType.DateTime, model.UpdateTime);
            db.AddInParameter(dbCommand, "UpdaterID", DbType.Int64, model.UpdaterID);
            db.AddInParameter(dbCommand, "UpdaterName", DbType.String, model.UpdaterName);

            dbCommand.Parameters.Add(new SqlParameter("@FK_SysFunctionIDTable", SqlDbType.Structured)
            {
                TypeName  = "TVP_IDTable",
                Direction = ParameterDirection.Input,
                Value     = XCLNetTools.DataSource.DataTableHelper.ToSingleColumnDataTable <long, long>(functionIdList)
            });

            db.AddOutParameter(dbCommand, "ResultCode", DbType.Int32, 4);
            db.AddOutParameter(dbCommand, "ResultMessage", DbType.String, 1000);
            db.ExecuteNonQuery(dbCommand);

            var result = XCLCMS.Data.DAL.Common.Common.GetProcedureResult(dbCommand.Parameters);

            if (result.IsSuccess)
            {
                return(true);
            }
            else
            {
                throw new Exception(result.ResultMessage);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 执行策略
        /// </summary>
        public override void DoWork <T>(T context)
        {
            var sysRoleContext = context as XCLCMS.Data.BLL.Strategy.SysRole.SysRoleContext;

            XCLCMS.Data.BLL.SysRoleFunction bll = new XCLCMS.Data.BLL.SysRoleFunction();

            XCLCMS.Data.Model.SysRoleFunction model = new XCLCMS.Data.Model.SysRoleFunction();
            model.CreaterID    = sysRoleContext.CurrentUserInfo.UserInfoID;
            model.CreaterName  = sysRoleContext.CurrentUserInfo.UserName;
            model.CreateTime   = DateTime.Now;
            model.UpdaterID    = model.CreaterID;
            model.UpdaterName  = model.CreaterName;
            model.UpdateTime   = model.CreateTime;
            model.FK_SysRoleID = sysRoleContext.SysRole.SysRoleID;
            model.RecordState  = XCLCMS.Data.CommonHelper.EnumType.RecordStateEnum.N.ToString();

            bool flag = false;

            try
            {
                using (var scope = new TransactionScope())
                {
                    flag = bll.Add(model, sysRoleContext.FunctionIdList);
                    if (flag)
                    {
                        bll.ClearInvalidNormalRoleFunctions();
                        scope.Complete();
                    }
                }
            }
            catch (Exception ex)
            {
                flag = false;
                this.ResultMessage += string.Format("异常信息:{0}", ex.Message);
            }

            if (flag)
            {
                this.Result = StrategyLib.ResultEnum.SUCCESS;
            }
            else
            {
                this.Result        = StrategyLib.ResultEnum.FAIL;
                this.ResultMessage = string.Format("保存角色功能信息失败!{0}", this.ResultMessage);
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(XCLCMS.Data.Model.SysRoleFunction model, List <long> functionIdList = null)
 {
     return(dal.Add(model, functionIdList));
 }