Exemple #1
0
        /// <summary>
        /// When the user has successfully dropped PRPO files into the application, this timer will initiate.
        /// The import process will then begin, importing all the data contained within the PRPO report into the
        /// Acces Database located in the resources folder.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ImportTimer_Tick(object sender, EventArgs e)
        {
            try
            {
                if (Importer.ImportComplete)
                {
                    Importer.ImportComplete = false;
                    ImportTimer.Stop();

                    BeginDataRemovalProcess();

                    foreach (var file in processedFiles)
                    {
                        if (file is UsPrpoExcelFile)
                        {
                            if (AccessDatabaseUtils.US_PRPO_TableExists)
                            {
                                DateTime dt = file.Date;
                                reportSettings.PrpoUsDate         = dt.Month.ToString() + " " + dt.Day.ToString() + " " + dt.Year.ToString();
                                reportSettings.PrpoUsReportLoaded = true;
                            }
                        }

                        if (file is MxPrpoExcelFile)
                        {
                            if (AccessDatabaseUtils.MX_PRPO_TableExists)
                            {
                                DateTime dt = file.Date;
                                reportSettings.PrpoMxDate         = dt.Month.ToString() + " " + dt.Day.ToString() + " " + dt.Year.ToString();
                                reportSettings.PrpoMxReportLoaded = true;
                            }
                        }

                        // Save the report settings
                        reportSettings.Save();
                    }
                }
            }
            catch (DataImporter.Importing.Exceptions.ImportExceptions.InvalidDataFileException)
            {
                ShowPage(Pages.DragDropDash);
            }
        }
Exemple #2
0
        /// <summary>
        /// When the user has successfully dropped PRPO files into the application, this timer will initiate.
        /// The import process will then begin, importing all the data contained within the PRPO report into the
        /// Acces Database located in the resources folder.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ImportTimer_Tick(object sender, EventArgs e)
        {
            try
            {
                if (!Importer.importStarted)
                {
                    Importer.importStarted = true;
                    NavigationLocked       = true; // Lock the navigation bar
                                                   // load loading screen
                    if (ExcelInfo.USUpdated)
                    {
                        // import only the US PRPO file
                        Importer usImport = new Importer(
                            new ExcelInfo()
                        {
                            FileName   = DragDropUtils.US_PRPO_FilePath,
                            HasHeaders = true,
                            SheetName  = ExcelInfo.sheetName[(int)ExcelInfo.SheetNames.US_PRPO]
                        },
                            new AccessInfo()
                        {
                            FileName  = Configuration.DbPath,
                            TableName = AccessInfo.mainTableNames[(int)AccessInfo.MainTables.US_PRPO]
                        }
                            );

                        usThread = new Thread(() =>
                        {
                            usImport.Run();
                        });
                        usThread.Name = "US";
                        usThread.Start();
                    }


                    if (ExcelInfo.MXUpdated)
                    {
                        // Import only the MX PRPO file.
                        Importer mxImport = new Importer(
                            new ExcelInfo()
                        {
                            FileName   = DragDropUtils.MX_PRPO_FilePath,
                            HasHeaders = true,
                            SheetName  = ExcelInfo.sheetName[(int)ExcelInfo.SheetNames.MX_PRPO]
                        },
                            new AccessInfo()
                        {
                            FileName  = Configuration.DbPath,
                            TableName = AccessInfo.mainTableNames[(int)AccessInfo.MainTables.MX_PRPO]
                        }
                            );


                        mxThread = new Thread(() =>
                        {
                            mxImport.Run();
                        });

                        mxThread.Name = "MX";
                        mxThread.Start();
                    }
                }


                if (Importer.ImportComplete)
                {
                    Importer.ImportComplete = false;
                    ImportTimer.Stop();
                    PRPO_DB_Utils.DataRemovalProcessStarted = false;
                    PRPO_DB_Utils.DataRemoved           = false;
                    PRPO_DB_Utils.CompletedDataRemovals = 0;
                    PRPO_DB_Utils.ScheduledDataRemovals = 0;
                    PRPO_DB_Utils.ConnectToDatabase();

                    if (AccessUtils.US_PRPO_TableExists)
                    {
                        string strFileName = Path.GetFileNameWithoutExtension(DragDropUtils.US_PRPO_FilePath);
                        string strMonth    = strFileName[7].ToString() + strFileName[8].ToString();
                        string strday      = strFileName[9].ToString() + strFileName[10].ToString();
                        string strYear     = strFileName[11].ToString() + strFileName[12].ToString() + strFileName[13].ToString() + strFileName[14].ToString();

                        int month = int.Parse(strMonth.TrimStart('0'));
                        int day   = int.Parse(strday.TrimStart('0'));
                        int year  = int.Parse(strYear);

                        DateTime dt = new DateTime(year, month, day);
                        lbl_dashboardDate.Text = dt.ToString("MMMM dd, yyyy");
                        Logger.Log(AppDirectoryUtils.LogFiles.LoadedUSDate, lbl_dashboardDate.Text);
                    }

                    if (AccessUtils.MX_PRPO_TableExists)
                    {
                        string strFileName = Path.GetFileNameWithoutExtension(DragDropUtils.MX_PRPO_FilePath);
                        string strMonth    = strFileName[7].ToString() + strFileName[8].ToString();
                        string strday      = strFileName[9].ToString() + strFileName[10].ToString();
                        string strYear     = strFileName[11].ToString() + strFileName[12].ToString() + strFileName[13].ToString() + strFileName[14].ToString();

                        int month = int.Parse(strMonth.TrimStart('0'));
                        int day   = int.Parse(strday.TrimStart('0'));
                        int year  = int.Parse(strYear);

                        DateTime dt = new DateTime(year, month, day);
                        lbl_dashboardDate.Text = dt.ToString("MMMM dd, yyyy");
                        Logger.Log(AppDirectoryUtils.LogFiles.LoadedMXDate, lbl_dashboardDate.Text);
                    }

                    DataRemovalTimer.Start();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.StackTrace, "Import Function Error");
            }
        }