Exemple #1
0
 //Returns true if successful
 public static bool RemoteCommand(string Command, bool ShowError = true)
 {
     if (ClientDDM != null && !ClientDDM.isClosed())
     {
         try
         {
             java.util.List lstMessages = ClientDDM.executeReturnMessageList(Command);
             if (lstMessages == null || lstMessages.size() == 0)
             {
                 return(true);
             }
             else
             {
                 for (int msgidx = 0; msgidx < lstMessages.size(); msgidx++)
                 {
                     com.ibm.jtopenlite.Message msg = (com.ibm.jtopenlite.Message)lstMessages.get(msgidx);
                     if (msg.getSeverity() > 1) // DDM returns sev 0-8 range (AS400 severity / 10 if you will )
                     {
                         if (ShowError)
                         {
                             MessageBox.Show(msg.getText(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                         }
                         return(false);
                     }
                 }
             }
             // Get here means no messages with Sev > 10, so ok
             return(true);
         } catch (Exception ex)
         {
             // command failed.
             return(false);
         }
     }
     else
     {
         return(false);
     }
 }
Exemple #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public UserInfo[] getUsers(final DDMConnection ddmConn) throws IOException
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
        public UserInfo[] getUsers(DDMConnection ddmConn)
        {
            IList <Message> messages = ddmConn.executeReturnMessageList("DSPUSRPRF USRPRF(*ALL) TYPE(*BASIC) OUTPUT(*OUTFILE) OUTFILE(QTEMP/TBALLUSERS)");

            if (messages.Count > 0)
            {
                if (messages.Count != 1 && !messages[0].ID.Equals("CPF9861"))   // Output file created.
                {
                    throw new MessageException("Error retrieving users: ", messages);
                }
            }

            users_.Clear();
            if (rf_ == null)
            {
                rf_ = ddmConn.getRecordFormat("QTEMP", "TBALLUSERS");
                rf_.getField("UPUSCL").CacheStrings = true;
                rf_.getField("UPPWEX").CacheStrings = true;
                rf_.getField("UPUPLK").CacheStrings = true;
                rf_.getField("UPUPDM").CacheStrings = true;
                rf_.getField("UPSTAT").CacheStrings = true;
            }

            done_ = false;

            DDMFile file = ddmConn.open("QTEMP", "TBALLUSERS", "TBALLUSERS", "QSYDSUPB", DDMFile.READ_ONLY, false, 160, 1);

            IList <DDMFileMemberDescription> desc = ddmConn.getFileMemberDescriptions(file);

            if (desc != null && desc.Count > 0)
            {
                uiListener_.totalRecords(desc[0].RecordCount);
            }

            while (!done())
            {
                ddmConn.readNext(file, this);
            }
            ddmConn.close(file);

            UserInfo[] arr = new UserInfo[users_.Count];
            return((UserInfo[])users_.toArray(arr));
        }