Ejemplo n.º 1
0
 private IEnumerable <XElement> StreamTimePeriods()
 {
     //loop through the descendants in document order
     while (this.GCCalculatorParams.DocToCalcReader.Read())
     {
         if (this.GCCalculatorParams.DocToCalcReader.NodeType
             == XmlNodeType.Element)
         {
             if (this.GCCalculatorParams.DocToCalcReader.Name
                 == Constants.ROOT_PATH)
             {
                 //skip using while
             }
             else if (this.GCCalculatorParams.DocToCalcReader.Name
                      == BudgetInvestment.BUDGET_TYPES.budgettimeperiod.ToString() ||
                      this.GCCalculatorParams.DocToCalcReader.Name
                      == BudgetInvestment.INVESTMENT_TYPES.investmenttimeperiod.ToString())
             {
                 //read currentElement including xmldocnodes
                 XElement currentElement
                     = CalculatorHelpers.GetCurrentElementWithAttributes(
                           this.GCCalculatorParams.DocToCalcReader);
                 //don't process previously calculated nodes
                 bool bIsAnnuity = TimePeriod.IsAnnuity(currentElement);
                 if (!bIsAnnuity)
                 {
                     //attach linked views separately (put in first position)
                     CalculatorHelpers.AddLinkedViewsToCurrentElementWithReader(this.GCCalculatorParams.ExtensionDocToCalcURI,
                                                                                this.GCCalculatorParams.AnalyzerParms.ObservationsPath, ref currentElement);
                     //OnSetAncestorObjects(GCArguments);
                     //use streaming techniques to process descendants
                     IEnumerable <XElement> childElements =
                         from childElement in StreamTimePeriodChildren()
                         select childElement;
                     if (currentElement != null)
                     {
                         if (childElements != null)
                         {
                             //add the child elements to the currentElement
                             currentElement.Add(childElements);
                         }
                         Task <bool> hascalc = this.RunCalculationsAndSetUpdatesAsync(currentElement);
                         yield return(currentElement);
                     }
                 }
             }
         }
         else if (this.GCCalculatorParams.DocToCalcReader.NodeType
                  == XmlNodeType.EndElement)
         {
             if (this.GCCalculatorParams.DocToCalcReader.Name
                 == BudgetInvestment.BUDGET_TYPES.budget.ToString() ||
                 this.GCCalculatorParams.DocToCalcReader.Name
                 == BudgetInvestment.INVESTMENT_TYPES.investment.ToString())
             {
                 break;
             }
         }
     }
 }
Ejemplo n.º 2
0
 protected virtual IEnumerable <XElement> StreamRoot()
 {
     //loop through the descendants in document order
     while (this.GCCalculatorParams.DocToCalcReader.Read())
     {
         if (this.GCCalculatorParams.DocToCalcReader.NodeType
             == XmlNodeType.Element)
         {
             if (this.GCCalculatorParams.DocToCalcReader.Name
                 == Constants.ROOT_PATH)
             {
                 XElement currentElement
                     = CalculatorHelpers.GetCurrentElementWithAttributes(
                           this.GCCalculatorParams.DocToCalcReader);
                 IEnumerable <XElement> childElements =
                     from childElement in StreamOperationComponentGroups()
                     select childElement;
                 if (currentElement != null)
                 {
                     if (childElements != null)
                     {
                         //add the child elements to the currentElement
                         currentElement.Add(childElements);
                     }
                     yield return(currentElement);
                 }
             }
         }
     }
 }
