示例#1
0
        /// <summary>
        /// If the files are valid so far, this function will populate the filepath variables that will be used to import into MS Access
        /// </summary>
        /// <param name="filePaths">The file paths of the PRPO files that were dropped by the user.</param>
        private static void ProcessPrpoReport(string _file)
        {
            if (_file.Contains("US"))
            {
                if (usPrpoFile == null)
                {
                    usPrpoFile      = new UsPrpoExcelFile();
                    usPrpoFile.Path = _file;
                    usPrpoFile.AssociatedCountry = Country.UnitedStates;

                    // Get and store the file
                    GetPrpoDate(usPrpoFile);
                }
                else
                {
                    MessageBox.Show("To avoid memory consumption, please do not load more than one PRPO file from the same country.");
                    ResetFileProcessing();
                    DisplayDragDropPage();
                }
            }
            else if (_file.Contains("MX")) // This file contains Mexico Data
            {
                if (mxPrpoFile == null)
                {
                    mxPrpoFile      = new MxPrpoExcelFile();
                    mxPrpoFile.Path = _file;
                    mxPrpoFile.AssociatedCountry = Country.Mexico;

                    // Get and store the file
                    GetPrpoDate(mxPrpoFile);
                }
                else
                {
                    MessageBox.Show("To avoid memory consumption, please do not load more than one PRPO file from the same country.");
                    ResetFileProcessing();
                    DisplayDragDropPage();
                }
            }
            else
            {
                // Cannot determine the SelectedCountry based on the file name.
                MessageBox.Show("Cannot determine the country of origin based on the file(s) name.");
            }
        }
示例#2
0
        /// <summary>
        /// Because of constant changes to the PRPO we need to check the date of the file because older version of the PRPO report
        /// are no longer accepted due to query changes because of column changes.
        /// </summary>
        /// <returns></returns>
        private static void GetPrpoDate(PrpoExcelFile _file)
        {
            try
            {
                string path        = Path.GetFileNameWithoutExtension(_file.Path);
                string strFileName = Path.GetFileNameWithoutExtension(path);
                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);

                // Store the date of the file within the excel file object
                _file.Date = dt;
            }
            catch (FileProcessingExceptions.PrpoDateProcessingErrorException)
            {
                throw;
            }
        }
示例#3
0
 /// <summary>
 /// Stop the fiel processing and load the drag drop screen.
 /// </summary>
 public static void ResetFileProcessing()
 {
     usPrpoFile = null;
     mxPrpoFile = null;
 }
示例#4
0
        /// <summary>
        /// Starts the threads to import the PRPO reports.
        /// </summary>
        /// <param name="_excelFile"></param>
        private void ImportPrpoExcelFile(PrpoExcelFile _excelFile)
        {
            ApplicationIOLibarary.ApplicationFiles.FileUtils fileUtils = new ApplicationIOLibarary.ApplicationFiles.FileUtils();

            ms_applicaitonMenuStrip.Enabled = false;

            // Lock the navigation functionality
            navigationSettings.Status = Navigation.Functionality.Locked;


            if (_excelFile is UsPrpoExcelFile)
            {
                reportSettings.PrpoUsReportFileName = _excelFile.Path;

                // import only the US PRPO file
                Importer usImport = new Importer(
                    new ExcelInfo()
                {
                    FileName   = _excelFile.Path,
                    HasHeaders = true,
                    SheetName  = ExcelInfo.sheetName[(int)ExcelInfo.SheetNames.US_PRPO]
                },
                    new AccessInfo(fileUtils.DbPath)
                {
                    TableName = AccessInfo.mainTableNames[(int)AccessInfo.MainTables.US_PRPO]
                }
                    );

                usThread = new Thread((mainThread) =>
                {
                    try
                    {
                        usImport.Run();
                    }
                    catch (ThreadInterruptedException)
                    {
                        ShowPage(Pages.DragDropDash);
                    }
                });

                usThread.Name = "US";
                usThread.Start(Thread.CurrentThread);
            }


            if (_excelFile is MxPrpoExcelFile)
            {
                reportSettings.PrpoMxReportFileName = _excelFile.Path;

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


                mxThread = new Thread((mainThread) =>
                {
                    try
                    {
                        mxImport.Run();
                    }
                    catch (ThreadInterruptedException)
                    {
                        ShowPage(Pages.DragDropDash);
                    }
                });

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