/// <summary>
        /// NOTE: The workingLibrary will be deleted when this method is called.
        ///
        /// </summary>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public DiskStatus[] getDiskStatuses(final CommandConnection cc, final DDMConnection ddmConn, String workingLibrary, boolean reset) throws IOException
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
        public virtual DiskStatus[] getDiskStatuses(CommandConnection cc, DDMConnection ddmConn, string workingLibrary, bool reset)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final SystemInfo si1 = cc.getInfo();
            SystemInfo si1 = cc.Info;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final SystemInfo si2 = ddmConn.getInfo();
            SystemInfo si2 = ddmConn.Info;

            if (!si1.System.Equals(si2.System) || si1.ServerLevel != si2.ServerLevel)
            {
                throw new IOException("Command connection does not match DDM connection.");
            }

            skip_   = 0;
            theEnd_ = false;
            statuses_.Clear();
            elapsedTime_        = null;
            done_               = false;
            outputQueueLibrary_ = workingLibrary;

            // I really wish spooled files could go into QTEMP!
            // DDMConnection conn = DDMConnection.getConnection("rchasa12", "csmith",
            // "s1r4l0in");
            // CommandConnection conn = CommandConnection.getConnection("rchasa12",
            // "csmith", "s1r4l0in");
            // System.out.println(conn.getJobName());
            CommandResult result = cc.execute("CLROUTQ OUTQ(" + workingLibrary + "/DSKSTS)");

            if (!result.succeeded())
            {
                IList <Message> messages = result.MessagesList;
                if (messages.Count != 1 && !messages[0].ID.Equals("CPF3357"))
                {
                    throw new IOException("Error clearing output queue: " + result.ToString());
                }
            }
            result = cc.execute("DLTLIB " + workingLibrary);
            if (!result.succeeded())
            {
                IList <Message> messages = result.MessagesList;
                if (messages.Count != 1 || !messages[0].ID.Equals("CPF2110"))   // Library
                // not
                // found.
                {
                    throw new IOException("Error deleting library: " + result.ToString());
                }
            }
            result = cc.execute("CRTLIB " + workingLibrary);
            if (!result.succeeded())
            {
                throw new IOException("Error creating library: " + result.ToString());
            }
            result = cc.execute("CRTPF " + workingLibrary + "/DSKSTS RCDLEN(132) MAXMBRS(*NOMAX) SIZE(*NOMAX) LVLCHK(*NO)");
            if (!result.succeeded())
            {
                throw new IOException("Error creating physical file: " + result.ToString());
            }
            result = cc.execute("CRTOUTQ OUTQ(" + workingLibrary + "/DSKSTS)");
            if (!result.succeeded())
            {
                throw new IOException("Error creating output queue: " + result.ToString());
            }
            result = cc.execute("CHGJOB OUTQ(" + workingLibrary + "/DSKSTS)");
            if (!result.succeeded())
            {
                throw new IOException("Error changing job: " + result.ToString());
            }
            result = cc.execute("WRKDSKSTS OUTPUT(*PRINT) RESET(" + (reset ? "*YES" : "*NO") + ")");
            if (!result.succeeded())
            {
                throw new IOException("Error running WRKDSKSTS: " + result.ToString());
            }
            OpenListOfSpooledFilesFormatOSPL0300 format = new OpenListOfSpooledFilesFormatOSPL0300();
            OpenListOfSpooledFiles list = new OpenListOfSpooledFiles(format, 256, -1, null, this, null, null, null);

            list.FormatListener = this;
            result = cc.call(list);
            if (!result.succeeded())
            {
                throw new IOException("Error retrieving spooled file: " + result.ToString());
            }
            ListInformation info  = list.ListInformation;
            CloseList       close = new CloseList(info.RequestHandle);

            result = cc.call(close);
            if (!result.succeeded())
            {
                throw new IOException("Error closing spooled file list: " + result.ToString());
            }
            string jobID = jobNumber_.Trim() + "/" + jobUser_.Trim() + "/"
                           + jobName_.Trim();

            result = cc.execute("CPYSPLF FILE(" + spooledFileName_.Trim() + ") TOFILE(" + workingLibrary + "/DSKSTS) JOB(" + jobID + ") SPLNBR(" + spooledFileNumber_ + ") MBROPT(*REPLACE)");
            if (!result.succeeded())
            {
                throw new IOException("Error copying spooled file: " + result.ToString());
            }

            DDMFile file = ddmConn.open(workingLibrary, "DSKSTS", "DSKSTS", "DSKSTS", DDMFile.READ_ONLY, false, 200, 1);

            while (!done())
            {
                ddmConn.readNext(file, this);
            }
            ddmConn.close(file);
            result = cc.execute("DLTLIB " + workingLibrary);

            DiskStatus[] arr = new DiskStatus[statuses_.Count];
            statuses_.toArray(arr);
            return(arr);

            /*
             * Class.forName("com.ibm.jtopenlite.database.jdbc.JDBCDriver");
             * java.sql.Connection c =
             * DriverManager.getConnection("jdbc:systemi://rchasa12", "csmith",
             * "s1r4l0in"); Statement s = c.createStatement(); ResultSet rs =
             * s.executeQuery("SELECT * FROM QZRDDSKSTS.DSKSTS"); int skip = 0;
             * boolean theEnd = false; while (rs.next()) { String line =
             * rs.getString(1); if (skip < 4) { ++skip; } else if (!theEnd) { if
             * (line.indexOf("E N D  O F  L I S T I N G") >= 0) { theEnd = true; }
             * else { StringTokenizer st = new StringTokenizer(line); String unit =
             * st.nextToken(); String type = st.nextToken(); String sizeMB =
             * st.nextToken(); String percentUsed = st.nextToken(); String
             * ioRequests = st.nextToken(); String requestSizeKB = st.nextToken();
             * String readRequests = st.nextToken(); String writeRequests =
             * st.nextToken(); String readKB = st.nextToken(); String writeKB =
             * st.nextToken(); String percentBusy = st.nextToken(); String asp =
             * st.nextToken(); String protectionType = st.nextToken(); String
             * protectionStatus = st.nextToken(); String compression =
             * st.nextToken(); //TODO } } } rs.close(); s.close(); c.close();
             */
        }
