}   //  end expandData for tree list

        private void expandData(List <LCDDO> listToExpand, string valueToExpand, List <StratumDO> sList,
                                string currSP)
        {
            //  expands valueToExpand in LCD data
            double calcValue = 0;

            foreach (LCDDO lte in listToExpand)
            {
                //  need strata acres to complete value
                int nthRow = sList.FindIndex(
                    delegate(StratumDO s)
                {
                    return(s.Code == lte.Stratum);
                });
                double currAC = Utilities.ReturnCorrectAcres(lte.Stratum, bslyr, (long)sList[nthRow].Stratum_CN);
                switch (valueToExpand)
                {
                case "EXPFAC":
                    if (sList[nthRow].Method == "3P")
                    {
                        calcValue += lte.TalliedTrees;
                    }
                    else
                    {
                        calcValue += lte.SumExpanFactor * currAC;
                    }
                    break;

                case "VOL":
                    calcValue += lte.SumNCUFT * currAC;
                    break;
                } //  end switch
            }     //  end foreach loop

            //  load list with calculated values
            LCDDO lcd = new LCDDO();

            lcd.Species = currSP;
            if (valueToExpand == "EXPFAC")
            {
                lcd.SumExpanFactor = calcValue;
            }
            else if (valueToExpand == "VOL")
            {
                lcd.SumNCUFT = calcValue;
            }
            speciesTotal.Add(lcd);
            calcValue = 0;
            return;
        }   //  end expandData for LCD data
Пример #2
0
        }     //  end CreateR3Reports

        private void AccumulateValues(LCDDO jg)
        {
            //  Accumulate values for R301
            double           currSTacres = 0;
            List <StratumDO> sList       = bslyr.getStratum();
            RegionalReports  rr          = new RegionalReports();

            rr.value1 = jg.Species;
            rr.value2 = jg.PrimaryProduct;
            if (jg.ContractSpecies == null)
            {
                rr.value3 = " ";
            }
            else
            {
                rr.value3 = jg.ContractSpecies;
            }
            List <LCDDO> lcdList = bslyr.GetLCDdata("WHERE CutLeave = @p1 AND Species = @p2 AND PrimaryProduct = @p3 AND ContractSpecies = @p4", jg, 5, "");

            //  sum up values needed
            foreach (LCDDO l in lcdList)
            {
                //  find current stratum to get acres to multiply
                int nthRow = sList.FindIndex(
                    delegate(StratumDO s)
                {
                    return(s.Code == l.Stratum);
                });
                if (nthRow >= 0)
                {
                    currSTacres = Utilities.ReturnCorrectAcres(l.Stratum, bslyr, (long)sList[nthRow].Stratum_CN);
                }
                else
                {
                    currSTacres = 0;
                }

                rr.value7  += l.SumGBDFT * currSTacres;
                rr.value8  += l.SumGCUFT * currSTacres;
                rr.value9  += l.SumNBDFT * currSTacres;
                rr.value10 += l.SumNCUFT * currSTacres;
                rr.value11 += l.SumNCUFTtop * currSTacres;
                rr.value12 += l.SumDBHOBsqrd * currSTacres;
                rr.value13 += l.SumExpanFactor * currSTacres;
            }   //  end foreach loop
            listToOutput.Add(rr);
            return;
        }   //  end AccumulateValues
Пример #3
0
        }     //  end CreateR3Reports

        private void AccumulateValues(LCDDO jg)
        {
            //  Accumulate values for R301
            double          currSTacres = 0;
            RegionalReports rr          = new RegionalReports();

            rr.value1 = jg.Species;
            rr.value2 = jg.PrimaryProduct;
            if (jg.ContractSpecies == null)
            {
                rr.value3 = " ";
            }
            else
            {
                rr.value3 = jg.ContractSpecies;
            }
            //  sum up values needed
            foreach (LCDDO l in
                     Global.BL.GetLCDdata("WHERE CutLeave = ? AND Species = ? AND PrimaryProduct = ? AND ContractSpecies = ?", jg, 5, ""))
            {
                //  find current stratum to get acres to multiply
                StratumDO stratum = Global.BL.getStratum().FirstOrDefault(s => s.Code == l.Stratum);
                if (stratum != null)
                {
                    currSTacres = Utilities.ReturnCorrectAcres(l.Stratum, (long)stratum.Stratum_CN);
                }
                else
                {
                    currSTacres = 0;
                }

                rr.value7  += l.SumGBDFT * currSTacres;
                rr.value8  += l.SumGCUFT * currSTacres;
                rr.value9  += l.SumNBDFT * currSTacres;
                rr.value10 += l.SumNCUFT * currSTacres;
                rr.value11 += l.SumNCUFTtop * currSTacres;
                rr.value12 += l.SumDBHOBsqrd * currSTacres;
                rr.value13 += l.SumExpanFactor * currSTacres;
            }   //  end foreach loop
            listToOutput.Add(rr);
            return;
        }   //  end AccumulateValues
