Ejemplo n.º 1
0
        }   //  end UpdateExpansionFactors

        private void DefaultSecondaryProduct(string currRegion)
        {
            List <SampleGroupDO> sgList = Global.BL.getSampleGroups().ToList();

            foreach (SampleGroupDO sgd in sgList)
            {
                if (sgd.SecondaryProduct == "" || sgd.SecondaryProduct == " " ||
                    sgd.SecondaryProduct == "  " || sgd.SecondaryProduct == null)
                {
                    switch (currRegion)
                    {
                    case "06":
                    case "6":
                        sgd.SecondaryProduct = "08";
                        ErrorLogMethods.LoadError("SampleGroup", "W", "19", (long)sgd.SampleGroup_CN, "SecondaryProduct");
                        break;

                    case "05":
                    case "5":
                        sgd.SecondaryProduct = "20";
                        ErrorLogMethods.LoadError("SampleGroup", "W", "19", (long)sgd.SampleGroup_CN, "SecondaryProduct");
                        break;

                    default:
                        sgd.SecondaryProduct = "02";
                        ErrorLogMethods.LoadError("SampleGroup", "W", "19", (long)sgd.SampleGroup_CN, "SecondaryProduct");
                        break;
                    } //  end switch
                }     //  endif
            }         //  end foreach loop
            Global.BL.SaveSampleGroups(sgList);
            return;
        }   //  end DefaultSecondaryProduct
Ejemplo n.º 2
0
        }     //  end MatchSpeciesProduct

        public static int CheckEquations(List <WeightEquationDO> wgtList)
        {
            int errorsFound = 0;

            foreach (WeightEquationDO wed in wgtList)
            {
                if (wed.WeightFactorPrimary == 0 && wed.PercentRemovedPrimary == 0)
                {
                    ErrorLogMethods.LoadError("Weight", "E", "2", wed.rowID);
                    errorsFound++;
                }   //  endif factors are zero

                //  duplicates?
                List <WeightEquationDO> dupEquations = wgtList.FindAll(
                    delegate(WeightEquationDO wedo)
                {
                    return(wedo.Species == wed.Species && wedo.LiveDead == wed.LiveDead && wedo.PrimaryProduct == wed.PrimaryProduct);
                });
                if (dupEquations.Count > 1)
                {
                    ErrorLogMethods.LoadError("Weight", "E", "7", wed.rowID);
                    errorsFound++;
                } //  endif dupEquations
            }     //  end foreach loop

            return(errorsFound);
        }   //  end CheckEquations
        //  edit check on sample groups
        public int CheckAllUOMandCutLeave(List <StratumDO> strList, List <SampleGroupDO> sgList, string FileName)
        {
            int             errorsFound = 0;
            ErrorLogMethods elm         = new ErrorLogMethods();

            foreach (StratumDO sdo in strList)
            {
                List <SampleGroupDO> strGroups = sgList.FindAll(
                    delegate(SampleGroupDO sgd)
                {
                    return(sgd.Stratum.Code == sdo.Code);
                });
                foreach (SampleGroupDO sg in strGroups)
                {
                    int nthRow = strGroups.FindIndex(
                        delegate(SampleGroupDO sgdo)
                    {
                        return(sgdo.CutLeave != sg.CutLeave && sgdo.PrimaryProduct != sg.PrimaryProduct &&
                               sgdo.UOM != sg.UOM && sgdo.Code == sg.Code);
                    });
                    if (nthRow >= 0)
                    {
                        elm.LoadError("SampleGroup", "E", "14", (long)sg.SampleGroup_CN, "Code");
                        errorsFound++;
                    }   //  endif nthRow

                    //  check length of sample group cpde and issue a warning message if more than 2 characters
                    if (sg.Code.Length > 2)
                    {
                        Utilities.LogError("SampleGroup", (int)sg.SampleGroup_CN, "W", "Sample Group is too long. Results may not be as expected.", FileName);
                    }
                } //  end foreach loop
            }     //  end foreach loop
            return(errorsFound);
        }         //  end CheckAllUOMandCutLeave
Ejemplo n.º 4
0
        }     //  end GeneralEquationChecks

        public static int FindBehrs(IEnumerable <VolumeEquationDO> volList)
        {
            int errorsFound = 0;

            foreach (VolumeEquationDO ved in volList)
            {
                if (ved.VolumeEquationNumber.Contains("BEH"))
                {
                    ErrorLogMethods.LoadError("VolumeEquation", "W", "Variable log length diameters cannot be computed with BEH equations", (long)ved.rowID, "NoName");
                    errorsFound++;
                }
                else if (ved.VolumeEquationNumber.Contains("MAT"))
                {
                    ErrorLogMethods.LoadError("VolumeEquation", "W", "Variable log length diameters cannot be computed with MAT equations", (long)ved.rowID, "NoName");
                    errorsFound++;
                }
                else if (ved.VolumeEquationNumber.Contains("DVE"))
                {
                    ErrorLogMethods.LoadError("VolumeEquation", "W", "Variable log length diameters cannot be computed with DVE equations", (long)ved.rowID, "NoName");
                    errorsFound++;
                }
                else if (ved.VolumeEquationNumber.Contains("CLK"))
                {
                    ErrorLogMethods.LoadError("VolumeEquation", "W", "Variable log length diameters cannot be computed with CLK equations", (long)ved.rowID, "NoName");
                    errorsFound++;
                } //  endif on equation number
            }     //  end foreach loop
            return(errorsFound);
        }         //  end FindBehrs
