public DialogResult ShowDialog(TreeVM tree) { if (tree == null) { throw new ArgumentNullException("tree"); } this._logs = new BindingList<LogDO>(tree.LoadLogs()); this._currentTree = tree; this._treeDesLbl.Text = tree.LogLevelDiscription; this._dataGrid.DataSource = this._logs; this._dataGrid.Focus(); var result = ShowDialog(); tree.LogCountDirty = true; return result; }
public void SetValues(TreeDO obj) { if(obj == null) { return; } Tree_GUID = obj.Tree_GUID; TreeNumber = obj.TreeNumber; Species = obj.Species; CountOrMeasure = obj.CountOrMeasure; TreeCount = obj.TreeCount; KPI = obj.KPI; STM = obj.STM; SeenDefectPrimary = obj.SeenDefectPrimary; SeenDefectSecondary = obj.SeenDefectSecondary; RecoverablePrimary = obj.RecoverablePrimary; HiddenPrimary = obj.HiddenPrimary; Initials = obj.Initials; LiveDead = obj.LiveDead; Grade = obj.Grade; HeightToFirstLiveLimb = obj.HeightToFirstLiveLimb; PoleLength = obj.PoleLength; ClearFace = obj.ClearFace; CrownRatio = obj.CrownRatio; DBH = obj.DBH; DRC = obj.DRC; TotalHeight = obj.TotalHeight; MerchHeightPrimary = obj.MerchHeightPrimary; MerchHeightSecondary = obj.MerchHeightSecondary; FormClass = obj.FormClass; UpperStemDiameter = obj.UpperStemDiameter; UpperStemHeight = obj.UpperStemHeight; DBHDoubleBarkThickness = obj.DBHDoubleBarkThickness; TopDIBPrimary = obj.TopDIBPrimary; TopDIBSecondary = obj.TopDIBSecondary; DefectCode = obj.DefectCode; DiameterAtDefect = obj.DiameterAtDefect; VoidPercent = obj.VoidPercent; Slope = obj.Slope; Aspect = obj.Aspect; Remarks = obj.Remarks; XCoordinate = obj.XCoordinate; YCoordinate = obj.YCoordinate; ZCoordinate = obj.ZCoordinate; MetaData = obj.MetaData; IsFallBuckScale = obj.IsFallBuckScale; ExpansionFactor = obj.ExpansionFactor; TreeFactor = obj.TreeFactor; PointFactor = obj.PointFactor; }
public TreeDO(TreeDO obj) : this() { SetValues(obj); }
public void TreeDOConstructorTest() { DAL DAL = null; TreeDO target = new TreeDO(DAL); TestContext.WriteLine("\r\nTesting countMeasure == NULL"); TestContext.BeginTimer("validate1"); Assert.IsFalse(target.Validate()); TestContext.EndTimer("validate1"); IDataErrorInfo tError = target; //display all errors TestContext.WriteLine("Error: " + tError.Error); //foreach (string colName in CruiseDAL.Schema.TREE._ALL) //{ // string error = tError[colName]; // if (string.IsNullOrEmpty(error)) { continue; } // TestContext.WriteLine(colName + " error = " + error); //} string sgError = tError["SampleGroup"]; Assert.IsFalse(string.IsNullOrEmpty(sgError), "SGError = " + sgError); //test countMeasure == C and revalidate TestContext.WriteLine("\r\nTesting countMeasure == C"); target.CountOrMeasure = "C"; TestContext.BeginTimer("validate2"); Assert.IsFalse(target.Validate()); TestContext.EndTimer("validate2"); //display all errors TestContext.WriteLine("Error: " + tError.Error); //foreach (string colName in CruiseDAL.Schema.TREE._ALL) //{ // string error = tError[colName]; // if (string.IsNullOrEmpty(error)) { continue; } // TestContext.WriteLine(colName + " error = " + error); //} sgError = tError["SampleGroup"]; Assert.IsFalse(string.IsNullOrEmpty(sgError), "SGError = " + sgError); TestContext.WriteLine("\r\nTesting countMeasure == M"); target.CountOrMeasure = "M"; TestContext.BeginTimer("validate3"); Assert.IsFalse(target.Validate()); TestContext.EndTimer("validate3"); //display all errors TestContext.WriteLine("Error: " + tError.Error); //foreach (string colName in CruiseDAL.Schema.TREE._ALL) //{ // string error = tError[colName]; // if (string.IsNullOrEmpty(error)) { continue; } // TestContext.WriteLine(colName + " error = " + error); //} TestContext.WriteLine("\r\nTesting countMeasure == M, DBH > 0"); target.DBH = 1; target.Validate(); TestContext.WriteLine("Error: " + tError.Error); TestContext.WriteLine("\r\nTesting countMeasure == M, Ht > 0"); target.TotalHeight = 1; target.Validate(); TestContext.WriteLine("Error: " + tError.Error); sgError = tError["SampleGroup"]; Assert.IsFalse(string.IsNullOrEmpty(sgError), "SGError = " + sgError); }
public int getReconData(StratumStatsDO curStrStats, SampleGroupStatsDO curSgStats, DAL rDAL, DAL fsDAL, List<PlotDO> myPlots, List<TreeDO> myTree, List<LogDO> myLogs, long? sampleGroupCN, bool first, int measHit) { TreeDO fsTree; LogDO fsLog; long? plotCN = 0; var myTreeList = myTree; var myLogList = myLogs; int treeCnt = 1; curStrStats.Stratum.CuttingUnits.Populate(); curSgStats.TreeDefaultValueStats.Populate(); // loop through design units foreach (CuttingUnitDO curUnit in curStrStats.Stratum.CuttingUnits) { // get number of plots for stratum and cutting unit var myPlotList = (from plt in myPlots where plt.CuttingUnit_CN == curUnit.CuttingUnit_CN select plt).ToList(); // loop through plots foreach (PlotDO curPlot in myPlotList) { // if first time for stratum, save plots plotCN = savePlots(curPlot, curStrStats.Stratum_CN, first); foreach (TreeDefaultValueDO curTdv in curSgStats.TreeDefaultValueStats) { if (curSgStats.MinDbh > 0 && curSgStats.MaxDbh > 0) { double maxDbh = curSgStats.MaxDbh + 0.0499; double minDbh = curSgStats.MinDbh - 0.0500; myTreeList = (from tcv in myTree where tcv.SampleGroup.PrimaryProduct == curSgStats.PrimaryProduct && tcv.Plot_CN == curPlot.Plot_CN && tcv.Species == curTdv.Species && tcv.LiveDead == curTdv.LiveDead && tcv.DBH >= minDbh && tcv.DBH <= maxDbh select tcv).ToList(); } else { myTreeList = (from tcv in myTree where tcv.SampleGroup.PrimaryProduct == curSgStats.PrimaryProduct && tcv.Plot_CN == curPlot.Plot_CN && tcv.Species == curTdv.Species && tcv.LiveDead == curTdv.LiveDead select tcv).ToList(); } foreach (TreeDO rTree in myTreeList) { fsTree = new TreeDO(fsDAL); fsTree.Stratum_CN = thisStrCN; fsTree.TreeDefaultValue_CN = curTdv.TreeDefaultValue_CN; fsTree.SampleGroup_CN = sampleGroupCN; fsTree.Plot_CN = plotCN; fsTree.CuttingUnit_CN = curUnit.CuttingUnit_CN; fsTree.TreeNumber = rTree.TreeNumber; fsTree.Species = rTree.Species; if (curStrStats.Method == "PCM" || curStrStats.Method == "FCM") { if (radioButton1.Checked) { // use frequency // check hit if (treeCnt == measHit) { fsTree.CountOrMeasure = "M"; measHit += (int)curSgStats.SamplingFrequency; } else fsTree.CountOrMeasure = "C"; } else if (radioButton2.Checked) { fsTree.CountOrMeasure = "C"; } else fsTree.CountOrMeasure = "M"; } else fsTree.CountOrMeasure = rTree.CountOrMeasure; treeCnt++; fsTree.TreeCount = 1; fsTree.SeenDefectPrimary = rTree.SeenDefectPrimary; fsTree.SeenDefectSecondary = rTree.SeenDefectSecondary; fsTree.RecoverablePrimary = rTree.RecoverablePrimary; fsTree.Initials = rTree.Initials; fsTree.LiveDead = rTree.LiveDead; fsTree.Grade = rTree.Grade; fsTree.HeightToFirstLiveLimb = rTree.HeightToFirstLiveLimb; fsTree.DBH = rTree.DBH; fsTree.DRC = rTree.DRC; fsTree.TotalHeight = rTree.TotalHeight; fsTree.MerchHeightPrimary = rTree.MerchHeightPrimary; fsTree.MerchHeightSecondary = rTree.MerchHeightSecondary; fsTree.FormClass = rTree.FormClass; fsTree.UpperStemHeight = rTree.UpperStemHeight; fsTree.TopDIBPrimary = rTree.TopDIBPrimary; fsTree.TopDIBSecondary = rTree.TopDIBSecondary; //fsTree.CreatedBy = rTree.CreatedBy; //fsTree.CreatedDate = rTree.CreatedDate; fsTree.Save(); // save logs myLogList = (from lcv in myLogs where lcv.Tree_CN == rTree.Tree_CN select lcv).ToList(); foreach (LogDO rLog in myLogList) { fsLog = new LogDO(fsDAL); fsLog.Tree_CN = rLog.Tree_CN; fsLog.LogNumber = rLog.LogNumber; fsLog.Grade = rLog.Grade; fsLog.SeenDefect = rLog.SeenDefect; fsLog.PercentRecoverable = rLog.PercentRecoverable; fsLog.Length = rLog.Length; fsLog.ExportGrade = rLog.ExportGrade; fsLog.SmallEndDiameter = rLog.SmallEndDiameter; fsLog.LargeEndDiameter = rLog.LargeEndDiameter; fsLog.GrossBoardFoot = rLog.GrossBoardFoot; fsLog.NetBoardFoot = rLog.NetBoardFoot; fsLog.GrossCubicFoot = rLog.GrossCubicFoot; fsLog.NetCubicFoot = rLog.NetCubicFoot; fsLog.DIBClass = rLog.DIBClass; fsLog.BarkThickness = rLog.BarkThickness; fsLog.Save(); } } } } } return (0); }
public DialogResult ShowDialog(TreeVM tree) { this._currentTree = tree; this._logs = new BindingList<LogDO>(tree.LoadLogs()); this._treeDesLbl.Text = tree.LogLevelDiscription; this._BS_Logs.DataSource = this._logs; this._dataGrid.DataSource = this._BS_Logs; this._dataGrid.Focus(); tree.LogCountDirty = true; return this.ShowDialog(); }
public int getReconData(StratumStatsDO curStrStats, SampleGroupStatsDO curSgStats, DAL rDAL, DAL fsDAL, List<PlotDO> myPlots, List<TreeDO> myTree, long? sampleGroupCN, bool first) { List<LogDO> rLog = new List<LogDO>(); TreeDO fsTree; LogDO fsLog; long? plotCN = 0; var myTreeList = myTree; curStrStats.Stratum.CuttingUnits.Populate(); curSgStats.TreeDefaultValueStats.Populate(); // loop through design units foreach (CuttingUnitDO curUnit in curStrStats.Stratum.CuttingUnits) { // get number of plots for stratum and cutting unit var myPlotList = (from plt in myPlots where plt.CuttingUnit_CN == curUnit.CuttingUnit_CN select plt).ToList(); // loop through plots foreach (PlotDO curPlot in myPlotList) { // if first time for stratum, save plots plotCN = savePlots(curPlot, curStrStats.Stratum_CN, first); foreach (TreeDefaultValueDO curTdv in curSgStats.TreeDefaultValueStats) { if (curSgStats.MinDbh > 0 && curSgStats.MaxDbh > 0) { double maxDbh = curSgStats.MaxDbh + 0.0499; double minDbh = curSgStats.MinDbh - 0.0500; myTreeList = (from tcv in myTree where tcv.SampleGroup.PrimaryProduct == curSgStats.PrimaryProduct && tcv.Plot_CN == curPlot.Plot_CN && tcv.Species == curTdv.Species && tcv.LiveDead == curTdv.LiveDead && tcv.DBH >= minDbh && tcv.DBH <= maxDbh select tcv).ToList(); } else { myTreeList = (from tcv in myTree where tcv.SampleGroup.PrimaryProduct == curSgStats.PrimaryProduct && tcv.Plot_CN == curPlot.Plot_CN && tcv.Species == curTdv.Species && tcv.LiveDead == curTdv.LiveDead select tcv).ToList(); } foreach (TreeDO rTree in myTreeList) { fsTree = new TreeDO(fsDAL); fsTree.Stratum_CN = curStrStats.Stratum_CN; fsTree.TreeDefaultValue_CN = curTdv.TreeDefaultValue_CN; fsTree.SampleGroup_CN = sampleGroupCN; fsTree.Plot_CN = plotCN; fsTree.CuttingUnit_CN = curUnit.CuttingUnit_CN; fsTree.TreeNumber = rTree.TreeNumber; fsTree.Species = rTree.Species; fsTree.CountOrMeasure = rTree.CountOrMeasure; fsTree.SeenDefectPrimary = rTree.SeenDefectPrimary; fsTree.SeenDefectSecondary = rTree.SeenDefectSecondary; fsTree.RecoverablePrimary = rTree.RecoverablePrimary; fsTree.Initials = rTree.Initials; fsTree.LiveDead = rTree.LiveDead; fsTree.Grade = rTree.Grade; fsTree.HeightToFirstLiveLimb = rTree.HeightToFirstLiveLimb; fsTree.DBH = rTree.DBH; fsTree.DRC = rTree.DRC; fsTree.TotalHeight = rTree.TotalHeight; fsTree.MerchHeightPrimary = rTree.MerchHeightPrimary; fsTree.MerchHeightSecondary = rTree.MerchHeightSecondary; fsTree.FormClass = rTree.FormClass; fsTree.UpperStemHeight = rTree.UpperStemHeight; fsTree.TopDIBPrimary = rTree.TopDIBPrimary; fsTree.TopDIBSecondary = rTree.TopDIBSecondary; fsTree.CreatedBy = rTree.CreatedBy; fsTree.CreatedDate = rTree.CreatedDate; fsTree.Save(); // save logs } } } } return (0); }