Exemplo n.º 1
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;
     }
 }