// This was added in interface version 4. public List <string> DeleteAllRelated(string folderPath, string baseLogName, bool deleteEmptyFolderAndParents) { if (TracerXServices.IsImpersonateClients) { return(DeleteRelated.DeleteAllRelated(folderPath, baseLogName, Log, deleteEmptyFolderAndParents, ServiceSecurityContext.Current.WindowsIdentity)); } else { return(DeleteRelated.DeleteAllRelated(folderPath, baseLogName, Log, deleteEmptyFolderAndParents, null)); } }
// This was added in interface version 4. public List <string> DeleteMany(string fileSpec, string folderSpec, DateTime minTimestamp, DateTime maxTimestamp, long minSize, long maxSize, bool tx1Files, bool txtFiles, bool deleteEmptyFolderAndParents, bool listOnly) { if (TracerXServices.IsImpersonateClients) { return(DeleteRelated.DeleteMany(fileSpec, folderSpec, minTimestamp, maxTimestamp, minSize, maxSize, tx1Files, txtFiles, deleteEmptyFolderAndParents, listOnly, Log, ServiceSecurityContext.Current.WindowsIdentity)); } else { return(DeleteRelated.DeleteMany(fileSpec, folderSpec, minTimestamp, maxTimestamp, minSize, maxSize, tx1Files, txtFiles, deleteEmptyFolderAndParents, listOnly, Log)); } }
// Returns true if any files were deleted or listed. private void Go(bool listFiles) { try { List <string> files = null; if (_server == null) { // Process local files directly. if (listFiles || DialogResult.Yes == MainForm.ShowMessageBoxBtns("Delete specified files?", MessageBoxButtons.YesNo)) { files = DeleteRelated.DeleteMany( txtFileSpec.Text, txtFolderSpec.Text, dtpFromTime.Value, dtpToTime.Value, int.Parse(txtFromSize.Text) * 1024, int.Parse(txtToSize.Text) * 1024, chkBinary.Checked, chkText.Checked, chkDeleteFolders.Checked, listFiles, Log); } } else { // Process remote files via the WCF server. using (ProxyFileEnum serviceProxy = new ProxyFileEnum()) { // Need to use host:port and credentials. serviceProxy.SetHost(_server.HostAndPort); serviceProxy.SetCredentials(_server.GetCreds()); int serverVersion = serviceProxy.ExchangeVersion(1); if (serverVersion >= 4) { // This version of the server has a method for deleting all the // matching files and parent folder(s) in one call, so display the // appropriate message and call that method. if (listFiles || DialogResult.Yes == MainForm.ShowMessageBoxBtns("Delete specified files?", MessageBoxButtons.YesNo)) { files = serviceProxy.DeleteMany( txtFileSpec.Text, txtFolderSpec.Text, dtpFromTime.Value, dtpToTime.Value, int.Parse(txtFromSize.Text) * 1024, int.Parse(txtToSize.Text) * 1024, chkBinary.Checked, chkText.Checked, chkDeleteFolders.Checked, listFiles); } } else { string msg = "Sorry, the TracerX-Service you're connected to is an old version that doesn't support this feature."; MainForm.ShowMessageBox(msg); } } } if (files != null) { Log.Info(files.Count, " files were returned by DeleteMany()."); if (files.Any()) { if (listFiles) { // Display the files. var dlg = new FullText(string.Join("\r\n", files), false, true); dlg.Height = 500; dlg.Text = "Matching Log Files (" + files.Count + ")"; dlg.ShowDialog(); } else { MainForm.ShowMessageBox(files.Count.ToString() + " files were deleted."); DidDeleteFiles = true; } } else { MainForm.ShowMessageBox("No files matched the specified criteria."); } } } catch (Exception ex) { MainForm.ShowMessageBox("An error occurred in the Clean Up Files dialog.\n\n" + ex.ToString()); } }