Exemple #2
0
        /// <summary>
        /// Calls the OpenListProgram, then loops calling GetListEntries, then finally calls CloseList. </summary>
        /// <param name="conn"> The connection to use. </param>
        /// <param name="numRecordsToReturn"> The number of records the GetListEntries call should return each time.
        ///  </param>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void process(CommandConnection conn, int numRecordsToReturn) throws IOException
        public virtual void process(CommandConnection conn, int numRecordsToReturn)
        {
            CommandResult result = conn.call(program_);

            if (!result.succeeded())
            {
                throw new IOException("Open list failed: " + result.ToString());
            }

            ListInformation listInfo = program_.ListInformation;

            sbyte[] requestHandle = listInfo.RequestHandle;
            close_.RequestHandle = requestHandle;

            if (listener_ != null)
            {
                listener_.openComplete();
            }

            try
            {
                int recordLength = listInfo.RecordLength;
                // Now, the list is building on the server.
                // Call GetListEntries once to wait for the list to finish building, for example.
                int receiverSize   = 8;
                int startingRecord = -1;
                getEntries_.LengthOfReceiverVariable = receiverSize;
                getEntries_.RequestHandle            = requestHandle;
                getEntries_.RecordLength             = recordLength;
                getEntries_.NumberOfRecordsToReturn  = 0;
                getEntries_.StartingRecord           = startingRecord;
                getEntries_.FormatListener           = null;
                result = conn.call(getEntries_);
                if (!result.succeeded())
                {
                    throw new IOException("Get list entries failed: " + result.ToString());
                }

                listInfo = getEntries_.ListInformation;
                int totalRecords = listInfo.TotalRecords;
                if (listener_ != null)
                {
                    listener_.totalRecordsInList(totalRecords);
                }

                // Now retrieve each object record in chunks of 800 at a time.
                receiverSize = recordLength * numRecordsToReturn;
                if (receiverSize <= 0)
                {
                    receiverSize = 100000;
                }
                startingRecord = 1;
                getEntries_.LengthOfReceiverVariable = receiverSize;
                getEntries_.NumberOfRecordsToReturn  = numRecordsToReturn;
                getEntries_.StartingRecord           = startingRecord;
                getEntries_.FormatListener           = listener_; // Ready to process.
                if (listener_ != null)
                {
                    while (!listener_.stopProcessing() && startingRecord <= totalRecords)
                    {
                        result = conn.call(getEntries_);
                        if (!result.succeeded())
                        {
                            throw new IOException("Get objects failed: " + result.ToString());
                        }
                        // Assuming it succeeded.
                        listInfo                   = getEntries_.ListInformation;
                        startingRecord            += listInfo.RecordsReturned;
                        getEntries_.StartingRecord = startingRecord;
                    }
                }
            }
            finally
            {
                conn.call(close_);
            }
        }