public FileTransfer(PscpOptions options, FileTransferRequest request)
        {
            this.Options = options;
            this.Request = request;

            this.Id = Interlocked.Increment(ref idSeed);
        }
        public PscpBrowserPanel(SessionData session, PscpOptions options, string localStartingDir)
            : this()
        {
            var fileTransferSession = (SessionData) session.Clone();

            // if the session doesn't contain a host, a port, or an username
            // try to get them from the putty profile
            if ((string.IsNullOrEmpty(fileTransferSession.Username) || string.IsNullOrEmpty(fileTransferSession.Host) || fileTransferSession.Port == 0)
                && !string.IsNullOrEmpty(fileTransferSession.PuttySession))
            {
                var puttyProfile = PuttyDataHelper.GetSessionData(fileTransferSession.PuttySession);

                fileTransferSession.Username = string.IsNullOrEmpty(fileTransferSession.Username)
                    ? puttyProfile.Username
                    : fileTransferSession.Username;

                fileTransferSession.Host = string.IsNullOrEmpty(fileTransferSession.Host)
                    ? puttyProfile.Host
                    : fileTransferSession.Host;

                fileTransferSession.Port = (fileTransferSession.Port == 0)
                    ? puttyProfile.Port
                    : fileTransferSession.Port;
            }

            this.Name = fileTransferSession.SessionName;
            this.TabText = fileTransferSession.SessionName;

            this.fileTransferPresenter = new FileTransferPresenter(options);
            this.localBrowserPresenter = new BrowserPresenter(
                "Local", new LocalBrowserModel(), fileTransferSession, fileTransferPresenter);
            this.remoteBrowserPresenter = new BrowserPresenter(
                "Remote", new RemoteBrowserModel(options), fileTransferSession, fileTransferPresenter);

            this.browserViewLocal.Initialize(this.localBrowserPresenter, new BrowserFileInfo(new DirectoryInfo(localStartingDir)));
            this.browserViewRemote.Initialize(this.remoteBrowserPresenter, RemoteBrowserModel.NewDirectory(ScpUtils.GetHomeDirectory(fileTransferSession)));
            this.fileTransferView.Initialize(this.fileTransferPresenter);
        }
 public PscpBrowserPanel(SessionData session, PscpOptions options)
     : this(session, options, Environment.GetFolderPath(Environment.SpecialFolder.Desktop))
 {
 }
 public FileTransferPresenter(PscpOptions options)
 {
     this.Options = options;
     this.ViewModel = new FileTransferViewModel();
 }
 public PscpClient(PscpOptions options, SessionData session)
 {
     this.Options = options;
     this.Session = session;
 }
Beispiel #6
0
        public void LocalToRemote()
        {
            SessionData session = new SessionData
            {
                Username = ScpConfig.UserName,
                Password = ScpConfig.Password,
                Host = ScpConfig.KnownHost,
                Port = 22
            };

            List<BrowserFileInfo> sourceFiles = new List<BrowserFileInfo>
            {
                //new BrowserFileInfo(new FileInfo(Path.GetTempFileName()))
                new BrowserFileInfo(new FileInfo( @"D:\Downloads\vs2012_winexp_enu.iso" ))
            };
            BrowserFileInfo target = new BrowserFileInfo
            {
                Path = string.Format("/home/{0}/", session.Username),
                Source = SourceType.Remote
            };

            PscpOptions options = new PscpOptions { PscpLocation = ScpConfig.PscpLocation, TimeoutMs = 5000 };
            PscpClient client = new PscpClient(options, session);
            PscpResult res = client.CopyFiles(
                sourceFiles,
                target,
                (complete, cancelAll, status) =>
                {
                    Log.InfoFormat(
                        "complete={0}, cancelAll={1}, fileName={2}, pctComplete={3}",
                        complete, cancelAll, status.Filename, status.PercentComplete);
                });

            Log.InfoFormat("Result: {0}", res);

            /*
            ListDirectoryResult res = client.ListDirectory(new BrowserFileInfo { Path = "." });

            Assert.AreEqual(ResultStatusCode.Success, res.StatusCode);
            Assert.Greater(res.Files.Count, 0);
            foreach (BrowserFileInfo file in res.Files)
            {
                Log.Info(file);
            }

            Log.InfoFormat("Result: {0}", res);*/
        }
 public RemoteBrowserModel(PscpOptions options)
 {
     this.Options = options;
 }