Ejemplo n.º 5
0
        //  edit check on sample groups
        public static int CheckAllUOMandCutLeave(IEnumerable <StratumDO> strList, IEnumerable <SampleGroupDO> sgList, string FileName)
        {
            int errorsFound = 0;

            foreach (StratumDO sdo in strList)
            {
                var sgdo = sgList.Where(spg => spg.Stratum.Code == sdo.Code);
                foreach (SampleGroupDO sg in sgdo)
                {
//                    int nthRow = strGroups.FindIndex(
//                        delegate(SampleGroupDO sgdo)
//                        {
                    var smpList = sgdo.Where(item => item.CutLeave != sg.CutLeave && item.PrimaryProduct != sg.PrimaryProduct &&
                                             item.UOM != sg.UOM && item.Code == sg.Code);
//                            return sgdo.CutLeave != sg.CutLeave && sgdo.PrimaryProduct != sg.PrimaryProduct
//                                       && sgdo.UOM != sg.UOM && sgdo.Code == sg.Code;
//                       });
                    if (smpList.Any())
                    {
                        ErrorLogMethods.LoadError("SampleGroup", "E", "14", (long)sg.SampleGroup_CN, "Code");
                        errorsFound++;
                    }   //  endif nthRow

                    //  check length of sample group cpde and issue a warning message if more than 2 characters
                    if (sg.Code.Length > 2)
                    {
                        Utilities.LogError("SampleGroup", (int)sg.SampleGroup_CN, "W", "Sample Group is too long. Results may not be as expected.");
                    }
                } //  end foreach loop
            }     //  end foreach loop
            return(errorsFound);
        }         //  end CheckAllUOMandCutLeave
Ejemplo n.º 6
0
        }   //  end IsEmpty

        //       public static List<VolumeEquationDO> GetAllEquationsToCalc(string currSP, string currPP)
        //       {
        //  This returns a list of equations for the current species and product to calculate volumes
        //List<VolumeEquationDO> returnList = volList.FindAll(
        //    delegate(VolumeEquationDO ved)
        //    {
        //        return ved.Species == currSP && ved.PrimaryProduct == currPP;
        //    });
        //return returnList;
        //           return DAL.Read<VolumeEquationDO>("VolumeEquation", "Where Species = ? AND PrimaryProduct = ?", currSP, currPP);

        //      }   //  end GetAllEquationsToCalc



        public static int MatchSpeciesProduct(IEnumerable <VolumeEquationDO> volList, IEnumerable <TreeDO> tList)
        {
            int errorsFound = 0;

            //  find each species or species/product combination in volume equations
            //int nthRow = -1;

            //List<TreeDO> tList1 = DAL.Read<TreeDO>("Tree", "GROUP BY Species, Tree.SampleGroup.PrimaryProduct", null);
            //VolumeEquationDO ved;
            foreach (TreeDO td in Global.BL.getTreeMatch())
            {
                //nthRow = 0;
                //                foreach(VolumeEquationDO ved in volList)
                //                {
                //                    if (ved.Species == td.Species && ved.PrimaryProduct == td.SampleGroup.PrimaryProduct)
                //                        nthRow++;
                //                }
                //ved = volList.Find(item => item.Species == td.Species && item.PrimaryProduct == td.SampleGroup.PrimaryProduct);
                //                nthRow = volList.FindIndex(
                //                    delegate(VolumeEquationDO ved)
                //                    {
                //                        return ved.Species == td.Species && ved.PrimaryProduct == td.SampleGroup.PrimaryProduct;
                //                    });
                //                if (nthRow == 0)
                if (volList.FirstOrDefault(item => item.Species == td.Species && item.PrimaryProduct == td.SampleGroup.PrimaryProduct) == null)
                {
                    ErrorLogMethods.LoadError("Tree", "E", "12", (long)td.Tree_CN, "Species");
                    errorsFound++;
                } //  endif nthRow
            }     //  end for k loop
            return(errorsFound);
        }         //  end MatchSpeciesProduct
