Exemple #1
0
        public void TransferFiles(FileTransferRequest request)
        {
            // Expand requests, if needed
            List <FileTransfer> transfers = new List <FileTransfer>();

            if (request.TargetFile.Source == SourceType.Local)
            {
                // remote-to-local: Create 1 transfer per source as pscp only allows 1 remote file per op
                foreach (BrowserFileInfo source in request.SourceFiles)
                {
                    FileTransferRequest req = new FileTransferRequest
                    {
                        TargetFile = request.TargetFile,
                        Session    = request.Session
                    };
                    req.SourceFiles.Add(source);
                    transfers.Add(new FileTransfer(this.Options, req));
                }
            }
            else
            {
                // local-to-remote: Create 1 transfer for all
                transfers.Add(new FileTransfer(this.Options, request));
            }

            // Add and start each transfer
            foreach (FileTransfer transfer in transfers)
            {
                AddTransfer(transfer);
                transfer.Start();
            }
        }
Exemple #2
0
 private void ResetDragDrop()
 {
     this.dragDropLastX        = -1;
     this.dragDropLastY        = -1;
     this.dragDropIsValid      = false;
     this.dragDropFileTransfer = null;
 }
        public void TransferFiles(FileTransferRequest request)
        {
            // Expand requests, if needed
            List<FileTransfer> transfers = new List<FileTransfer>();
            if (request.TargetFile.Source == SourceType.Local)
            {
                // remote-to-local: Create 1 transfer per source as pscp only allows 1 remote file per op
                foreach (BrowserFileInfo source in request.SourceFiles)
                {
                    FileTransferRequest req = new FileTransferRequest
                    {
                        TargetFile = request.TargetFile,
                        Session = request.Session
                    };
                    req.SourceFiles.Add(source);
                    transfers.Add(new FileTransfer(this.Options, req));
                }
            }
            else
            {
                // local-to-remote: Create 1 transfer for all
                transfers.Add(new FileTransfer(this.Options, request));
            }

            // Add and start each transfer
            foreach (FileTransfer transfer in transfers)
            {
                AddTransfer(transfer);
                transfer.Start();
            }
        }
Exemple #4
0
        public FileTransfer(PscpOptions options, FileTransferRequest request)
        {
            this.Options = options;
            this.Request = request;

            this.Id = Interlocked.Increment(ref idSeed);
        }
Exemple #5
0
        public FileTransfer(PscpOptions options, FileTransferRequest request)
        {
            this.Options = options;
            this.Request = request;

            this.Id = Interlocked.Increment(ref idSeed);
        }
Exemple #6
0
        private void listViewFiles_DragEnter(object sender, DragEventArgs e)
        {
            // Check for copy allowed, payload = DataFormats.FileDrop or BrowserFileInfo
            bool copyAllowed   = (e.AllowedEffect & DragDropEffects.Copy) == DragDropEffects.Copy;
            bool isFile        = e.Data.GetDataPresent(DataFormats.FileDrop, false);
            bool isBrowserFile = e.Data.GetDataPresent(typeof(BrowserFileInfo[]));

            this.dragDropIsValid = copyAllowed && (isFile || isBrowserFile);

            // update effect
            e.Effect = dragDropIsValid ? DragDropEffects.Copy : DragDropEffects.None;

            // parse out payload
            if (this.dragDropIsValid)
            {
                this.dragDropFileTransfer = new FileTransferRequest {
                    Session = this.Presenter.Session
                };

                // Get source files (payload)
                if (e.Data.GetDataPresent(DataFormats.FileDrop))
                {
                    // windows files
                    Array files = (Array)e.Data.GetData(DataFormats.FileDrop, false);
                    foreach (string fileName in files)
                    {
                        BrowserFileInfo item = Directory.Exists(fileName)
                            ? new BrowserFileInfo(new DirectoryInfo(fileName))
                            : new BrowserFileInfo(new FileInfo(fileName));
                        this.dragDropFileTransfer.SourceFiles.Add(item);
                    }
                }
                else if (e.Data.GetDataPresent(typeof(BrowserFileInfo[])))
                {
                    // from another browser
                    BrowserFileInfo[] files = (BrowserFileInfo[])e.Data.GetData(typeof(BrowserFileInfo[]));
                    this.dragDropFileTransfer.SourceFiles.AddRange(files);
                }
            }

            Log.DebugFormat(
                "DragEnter: allowedEffect={0}, effect={1}, isFile={2}, isBrowserFile={3}",
                e.AllowedEffect, e.Effect, isFile, isBrowserFile);
        }
Exemple #7
0
 /// <summary>Transfer a file between two locations</summary>
 /// <param name="fileTransferReqeust">The request data containing files to transfer</param>
 public void TransferFiles(FileTransferRequest fileTransferReqeust)
 {
     this.FileTransferPresenter.TransferFiles(fileTransferReqeust);
 }
 /// <summary>Transfer a file between two locations</summary>
 /// <param name="fileTransferReqeust">The request data containing files to transfer</param>
 public void TransferFiles(FileTransferRequest fileTransferReqeust)
 {
     this.FileTransferPresenter.TransferFiles(fileTransferReqeust);
 }
 public void TransferFiles(FileTransferRequest transfer)
 {
     Log.InfoFormat("TransferFiles: {0}", transfer);
     this.LastRequest = transfer;
 }
Exemple #10
0
 private void ResetDragDrop()
 {
     this.dragDropLastX = -1;
     this.dragDropLastY = -1;
     this.dragDropIsValid = false;
     this.dragDropFileTransfer = null;
 }
Exemple #11
0
        private void listViewFiles_DragEnter(object sender, DragEventArgs e)
        {
            // Check for copy allowed, payload = DataFormats.FileDrop or BrowserFileInfo
            bool copyAllowed = (e.AllowedEffect & DragDropEffects.Copy) == DragDropEffects.Copy;
            bool isFile = e.Data.GetDataPresent(DataFormats.FileDrop, false);
            bool isBrowserFile = e.Data.GetDataPresent(typeof(BrowserFileInfo[]));
            this.dragDropIsValid = copyAllowed && ( isFile || isBrowserFile);

            // update effect
            e.Effect = dragDropIsValid ? DragDropEffects.Copy : DragDropEffects.None;

            // parse out payload
            if (this.dragDropIsValid)
            {
                this.dragDropFileTransfer = new FileTransferRequest { Session = this.Presenter.Session };

                // Get source files (payload)
                if (e.Data.GetDataPresent(DataFormats.FileDrop))
                {
                    // windows files
                    Array files = (Array)e.Data.GetData(DataFormats.FileDrop, false);
                    foreach (string fileName in files)
                    {
                        BrowserFileInfo item = Directory.Exists(fileName)
                            ? new BrowserFileInfo(new DirectoryInfo(fileName))
                            : new BrowserFileInfo(new FileInfo(fileName));
                        this.dragDropFileTransfer.SourceFiles.Add(item);
                    }
                }
                else if (e.Data.GetDataPresent(typeof(BrowserFileInfo[])))
                {
                    // from another browser
                    BrowserFileInfo[] files = (BrowserFileInfo[])e.Data.GetData(typeof(BrowserFileInfo[]));
                    this.dragDropFileTransfer.SourceFiles.AddRange(files);
                }
            }

            Log.DebugFormat(
                "DragEnter: allowedEffect={0}, effect={1}, isFile={2}, isBrowserFile={3}",
                e.AllowedEffect, e.Effect, isFile, isBrowserFile);
        }