Beispiel #1
0
        public void ExecuteSCP(ScpParameter scp_param)
        {
            // making command string for scp
            string cmd = String.Format("scp {0} {1}", scp_param.Direction == SCPCopyDirection.LocalToRemote ? "-t" : "-f", scp_param.RemoteFilename);
            ScpChannelReceiverBase receiver_base;

            if (scp_param.Direction == SCPCopyDirection.LocalToRemote)
            {
                ScpLocalToRemoteReceiver receiver = new ScpLocalToRemoteReceiver(scp_param);
                receiver_base = receiver;
                // exec command
                receiver.Run(DoExecCommand(receiver, cmd));
            }
            else
            {
                ScpRemoteToLocalReceiver receiver = new ScpRemoteToLocalReceiver(scp_param);
                receiver_base = receiver;
                // exec command
                receiver.Run(DoExecCommand(receiver, cmd));
                //Note: asynchronously operation should be supported
                receiver.CompleteEvent.WaitOne();
            }

            Debug.Assert(scp_param.LocalSource.IsClosed); //the local source must be closed regardless of the transmission

            receiver_base.Dipose();

            if (!receiver_base.Succeeded)
            {
                throw receiver_base.Error;
            }
        }
Beispiel #2
0
        public void ExecuteSCP(ScpParameter scp_param) {
            // making command string for scp
            string cmd = String.Format("scp {0} {1}", scp_param.Direction == SCPCopyDirection.LocalToRemote ? "-t" : "-f", scp_param.RemoteFilename);
            ScpChannelReceiverBase receiver_base;

            if (scp_param.Direction == SCPCopyDirection.LocalToRemote) {
                ScpLocalToRemoteReceiver receiver = new ScpLocalToRemoteReceiver(scp_param);
                receiver_base = receiver;
                // exec command
                receiver.Run(DoExecCommand(receiver, cmd));
            }
            else {
                ScpRemoteToLocalReceiver receiver = new ScpRemoteToLocalReceiver(scp_param);
                receiver_base = receiver;
                // exec command
                receiver.Run(DoExecCommand(receiver, cmd));
                //Note: asynchronously operation should be supported
                receiver.CompleteEvent.WaitOne();
            }

            Debug.Assert(scp_param.LocalSource.IsClosed); //the local source must be closed regardless of the transmission

            receiver_base.Dipose();

            if (!receiver_base.Succeeded)
                throw receiver_base.Error;
        }