DevTreks.Data/AppHelpers/Economics1.cs
/// <summary>
/// Build and save sub totals documents based on the group totals document sent in.
/// </summary>
Build and save sub totals documents based on the group totals document sent in.
Build and save sub totals documents based on the group totals document sent in .
private async Task<bool> InitSaveTotals(ContentURI docToCalcURI, ContentURI calcDocURI,
            XPathNodeIterator totalsNodeIterator, XmlDocument baseDoc,
            string directoryPath, IDictionary<string, string> childrenLinkedView)
        {
            bool bHasCompleted = false;
            if (totalsNodeIterator != null)
            {
                XPathNavigator oNavigator = totalsNodeIterator.Current.Clone();
                if (oNavigator.LocalName == Helpers.GeneralHelpers.ROOT_PATH)
                {
                    totalsNodeIterator.MoveNext();
                }
                XmlElement oDocElement = (XmlElement)((IHasXmlNode)totalsNodeIterator.Current).GetNode().CloneNode(false);
                AppHelpers.LinkedViews oLinkedView = new AppHelpers.LinkedViews();
                oLinkedView.SaveSummaryDoc(docToCalcURI, calcDocURI,
                    oDocElement, baseDoc, oNavigator, directoryPath, childrenLinkedView);
                bool bIsDeepClone = false;
                EditHelpers.XmlIO.AppendNodeToLastDocNode(oDocElement, bIsDeepClone, 
                    baseDoc.FirstChild, ref baseDoc);
                await oLinkedView.SaveFullDoc(docToCalcURI, calcDocURI,
                    oDocElement, baseDoc, oNavigator, directoryPath, childrenLinkedView);
                if (oNavigator.HasChildren == true
                    && oNavigator.LocalName != BUDGET_TYPES.budget.ToString()
                    && oNavigator.LocalName != INVESTMENT_TYPES.investment.ToString())
                {
                    XPathNodeIterator oChildrenIterator = oNavigator.SelectChildren(XPathNodeType.Element);
                    while (oChildrenIterator.MoveNext())
                    {
                        if (oChildrenIterator.Current.LocalName != Helpers.GeneralHelpers.ROOT_PATH)
                        {
                            string sId = oChildrenIterator.Current.GetAttribute(AppHelpers.Calculator.cId, string.Empty);
                            string sCurrentDirectoryName = string.Concat(oChildrenIterator.Current.LocalName,
                                Helpers.GeneralHelpers.FILENAME_DELIMITER, sId);
                            string sSubDirectoryPath = LinkedViews.GetCurrentDirectoryPath(directoryPath, sCurrentDirectoryName);
                            await InitSaveTotals(docToCalcURI, calcDocURI, oChildrenIterator,
                                baseDoc, sSubDirectoryPath, childrenLinkedView);
                            EditHelpers.XmlIO.RemoveLastNode(baseDoc.FirstChild, ref baseDoc);
                        }
                    }
                }
            }
            bHasCompleted = true;
            return bHasCompleted;
        }
private async Task < bool > InitSaveTotals ( ContentURI docToCalcURI , ContentURI calcDocURI , XPathNodeIterator totalsNodeIterator , XmlDocument baseDoc , string directoryPath , IDictionary < string , string > childrenLinkedView ) { bool bHasCompleted = false ; if ( totalsNodeIterator != null ) { XPathNavigator oNavigator = totalsNodeIterator . Current . Clone ( ) ; if ( oNavigator . LocalName == Helpers . GeneralHelpers . ROOT_PATH ) { totalsNodeIterator . MoveNext ( ) ; } XmlElement oDocElement = ( XmlElement ) ( ( IHasXmlNode ) totalsNodeIterator . Current ) . GetNode ( ) . CloneNode ( false ) ; AppHelpers . LinkedViews oLinkedView = new AppHelpers . LinkedViews ( ) ; oLinkedView . SaveSummaryDoc ( docToCalcURI , calcDocURI , oDocElement , baseDoc , oNavigator , directoryPath , childrenLinkedView ) ; bool bIsDeepClone = false ; EditHelpers . XmlIO . AppendNodeToLastDocNode ( oDocElement , bIsDeepClone , baseDoc . FirstChild , ref baseDoc ) ; await oLinkedView . SaveFullDoc ( docToCalcURI , calcDocURI , oDocElement , baseDoc , oNavigator , directoryPath , childrenLinkedView ) ; if ( oNavigator . HasChildren == true && oNavigator . LocalName != BUDGET_TYPES . budget . ToString ( ) && oNavigator . LocalName != INVESTMENT_TYPES . investment . ToString ( ) ) { XPathNodeIterator oChildrenIterator = oNavigator . SelectChildren ( XPathNodeType . Element ) ; while ( oChildrenIterator . MoveNext ( ) ) { if ( oChildrenIterator . Current . LocalName != Helpers . GeneralHelpers . ROOT_PATH ) { string sId = oChildrenIterator . Current . GetAttribute ( AppHelpers . Calculator . cId , string . Empty ) ; string sCurrentDirectoryName = string . Concat ( oChildrenIterator . Current . LocalName , Helpers . GeneralHelpers . FILENAME_DELIMITER , sId ) ; string sSubDirectoryPath = LinkedViews . GetCurrentDirectoryPath ( directoryPath , sCurrentDirectoryName ) ; await InitSaveTotals ( docToCalcURI , calcDocURI , oChildrenIterator , baseDoc , sSubDirectoryPath , childrenLinkedView ) ; EditHelpers . XmlIO . RemoveLastNode ( baseDoc . FirstChild , ref baseDoc ) ; } } } } bHasCompleted = true ; return bHasCompleted ; }
Build and save sub totals documents based on the group totals document sent in.
Build and save sub totals documents based on the group totals document sent in .
//create a navigator to navigate through children //clone just the node (not the children) for the various documents //save the summary docs //the base doc has these shallow cloned elements added //save the full docs //no summary docs needed for time period nodes  //it's a subdirectory of directoryPath //recurse to the next node (round 2 is budget/investments; no round 3 needed //at this point have a good series of time periods for one budget //fix the base doc back to original state by removing that budget (so that next one can be added)
docToCalcURI
ContentURI
<not_specific>
calcDocURI
ContentURI
<not_specific>
totalsNodeIterator
XPathNodeIterator
<not_specific>
baseDoc
XmlDocument
<not_specific>
directoryPath
string
<not_specific>
childrenLinkedView
IDictionary<string, string>
<not_specific>