Ejemplo n.º 3
0
 private IEnumerable <XElement> StreamOutcome()
 {
     //loop through the descendants in document order
     while (this.GCCalculatorParams.DocToCalcReader.Read())
     {
         if (this.GCCalculatorParams.DocToCalcReader.NodeType
             == XmlNodeType.Element)
         {
             if (this.GCCalculatorParams.DocToCalcReader.Name
                 == Constants.ROOT_PATH)
             {
                 //skip using while
             }
             else if (this.GCCalculatorParams.DocToCalcReader.Name
                      == Outcome.OUTCOME_PRICE_TYPES.outcome.ToString())
             {
                 //use streaming techniques to process descendants
                 XElement currentElement
                     = CalculatorHelpers.GetCurrentElementWithAttributes(
                           this.GCCalculatorParams.DocToCalcReader);
                 //attach linked views separately (or the readdescendant syntax skips)
                 CalculatorHelpers.AddLinkedViewsToCurrentElementWithReader(
                     this.GCCalculatorParams.ExtensionDocToCalcURI,
                     this.GCCalculatorParams.AnalyzerParms.ObservationsPath, ref currentElement);
                 //set stateful ancestor objects (i.e. this.GCCalculatorParams.ParentBudget)
                 //that descendants use in their calculations
                 this.GCArguments.CurrentElement = currentElement;
                 OnSetAncestorObjects(this.GCArguments);
                 IEnumerable <XElement> childElements = null;
                 if (this.GCCalculatorParams.DocToCalcReader.Name
                     == Outcome.OUTCOME_PRICE_TYPES.outcome.ToString())
                 {
                     childElements =
                         from childElement in StreamOutcomeOutput()
                         select childElement;
                 }
                 if (currentElement != null)
                 {
                     if (childElements != null)
                     {
                         //add the child elements to the currentElement
                         currentElement.Add(childElements);
                     }
                     this.RunCalculationsAndSetUpdates(ref currentElement);
                     yield return(currentElement);
                 }
             }
         }
         else if (this.GCCalculatorParams.DocToCalcReader.NodeType
                  == XmlNodeType.EndElement)
         {
             if (this.GCCalculatorParams.DocToCalcReader.Name
                 == Outcome.OUTCOME_PRICE_TYPES.outcomegroup.ToString())
             {
                 break;
             }
         }
     }
 }
Ejemplo n.º 4
0
 private IEnumerable <XElement> StreamBudgetInvestments()
 {
     //loop through the descendants in document order
     while (this.GCCalculatorParams.DocToCalcReader.Read())
     {
         if (this.GCCalculatorParams.DocToCalcReader.NodeType
             == XmlNodeType.Element)
         {
             if (this.GCCalculatorParams.DocToCalcReader.Name
                 == Constants.ROOT_PATH)
             {
                 //skip using while
             }
             else if (this.GCCalculatorParams.DocToCalcReader.Name
                      == BudgetInvestment.BUDGET_TYPES.budget.ToString() ||
                      this.GCCalculatorParams.DocToCalcReader.Name
                      == BudgetInvestment.INVESTMENT_TYPES.investment.ToString())
             {
                 //use streaming techniques to process descendants
                 XElement currentElement
                     = CalculatorHelpers.GetCurrentElementWithAttributes(
                           this.GCCalculatorParams.DocToCalcReader);
                 //attach linked views separately (or the ancestor.linkedview can't be set)
                 CalculatorHelpers.AddLinkedViewsToCurrentElementWithReader(
                     this.GCCalculatorParams.ExtensionDocToCalcURI,
                     this.GCCalculatorParams.AnalyzerParms.ObservationsPath, ref currentElement);
                 //set stateful ancestor objects (i.e. this.GCCalculatorParams.ParentBudget)
                 //that descendants use in their calculations
                 GCArguments.CurrentElement = currentElement;
                 OnSetAncestorObjects(GCArguments);
                 IEnumerable <XElement> childElements =
                     from childElement in StreamTimePeriods()
                     select childElement;
                 if (currentElement != null)
                 {
                     if (childElements != null)
                     {
                         //add the child elements to the currentElement
                         currentElement.Add(childElements);
                     }
                     this.RunCalculationsAndSetUpdates(ref currentElement);
                     yield return(currentElement);
                 }
             }
         }
         else if (this.GCCalculatorParams.DocToCalcReader.NodeType
                  == XmlNodeType.EndElement)
         {
             if (this.GCCalculatorParams.DocToCalcReader.Name
                 == BudgetInvestment.BUDGET_TYPES.budgetgroup.ToString() ||
                 this.GCCalculatorParams.DocToCalcReader.Name
                 == BudgetInvestment.INVESTMENT_TYPES.investmentgroup.ToString())
             {
                 break;
             }
         }
     }
 }
