예제 #1
0
        }     //  end onButton4Click

        private void onButton5Click(object sender, EventArgs e)
        {
            //  Cannot continue if filename is blank
            if (fileName == "")
            {
                MessageBox.Show("No filename selected.  Cannot continue.\nPlease select a filename.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }                      //  endif fileName

            if (whichProcess == 1) //  equations
            {
                //  calls R9 volume equation entry
                R9VolEquation r9vol = new R9VolEquation();
                r9vol.fileName = fileName;
                r9vol.setupDialog();
                r9vol.ShowDialog();
            }
            else if (whichProcess == 4)      //  output
            {
                //  calls routine to preview output file -- print preview
                PrintPreview p = new PrintPreview();
                p.fileName = fileName;
                p.setupDialog();
                p.ShowDialog();
                return;
            } //  endif whichProcess
        }     //  end onButton5Click
예제 #2
0
        private void on_GO(object sender, EventArgs e)
        {
            processingStatus.Text = "READY TO BEGIN?  Click GO.";
            Cursor.Current        = Cursors.WaitCursor;
            //  perform edit checks --
            processingStatus.Text = "Edit checking the data.  Please wait.";
            processingStatus.Refresh();
            //  calls edit check routines
            string outputFileName;
            //  check for errors from FScruiser before running edit checks
            //  generate an error report
            //  June 2013
            List <ErrorLogDO> fscList = Global.BL.getErrorMessages("E", "FScruiser").ToList();

            if (fscList.Count > 0)
            {
                ErrorReport eRpt = new ErrorReport();
                eRpt.fileName  = fileName;
                outputFileName = eRpt.PrintFScruiserErrors(fscList);
                string outputMessage = "ERRORS FROM FSCRUISER FOUND!\nCorrect data and rerun\nOutput file is:" + outputFileName;
                MessageBox.Show(outputMessage, "ERRORS", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                //  request made to open error report in preview -- May 2015
                PrintPreview pp = new PrintPreview();
                pp.fileName = outputFileName;
                pp.setupDialog();
                pp.ShowDialog();
                Environment.Exit(0);
            }   //  endif report needed

            //  clear out error log table for just CruiseProcessing before performing checks
            Global.BL.DeleteErrorMessages();

            EditChecks eChecks = new EditChecks();

            eChecks.fileName = fileName;

            List <SaleDO>        saleList = Global.BL.getSale().ToList();
            List <SampleGroupDO> sgList   = Global.BL.getSampleGroups().ToList();
            List <StratumDO>     sList    = Global.BL.getStratum().ToList();
            List <CountTreeDO>   ctList   = Global.BL.getCountTrees().ToList();
            List <TreeDO>        tList    = Global.BL.getTrees().ToList();

            int errors = eChecks.TableEditChecks(Global.BL.getSale(),
                                                 sList,
                                                 ctList,
                                                 tList,
                                                 sgList);

            if (errors == -1)
            {
                //  no measured trees detected in the cruise.  critical errpor stops the program.
                Close();
                return;
            }   //  endif
            errors = eChecks.MethodChecks();
            if (errors == -1)
            {
                //  empty stratum detected and user wants to quit
                Close();
                return;
            }   //  endif
            //  just check the ErrorLog table for entries
            List <ErrorLogDO> errList = Global.BL.getErrorMessages("E", "CruiseProcessing").ToList();

            if (errList.Count > 0)
            {
                ErrorReport er = new ErrorReport();
                er.fileName    = fileName;
                outputFileName = er.PrintErrorReport(errList);
                string outputMessage = "ERRORS FOUND!\nCorrect data and rerun\nOutput file is:" + outputFileName;
                MessageBox.Show(outputMessage, "ERRORS", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                //  request made to open error report in preview -- May 2015
                PrintPreview pp = new PrintPreview();
                pp.fileName = outputFileName;
                pp.setupDialog();
                pp.ShowDialog();
                Environment.Exit(0);
            }   //  endif report needed

            //  Show editCheck message -- edit checks complete
            editCheck.Enabled = true;

            //  next show preparation of data
            processingStatus.Text = "Preparing data for processing.";
            processingStatus.Refresh();

            //  before making IDs, need to check for blank or null secondary products in sample groups
            //  if blank, default to 02 for every region but 6 where it will be 08 instead
            //  put a warning message in the error log table indicating the secondary product was set to a default
            //  June 2013
            string currRegion = Global.BL.getRegion();

            DefaultSecondaryProduct(currRegion);

            CalculatedValues calcVal = new CalculatedValues();


            //  retrieve lists needed and sets up population IDs
            calcVal.fileName = fileName;
            //List<TreeCalculatedValuesDO> tcvList = Global.BL.getTreeCalculatedValues();
            //List<TreeDefaultValueDO> tdvList = Global.BL.getTreeDefaults();
            List <CuttingUnitDO> cuList  = Global.BL.getCuttingUnits().ToList();
            List <LCDDO>         lcdList = Global.BL.getLCD().ToList();
            List <POPDO>         popList = Global.BL.getPOP().ToList();
            List <PRODO>         proList = Global.BL.getPRO().ToList();
            List <PlotDO>        pList   = Global.BL.getPlots().ToList();

            //List<VolumeEquationDO> vqList = Global.BL.getVolumeEquations();

            calcVal.ClearCalculatedTables();

            calcVal.MakePopulationIDs(sgList);
            //  now need some other tables to start summing values
            List <PlotDO> justPlots;

            //  show preparation of data is complete
            prepareCheck.Enabled = true;
            //  now loop through strata and show status message updating for each stratum
            StringBuilder sb = new StringBuilder();

            foreach (StratumDO sdo in sList)
            {
                CalculateTreeValues calcTreeVal = new CalculateTreeValues();
                //  update status message for next stratum
                sb.Remove(0, sb.Length);
                sb.Append("Calculating stratum ");
                sb.Append(sdo.Code);
                processingStatus.Text = sb.ToString();
                processingStatus.Refresh();

                //  Sum counts and KPI for LCD table
                justPlots = PlotMethods.GetStrata(pList, sdo.Code).ToList();
                //  need cut and leave trees for this
                //List<LCDDO> justCurrentLCD = LCDmethods.GetStratum(lcdList, sdo.Code);
                calcVal.SumTreeCountsLCD(sdo.Code, ctList, justPlots, sdo.Method, lcdList);

                //  Sum counts and KPI for POP table
                // List<POPDO> justCurrentPOP = POPmethods.GetStratumData(popList, sdo.Code, "");
                calcVal.SumTreeCountsPOP(sdo.Code, ctList, justPlots, sdo.Method, popList);

                //  Sum counts and KPI for PRO table
                // List<PRODO> justCurrentPRO = Global.BL.getPRO(sdo.Code);
                calcVal.SumTreeCountsPRO(sdo.Code, (long)sdo.Stratum_CN, tList, cuList, ctList, sgList, justPlots, proList, sdo.Method);

                //  Calculate expansion factor
                calcVal.CalcExpFac(sdo, justPlots, popList);

                //  Calculate volumes
                //calcTreeVal.fileName = fileName;
                calcTreeVal.ProcessTrees(saleList, tList, Global.BL.getVolumeEquations(), sdo.Code, sdo.Method, (long)sdo.Stratum_CN);


                //  Update 3P tally
                //List<TreeDO> justCurrentStratum = Global.BL.getTreeStratum((long)sdo.Stratum_CN);

                if (sdo.Method == "3P")
                {
                    Update3Ptally(ctList, sdo.Code, lcdList);
                }   //  endif method is 3P


                //  Update expansion factors for methods 3PPNT, F3P, and P3P
                if (sdo.Method == "3PPNT" || sdo.Method == "F3P" || sdo.Method == "P3P")
                {
                    //List<TreeCalculatedValuesDO> tcvList = Global.BL.getTreeCalculatedValues((int)sdo.Stratum_CN);
                    UpdateExpansionFactors(Global.BL.getTreeCalculatedValues(), (long)sdo.Stratum_CN);
                    //  Save update
                }   //  endif on method

                //  Sum data for the LCD, POP and PRO table
                SumAll sall = new SumAll();
                sall.fileName = fileName;
                sall.SumAllValues(sdo.Code, sdo.Method, (long)sdo.Stratum_CN, sList, pList, lcdList,
                                  popList, proList);
                Global.BL.SavePOP(popList);
                Global.BL.SavePRO(proList);
                Global.BL.SaveLCD(lcdList);

                //  Update STR tally after expansion factors are summed
                if (sdo.Method == "STR")
                {
                    UpdateSTRtally(fileName, sdo.Code, ctList, lcdList);
                } //  endif method is STR
            }     //  end foreach stratum

            //  show volume calculation is finished
            volumeCheck.Enabled   = true;
            processingStatus.Text = "Processing is DONE";
            processingStatus.Refresh();
            System.Threading.Thread.Sleep(5000);
            Close();
            return;
        }   //  end on_GO
        public int CheckErrors()
        {
            string          outputFileName;
            CPbusinessLayer bslyr = new CPbusinessLayer();

            bslyr.DAL      = DAL;
            bslyr.fileName = fileName;
            //  check for errors from FScruiser before running edit checks
            //  generate an error report
            //  June 2013
            List <ErrorLogDO> fscList = bslyr.getErrorMessages("E", "FScruiser");

            if (fscList.Count > 0)
            {
                ErrorReport eRpt = new ErrorReport();
                eRpt.fileName       = fileName;
                eRpt.bslyr.fileName = bslyr.fileName;
                eRpt.bslyr.DAL      = DAL;
                outputFileName      = eRpt.PrintFScruiserErrors(fscList);
                string outputMessage = "ERRORS FROM FSCRUISER FOUND!\nCorrect data and rerun\nOutput file is:" + outputFileName;
                MessageBox.Show(outputMessage, "ERRORS", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                //  request made to open error report in preview -- May 2015


                PrintPreview pp = new PrintPreview();
                pp.fileName = outputFileName;
                pp.setupDialog();
                pp.ShowDialog();
                Environment.Exit(0);
            }   //  endif report needed

            //  clear out error log table for just CruiseProcessing before performing checks
            bslyr.DeleteErrorMessages();


            int errors = TableEditChecks();

            if (errors == -1)
            {
                //  no measured trees detected in the cruise.  critical errpor stops the program.
                return(-1);
            }   //  endif
            errors = MethodChecks();
            if (errors == -1)
            {
                //  empty stratum detected and user wants to quit
                return(-1);
            }   //  endif
            //  just check the ErrorLog table for entries
            List <ErrorLogDO> errList = bslyr.getErrorMessages("E", "CruiseProcessing");

            if (errList.Count > 0)
            {
                ErrorReport er = new ErrorReport();
                er.fileName       = fileName;
                er.bslyr.fileName = fileName;
                er.bslyr.DAL      = bslyr.DAL;
                outputFileName    = er.PrintErrorReport(errList);
                string outputMessage = "ERRORS FOUND!\nCorrect data and rerun\nOutput file is:" + outputFileName;
                MessageBox.Show(outputMessage, "ERRORS", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                //  request made to open error report in preview -- May 2015
                PrintPreview pp = new PrintPreview();
                pp.fileName = outputFileName;
                pp.setupDialog();
                pp.ShowDialog();
                Environment.Exit(0);
            }   //  endif report needed
            return(0);
        }