private async Task <bool> RunBasicCalculationsAndSetUpdatesAsync(XElement currentElement) { bool bHasCalculations = false; if (!currentElement.HasAttributes) { return(true); } //1. set parameters needed by updates collection this.GCCalculatorParams.CurrentElementNodeName = currentElement.Name.LocalName; this.GCCalculatorParams.CurrentElementURIPattern = CalculatorHelpers.MakeNewURIPatternFromElement(this.GCCalculatorParams.ExtensionDocToCalcURI.URIPattern, currentElement); //2. don't run calcs on ancestors bool bIsSelfOrDescendentNode = CalculatorHelpers.IsSelfOrDescendentNode( this.GCCalculatorParams, this.GCCalculatorParams.CurrentElementNodeName); if (bIsSelfOrDescendentNode) { //3. get the calculator to use //(this.GCCalculatorParams.CalculationEl, or currentElement.xmldoc) XElement linkedViewElement = null; linkedViewElement = CalculatorHelpers.GetCalculator( this.GCCalculatorParams, currentElement); //some apps, such as locals, work differently CalculatorHelpers.AdjustSpecialtyLinkedViewElements(currentElement, linkedViewElement, this.GCCalculatorParams); //4. Set bool to update base node attributes in db this.GCCalculatorParams.AttributeNeedsDbUpdate = CalculatorHelpers.NeedsUpdateAttribute(this.GCCalculatorParams); //5. raise event to carry out calculations //v180: no children xml doc changes when Overwrite = false and UseSameCalc = false bool bNeedsLVUpdate = CalculatorHelpers.NeedsLVUpdate(this.GCCalculatorParams); if (bNeedsLVUpdate) { bHasCalculations = await RunCalculationAsync(currentElement, linkedViewElement); } else { //but if it's a child it might still need to be displayed //will only be displayed by setting CalculatorId or AnalyzerType in currentEl if (CalculatorHelpers.IsSelfOrChildNode(this.GCCalculatorParams, this.GCCalculatorParams.CurrentElementNodeName)) { CalculatorHelpers.SetCalculatorId(linkedViewElement, currentElement); } } if (bHasCalculations) { //v182 added resetting because async starts next node (i.e. parent) and these change before the method is finished //1. set parameters needed by updates collection //this.GCCalculatorParams.CurrentElementNodeName // = currentElement.Name.LocalName; //this.GCCalculatorParams.CurrentElementURIPattern // = CalculatorHelpers.MakeNewURIPatternFromElement(this.GCCalculatorParams.ExtensionDocToCalcURI.URIPattern, // currentElement); //6. 100% Rules: don't allow analyzers to db update descendent calculators CalculatorHelpers.ChangeLinkedViewCalculator(currentElement, linkedViewElement, this.GCCalculatorParams); //7. replace the this.GCCalculatorParams.LinkedViewElement when //the originating doctocalcuri node is processed bool bHasReplacedCalculator = CalculatorHelpers.ReplaceCalculations(this.GCCalculatorParams, currentElement, linkedViewElement); //8. v180 SetXmlDocAttributes only set db updates (xmldoc lvs are automatically changed by RunCalcAsync) CalculatorHelpers.SetXmlDocUpdates(this.GCCalculatorParams, linkedViewElement, currentElement, this.GCCalculatorParams.Updates); } } else { //basic calculators don't need full collections that include ancestobrs bHasCalculations = true; } return(bHasCalculations); }