Ejemplo n.º 5
0
 protected virtual IEnumerable <XElement> StreamLocalGroups()
 {
     //loop through the descendents in document order
     while (this.GCCalculatorParams.DocToCalcReader.Read())
     {
         if (this.GCCalculatorParams.DocToCalcReader.NodeType
             == XmlNodeType.Element)
         {
             if (this.GCCalculatorParams.DocToCalcReader.Name
                 == Constants.ROOT_PATH)
             {
                 //attach calculators to parents
                 XElement xmlDocElement = XElement.Load(
                     this.GCCalculatorParams.DocToCalcReader.ReadSubtree());
                 yield return(xmlDocElement);
             }
             else if (this.GCCalculatorParams.DocToCalcReader.Name
                      == DevTreks.Data.AppHelpers.Locals.LOCAL_TYPES.localaccountgroup.ToString() ||
                      this.GCCalculatorParams.DocToCalcReader.Name
                      == DevTreks.Data.AppHelpers.Locals.LOCALGROUP_NS.ToString())
             {
                 this.GCCalculatorParams.ChangeStartingParams(
                     this.GCCalculatorParams.DocToCalcReader.Name);
                 //use streaming techniques to process descendents
                 XElement currentElement
                     = CalculatorHelpers.GetCurrentElementWithAttributes(
                           this.GCCalculatorParams.DocToCalcReader);
                 IEnumerable <XElement> childElements =
                     from childElement in StreamLocals()
                     select childElement;
                 if (currentElement != null)
                 {
                     if (childElements != null)
                     {
                         //add the child elements to the currentElement
                         currentElement.Add(childElements);
                     }
                     //0.8.4: locals only run for currentcalcdocid (child local node)
                     //this.RunCalculationsAndSetUpdates(ref currentElement);
                     yield return(currentElement);
                 }
             }
         }
         else if (this.GCCalculatorParams.DocToCalcReader.NodeType
                  == XmlNodeType.EndElement)
         {
             if (this.GCCalculatorParams.DocToCalcReader.Name
                 == Constants.ROOT_PATH)
             {
                 break;
             }
         }
     }
 }
Ejemplo n.º 6
0
 protected virtual IEnumerable <XElement> StreamOperationComponentGroups()
 {
     //loop through the descendants in document order
     while (this.GCCalculatorParams.DocToCalcReader.Read())
     {
         if (this.GCCalculatorParams.DocToCalcReader.NodeType
             == XmlNodeType.Element)
         {
             if (this.GCCalculatorParams.DocToCalcReader.Name
                 == OperationComponent.OPERATION_PRICE_TYPES.operationgroup.ToString() ||
                 this.GCCalculatorParams.DocToCalcReader.Name
                 == OperationComponent.COMPONENT_PRICE_TYPES.componentgroup.ToString())
             {
                 this.GCCalculatorParams.ChangeStartingParams(
                     this.GCCalculatorParams.DocToCalcReader.Name);
                 //use streaming techniques to process descendants
                 XElement currentElement
                     = CalculatorHelpers.GetCurrentElementWithAttributes(
                           this.GCCalculatorParams.DocToCalcReader);
                 //attach linked views separately (or the ancestor.linkedview can't be set)
                 CalculatorHelpers.AddLinkedViewsToCurrentElementWithReader(
                     this.GCCalculatorParams.ExtensionDocToCalcURI,
                     this.GCCalculatorParams.AnalyzerParms.ObservationsPath, ref currentElement);
                 //set stateful ancestor objects (i.e. this.GCCalculatorParams.ParentBudget)
                 //that descendants use in their calculations
                 this.GCArguments.CurrentElement = currentElement;
                 OnSetAncestorObjects(this.GCArguments);
                 IEnumerable <XElement> childElements =
                     from childElement in StreamOperationComponent()
                     select childElement;
                 if (currentElement != null)
                 {
                     if (childElements != null)
                     {
                         //add the child elements to the currentElement
                         currentElement.Add(childElements);
                     }
                     this.RunCalculationsAndSetUpdates(ref currentElement);
                     yield return(currentElement);
                 }
             }
         }
         else if (this.GCCalculatorParams.DocToCalcReader.NodeType
                  == XmlNodeType.EndElement)
         {
             if (this.GCCalculatorParams.DocToCalcReader.Name
                 == Constants.ROOT_PATH)
             {
                 break;
             }
         }
     }
 }
