public static bool DownloadFile(string Local, string Remote, DDMStreamCallbackAdaptor callback) { bool Result = false; try { if (ClientDDM != null && !ClientDDM.isClosed()) { string[] parts = Remote.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries); string remotelib = parts[1].Replace(".lib", ""); string remotefile = parts[2].Replace(".file", ""); string remotembr = parts[3].Replace(".mbr", ""); DDMRecordFormat remotefmt = ClientDDM.getRecordFormat(remotelib, remotefile); if (remotefmt != null) { DDMFile remote = ClientDDM.open(remotelib, remotefile, remotembr, remotefmt.getName()); if (remote != null) { // Open local file and pass to Reader StreamWriter sw = new StreamWriter(Local, false, Encoding.ASCII); callback.Format = remotefmt; callback.Writer = sw; while (!callback.isDone()) { ClientDDM.readNext(remote, callback); } ClientDDM.close(remote); sw.Close(); } } } else { return(true); //error } } catch (Exception e) { Result = true; } return(Result); }
//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)); }
/// <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(); */ }
internal DDMCallbackEvent(DDMFile f) { file_ = f; }
//Returns true if successful public static bool UploadFile(string Local, string Remote) { if (ClientDDM != null && !ClientDDM.isClosed()) { string[] parts = Remote.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries); string remotelib = parts[1].Replace(".lib", ""); string remotefile = parts[2].Replace(".file", ""); string remotembr = parts[3].Replace(".mbr", ""); try { DDMRecordFormat remotefmt = ClientDDM.getRecordFormat(remotelib, remotefile); if (remotefmt != null) { // At this stage - file does exist, we have to clear member first // Cross fingers we finish this out! if (!RemoteCommand("CLRPFM FILE(" + remotelib + "/" + remotefile + ") MBR(" + remotembr + ")")) { return(false); } DDMFile remote = ClientDDM.open(remotelib, remotefile, remotembr, remotefmt.getName(), DDMFile.WRITE_ONLY, false, 1, 1); if (remote != null) { // Open local file and pass to Writer StreamReader sr = new StreamReader(Local, Encoding.ASCII); int sequence = 1; //MyDDMWriteCallback writer = new MyDDMWriteCallback(sr, remotefmt); String data = sr.ReadLine(); while (data != null) { //ClientDDM.write(remote, writer); byte[] returnData = remote.getRecordDataBuffer(); // new byte[_format.getLength() + _format.getFieldCount()]; for (int idx = 0; idx < remotefmt.getFieldCount(); idx++) { DDMField fld = remotefmt.getField(idx); // SRCSEQ/SRCDAT have to be handled differently (as not stored locally yet) if ("SRCSEQ".Equals(fld.getName(), StringComparison.InvariantCultureIgnoreCase)) { fld.setString(sequence.ToString("000000"), returnData); sequence = sequence + 1; } else if ("SRCDAT".Equals(fld.getName(), StringComparison.InvariantCultureIgnoreCase)) { int dummyDate = 0; fld.setString(dummyDate.ToString("000000"), returnData); } //if ("SRCDTA".Equals(fld.getName(), StringComparison.InvariantCultureIgnoreCase)) else { fld.setString(data, returnData); } } bool[] nulls = new bool[remotefmt.getFieldCount()]; for (int idx = 0; idx < remotefmt.getFieldCount(); idx++) { nulls[idx] = false; } ClientDDM.write(remote, returnData, 0, nulls, null); data = sr.ReadLine(); } ClientDDM.close(remote); sr.Close(); } } } catch (Exception ex) { // Exception in writing return(false); } return(true); } else { return(false); } }