Exemplo n.º 1
0
        public static bool ProcessSftp(Dictionary <string, object> deliveryMethodDictionary, string fileName)
        {
            FtpWrapper ftpWrapper = new FtpWrapper();

            ftpWrapper.SftpOrFtpTransfer(deliveryMethodDictionary, fileName);


            return(true);
        }
Exemplo n.º 2
0
        public Tasker.Conclusion SyncRemoteGamesFTP(Tasker tasker, Object syncObject = null)
        {
            // transfer games
            tasker.SetProgress(0, 100, Tasker.State.Running, Resources.UploadingGames);
            bool uploadSuccessful = false;

            if (!transferGameSet.Any())
            {
                Trace.WriteLine("No file to upload");
                uploadSuccessful = true;
            }
            else
            {
                Trace.WriteLine("Uploading through FTP");
                using (var ftp = new FtpWrapper(transferGameSet))
                {
                    Trace.WriteLine($"Upload size: " + Shared.SizeSuffix(ftp.Length));
                    if (ftp.Length > 0)
                    {
                        DateTime startTime = DateTime.Now, lastTime = DateTime.Now;
                        ftp.OnReadProgress += delegate(long pos, long len, string filename)
                        {
                            if (DateTime.Now.Subtract(lastTime).TotalMilliseconds >= UpdateFreq)
                            {
                                transferForm.SetAdvancedProgress(pos, len, filename);
                                lastTime = DateTime.Now;
                            }
                        };
                        if (ftp.Connect((hakchi.Shell as INetworkShell).IPAddress, 21, hakchi.USERNAME, hakchi.PASSWORD))
                        {
                            ftp.Upload(uploadPath);
                            uploadSuccessful = true;
                            Trace.WriteLine("Uploaded " + (int)(ftp.Length / 1024) + "kb in " + DateTime.Now.Subtract(startTime).TotalSeconds + " seconds");
                        }
                    }
                    transferForm.SetAdvancedProgress(ftp.Length, ftp.Length, "");
                }
            }

            // don't continue if upload wasn't successful
            if (!uploadSuccessful)
            {
                Trace.WriteLine("Something happened during transfer, cancelling");
                return(Tasker.Conclusion.Error);
            }

            return(Tasker.Conclusion.Success);
        }