Пример #4
0
        }             //  end SumUpGroups

        private double pull3PtallyTrees(IEnumerable <PRODO> proList, IEnumerable <LCDDO> lcdList, string currSG,
                                        string currSP, string currST, string currPP, string currLD,
                                        string currSTM, string currCU)
        {
            double talliedTrees = 0;

            //  Are there multiple species in the current sample group
            //  for just non-STM first
            //  need entire LCD list for UC5-6
            //lcdList = Global.BL.getLCD();

            if (lcdList.Where(
                    l => l.Stratum == currST && l.SampleGroup == currSG && l.STM == "N").Count() > 1)
            {
                //  find number of tallied trees in LCD for current species
                LCDDO lcddo = lcdList.FirstOrDefault(
                    l => l.Stratum == currST && l.Species == currSP &&
                    l.SampleGroup == currSG && l.PrimaryProduct == currPP &&
                    l.LiveDead == currLD && l.STM == currSTM);
                if (lcddo != null)
                {
                    talliedTrees += lcddo.TalliedTrees;
                }
            }
            else
            {
                //  that means only one species per sample group
                //  so return number of tallied trees from the PRO table
                PRODO prodo = proList.FirstOrDefault(
                    p => p.Stratum == currST && p.SampleGroup == currSG &&
                    p.CuttingUnit == currCU && p.PrimaryProduct == currPP &&
                    p.STM == currSTM);
                if (prodo != null)
                {
                    talliedTrees += prodo.TalliedTrees;
                }
            }   //  endif

            return(talliedTrees);
        }   //  end pull3PtallyTrees
Пример #5
0
        }   //  end CreateTreeGradeReports

        private void LoadEachLine(string volType, ref int firstLine, LCDDO lcd, int whichPage)
        {
            ReportSubtotal ea     = new ReportSubtotal();
            int            nthRow = 0;

            //  is this the first line?
            if (firstLine == 1)
            {
                ea.Value1 = lcd.PrimaryProduct;
                ea.Value2 = lcd.Species;
                eachLine.Add(ea);
                nthRow    = 0;
                firstLine = 0;
            }
            else
            {
                //  is this species in the list?
                nthRow = eachLine.FindIndex(
                    delegate(ReportSubtotal rs)
                {
                    return(rs.Value2 == lcd.Species);
                });
                if (nthRow == -1)
                {
                    // not there; add it
                    if (firstLine == 0)
                    {
                        ea.Value1 = "";
                    }
                    ea.Value2 = lcd.Species;
                    if (eachLine.Count == 0)
                    {
                        nthRow = 0;
                    }
                    else
                    {
                        nthRow = eachLine.Count + 1;
                    }
                    eachLine.Add(ea);
                } //  endif nthRow
            }     //  endif firstLine

            //  update tree grade fields with appropriate volume
            double currentValue = 0;

            if (whichPage == 1)
            {
                currentValue = lcd.SumExpanFactor;
            }
            else if (volType == "BDFT")
            {
                currentValue = lcd.SumNBDFT;
            }
            else if (volType == "CUFT")
            {
                currentValue = lcd.SumNCUFT;
            }
            //  also need strata acres to expand volume
            List <StratumDO> sList     = bslyr.getStratum();
            long             currStrCN = StratumMethods.GetStratumCN(lcd.Stratum, sList);
            double           currAcres = Utilities.ReturnCorrectAcres(lcd.Stratum, bslyr, currStrCN);

            switch (lcd.TreeGrade)
            {
            case "0":
                eachLine[nthRow].Value3 += currentValue * currAcres;
                break;

            case "1":
                eachLine[nthRow].Value4 += currentValue * currAcres;
                break;

            case "2":
                eachLine[nthRow].Value5 += currentValue * currAcres;
                break;

            case "3":
                eachLine[nthRow].Value6 += currentValue * currAcres;
                break;

            case "4":
                eachLine[nthRow].Value7 += currentValue * currAcres;
                break;

            case "5":
                eachLine[nthRow].Value8 += currentValue * currAcres;
                break;

            case "6":
                eachLine[nthRow].Value9 += currentValue * currAcres;
                break;

            case "7":
                eachLine[nthRow].Value10 += currentValue * currAcres;
                break;

            case "8":
                eachLine[nthRow].Value11 += currentValue * currAcres;
                break;

            case "9":
                eachLine[nthRow].Value12 += currentValue * currAcres;
                break;

            case " ":
            case "":
            case null:
                eachLine[nthRow].Value13 += currentValue * currAcres;
                break;
            }   //  end switch
            //  Add volume to line total
            eachLine[nthRow].Value14 += currentValue * currAcres;
            return;
        }   //  end LoadEachLine
