Ejemplo n.º 1
0
        private void backgroundWorkerTime_DoWork(object sender, DoWorkEventArgs e)
        {
            current = 0;
            tproc   = e.Argument as TimeProcessor;
            BackgroundWorker worker = sender as BackgroundWorker;

            try
            {
                for (int a = 6; a < 10; a++)
                {
                    tproc.processTimeEntries(a.ToString());
                    backgroundWorkerTime.ReportProgress(current);
                    var tlist = tproc.allTimes.ToList();
                    foreach (TimeEntry tt in tlist)
                    {
                        current++;
                        tproc.compareTimeEntries(tt);
                        backgroundWorkerTime.ReportProgress(current);
                    }
                }
            }
            catch (Exception ex1)
            {
                e.Result = ex1;
            }

            if (tproc.correctedTimes.Count == 0)
            {
                MessageBox.Show("There were no issues found in your time entries," + "\r\n" + "so no changes are needed. The tool will now close");
                Environment.ExitCode = 1;
                Application.Exit();
            }
            else
            {
                DataTable dt = ConvertTo(tproc.correctedTimes);
                Errors = new DataSet();
                Errors.Tables.Add(dt);
                DialogResult tpr = seePreReport();
                if (tpr == DialogResult.Yes)
                {
                    ReportDisplay rpds = new ReportDisplay(Errors, null, 0);
                    rpds.ShowDialog();
                    for (int d = 0; d < 10; d++)
                    {
                        var typeList = tproc.correctedTimes.Where(c => c.newEntryStatus == d).ToList();
                        tproc.updateTimeEntries(typeList, d);
                        backgroundWorkerTime.ReportProgress(current);
                        current++;
                    }
                }
                else if (tpr == DialogResult.No)
                {
                    for (int d = 0; d < 10; d++)
                    {
                        var typeList = tproc.correctedTimes.Where(c => c.newEntryStatus == d).ToList();
                        tproc.updateTimeEntries(typeList, d);
                        backgroundWorkerTime.ReportProgress(current);
                        current++;
                    }
                }
                else if (tpr == DialogResult.Cancel)
                {
                    Environment.ExitCode = 1;
                    Application.Exit();
                }
            }
        }