private void ftpTestSync_Click(object sender, RoutedEventArgs e) { Action <bool, dynamic> isOk = (isSaved, objToSave) => { isDownloadedFromFtp = isSaved; sync = objToSave; }; Action <dynamic, Action <string>, Action <bool, dynamic> > action = (ftpsync, report, save) => { ftpsync.Synchronize(report); save(true, ftpsync); }; if (isDownloadedFromFtp) { Progress prog = new Progress(sync, action, isOk); prog.ShowDialog(); Init(); JsonIt(pathToFileTree, sync.ServerFiles); XmlIt("tree.xml", sync.ServerFiles); } else { MessageBox.Show("Вначале необходимо запросить синхронизацию с сервером."); } }
private void LoadSync() { if (sync == null) { sync = new FtpSync(new FluentFTP.FtpClient { Host = ftpServerIp.Text, Credentials = new System.Net.NetworkCredential(ftpUsername.Text, ftpPassword.Password) }, mainPath); } }
private void ftpTest_Click(object sender, RoutedEventArgs e) { if (Directory.Exists(mainPath)) { Directory.Delete(mainPath, true); } sync = new FtpSync(new FluentFTP.FtpClient { Host = ftpServerIp.Text, Credentials = new System.Net.NetworkCredential(ftpUsername.Text, ftpPassword.Password) }, mainPath); try { Action <dynamic, Action <string>, Action <bool, dynamic> > action = (ftpsync, report, save) => { ftpsync.GetFileStructureFromServer(ftpsync.ServerFiles.RootFile, "", report); ftpsync.DownloadFiles(report); save(true, ftpsync); }; Action <bool, dynamic> isOk = (isSaved, objToSave) => { isDownloadedFromFtp = isSaved; sync = objToSave; }; Progress prog = new Progress(sync, action, isOk); prog.ShowDialog(); Init(); JsonIt(pathToFileTree, sync.ServerFiles); XmlIt("tree.xml", sync.ServerFiles); } catch (Exception ex) { MessageBox.Show(ex.Message); } }