Ejemplo n.º 7
0
 protected virtual IEnumerable <XElement> StreamInputOrOutputGroups()
 {
     //loop through the descendants in document order
     while (this.GCCalculatorParams.DocToCalcReader.Read())
     {
         if (this.GCCalculatorParams.DocToCalcReader.NodeType
             == XmlNodeType.Element)
         {
             if (this.GCCalculatorParams.DocToCalcReader.Name
                 == Input.INPUT_PRICE_TYPES.inputgroup.ToString() ||
                 this.GCCalculatorParams.DocToCalcReader.Name
                 == Output.OUTPUT_PRICE_TYPES.outputgroup.ToString())
             {
                 this.GCCalculatorParams.ChangeStartingParams(
                     this.GCCalculatorParams.DocToCalcReader.Name);
                 //use streaming techniques to process descendants
                 XElement currentElement
                     = CalculatorHelpers.GetCurrentElementWithAttributes(
                           this.GCCalculatorParams.DocToCalcReader);
                 //attach linked views separately (or the ancestor.linkedview can't be set)
                 CalculatorHelpers.AddLinkedViewsToCurrentElementWithReader(this.GCCalculatorParams.ExtensionDocToCalcURI,
                                                                            this.GCCalculatorParams.AnalyzerParms.ObservationsPath, ref currentElement);
                 //SetAncestorObjects(currentElement);
                 IEnumerable <XElement> childElements =
                     from childElement in StreamInputOrOutputs()
                     select childElement;
                 if (currentElement != null)
                 {
                     if (childElements != null)
                     {
                         //add the child elements to the currentElement
                         currentElement.Add(childElements);
                     }
                     Task <bool> hascalc = this.RunCalculationsAndSetUpdatesAsync(currentElement);
                     //_lvTasks.Add(this.RunCalculationsAndSetUpdatesAsync(currentElement));
                     yield return(currentElement);
                 }
             }
         }
         else if (this.GCCalculatorParams.DocToCalcReader.NodeType
                  == XmlNodeType.EndElement)
         {
             if (this.GCCalculatorParams.DocToCalcReader.Name
                 == Constants.ROOT_PATH)
             {
                 break;
             }
         }
     }
 }
Ejemplo n.º 8
0
 protected virtual IEnumerable <IEnumerable <XElement> > StreamingRoot()
 {
     //loop through the descendants in document order
     while (this.GCCalculatorParams.DocToCalcReader.Read())
     {
         if (this.GCCalculatorParams.DocToCalcReader.NodeType
             == XmlNodeType.Element)
         {
             if (this.GCCalculatorParams.DocToCalcReader.Name
                 == Constants.ROOT_PATH)
             {
                 XElement currentElement
                     = CalculatorHelpers.GetCurrentElementWithAttributes(
                           this.GCCalculatorParams.DocToCalcReader);
                 IEnumerable <XElement> childElements =
                     from childElement in StreamInputOrOutputGroups()
                     select childElement;
                 yield return(childElements);
             }
         }
     }
 }