Ejemplo n.º 7
0
        }         //  end CheckFBS

        public static int CheckVLL(List <LogDO> logList)
        {
            int errorsFound = 0;

            foreach (LogDO ld in logList)
            {
                if (ld.LogNumber == "" || ld.LogNumber == " " || ld.LogNumber == null)
                {
                    ErrorLogMethods.LoadError("Log", "E", "19", (long)ld.Log_CN, "LogNumber");
                    errorsFound++;
                }   //  endif log number missing
                if (ld.Grade == "" || ld.Grade == " " || ld.Grade == null)
                {
                    ErrorLogMethods.LoadError("Log", "E", "19", (long)ld.Log_CN, "Grade");
                    errorsFound++;
                }   //  endif log grade missing
                if (ld.ExportGrade == "" || ld.ExportGrade == " " || ld.ExportGrade == null)
                {
                    ErrorLogMethods.LoadError("Log", "E", "19", (long)ld.Log_CN, "ExportGrade");
                    errorsFound++;
                }   //  endif export grade (log sort) missing
                if (ld.Length == 0)
                {
                    ErrorLogMethods.LoadError("Log", "E", "19", (long)ld.Log_CN, "Length");
                    errorsFound++;
                } //  endif log length missing
            }     //  end foreach loop
            return(errorsFound);
        }         //  end CheckVLL
Ejemplo n.º 8
0
        }             //  end CheckNumberLogs

        public static int CheckFBS(List <LogDO> logList)
        {
            int          errorsFound = 0;
            bool         netGross    = false;
            List <LogDO> justFBS     = logList.FindAll(
                delegate(LogDO l)
            {
                return(l.Tree.IsFallBuckScale == 1);
            });

            foreach (LogDO j in justFBS)
            {
                //  check board and cubic volume for net larger than gross
                if (j.NetBoardFoot > j.GrossBoardFoot)
                {
                    netGross = true;
                }
                if (j.NetCubicFoot > j.GrossCubicFoot)
                {
                    netGross = true;
                }

                if (netGross == true)
                {
                    ErrorLogMethods.LoadError("Log", "E", "20", (long)j.Log_CN, "GrossVolume");
                    errorsFound++;
                    netGross = false;
                } //  endif net greater than gross
            }     //  end foreach loop
            return(errorsFound);
        }         //  end CheckFBS
Ejemplo n.º 9
0
        }       //  end TableEditChecks

        public int MethodChecks()
        {
            IEnumerable <TreeDO> tList = Global.BL.getTrees();

            errorValue = ErrorLogMethods.CheckCruiseMethods(Global.BL.getStratum(), tList);
            errList    = ErrorLogMethods.errList;
            if (errList.Count > 0)
            {
                Global.BL.SaveErrorMessages(errList);
            }
            return(errorValue);
        } //  end MethodChecks
Ejemplo n.º 10
0
        }   //  end CheckDefect

        //  Added a check for log grade of null
        public static int CheckLogGrade(List <LogDO> logList)
        {
            int errorsFound = 0;

            foreach (LogDO ld in logList)
            {
                if (ld.Grade == null)
                {
                    ErrorLogMethods.LoadError("Log", "E", "9", (long)ld.Log_CN, "Loggrade");
                    errorsFound++;
                } //  endif
            }     //  end foreach
            return(errorsFound);
        }         //  end CheckLogGrade
Ejemplo n.º 11
0
        }         //  end CheckVLL

        public static int CheckDefect(List <LogDO> logList)
        {
            int errorsFound = 0;

            foreach (LogDO ld in logList)
            {
                if (ld.PercentRecoverable > ld.SeenDefect)
                {
                    ErrorLogMethods.LoadError("Log", "E", "29", (long)ld.Log_CN, "PercentRecoverable");
                    errorsFound++;
                }
            }   //  end foreach

            return(errorsFound);
        }   //  end CheckDefect
Ejemplo n.º 12
0
        //  edit checks
        public static int MatchSpeciesProduct(List <WeightEquationDO> wgtList, string[,] justSpPr,
                                              ArrayList justTreeSp)
        {
            int errorsFound = 0;
            //  find each species or species/product combination in weight equations
            int nthRow = -1;

            for (int k = 0; k < justSpPr.Length; k++)
            {
                nthRow = wgtList.FindIndex(
                    delegate(WeightEquationDO wed)
                {
                    return(wed.Species == justSpPr[k, 0] && wed.PrimaryProduct == justSpPr[k, 1]);
                });
                if (nthRow == -1)        //  species/product not found in weight equations
                {
                    ErrorLogMethods.LoadError("TreeDefaultValue", "E", "18", k);
                    errorsFound++;
                }
                else
                {
                    nthRow = -1;
                }
            }   //  end for k loop

            //  Find any species from tree table not in weight equations (user could have overridden default value)
            nthRow = -1;
            for (int k = 0; k < justTreeSp.Count; k++)
            {
                nthRow = wgtList.FindIndex(
                    delegate(WeightEquationDO wed)
                {
                    return(wed.Species == justTreeSp[k].ToString());
                });
                if (nthRow == -1)
                {
                    ErrorLogMethods.LoadError("Tree", "E", "43", k);
                    errorsFound++;
                }
                else
                {
                    nthRow = -1;
                }
            } //  end for k loop
            return(errorsFound);
        }     //  end MatchSpeciesProduct
