コード例 #1
0
            byte[] DDMWriteCallback.getRecordData(DDMCallbackEvent ddmce, int i)
            {
                String data = _reader.ReadLine();

                byte[] returnData = ddmce.getFile().getRecordDataBuffer();

                for (int idx = 0; idx < _format.getFieldCount(); idx++)
                {
                    DDMField fld = _format.getField(idx);

                    // SRCSEQ/SRCDAT have to be handled differently
                    if ("SRCSEQ".Equals(fld.getName(), StringComparison.InvariantCultureIgnoreCase))
                    {
                        fld.setString(String.Format("{0}", _sequence), returnData);
                        _sequence += 1;
                    }
                    else if ("SRCDAT".Equals(fld.getName(), StringComparison.InvariantCultureIgnoreCase))
                    {
                        fld.setString(String.Format("{0}", 0), returnData);
                    }
                    //if ("SRCDTA".Equals(fld.getName(), StringComparison.InvariantCultureIgnoreCase))
                    else
                    {
                        fld.setString(data, returnData);
                    }
                }
                return(returnData);
            }
コード例 #2
0
        //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);
            }
        }