Пример #6
0
        }     //  end LoadColumnHeader

        private IEnumerable <TreeCalculatedValuesDO> GetCurrentGroup(IEnumerable <TreeCalculatedValuesDO> treeData, LCDDO jg)
        {
            switch (GroupedBy)
            {
            case "SPU":
                return(treeData.Where(
                           tcv => tcv.Tree.Species == jg.Species &&
                           tcv.Tree.SampleGroup.PrimaryProduct == jg.PrimaryProduct &&
                           tcv.Tree.SampleGroup.UOM == jg.UOM));

            case "S":
                return(treeData.Where(tcv => tcv.Tree.Species == jg.Species));
            } //  end switch
            return(new List <TreeCalculatedValuesDO>());
        }     //  end GetCurrentGroup
Пример #7
0
        }   //  end GetStratumGroupedBy

        public static void LoadLCDID(ref ArrayList prtFields, LCDDO currGRP, int currPP, string currRPT)
        {
            prtFields.Add("");
            prtFields.Add(currGRP.Stratum.PadLeft(2, ' '));
            //  first part of line is report dependent
            switch (currRPT)
            {
            case "VSM1":
            case "VPA1":
            case "VAL1":
            case "VSM6":
                prtFields.Add(currGRP.Species.PadRight(6, ' '));
                if (currPP == 1)
                {
                    prtFields.Add(currGRP.PrimaryProduct.PadLeft(2, '0'));
                    prtFields.Add("P");
                }
                else if (currPP == 2)
                {
                    prtFields.Add(currGRP.SecondaryProduct.PadLeft(2, '0'));
                    prtFields.Add("S");
                }
                else if (currPP == 3)
                {
                    prtFields.Add(currGRP.SecondaryProduct.PadLeft(2, '0'));
                    prtFields.Add("R");
                }
                prtFields.Add(currGRP.UOM.PadLeft(2, '0'));
                prtFields.Add(currGRP.LiveDead);
                prtFields.Add(currGRP.CutLeave.Trim());
                prtFields.Add(currGRP.Yield.Trim());
                prtFields.Add(currGRP.SampleGroup.PadLeft(2, ' '));
                prtFields.Add(currGRP.STM);
                prtFields.Add(currGRP.TreeGrade.PadLeft(1, ' '));
                if (currGRP.ContractSpecies == null)
                {
                    prtFields.Add("    ");
                }
                else
                {
                    prtFields.Add(currGRP.ContractSpecies.PadRight(4, ' '));
                }
                break;

            case "VSM2":
            case "VPA2":
            case "VAL2":
            case "LV01":
                if (currPP == 1)
                {
                    prtFields.Add(currGRP.PrimaryProduct.PadLeft(2, '0'));
                    prtFields.Add("P");
                }
                else if (currPP == 2)
                {
                    prtFields.Add(currGRP.SecondaryProduct.PadLeft(2, '0'));
                    prtFields.Add("S");
                }
                else if (currPP == 3)
                {
                    prtFields.Add(currGRP.SecondaryProduct.PadLeft(2, '0'));
                    prtFields.Add("R");
                }
                prtFields.Add(currGRP.UOM.PadLeft(2, '0'));
                prtFields.Add(currGRP.SampleGroup.PadLeft(2, ' '));
                prtFields.Add(currGRP.STM.PadLeft(1, ' '));
                break;

            case "VSM3":
            case "VPA3":
            case "VAL3":
            case "LV02":
                if (currPP == 1)
                {
                    prtFields.Add(currGRP.PrimaryProduct.PadLeft(2, '0'));
                    prtFields.Add("P");
                }
                else if (currPP == 2)
                {
                    prtFields.Add(currGRP.SecondaryProduct.PadLeft(2, '0'));
                    prtFields.Add("S");
                }
                else if (currPP == 3)
                {
                    prtFields.Add(currGRP.SecondaryProduct.PadLeft(2, '0'));
                    prtFields.Add("R");
                }
                prtFields.Add(currGRP.UOM.PadLeft(2, '0'));
                break;
            } //  end switch on report
            return;
        }     //  end LoadLCDID
        }     //  end LoadColumnHeader

        private List <TreeCalculatedValuesDO> GetCurrentGroup(List <TreeCalculatedValuesDO> treeData, LCDDO jg)
        {
            List <TreeCalculatedValuesDO> groupToReturn = new List <TreeCalculatedValuesDO>();

            switch (GroupedBy)
            {
            case "SPU":
                groupToReturn = treeData.FindAll(
                    delegate(TreeCalculatedValuesDO tcv)
                {
                    return(tcv.Tree.Species == jg.Species &&
                           tcv.Tree.SampleGroup.PrimaryProduct == jg.PrimaryProduct &&
                           tcv.Tree.SampleGroup.UOM == jg.UOM);
                });
                break;

            case "S":
                groupToReturn = treeData.FindAll(
                    delegate(TreeCalculatedValuesDO tcv)
                {
                    return(tcv.Tree.Species == jg.Species);
                });
                break;
            } //  end switch
            return(groupToReturn);
        }     //  end GetCurrentGroup
