Example #1
0
        // The FileListProcessor completed.
        private void processorCompletion(object sender, CompletionEventArgs args)
        {
            listProcessor       = null;
            listProcessorThread = null;

            // Open the GUI.
            UnlockGUI();
            barStatus.ProgressBar.Value = 0;

            // Clear out the icon of the file that was marked as in-process.
            for (int i = 0; i < listFiles.Items.Count; i++)
            {
                if (listFiles.Items[i].ImageIndex == 4)
                {
                    listFiles.Items[i].ImageIndex = 0;
                    break;
                }
            }

            // If there's an error, show it to the user.
            if (args.Exception != null)
            {
                FrmLog.Instance.AddLine();

                if (args.Exception is ThreadAbortException)
                {
                    FrmLog.Instance.AddLine("--Processing Aborted by User--");
                }
                else
                {
                    FrmLog.Instance.AddLine("--Error: " + args.Exception.Message + "--");
                    MessageBox.Show("There was an error while processing the files:" +
                                    Environment.NewLine + Environment.NewLine +
                                    args.Exception.Message,
                                    "Verify", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            // Put final results into the log.
            FrmLog.Instance.AddLine();
            FrmLog.Instance.AddLine("    Total Files: " + listFiles.Items.Count.ToString(System.Globalization.CultureInfo.InvariantCulture.NumberFormat));
            FrmLog.Instance.AddLine("Files Processed: " + (fileListGood + fileListBad + fileListMissing + fileListIgnored).ToString(System.Globalization.CultureInfo.InvariantCulture.NumberFormat));
            FrmLog.Instance.AddLine("     Good Files: " + fileListGood.ToString(System.Globalization.CultureInfo.InvariantCulture.NumberFormat));
            FrmLog.Instance.AddLine("      Bad Files: " + fileListBad.ToString(System.Globalization.CultureInfo.InvariantCulture.NumberFormat));
            FrmLog.Instance.AddLine("  Missing Files: " + fileListMissing.ToString(System.Globalization.CultureInfo.InvariantCulture.NumberFormat));
            FrmLog.Instance.AddLine("       Finished: " + DateTime.Now.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'sszzz"));

            // Save the log.
            if (cfg.GetValue("Program", "AutomaticallySaveLog", false))
            {
                FrmLog.Instance.Save(Path.ChangeExtension(FileList.sourceFile, ".log"));
            }
        }
Example #2
0
        // User wants to verify the current file list.
        private void initiateVerify(object sender, System.EventArgs args)
        {
            // Make sure there's a list to work with.
            if (FileList == null)
            {
                MessageBox.Show("No file verification list has been opened.", "Verify", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            // See if they're trying to abort.
            if (listProcessorThread != null)
            {
                if (MessageBox.Show("Stop processing the current list?", "Verify", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                {
                    return;
                }

                // We have to check if it's still processing, in case they took too long with the messagebox.
                if (listProcessorThread != null)
                {
                    listProcessorThread.Abort();
                }
                return;
            }

            // Clear things up in preparation.
            ClearResults();

            // Set up the processor.
            listProcessor             = new FileListProcessor(FileList);
            listProcessor.Progress   += new FileListProcessor.ProgressEventHandler(this.processorProgress);
            listProcessor.Completion += new FileListProcessor.CompletionEventHandler(this.processorCompletion);

            // Start the log.
            FrmLog.Instance.AddHeader();
            FrmLog.Instance.AddLine("      File List: " + FileList.sourceFile);
            FrmLog.Instance.AddLine("      List Type: " + FileList.type.ToString());
            FrmLog.Instance.AddLine("          Start: " + DateTime.Now.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'sszzz"));
            FrmLog.Instance.AddLine();

            // Lock up the GUI.
            LockGUI();

            // Start the processor.
            listProcessorThread = new Thread(new ThreadStart(listProcessor.Start));
            listProcessorThread.IsBackground = true;
            listProcessorThread.Priority     = (ThreadPriority)Enum.Parse(typeof(ThreadPriority), cfg.GetValue("Program", "ProcessingThreadPriority", "Normal"));
            listProcessorThread.Start();
        }