Ejemplo n.º 9
0
 private IEnumerable <XElement> StreamInvestmentOutcome()
 {
     //not all calculations include outcomes, so use ReadToDescendent syntax
     //this works even without outcomes as long as the parent "outcomes" node
     //is yielded, and that node has no xmldoc calcs
     while (this.GCCalculatorParams.DocToCalcReader.ReadToDescendant(
                BudgetInvestment.INVESTMENT_TYPES.investmentoutcome.ToString()))
     {
         if (this.GCCalculatorParams.DocToCalcReader.NodeType
             == XmlNodeType.Element)
         {
             //use streaming techniques to process descendants
             XElement currentElement
                 = CalculatorHelpers.GetCurrentElementWithAttributes(
                       this.GCCalculatorParams.DocToCalcReader);
             //attach linked views separately (or the readdescendant syntax skips)
             CalculatorHelpers.AddLinkedViewsToCurrentElementWithReader(
                 this.GCCalculatorParams.ExtensionDocToCalcURI,
                 this.GCCalculatorParams.AnalyzerParms.ObservationsPath, ref currentElement);
             //don't process previously calculated nodes
             bool bIsAnnuity = TimePeriod.IsAnnuity(currentElement);
             if (!bIsAnnuity)
             {
                 //set stateful ancestor objects (i.e. this.GCCalculatorParams.ParentOutcome)
                 //that descendants use in their calculations
                 GCArguments.CurrentElement = currentElement;
                 OnSetAncestorObjects(GCArguments);
                 IEnumerable <XElement> childElements = null;
                 childElements =
                     from childElement in StreamInvestmentOutput()
                     select childElement;
                 if (currentElement != null)
                 {
                     if (childElements != null)
                     {
                         currentElement.Add(childElements);
                     }
                     this.RunCalculationsAndSetUpdates(ref currentElement);
                     yield return(currentElement);
                 }
             }
             //process sibling outcomes
             while (this.GCCalculatorParams.DocToCalcReader
                    .ReadToNextSibling(BudgetInvestment.INVESTMENT_TYPES.investmentoutcome.ToString()))
             {
                 if (this.GCCalculatorParams.DocToCalcReader.NodeType
                     == XmlNodeType.Element)
                 {
                     XElement siblingElement
                         = CalculatorHelpers.GetCurrentElementWithAttributes(
                               this.GCCalculatorParams.DocToCalcReader);
                     //attach linked views separately (or the readdescendant syntax skips)
                     CalculatorHelpers.AddLinkedViewsToCurrentElementWithReader(
                         this.GCCalculatorParams.ExtensionDocToCalcURI,
                         this.GCCalculatorParams.AnalyzerParms.ObservationsPath, ref siblingElement);
                     //don't process previously calculated nodes
                     bIsAnnuity = TimePeriod.IsAnnuity(siblingElement);
                     if (!bIsAnnuity)
                     {
                         //set stateful ancestor objects (i.e. this.GCCalculatorParams.ParentOutcome)
                         //that descendants use in their calculations
                         GCArguments.CurrentElement = siblingElement;
                         OnSetAncestorObjects(GCArguments);
                         IEnumerable <XElement> childElements = null;
                         childElements =
                             from childElement in StreamInvestmentOutput()
                             select childElement;
                         if (siblingElement != null)
                         {
                             if (childElements != null)
                             {
                                 siblingElement.Add(childElements);
                             }
                             this.RunCalculationsAndSetUpdates(ref siblingElement);
                             yield return(siblingElement);
                         }
                     }
                 }
                 else if (this.GCCalculatorParams.DocToCalcReader.NodeType
                          == XmlNodeType.EndElement)
                 {
                     if (this.GCCalculatorParams.DocToCalcReader.Name
                         == BudgetInvestment.BUDGET_TYPES.budgetoutcomes.ToString() ||
                         this.GCCalculatorParams.DocToCalcReader.Name
                         == BudgetInvestment.INVESTMENT_TYPES.investmentoutcomes.ToString())
                     {
                         break;
                     }
                 }
             }
         }
         else if (this.GCCalculatorParams.DocToCalcReader.NodeType
                  == XmlNodeType.EndElement)
         {
             if (this.GCCalculatorParams.DocToCalcReader.Name
                 == BudgetInvestment.BUDGET_TYPES.budgetoutcomes.ToString() ||
                 this.GCCalculatorParams.DocToCalcReader.Name
                 == BudgetInvestment.INVESTMENT_TYPES.investmentoutcomes.ToString())
             {
                 break;
             }
         }
     }
 }
