Пример #1
0
        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);
        }
Пример #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));
        }