Пример #9
0
        }   //  end ClearCalculatedTables

        public void MakePopulationIDs(List <SampleGroupDO> sgList, List <TreeDefaultValueDO> tdvList)
        {
            CPbusinessLayer bslyr = new CPbusinessLayer();

            bslyr.DAL      = DAL;
            bslyr.fileName = fileName;
            //  Load ID info into tables
            List <LCDDO>  lcdList = new List <LCDDO>();
            List <POPDO>  popList = new List <POPDO>();
            List <PRODO>  proList = new List <PRODO>();
            List <TreeDO> tList   = bslyr.getTrees();

            //  need to check Contract Species in TDV table before doing unique
            //  reset to a blank if it is null -- September 2016
            List <TreeDefaultValueDO> treeDefaults = bslyr.getTreeDefaults();

            foreach (TreeDefaultValueDO tdv in treeDefaults)
            {
                if (tdv.ContractSpecies == null)
                {
                    tdv.ContractSpecies = " ";
                }
                else if (tdv.ContractSpecies == "")
                {
                    tdv.ContractSpecies = " ";
                }
            }   //  end foreach
            bslyr.SaveTreeDefaults(treeDefaults);

            foreach (SampleGroupDO sgd in sgList)
            {
                //  Load LCD population IDs
                //  Need unique species, livedead and grade from Tree table
                // not sure about the count table -- need IDs from there?  11/2012
                List <TreeDO> distinctSpecies = bslyr.GetDistinctSpecies((long)sgd.SampleGroup_CN);
                foreach (TreeDO t in distinctSpecies)
                {
                    LCDDO lcd = new LCDDO();
                    lcd.CutLeave         = sgd.CutLeave;
                    lcd.Stratum          = sgd.Stratum.Code;
                    lcd.SampleGroup      = sgd.Code;
                    lcd.PrimaryProduct   = sgd.PrimaryProduct;
                    lcd.SecondaryProduct = sgd.SecondaryProduct;
                    lcd.UOM      = sgd.UOM;
                    lcd.Species  = t.Species;
                    lcd.LiveDead = t.LiveDead;
                    if (t.Grade == null)
                    {
                        lcd.TreeGrade = "";
                    }
                    else
                    {
                        lcd.TreeGrade = t.Grade;
                    }
                    lcd.STM = t.STM;
                    //  per K.Cormier, because a null value in contract species causes
                    //  causes problems, it is being dropped from the population ID for LCD
                    //  Howeverm it will be stored as null but not used as part of the ID
                    //  September 2016
                    //  Found a slicker way to address this -- default contract species to a blank
                    //  however, this would be in the TreeDefaultValue table and only affects
                    //  new cruises.  CP still needs to set CS in TDV to blank (see above).
                    lcd.ContractSpecies = t.TreeDefaultValue.ContractSpecies;
                    //if (t.TreeDefaultValue.ContractSpecies != null)
                    //    lcd.ContractSpecies = t.TreeDefaultValue.ContractSpecies;
                    //else lcd.ContractSpecies = "";
                    if (t.Stratum.YieldComponent != null)
                    {
                        lcd.Yield = t.Stratum.YieldComponent;
                    }
                    else
                    {
                        lcd.Yield = "";
                    }
                    //}   //  endif nthRow

                    lcdList.Add(lcd);
                }   //  end foreach loop on species

                //  Load POP population IDs
                POPDO pop = new POPDO();
                //  Don't need unique species for this group
                pop.CutLeave         = sgd.CutLeave;
                pop.Stratum          = sgd.Stratum.Code;
                pop.SampleGroup      = sgd.Code;
                pop.PrimaryProduct   = sgd.PrimaryProduct;
                pop.SecondaryProduct = sgd.SecondaryProduct;
                pop.UOM = sgd.UOM;
                //  check for sure-to-measure trees for this group
                //  Add non-sure-to-measure first  and then STM
                pop.STM = "N";
                popList.Add(pop);
                List <TreeDO> justSTM = tList.FindAll(
                    delegate(TreeDO td)
                {
                    return(sgd.CutLeave == td.SampleGroup.CutLeave && sgd.Stratum.Code == td.Stratum.Code &&
                           sgd.Code == td.SampleGroup.Code && sgd.PrimaryProduct == td.SampleGroup.PrimaryProduct &&
                           sgd.SecondaryProduct == td.SampleGroup.SecondaryProduct && sgd.UOM == td.SampleGroup.UOM &&
                           td.STM == "Y");
                });
                if (justSTM.Count > 0)
                {
                    POPDO popSTM = new POPDO();
                    popSTM.CutLeave         = sgd.CutLeave;
                    popSTM.Stratum          = sgd.Stratum.Code;
                    popSTM.SampleGroup      = sgd.Code;
                    popSTM.PrimaryProduct   = sgd.PrimaryProduct;
                    popSTM.SecondaryProduct = sgd.SecondaryProduct;
                    popSTM.UOM = sgd.UOM;
                    popSTM.STM = "Y";
                    popList.Add(popSTM);
                }   //  endif

                //  Load PRO population IDs
                //  These need cutting unit numbers -- from Cutting Unit
                List <CuttingUnitStratumDO> strataUnits = bslyr.getCuttingUnitStratum((long)sgd.Stratum_CN);
                foreach (CuttingUnitStratumDO cudo in strataUnits)
                {
                    PRODO pro = new PRODO();
                    pro.CutLeave         = sgd.CutLeave;
                    pro.Stratum          = sgd.Stratum.Code;
                    pro.CuttingUnit      = cudo.CuttingUnit.Code;
                    pro.SampleGroup      = sgd.Code;
                    pro.PrimaryProduct   = sgd.PrimaryProduct;
                    pro.SecondaryProduct = sgd.SecondaryProduct;
                    pro.UOM = sgd.UOM;
                    //  check for sure-to-measure trees for this group
                    //  Add non-sure-to-measure first  and then STM
                    pro.STM = "N";
                    proList.Add(pro);
                    justSTM = tList.FindAll(
                        delegate(TreeDO td)
                    {
                        return(sgd.CutLeave == td.SampleGroup.CutLeave && sgd.Stratum.Code == td.Stratum.Code &&
                               cudo.CuttingUnit.Code == td.CuttingUnit.Code &&
                               sgd.Code == td.SampleGroup.Code && sgd.PrimaryProduct == td.SampleGroup.PrimaryProduct &&
                               sgd.SecondaryProduct == td.SampleGroup.SecondaryProduct && sgd.UOM == td.SampleGroup.UOM &&
                               td.STM == "Y");
                    });
                    if (justSTM.Count > 0)
                    {
                        PRODO proSTM = new PRODO();
                        proSTM.CutLeave         = sgd.CutLeave;
                        proSTM.Stratum          = sgd.Stratum.Code;
                        proSTM.CuttingUnit      = cudo.CuttingUnit.Code;
                        proSTM.SampleGroup      = sgd.Code;
                        proSTM.PrimaryProduct   = sgd.PrimaryProduct;
                        proSTM.SecondaryProduct = sgd.SecondaryProduct;
                        proSTM.UOM = sgd.UOM;
                        proSTM.STM = "Y";
                        proList.Add(proSTM);
                    } //  endif
                }     //  end foreach loop on strataUnits
            }         //  end foreach loop on SampleGroup
            bslyr.SaveLCD(lcdList);
            bslyr.SavePOP(popList);
            bslyr.SavePRO(proList);

            return;
        }   //  end MakePopulationIDs