Ejemplo n.º 10
0
 private IEnumerable <XElement> StreamOperationComponent()
 {
     //loop through the descendants in document order
     while (this.GCCalculatorParams.DocToCalcReader.Read())
     {
         if (this.GCCalculatorParams.DocToCalcReader.NodeType
             == XmlNodeType.Element)
         {
             if (this.GCCalculatorParams.DocToCalcReader.Name
                 == BudgetInvestment.BUDGET_TYPES.budgetoperation.ToString() ||
                 this.GCCalculatorParams.DocToCalcReader.Name
                 == BudgetInvestment.INVESTMENT_TYPES.investmentcomponent.ToString())
             {
                 //use streaming techniques to process descendants
                 XElement currentElement
                     = CalculatorHelpers.GetCurrentElementWithAttributes(
                           this.GCCalculatorParams.DocToCalcReader);
                 //attach linked views separately (or the readdescendant syntax skips)
                 CalculatorHelpers.AddLinkedViewsToCurrentElementWithReader(
                     this.GCCalculatorParams.ExtensionDocToCalcURI,
                     this.GCCalculatorParams.AnalyzerParms.ObservationsPath, ref currentElement);
                 //don't process previously calculated nodes
                 bool bIsAnnuity = TimePeriod.IsAnnuity(currentElement);
                 if (!bIsAnnuity)
                 {
                     //set stateful ancestor objects (i.e. this.GCCalculatorParams.ParentBudget)
                     //that descendants use in their calculations
                     GCArguments.CurrentElement = currentElement;
                     OnSetAncestorObjects(GCArguments);
                     IEnumerable <XElement> childElements = null;
                     if (this.GCCalculatorParams.DocToCalcReader.Name
                         == BudgetInvestment.BUDGET_TYPES.budgetoperation.ToString())
                     {
                         childElements =
                             from childElement in StreamBudgetInput()
                             select childElement;
                     }
                     else if (this.GCCalculatorParams.DocToCalcReader.Name
                              == BudgetInvestment.INVESTMENT_TYPES.investmentcomponent.ToString())
                     {
                         childElements =
                             from childElement in StreamInvestmentInput()
                             select childElement;
                     }
                     if (currentElement != null)
                     {
                         if (childElements != null)
                         {
                             currentElement.Add(childElements);
                         }
                         this.RunCalculationsAndSetUpdates(ref currentElement);
                         yield return(currentElement);
                     }
                 }
             }
         }
         else if (this.GCCalculatorParams.DocToCalcReader.NodeType
                  == XmlNodeType.EndElement)
         {
             if (this.GCCalculatorParams.DocToCalcReader.Name
                 == BudgetInvestment.BUDGET_TYPES.budgetoperations.ToString() ||
                 this.GCCalculatorParams.DocToCalcReader.Name
                 == BudgetInvestment.INVESTMENT_TYPES.investmentcomponents.ToString())
             {
                 break;
             }
         }
     }
 }
Ejemplo n.º 11
0
 private IEnumerable <XElement> StreamTimePeriodChildren()
 {
     while (this.GCCalculatorParams.DocToCalcReader.Read())
     {
         XElement currentElement = null;
         if (this.GCCalculatorParams.DocToCalcReader.NodeType
             == XmlNodeType.Element)
         {
             if (this.GCCalculatorParams.DocToCalcReader.Name
                 == BudgetInvestment.BUDGET_TYPES.budgetoutcomes.ToString() ||
                 this.GCCalculatorParams.DocToCalcReader.Name
                 == BudgetInvestment.INVESTMENT_TYPES.investmentoutcomes.ToString())
             {
                 //use streaming techniques to process descendants
                 currentElement
                     = CalculatorHelpers.GetCurrentElementWithAttributes(
                           this.GCCalculatorParams.DocToCalcReader);
                 IEnumerable <XElement> childElements = null;
                 if (this.GCCalculatorParams.DocToCalcReader.Name
                     == BudgetInvestment.BUDGET_TYPES.budgetoutcomes.ToString())
                 {
                     childElements =
                         from childElement in StreamBudgetOutcome()
                         select childElement;
                 }
                 else if (this.GCCalculatorParams.DocToCalcReader.Name
                          == BudgetInvestment.INVESTMENT_TYPES.investmentoutcomes.ToString())
                 {
                     childElements =
                         from childElement in StreamInvestmentOutcome()
                         select childElement;
                 }
                 if (currentElement != null)
                 {
                     if (childElements != null)
                     {
                         //add the child elements to the currentElement
                         currentElement.Add(childElements);
                     }
                     this.RunCalculationsAndSetUpdates(ref currentElement);
                     yield return(currentElement);
                 }
             }
             else if (this.GCCalculatorParams.DocToCalcReader.Name
                      == BudgetInvestment.BUDGET_TYPES.budgetoperations.ToString() ||
                      this.GCCalculatorParams.DocToCalcReader.Name
                      == BudgetInvestment.INVESTMENT_TYPES.investmentcomponents.ToString())
             {
                 //use streaming techniques to process descendants
                 //note: if no costs, would need the same streaming techniques as outcomes
                 currentElement
                     = CalculatorHelpers.GetCurrentElementWithAttributes(
                           this.GCCalculatorParams.DocToCalcReader);
                 IEnumerable <XElement> childElements =
                     from childElement in StreamOperationComponent()
                     select childElement;
                 if (currentElement != null)
                 {
                     if (childElements != null)
                     {
                         //add the child elements to the currentElement
                         currentElement.Add(childElements);
                     }
                     this.RunCalculationsAndSetUpdates(ref currentElement);
                     yield return(currentElement);
                 }
             }
         }
         else if (this.GCCalculatorParams.DocToCalcReader.NodeType
                  == XmlNodeType.EndElement)
         {
             if (this.GCCalculatorParams.DocToCalcReader.Name
                 == BudgetInvestment.BUDGET_TYPES.budgettimeperiod.ToString() ||
                 this.GCCalculatorParams.DocToCalcReader.Name
                 == BudgetInvestment.INVESTMENT_TYPES.investmenttimeperiod.ToString())
             {
                 break;
             }
         }
     }
 }