Ejemplo n.º 13
0
        //  edit checks on log table
        public static int CheckNumberLogs(List <LogDO> logList)
        {
            int  errorsFound = 0;
            long prevTree_CN = -1;

            foreach (LogDO ld in logList)
            {
                if (prevTree_CN != ld.Tree_CN)
                {
                    prevTree_CN = Convert.ToInt64(ld.Tree_CN);
                    if (GetLogRecords(logList, Convert.ToInt64(ld.Tree_CN)).Count() > 20)
                    {
                        ErrorLogMethods.LoadError("Log", "E", "13", (long)ld.Log_CN, "NoName");
                        errorsFound++;
                    } //  endif logs count
                }     //  endif
            }         //  end foreach loop
            return(errorsFound);
        }             //  end CheckNumberLogs
Ejemplo n.º 14
0
        //  edit checks
        public static int CheckEquations(IEnumerable <QualityAdjEquationDO> qaeList)
        {
            int errorsFound = 0;

            foreach (QualityAdjEquationDO qed in qaeList)
            {
                if (qed.QualityAdjEq != "QUAL0391" && qed.QualityAdjEq != "QUAL0392")
                {
                    ErrorLogMethods.LoadError("Quality Adjustment", "E", "1", (long)qed.rowID, "QualityAdjEq");
                    errorsFound++;
                }   //  endif equation is bad
                if (qed.Coefficient1 == 0 && qed.Coefficient2 == 0 &&
                    qed.Coefficient3 == 0 && qed.Coefficient4 == 0)
                {
                    ErrorLogMethods.LoadError("Quality Adjustment", "E", "2", (long)qed.rowID, "Coefficient");
                    errorsFound++;
                } //  endif coefficients are missing
            }     //  end foreach loop
            return(errorsFound);
        }         //  end CheckEquations
Ejemplo n.º 15
0
        }   //  end UpdateExpansionFactors

        private void DefaultSecondaryProduct(string currRegion)
        {
            CPbusinessLayer bslyr = new CPbusinessLayer();
            ErrorLogMethods elm   = new ErrorLogMethods();

            bslyr.DAL = DAL;

            List <SampleGroupDO> sgList = bslyr.getSampleGroups();

            foreach (SampleGroupDO sgd in sgList)
            {
                if (sgd.SecondaryProduct == "" || sgd.SecondaryProduct == " " ||
                    sgd.SecondaryProduct == "  " || sgd.SecondaryProduct == null)
                {
                    switch (currRegion)
                    {
                    case "06":
                    case "6":
                        sgd.SecondaryProduct = "08";
                        elm.LoadError("SampleGroup", "W", "19", (long)sgd.SampleGroup_CN, "SecondaryProduct");
                        break;

                    case "05":
                    case "5":
                        sgd.SecondaryProduct = "20";
                        elm.LoadError("SampleGroup", "W", "19", (long)sgd.SampleGroup_CN, "SecondaryProduct");
                        break;

                    default:
                        sgd.SecondaryProduct = "02";
                        elm.LoadError("SampleGroup", "W", "19", (long)sgd.SampleGroup_CN, "SecondaryProduct");
                        break;
                    } //  end switch
                }     //  endif
            }         //  end foreach loop
            bslyr.SaveSampleGroups(sgList);
            return;
        }   //  end DefaultSecondaryProduct
Ejemplo n.º 16
0
        }         //  end MatchSpeciesProduct

        public static int GeneralEquationChecks(IEnumerable <VolumeEquationDO> volList)
        {
            //  Checks for more than one quation for species/product combination
            //  check duplicate volumes requested on species/product combination
            //  for non-profile models (DVE) make sure primary flags are set if secondary also set
            //  check for secondary top DIB greater than primary top DIB
            //  check for same equation number with different primary top diameters (DVE only)
            //  check length of equation -- possible species error
            int errorsFound = 0;

//            List<VolumeEquationDO> dupEquations = new List<VolumeEquationDO>();
            foreach (VolumeEquationDO ved in volList)
            {
                //  Capture equation for non-profile models, species and product for error report if needed
                if (ved.VolumeEquationNumber.Contains("DVE") == true)
                {
                    // make sure primary flags are set
                    if (ved.CalcTopwood == 1 && (ved.CalcBoard == 0 && ved.CalcCubic == 0 && ved.CalcCord == 0))
                    {
                        ErrorLogMethods.LoadError("VolumeEquation", "E", "3", (long)ved.rowID, "VolumeFlags");
                        errorsFound++;
                    }   //  endif

                    //  check for different top DIBs
                    //                    dupEquations = volList.FindAll(
                    //                        delegate(VolumeEquationDO voleq)
                    //                        {
                    var dupEq = volList.Where(vl => vl.VolumeEquationNumber == ved.VolumeEquationNumber && vl.PrimaryProduct == ved.PrimaryProduct && vl.TopDIBPrimary == ved.TopDIBPrimary);
                    //                          return voleq.VolumeEquationNumber == ved.VolumeEquationNumber &&
                    //                                 voleq.PrimaryProduct == ved.PrimaryProduct &&
                    //                                 voleq.TopDIBPrimary != ved.TopDIBPrimary;
                    //                      });
                    if (dupEq.Count() > 1)  //  means top DIBs are different
                    {
                        ErrorLogMethods.LoadError("VolumeEquation", "E", "6", (long)ved.rowID, "TopDIBPrimary");
                        errorsFound++;
                    }
                }   //  endif non-profile model

                if (ved.TopDIBSecondary > ved.TopDIBPrimary)
                {
                    ErrorLogMethods.LoadError("VolumeEquation", "E", "4", (long)ved.rowID, "TopDIBSecondary");
                    errorsFound++;
                }

                if (ved.VolumeEquationNumber.Length != 10)
                {
                    ErrorLogMethods.LoadError("VolumeEquation", "E", "1", (long)ved.rowID, "VolumeEquationNumber");
                    errorsFound++;
                }

//                dupEquations = volList.FindAll(
//                    delegate(VolumeEquationDO voleq)
//                    {
                var dupEquations = volList.Where(vl => vl.VolumeEquationNumber == ved.VolumeEquationNumber && vl.PrimaryProduct == ved.PrimaryProduct && vl.Species == ved.Species);
//                        return voleq.VolumeEquationNumber == ved.VolumeEquationNumber &&
//                               voleq.Species == ved.Species &&
//                               voleq.PrimaryProduct == ved.PrimaryProduct;
//                    });
                if (dupEquations.Count() > 1)
                {
                    ErrorLogMethods.LoadError("VolumeEquation", "E", "5", (long)ved.rowID, "VolumeEquationNumber");
                    errorsFound++;
                }
            } //  end foreach loop
            return(errorsFound);
        }     //  end GeneralEquationChecks
