示例#1
0
        public SigmaResultType AddSigmaRole(TypeSigmaRole objSigmaRole)
        {
            TransactionScope scope = null;
            SigmaResultType result = new SigmaResultType();

            // Get connection string
            string connStr = ConnStrHelper.getDbConnString();

            List<SqlParameter> paramList = new List<SqlParameter>();
            paramList.Add(new SqlParameter("@Name", objSigmaRole.Name));
            paramList.Add(new SqlParameter("@SubSystem", objSigmaRole.SubSystem));
            paramList.Add(new SqlParameter("@RoleTypeCode", objSigmaRole.RoleTypeCode));
            paramList.Add(new SqlParameter("@RoleDescription", objSigmaRole.RoleDescription));
            paramList.Add(new SqlParameter("@CreatedBy", objSigmaRole.CreatedBy));
            paramList.Add(new SqlParameter("@SigmaRoleGuid", Guid.NewGuid().ToString().ToUpper()));
            SqlParameter outParam = new SqlParameter("@NewId", SqlDbType.Int);
            outParam.Direction = ParameterDirection.Output;
            paramList.Add(outParam);

            using (scope = new TransactionScope(TransactionScopeOption.Required))
            {
                result.AffectedRow = SqlHelper.ExecuteNonQuery(connStr, CommandType.StoredProcedure, "usp_AddSigmaRole", paramList.ToArray());
                if (result.AffectedRow > 0)
                {
                    result.IsSuccessful = true;
                    result.ScalarValue = (int)outParam.Value;
                }
                else
                {
                    result.IsSuccessful = false;
                    result.ErrorMessage = "The role already exists";
                }
                scope.Complete();

            }

            return result;
        }
示例#2
0
        public SigmaResultType MultiSigmaRoleSigmaJob(TypeSigmaRole listObj)
        {
            TypeUserInfo userinfo = AuthMgr.GetUserInfo();
            listObj.CreatedBy = userinfo.SigmaUserId;

            TransactionScope scope = null;
            SigmaResultType result = new SigmaResultType();

            // Get connection string
            string connStr = ConnStrHelper.getDbConnString();

            if(listObj.SigmaRoleId != null)
                RemoveSigmaRoleSigmaJob(listObj.SigmaRoleId);

            int sigmaRoleId = listObj.SigmaRoleId;

            using (scope = new TransactionScope(TransactionScopeOption.RequiresNew))
            {
                SigmaRoleMgr sigmaRoleMgr = new SigmaRoleMgr();

                switch (listObj.SigmaOperation)
                {
                    case "C":
                        result = sigmaRoleMgr.AddSigmaRole(listObj);
                        sigmaRoleId = result.ScalarValue;
                        break;
                    case "U":
                        result = sigmaRoleMgr.UpdateSigmaRole(listObj);
                        break;
                }

                if (result.IsSuccessful)
                {

                    listObj.typeSigmaRoleSigmaJob.ForEach(x => x.CreatedBy = userinfo.SigmaUserId);
                    listObj.typeSigmaRoleSigmaJob.ForEach(x => x.SigmaRoleId = sigmaRoleId);

                    foreach (TypeSigmaRoleSigmaJob anObj in listObj.typeSigmaRoleSigmaJob)
                    {
                        AddSigmaRoleSigmaJob(anObj);
                    }
                    result.IsSuccessful = true;
                    scope.Complete();
                }
            }

            return result;
        }
 public SigmaResultType AddSigmaRole(TypeSigmaRole objSigmaRole)
 {
     SigmaResultType result = new SigmaResultType();
     try
     {
         SigmaRoleMgr sigmaRoleMgr = new SigmaRoleMgr();
         result = sigmaRoleMgr.AddSigmaRole(objSigmaRole);
         return result;
     }
     catch (Exception ex)
     {
         // Log Exception
         ExceptionHelper.logException(ex);
         result.IsSuccessful = false;
         result.ErrorMessage = ex.Message;
         return result;
     }
 }
        public SigmaResultType UpdateSigmaRole(TypeSigmaRole objSigmaRole)
        {
            SigmaResultType result = new SigmaResultType();

            try
            {
                result.IsSuccessful = true;
                return result;
            }
            catch (Exception ex)
            {
                // Log Exception
                ExceptionHelper.logException(ex);
                result.IsSuccessful = false;
                result.ErrorMessage = ex.Message;
                return result;
            }
        }
        public SigmaResultType MultiRolesNPermissions(TypeSigmaRole listObj)
        {
            SigmaResultType result = new SigmaResultType();

            try
            {
                PermissionMgr permissionMgr = new PermissionMgr();
                result = permissionMgr.MultiSigmaRoleSigmaJob(listObj);
                return result;
            }
            catch (Exception ex)
            {
                // Log Exception
                ExceptionHelper.logException(ex);
                result.IsSuccessful = false;
                result.ErrorMessage = ex.Message;
                return result;
            }
        }
示例#6
0
        public SigmaResultType UpdateSigmaRole(TypeSigmaRole objSigmaRole)
        {
            TransactionScope scope = null;
            SigmaResultType result = new SigmaResultType();

            // Get connection string
            string connStr = ConnStrHelper.getDbConnString();

            // Compose parameters
            SqlParameter[] parameters = new SqlParameter[] {
                    new SqlParameter("@SigmaRoleId", objSigmaRole.SigmaRoleId),
                    new SqlParameter("@Name", objSigmaRole.Name),
                    new SqlParameter("@SubSystem", objSigmaRole.SubSystem),
                    new SqlParameter("@RoleDescription", objSigmaRole.RoleDescription),
                    new SqlParameter("@UpdatedBy", AuthMgr.GetUserInfo().SigmaUserId.Trim()),
                    new SqlParameter("@SigmaRoleGuid", objSigmaRole.SigmaRoleGuid)
                };

            using (scope = new TransactionScope(TransactionScopeOption.Required))
            {
                result.AffectedRow = SqlHelper.ExecuteNonQuery(connStr, "usp_UpdateSigmaRole", parameters);
                result.IsSuccessful = true;
                scope.Complete();

            }

            return result;
        }
示例#7
0
        public SigmaResultType RemoveSigmaRole(TypeSigmaRole objSigmaRole)
        {
            SigmaResultType result = new SigmaResultType();
            TransactionScope scope = null;

            // Get connection string
            string connStr = ConnStrHelper.getDbConnString();

            // Compose parameters
            SqlParameter[] parameters = new SqlParameter[] {
                    new SqlParameter("@SigmaRoleId", objSigmaRole.SigmaRoleId)
                };

            using (scope = new TransactionScope(TransactionScopeOption.Required))
            {
                result.AffectedRow = SqlHelper.ExecuteNonQuery(connStr, "usp_RemoveSigmaRole", parameters);
                result.IsSuccessful = true;
                scope.Complete();
            }

            return result;
        }