Esempio n. 1
0
        private void ButtonCreateSelectedPDFs_Click(object sender, EventArgs e)
        {
            // make sure that it goes no further if there are no files selected
            // Get all the CSV files that are checked in the datagrid list view
            List <string> filesToProcess = new List <string>();

            FileList_DataGrid.Rows.OfType <DataGridViewRow>().ToList <DataGridViewRow>().ForEach(
                row =>
            {
                if ((bool)row.Cells[0].Value == true)
                {
                    filesToProcess.Add(row.Cells[1].Value.ToString());
                }
            });
            if (filesToProcess.Count == 0)
            {
                MessageBox.Show("There are no reports selected!");
                return;
            }

            // this will fire the background worker to get the reports generated
            if (backgroundWorkerPDF.IsBusy != true)
            {
                // create a new instance of the alert form
                pDFProgressBar = new PDFProgressBarForm();
                // event handler for the Cancel button in AlertForm
                pDFProgressBar.Canceled     += new EventHandler <EventArgs>(Button_cancelPDF_Click);
                pDFProgressBar.StartPosition = FormStartPosition.CenterScreen;
                pDFProgressBar.Show();
                pDFProgressBar.ButtonText = "Cancel";
                // Start the asynchronous operation.
                backgroundWorkerPDF.RunWorkerAsync();
            }
        }
Esempio n. 2
0
        private void BackgroundWorkerPDF_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (e.Cancelled == true)
            {
                pDFProgressBar.Message = "Canceled!";
                WaitAndClose();
            }
            else if (e.Error != null)
            {
                pDFProgressBar.Message = "Error: " + e.Error.Message;
            }
            else
            {
                pDFProgressBar.Message = "Processing Documents Complete!";
                WaitAndClose();
                // now open the folder with the pdf files in it for viewing
                System.Diagnostics.Process.Start(GlobalData.pdfOutputFolderPath);
            }

            void WaitAndClose()
            {
                System.Threading.Thread.Sleep(2000);
                pDFProgressBar.Close();
                pDFProgressBar.Dispose();
                pDFProgressBar = null;
            }
        }