Ejemplo n.º 17
0
        //  edit checks
        public int CheckEquations(List <ValueEquationDO> valList, string currRegion)
        {
            //  Per K.Andregg some time ago, value is not used in Region 8
            string[] R1equations = new string[8] {
                "VLPP0101", "VLPP0102", "VLPP0103", "VLPP0104",
                "VLPP0106", "VLPP0107", "VLPP0110", "VLPP0112"
            };
            string[] R2equations = new string[8] {
                "VLPP0201", "VLPP0202", "VLPP0203", "VLPP0204",
                "VLPP0206", "VLPP0207", "VLPP0210", "VLPP0212"
            };
            string[] R3equations = new string[8] {
                "VLPP0301", "VLPP0302", "VLPP0303", "VLPP0304",
                "VLPP0306", "VLPP0307", "VLPP0310", "VLPP0312"
            };
            string[] R4equations = new string[4] {
                "VLPP0401", "VLPP0402", "VLPP0403", "VLPP0404"
            };
            string[] R5equations = new string[8] {
                "VLPP0501", "VLPP0502", "VLPP0503", "VLPP0504",
                "VLPP0506", "VLPP0507", "VLPP0510", "VLPP0512"
            };
            string[] R8equations = new string[8] {
                "VLPP0801", "VLPP0802", "VLPP0803", "VLPP0804",
                "VLPP0806", "VLPP0807", "VLPP0810", "VLPP0812"
            };
            string[] R9equations = new string[14] {
                "VLPP0901", "VLPP0902", "VLPP0903", "VLPP0904",
                "VLPP0905", "VLPP0906", "VLPP0907", "VLPP0908",
                "VLPP0909", "VLPP0910", "VLPP0911", "VLPP0912",
                "VLPP0913", "VLPP0914"
            };
            string[] R10equations = new string[8] {
                "VLPP0001", "VLPP0002", "VLPP0003", "VLPP0004",
                "VLPP0006", "VLPP0007", "VLPP0010", "VLPP0012"
            };
            ErrorLogMethods elm            = new ErrorLogMethods();
            int             errorsFound    = 0;
            bool            badEquation    = false;
            bool            badCoefficient = false;

            foreach (ValueEquationDO val in valList)
            {
                switch (currRegion)
                {
                case "01":
                case "1":
                    if (R1equations.Contains(val.ValueEquationNumber) == false)
                    {
                        badEquation = true;
                    }
                    if (val.Coefficient1 == 0 && val.Coefficient2 == 0)
                    {
                        badCoefficient = true;
                    }
                    break;

                case "02":
                case "2":
                    if (R2equations.Contains(val.ValueEquationNumber) == false)
                    {
                        badEquation = true;
                    }
                    if (val.Coefficient1 == 0 && val.Coefficient2 == 0)
                    {
                        badCoefficient = true;
                    }
                    break;

                case "03":
                case "3":
                    if (R3equations.Contains(val.ValueEquationNumber) == false)
                    {
                        badEquation = true;
                    }
                    if (val.Coefficient1 == 0 && val.Coefficient2 == 0)
                    {
                        badCoefficient = true;
                    }
                    break;

                case "04":
                case "4":
                    if (R4equations.Contains(val.ValueEquationNumber) == false)
                    {
                        badEquation = true;
                    }
                    if (val.Coefficient1 == 0 && val.Coefficient2 == 0 &&
                        val.Coefficient3 == 0 && val.Coefficient4 == 0)
                    {
                        badCoefficient = true;
                    }
                    break;

                case "05":
                case "5":
                    if (R5equations.Contains(val.ValueEquationNumber) == false)
                    {
                        badEquation = true;
                    }
                    if (val.Coefficient1 == 0 && val.Coefficient2 == 0)
                    {
                        badCoefficient = true;
                    }
                    break;

                case "08":
                case "8":
                    if (R8equations.Contains(val.ValueEquationNumber) == false)
                    {
                        badEquation = true;
                    }
                    if (val.Coefficient1 == 0 && val.Coefficient2 == 0)
                    {
                        badCoefficient = true;
                    }
                    break;

                case "09":
                case "9":
                    if (R9equations.Contains(val.ValueEquationNumber) == false)
                    {
                        badEquation = true;
                    }
                    if (val.Coefficient1 == 0 && val.Coefficient2 == 0)
                    {
                        badCoefficient = true;
                    }
                    break;

                case "10":
                    if (R10equations.Contains(val.ValueEquationNumber) == false)
                    {
                        badEquation = true;
                    }
                    if (val.Coefficient1 == 0 && val.Coefficient2 == 0)
                    {
                        badCoefficient = true;
                    }
                    break;
                }   //  end switch on region

                if (val.ValueEquationNumber == null)
                {
                    badEquation = true;
                }

                if (badEquation)
                {
                    elm.LoadError("ValueEquation", "E", "1", (long)val.rowID, "ValueEquationNumber");
                    errorsFound++;
                    badEquation = false;
                }   //  endif bad equation
                if (badCoefficient)
                {
                    elm.LoadError("ValueEquation", "E", "2", (long)val.rowID, "Coefficient");
                    errorsFound++;
                    badCoefficient = false;
                } //  endif badCoefficient
            }     //  end foreach loop
            return(errorsFound);
        }         //  end CheckEquations
