private void btnCleanup_Click(object sender, EventArgs e) { var confirmResult = MessageBox.Show("Are you sure to want to delete ALL POSTS and UPLOADS, including IMAGES from the blog?", "Confirm Delete!!", MessageBoxButtons.YesNo); if (confirmResult != DialogResult.Yes) return; var programOptionsFactory = new ProgramOptionsFactory(); _options = programOptionsFactory.Get(); if (string.IsNullOrEmpty(_options.FtpUrl)) { MessageBox.Show("In order to delete images, please set up FTP account from settings."); return; } _ftp = new Ftp.Ftp(FtpConfiguration); if (!string.IsNullOrEmpty(_ftp.TestConnection())) { MessageBox.Show("Cannot connect to FTP, please check your settings."); return; } try { _ftp.DirectoryListingProgressing += FtpDirectoryListingProgressing; _ftp.DirectoryListingFetchFinished += FtpDirectoryListingFetchFinished; _ftp.DirectoryDeletionProgressing += FtpDirectoryDeletionProgress; _ftp.DirectoryDeletionFinished += FtpDirectoryDeletionFinished; EnDis(false); _ftp.DeleteDirectory("wp-content/uploads/"); } catch (Exception exception) { EnDis(true); MessageBox.Show(exception.ToString()); Logger.LogExceptions(exception); } }
private void PrepareTemplates() { var programOptionsFactory = new ProgramOptionsFactory(); _options = programOptionsFactory.Get(); if (string.IsNullOrEmpty(_options.FtpUrl)) { MessageBox.Show("In order to update wp files, please set up FTP account from settings."); return; } var ftp = new Ftp(FtpConfiguration); if (!string.IsNullOrEmpty(ftp.TestConnection())) { MessageBox.Show("Cannot connect to FTP, please check your settings."); return; } var frmPrepareTemplate = new frmPrepareTemplate(); frmPrepareTemplate.ShowDialog(); }
private void bw_DoWork(object sender, DoWorkEventArgs e) { var checkedSites = (from object checkedItem in lstPlugins.CheckedItems select checkedItem.ToString()).ToList(); var directoriesCreated = new HashSet<string>(); var programOptionsFactory = new ProgramOptionsFactory(); _options = programOptionsFactory.Get(); DeleteLocallyExtractedPlugins(); if (!chkRemoteUnzip.Checked) { UnzipPluginsLocally(checkedSites); } var ftp = new Ftp.Ftp(FtpConfiguration); var fileUploaded = 0; foreach (var file in _files) { fileUploaded++; if ((bw.CancellationPending)) { e.Cancel = true; break; } var fileInfo = new FileInfo(file); var dir = fileInfo.Directory; if (dir == null) { continue; } var ftpDir = dir.FullName.Replace(Helper.AssemblyDirectory + "\\blog", "").Replace("\\", "/"); if (ftpDir.StartsWith("/")) { ftpDir = ftpDir.Substring(1); } try { if (!directoriesCreated.Contains(ftpDir)) { ftp.MakeFtpDir(ftpDir); bw.ReportProgress(fileUploaded, "Creating Ftp Directory " + ftpDir); directoriesCreated.Add(ftpDir); } } catch (Exception exception) { MessageBox.Show(exception.ToString()); return; } try { var uploadFile = true; //upload ewww folder only if ewww-image-optimizer selected if (!checkedSites.Contains("ewww-image-optimizer") && fileInfo.Directory.Name == "ewww") { continue; } var fileName = Path.GetFileNameWithoutExtension(file); if (IsPluginFile(fileInfo)) { if (chkRemoteUnzip.Checked) //if remotely unzipping, then upload only zip files for checked plugins { if (!checkedSites.Contains(fileName) || Path.GetExtension(file) != ".zip") { uploadFile = false; } } else//if locally unzipping, then upload only extracted files for checked plugins { if (fileInfo.Directory.Name == "plugins") { uploadFile = false; } } } else { uploadFile = chkUploadAllExceptPlugin.Checked; } if (!uploadFile) continue; ftp.UploadFileFtp(file, ftpDir); bw.ReportProgress(fileUploaded, "Uploading " + file); } catch (Exception exception) { MessageBox.Show(exception.ToString()); } } if (chkRemoteUnzip.Checked) { try { UnzipPluginsRemotely(fileUploaded); } catch (Exception exception) { MessageBox.Show(exception.ToString()); return; } } try { SetPluginData(); } catch (Exception exception) { MessageBox.Show(exception.ToString()); return; } }
private void btnTestFtpConnection_Click(object sender, EventArgs e) { var ftp = new Ftp.Ftp(FtpConfiguration); string result = ftp.TestConnection(); if (string.IsNullOrEmpty(result)) { MessageBox.Show("Successfull!"); return; } MessageBox.Show("Failed: " + result); }