Ejemplo n.º 12
0
 private IEnumerable <XElement> StreamOperationComponents()
 {
     //loop through the descendants in document order
     while (this.GCCalculatorParams.DocToCalcReader.Read())
     {
         if (this.GCCalculatorParams.DocToCalcReader.NodeType
             == XmlNodeType.Element)
         {
             if (this.GCCalculatorParams.DocToCalcReader.Name
                 == Constants.ROOT_PATH)
             {
                 //skip using while
             }
             else if (this.GCCalculatorParams.DocToCalcReader.Name
                      == OperationComponent.OPERATION_PRICE_TYPES.operation.ToString() ||
                      this.GCCalculatorParams.DocToCalcReader.Name
                      == OperationComponent.COMPONENT_PRICE_TYPES.component.ToString())
             {
                 //use streaming techniques to process descendants
                 XElement currentElement
                     = CalculatorHelpers.GetCurrentElementWithAttributes(
                           this.GCCalculatorParams.DocToCalcReader);
                 //attach linked views separately (or the readdescendant syntax skips)
                 CalculatorHelpers.AddLinkedViewsToCurrentElementWithReader(this.GCCalculatorParams.ExtensionDocToCalcURI,
                                                                            this.GCCalculatorParams.AnalyzerParms.ObservationsPath, ref currentElement);
                 //OnSetAncestorObjects(this.GCArguments);
                 IEnumerable <XElement> childElements = null;
                 if (this.GCCalculatorParams.DocToCalcReader.Name
                     == OperationComponent.OPERATION_PRICE_TYPES.operation.ToString())
                 {
                     childElements =
                         from childElement in StreamOperationInputs()
                         select childElement;
                 }
                 else if (this.GCCalculatorParams.DocToCalcReader.Name
                          == OperationComponent.COMPONENT_PRICE_TYPES.component.ToString())
                 {
                     childElements =
                         from childElement in StreamComponentInputs()
                         select childElement;
                 }
                 if (currentElement != null)
                 {
                     if (childElements != null)
                     {
                         //add the child elements to the currentElement
                         currentElement.Add(childElements);
                     }
                     Task <bool> hascalc = this.RunCalculationsAndSetUpdatesAsync(currentElement);
                     yield return(currentElement);
                 }
             }
         }
         else if (this.GCCalculatorParams.DocToCalcReader.NodeType
                  == XmlNodeType.EndElement)
         {
             if (this.GCCalculatorParams.DocToCalcReader.Name
                 == OperationComponent.OPERATION_PRICE_TYPES.operationgroup.ToString() ||
                 this.GCCalculatorParams.DocToCalcReader.Name
                 == OperationComponent.COMPONENT_PRICE_TYPES.componentgroup.ToString())
             {
                 break;
             }
         }
     }
 }