Ejemplo n.º 18
0
        public int TableEditChecks(IEnumerable <SaleDO> saleList, IEnumerable <StratumDO> strList,
                                   IEnumerable <CountTreeDO> cntList, IEnumerable <TreeDO> tList, IEnumerable <SampleGroupDO> sgList)
        {
            ErrorLogMethods.fileName = fileName;
            string currentRegion = Global.BL.getRegion();
            string isVLL         = "";

            //string isVLL = Global.BL.getVLL();

            //  edit checks for each table
            //  sale table
            //  empty or more than one record?
            errorValue = SaleMethods.MoreThanOne(saleList);
            if (errorValue == 0)
            {
                ErrorLogMethods.LoadError("Sale", "E", "25", errorValue, "NoName");           //  error 25 -- table cannot be empty
            }
            else if (errorValue > 1)
            {
                ErrorLogMethods.LoadError("Sale", "E", "28", errorValue, "SaleNumber");           //  error 28 -- more than one sale record not allowed
            }
            if (errorValue == 1)
            {
                //  and blank sale number
                errorValue = SaleMethods.BlankSaleNum(saleList);
                if (errorValue != -1)
                {
                    ErrorLogMethods.LoadError("Sale", "E", " 8Sale Number", errorValue, "SaleNumber");
                }
            }       //  endif
            //  end sale table edit checks

            // *******************************************************************
            //  stratum table
//                List<StratumDO> strList = Global.BL.getStratum();
            errorValue = StratumMethods.IsEmpty(strList);
            if (errorValue != 0)
            {
                ErrorLogMethods.LoadError("Stratum", "E", errorValue.ToString(), errorValue, "NoName");
            }
            else if (errorValue == 0)        //  means there are records to check
            {
                foreach (StratumDO sdo in strList)
                {
                    //  check for valid fixed plot size or BAF for each stratum
                    double BAForFPS = StratumMethods.CheckMethod(strList, sdo.Code);
                    if ((sdo.Method == "PNT" || sdo.Method == "P3P" || sdo.Method == "PCM" ||
                         sdo.Method == "PCMTRE" || sdo.Method == "3PPNT") && BAForFPS == 0)
                    {
                        ErrorLogMethods.LoadError("Stratum", "E", "22", (long)sdo.Stratum_CN, "BasalAreaFactor");
                    }
                    else if ((sdo.Method == "FIX" || sdo.Method == "F3P" || sdo.Method == "FIXCNT" ||
                              sdo.Method == "FCM") && BAForFPS == 0)
                    {
                        ErrorLogMethods.LoadError("Stratum", "E", "23", (long)sdo.Stratum_CN, "FixedPlotSize");
                    }

                    //  check for acres on area based methods
                    double currAcres = Utilities.AcresLookup((long)sdo.Stratum_CN, sdo.Code);
                    if ((sdo.Method == "PNT" || sdo.Method == "FIX" || sdo.Method == "P3P" ||
                         sdo.Method == "F3P" || sdo.Method == "PCM" || sdo.Method == "3PPNT" ||
                         sdo.Method == "FCM" || sdo.Method == "PCMTRE") && currAcres == 0)
                    {
                        ErrorLogMethods.LoadError("Stratum", "E", "24", (long)sdo.Stratum_CN, "NoName");
                    }
                    else if ((sdo.Method == "100" || sdo.Method == "3P" ||
                              sdo.Method == "S3P" || sdo.Method == "STR") && currAcres == 0)
                    {
                        ErrorLogMethods.LoadError("Stratum", "W", "Stratum has no acres", (long)sdo.Stratum_CN, "NoName");
                    }

                    //  August 2017 -- added check for valid yield component code
                    if (sdo.YieldComponent != "CL" && sdo.YieldComponent != "CD" &&
                        sdo.YieldComponent != "ND" && sdo.YieldComponent != "NL" &&
                        sdo.YieldComponent != "" && sdo.YieldComponent != " " &&
                        sdo.YieldComponent != null)
                    {
                        ErrorLogMethods.LoadError("Stratum", "W", "Yield Component has invalid code", (long)sdo.Stratum_CN, "YieldComponent");
                    }
                }   //  end foreach loop
            }       //  endif
            //  end stratum table edit checks

            //  ************************************************************************
            // cutting unit table
            //List<CuttingUnitDO> cuList = Global.BL.getCuttingUnits();
            errorValue = CuttingUnitMethods.IsEmpty(Global.BL.getCuttingUnits());
            if (errorValue != 0)
            {
                ErrorLogMethods.LoadError("Cutting Unit", "E", errorValue.ToString(), 0, "NoName");
            }
            //  end cutting unit edit checks

            //  **************************************************************************
            //  count table
            //List<CountTreeDO> cntList = Global.BL.getCountTrees();
            foreach (StratumDO sl in strList)
            {
                errorValue = CountTreeMethods.check3Pcounts(cntList, sl);
                if (errorValue != 0)
                {
                    ErrorLogMethods.LoadError("CountTree", "E", "Cannot tally by sample group for 3P strata.", (long)sl.Stratum_CN, "TreeDefaultValue");
                }
            }       //  end foreach on stratum

            //  **************************************************************************
            //  tree table
            //List<TreeDO> tList = Global.BL.getTrees();
            errorValue = TreeListMethods.IsEmpty(tList);
            if (errorValue != 0)
            {
                ErrorLogMethods.LoadError("Tree", "E", errorValue.ToString(), 0, "NoName");
            }
            else if (errorValue == 0)           //  means tree table has records
            {
                //  make sure single stratum is NOT FIXCNT which cannot have measured trees anyway.
                //if(strList.Count == 1 && strList[0].Method != "FIXCNT")
                //  doesn't matter if it's a single stratum or any stratum that's FIXCNT
                //  that method still has no measured trees so need to skip these checks.
                if (strList.First().Method != "FIXCNT")
                {
                    var tMeas = tList.Select(tree => tree.CountOrMeasure = "M");
                    //tList = Global.BL.JustMeasuredTrees();
                    //  March 2016 -- if the entire cruisde has no measured trees, that uis a critical erro
                    //  and should stop the program.  Since no report can be generated, a message box appears to warn the user
                    //  of the condition.
                    if (tMeas.Count() == 0)
                    {
                        MessageBox.Show("NO MEASURED TREES IN THIS CRUISE.\nCannot continue and cannot produce any reports.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                        return(-1);
                    }       //endif
                    //  general checks include  checking for secondary top DIB greater than primary
                    //  recoverable percent greater than seen defect primary
                    //  missing species, product or uom when tree count is greater than zero or DBH is greater than zero
                    //  and check for upper stem diameter greater than DBH
                    errorValue = TreeListMethods.GeneralChecks(tList, currentRegion);
                }   //  endif single stratum
            }       //  endif
            //  end tree table edit checks

            //  *************************************************************************
            //  log table
            List <LogDO> logList = Global.BL.getLogs().ToList();

            if (logList.Count > 0)
            {
                errorValue = LogMethods.CheckNumberLogs(logList);
                errorValue = LogMethods.CheckFBS(logList);
                if (isVLL == "true")
                {
                    errorValue = LogMethods.CheckVLL(logList);
                }
                errorValue = LogMethods.CheckDefect(logList);
                if (currentRegion != "05")
                {
                    errorValue = LogMethods.CheckLogGrade(logList);
                }
            }       //  endif records in log table to check
            //  end log table edit checks

            //  *************************************************************************
            //  volume equation table
            List <VolumeEquationDO> volList = Global.BL.getVolumeEquations().ToList();

            errorValue = VolumeEqMethods.IsEmpty(volList);
            //  pull region
            string currRegion = saleList.First().Region;

            //string currRegion =  Global.BL.getRegion();
            if (errorValue != 0)
            {
                ErrorLogMethods.LoadError("VolumeEquation", "E", errorValue.ToString(), 0, "NoName");
            }
            else if (errorValue == 0)        //  means the table is not empty and checks can proceed
            {
                //  Match unique species/product to volume equation   \
                errorValue = VolumeEqMethods.MatchSpeciesProduct(volList, tList);
                errorValue = VolumeEqMethods.GeneralEquationChecks(volList);
                //  if VLL, check equations for Behrs
                if (isVLL == "true")
                {
                    errorValue = VolumeEqMethods.FindBehrs(volList);
                }
            }       //  endif
            //  end volume equation edit checks

            //  *************************************************************************
            //  value equations
            // Check for valid equations
            IEnumerable <ValueEquationDO> valList = Global.BL.getValueEquations();

            if (valList.Any())          //  there are records to check
            {
                errorValue = ValueEqMethods.CheckEquations(valList, currentRegion);
            }
            //  end value equation edit checks

            //  *************************************************************************
            //  quality adjustment equations
            IEnumerable <QualityAdjEquationDO> qaeList = Global.BL.getQualAdjEquations();

            if (qaeList.Any())          //  there are records to check
            {
                errorValue = QualityAdjMethods.CheckEquations(qaeList);
            }
            //  end quality adjustment equation edit checks

            //  ************************************************************************
            //  June 2014 -- apparently the error log table is not meant to capture
            //  errors on the basis of an entire table.  Only on individual records.
            //  so if no reports have been selected, this check needs to move to
            //  the Output section when the user clicks GO.  If the reports list
            //  comes up empty then display a message box telling them to go back
            //  and enter reports.
            //  no reports selected

/*
 *              List<ReportsDO> selectedReports = Global.BL.GetSelectedReports();
 *              if (selectedReports.Count == 0)
 *              {
 *                  ErrorLogMethods.LoadError("Reports", "E", "26", 0,"NoName");
 *                  errorValue++;
 *              }   //  endif no reports
 */
            //  ************************************************************************
            //  sample group table
            //List<SampleGroupDO> sampGroups = Global.BL.getSampleGroups();
            errorValue = SampleGroupMethods.CheckAllUOMandCutLeave(strList, sgList, fileName);
            //  ************************************************************************
            errList = ErrorLogMethods.errList;
            if (errList.Count > 0)
            {
                Global.BL.SaveErrorMessages(errList);
            }   //  endif
            return(errorValue);
        }       //  end TableEditChecks
        }   //  end CheckForNoDBH

        private int CheckForMeasuredTrees(List <TreeDO> treeList, int currST_CN, string currMeth, CPbusinessLayer bslyr)
        {
            int             numErrs = 0;
            ErrorLogMethods elm     = new ErrorLogMethods();

            //  if the tree list is empty, could be the strata just doesn't have any trees.
            //  this is probably a cruise in process so return no errors on this stratum.
            //  October 2014
            if (treeList.Count == 0)
            {
                return(numErrs);
            }

            //  need sample group(s) for current stratum
            List <SampleGroupDO> sgList = bslyr.getSampleGroups(currST_CN);

            //  check is method based
            switch (currMeth)
            {
            case "3P":
            case "STR":
            case "S3P":
                foreach (SampleGroupDO sg in sgList)
                {
                    //  find count records for the sample group
                    List <CountTreeDO> justGroups = bslyr.getCountTrees((long)sg.SampleGroup_CN);
                    //  sum up tree count
                    float totalCount = justGroups.Sum(jg => jg.TreeCount);
                    if (totalCount > 0)
                    {
                        //  Any measured trees?  look for just one measured tree in the stratum
                        List <TreeDO> justMeasured = treeList.FindAll(
                            delegate(TreeDO t)
                        {
                            return(t.CountOrMeasure == "M" && t.SampleGroup_CN == sg.SampleGroup_CN && t.Stratum_CN == currST_CN);
                        });
                        if (justMeasured.Count == 0)
                        {
                            //  this is the error
                            elm.LoadError("SampleGroup", "W", "30", (long)sg.SampleGroup_CN, "NoName");
                            numErrs++;
                        } //  endif
                    }     //  endif totalCount
                }         //  end foreach loop
                break;

            default:            //  all area based
                foreach (SampleGroupDO sg in sgList)
                {
                    List <TreeDO> justGroups = treeList.FindAll(
                        delegate(TreeDO t)
                    {
                        return(t.SampleGroup_CN == sg.SampleGroup_CN);
                    });

                    float totalCount = justGroups.Sum(jg => jg.TreeCount);
                    if (totalCount > 0)
                    {
                        //  any measured trees?
                        List <TreeDO> justMeasured = justGroups.FindAll(
                            delegate(TreeDO td)
                        {
                            return(td.CountOrMeasure == "M");
                        });
                        if (justMeasured.Count == 0)
                        {
                            // here's the error
                            elm.LoadError("SampleGroup", "W", "30", (long)sg.SampleGroup_CN, "NoName");
                            numErrs++;
                        } //  endif
                    }     //  endif totalCount
                }         //  end foreach loop
                break;
            }             //  end switch
            return(numErrs);
        }                 //  end CheckForMeasuredTrees