/// <summary> /// This is called after all the files have been processed. /// </summary> /// <param name="sender">The sending ZeroMunge form.</param> public static void Complete(ZeroMunge sender) { isRunning = false; sender.Log(""); sender.Log("**************************************************************"); sender.Log("******** FINISHED JOB"); sender.Log("**************************************************************"); // Re-enable the UI sender.EnableUI(true); sender.CompleteCallback(fileList); // when setting Control properties a 'BeginInvoke' should be used. //if (sender.prefs.ShowNotificationPopups) //{ // sender.trayIcon.Text = "Zero Munge: Idle"; // sender.trayIcon.BalloonTipTitle = "Success"; // sender.trayIcon.BalloonTipText = "The operation was completed successfully."; // sender.trayIcon.ShowBalloonTip(30000); // sender.stat_JobStatus.Text = "Idle"; //} Utilities.PlaySound(Utilities.SoundType.Success); if (fileList.Count > 0 && !fileList[0].FileDir.EndsWith("\\_BUILD\\munge.bat", StringComparison.OrdinalIgnoreCase)) { // We should only open the munge log if we are running the munge.bat(s) one by one; // the main '_BUILD\\mung.bat' will already open the file munge log. sender.ShowMungeLog(false, "Notepad.exe"); } }
/// <summary> /// Aborts the active process. /// </summary> /// <param name="sender">The sending ZeroMunge form.</param> public static void Abort(ZeroMunge sender) { if (!isRunning) { return; } isRunning = false; if (sender.prefs.ShowTrayIcon) { sender.trayIcon.Text = "Zero Munge: Idle"; sender.stat_JobStatus.Text = "Idle"; } Utilities.PlaySound(Utilities.SoundType.Abort); procAborted = true; // Kill the process if (curProc != null && !curProc.HasExited) { curProc.Kill(); } // Reset the stored list of checked files //fileList = null; fileList.Clear(); sender.Log(""); sender.Log("**************************************************************"); sender.Log("******** ABORTED JOB"); sender.Log("**************************************************************"); // Re-enable the UI sender.EnableUI(true); }
/// <summary> /// Goes through the specified list of files and executes the ones that are checked. /// </summary> /// <param name="sender">The sending ZeroMunge form.</param> /// <param name="files">List of MungeFactory members that should be used as the file list.</param> /// <param name="dataGridView">The DataGridView control that the files have been added to.</param> public static void Start(ZeroMunge sender, List <MungeFactory> files, DataGridView dataGridView) { // Disable the UI sender.EnableUI(false); string mungeLog = sender.MungeLogName; if (File.Exists(mungeLog)) { File.Delete(mungeLog); } isRunning = true; // Update tray icon text and play start sound if (sender.prefs.ShowTrayIcon) { sender.trayIcon.Text = "Zero Munge: Running"; sender.stat_JobStatus.Text = "Running"; } // Grab the list of checked files fileList = files; // BEGIN CHECKING FOR ROW ERRORS int procError = 0; // Are there no items in the list? if (sender.data_Files.Rows[0].IsNewRow) { if (dataGridView.Rows[0].Cells[ZeroMunge.STR_DATA_FILES_TXT_FILE].Value == null || dataGridView.Rows[0].Cells[ZeroMunge.STR_DATA_FILES_TXT_STAGING].Value == null || dataGridView.Rows[0].Cells[ZeroMunge.STR_DATA_FILES_TXT_MUNGE_DIR].Value == null) { Debug.WriteLine("First row is new row"); procError = 1; } } else { // Are none of the items checked? if (fileList.Count <= 0) { procError = 2; } } // Report the error if one is present if (procError > 0) { string errorMessage = ""; switch (procError) { case 1: errorMessage = "File list must contain at least one file"; break; case 2: errorMessage = "At least one item must be checked"; break; } sender.Log(errorMessage, LogType.Error); Utilities.PlaySound(Utilities.SoundType.Abort); // Re-enable the UI sender.EnableUI(true); isRunning = false; return; } if (fileList.Count == 0) { return; } // FINISH CHECKING FOR ROW ERRORS Utilities.PlaySound(Utilities.SoundType.Start); activeFile = 0; procAborted = false; sender.Log(""); sender.Log("**************************************************************"); sender.Log("******** STARTED JOB"); sender.Log("**************************************************************"); sender.Log(""); // Activate the first file ActivateProcess(sender, 0); }