public void AssignModuleFileNameSubNodes() { SysCollGen.SortedDictionary <string, CValueTableModule> sdictOfTableModules; SysCollGen.SortedDictionary <string, CModuleFileOwnerInfo> sdictOfModuleName_to_FileNameNodes; SysCollGen.SortedDictionary <string, SysCollGen.List <CValueTableTable> > sdictOfParentChilds; SysCollGen.SortedDictionary <string, SysCollGen.List <CValueTableTable> > sdictOfChildParents; SysCollGen.SortedDictionary <string, SysCollGen.List <CValueTableModule> > sdictOfModuleTables; SysCollGen.SortedDictionary <string, SysCollGen.List <CValueTableModule> > .KeyCollection sKeysModuleNames_MT; SysCollGen.List <CValueTableModule> listTableModules_MT; SysCollGen.List <CValueTableTable> listTableTable_CP, listTableTable_PC; CValueTableTable valueTableTable_CP = null, valueTableTable_PC; CValueTableModule valueTableModule_MT, valueTableModule_TM; CModuleFileOwnerInfo moduleFileOwnerInfo; int nSubNodeTracker, uuu, nCountLoops; int nDebugging_SubNode_Previous = -3; string sSubNodeTracker; string eachTableNameLowercase_CP_Previous = ""; // sdictOfChildParents = this.m_runProperties.GetSDictOfChildParents(); sdictOfParentChilds = this.m_runProperties.GetSDictOfParentChilds(); sdictOfTableModules = m_runProperties.GetSDictOfTableModules(); sdictOfModuleTables = m_runProperties.GetSDictOfModuleTables(); sdictOfModuleName_to_FileNameNodes = this.m_runProperties .GetSDictOfModuleName_to_FileNameNodes(); //___ 1 __________ LOOP ______ CP ____________________________ // Reset all per-module counters of single-line entry items, for SubNodeTracker to utilize. foreach (CModuleFileOwnerInfo eachMFOInfo in sdictOfModuleName_to_FileNameNodes.Values ) { eachMFOInfo.RunningCountOfTablesForSubNodeGeneration = 0; } foreach (string eachTableNameLowercase_CP in sdictOfChildParents.Keys) // Merely alphabetical. { listTableTable_CP = sdictOfChildParents[eachTableNameLowercase_CP]; // Get the correct per-module entry item counter, for the Left (C) table. valueTableModule_TM = sdictOfTableModules[eachTableNameLowercase_CP]; moduleFileOwnerInfo = sdictOfModuleName_to_FileNameNodes [valueTableModule_TM.GetModuleNameLowercaseNoSpaces()]; // Manage the nSubNodeTracker. // 77 / 100 == 0. nSubNodeTracker = 11 + moduleFileOwnerInfo.RunningCountOfTablesForSubNodeGeneration / this.m_runProperties.GetMaxItems_SubNode_CPPC_File_PerModule(); sSubNodeTracker = nSubNodeTracker.ToString(); // Yuk ??, tons of string objects created, bashes the GC. valueTableModule_TM.SubNode_CP_PerModule = sSubNodeTracker; for (int sss = 0; sss < listTableTable_CP.Count; sss++) { valueTableTable_CP = listTableTable_CP[sss]; valueTableTable_CP.SubNode_CP_PerModule = sSubNodeTracker; ++(moduleFileOwnerInfo.RunningCountOfTablesForSubNodeGeneration); } // DEBUGGING ONLY, TEMPORARY. 2013-02-08 13:10pm if (-1 < String.Compare(eachTableNameLowercase_CP_Previous, eachTableNameLowercase_CP)) // Debugging only. { Console.WriteLine("DEBUGGING_WARNING_2752xw3: Bad nonAlphabetical sequence of Left table names in sdict CP!!"); } if (nDebugging_SubNode_Previous > Convert.ToInt32(valueTableTable_CP.SubNode_CP_PerModule)) { Console.WriteLine("DEBUGGING_WARNING_2763xw4: Bad SubNode sequence of Left table names in sdict CP!!"); } eachTableNameLowercase_CP_Previous = eachTableNameLowercase_CP; // Debugging } // EOForeach eachTableNameLowercase_CP //___ 2 __________ LOOP ______ PC ____________________________ // Reset all per-module counters of single-line entry items, for SubNodeTracker to utilize. foreach (CModuleFileOwnerInfo eachMFOInfo in sdictOfModuleName_to_FileNameNodes.Values ) { eachMFOInfo.RunningCountOfTablesForSubNodeGeneration = 0; } foreach (string eachTableNameLowercase_PC in sdictOfParentChilds.Keys) // Merely alphabetical. { listTableTable_PC = sdictOfParentChilds[eachTableNameLowercase_PC]; // Get the correct per-module entry item counter, for the Left (P) table. valueTableModule_TM = sdictOfTableModules[eachTableNameLowercase_PC]; moduleFileOwnerInfo = sdictOfModuleName_to_FileNameNodes [valueTableModule_TM.GetModuleNameLowercaseNoSpaces()]; // Manage the nSubNodeTracker. // 77 / 100 == 0. nSubNodeTracker = 11 + moduleFileOwnerInfo.RunningCountOfTablesForSubNodeGeneration / this.m_runProperties.GetMaxItems_SubNode_CPPC_File_PerModule(); sSubNodeTracker = nSubNodeTracker.ToString(); valueTableModule_TM.SubNode_PC_PerModule = sSubNodeTracker; for (int sss = 0; sss < listTableTable_PC.Count; sss++) { valueTableTable_PC = listTableTable_PC[sss]; valueTableTable_PC.SubNode_PC_PerModule = sSubNodeTracker; ++(moduleFileOwnerInfo.RunningCountOfTablesForSubNodeGeneration); } } // EOForeach eachTableNameLowercase_PC //______ 3 ___________ LOOPs ___________ MT _____________ // These nested loops, thru list _MT objects, meet the upcoming needs of // 'SubNode_MT_PerModule', for MT .htm file content boundaries. sKeysModuleNames_MT = sdictOfModuleTables.Keys; foreach (string sModuleNameLowercaseNoSpaces_MT in sKeysModuleNames_MT) { listTableModules_MT = sdictOfModuleTables[sModuleNameLowercaseNoSpaces_MT]; nSubNodeTracker = 11; sSubNodeTracker = nSubNodeTracker.ToString(); //____ 3.1 _____________ LOOP _______ MT __________________ // Thru table names, from sdict MT .Value items, for one module. // Nested loop. for (uuu = 0; uuu < listTableModules_MT.Count; uuu++) { valueTableModule_MT = listTableModules_MT[uuu]; valueTableModule_MT.SubNode_MT_PerModule = sSubNodeTracker; // // While we have all this info handy, also populate the subnode _MT // // info into the other TM SortedDictionary that has Values of type List for CValueTableModule. // // This additional location will be very handy later to the Outputter of MT .htm. valueTableModule_TM = sdictOfTableModules[valueTableModule_MT.GetTableNameLowercase()]; valueTableModule_TM.SubNode_MT_PerModule = valueTableModule_MT.SubNode_MT_PerModule; if ((uuu >= this.m_runProperties.GetMaxItems_SubNode_CPPC_File_PerModule()) && (0 == (uuu % this.m_runProperties.GetMaxItems_SubNode_CPPC_File_PerModule())) ) { sSubNodeTracker = (++nSubNodeTracker).ToString(); } } //EOFor uuu } // EOForeach sModuleNameLowercaseNoSpaces_MT //_______ 4 ___________ LOOP ___________ TM ____________________ // This loop, thru the one list _TM object, meets the needs of // 'SubNode_TM_All', for .htm files // 'All-TableModule_*.htm'. // (Not that the plural of Modules here is a legacy misnomer.) nSubNodeTracker = 11; sSubNodeTracker = nSubNodeTracker.ToString(); nCountLoops = 0; foreach (CValueTableModule eachValueTableModule_TM in sdictOfTableModules.Values) { ++nCountLoops; eachValueTableModule_TM.SubNode_TM_All = sSubNodeTracker; if ((nCountLoops >= this.m_runProperties.GetMaxItems_SubNode_TM_TablesChunk()) && (0 == (nCountLoops % this.m_runProperties.GetMaxItems_SubNode_TM_TablesChunk())) ) { sSubNodeTracker = (++nSubNodeTracker).ToString(); } } //EOForeach vTM return; }
/// <summary> /// Such as CustTable might be a child of three other tables, according to Dynamics AX 2012 AOT /// (thus three key-value pairs for CustTable). /// </summary> /// <returns>SortedDictionary, key=ChildTableName (+" "+ParentTableName), value=CValueTableTable. /// Never null.</returns> /// <remarks>Caution: In this method pair, GetSortDictFor* ChildParents & ParentChilds, /// each method initializes both itself and the other sdict, when appropriate. /// </remarks> public void BuildSortDictForChildParents_and_ParentChilds() { SysIo.FileStream fileStream; SysIo.StreamReader streamReader; SysCollGen.List <CValueTableTable> listTableTable; CValueTableTable valueTableTable_CP, valueTableTable_PC; char[] cDelims = { '\t' }; string[] sSplits; string sLine = "Initialize."; string sChildTableName, sParentTableName; int nKeyTT; int nLineReadCount = 0; // if (null != this.m_runProperties.m_sdictChildParents) { goto LABEL_RETURN_msj58_LABEL; } else { this.m_runProperties.m_sdictChildParents = new SysCollGen.SortedDictionary // C-P <string, SysCollGen.List <CValueTableTable> >(); this.m_runProperties.m_sdictParentChilds = new SysCollGen.SortedDictionary // P-C <string, SysCollGen.List <CValueTableTable> >(); } using ( fileStream = new SysIo.FileStream ( this.m_runProperties.GetPathToInputDelimFiles() + this.m_runProperties.GetInputDelimFilesCommonPrefix() + this.m_runProperties.GetDelimFileChildParents(), SysIo.FileMode.Open, SysIo.FileAccess.Read, SysIo.FileShare.Read ) ) { streamReader = new SysIo.StreamReader(fileStream); while (streamReader.Peek() >= 0) { try { nLineReadCount++; sLine = streamReader.ReadLine(); sSplits = sLine.Split(cDelims, StringSplitOptions.RemoveEmptyEntries); if (3 > sSplits.Length) { continue; } if (sSplits[0].StartsWith("//")) { continue; } if (sSplits[0].Trim().Length == 0) { continue; } nKeyTT = Convert.ToInt32(sSplits[0]); sChildTableName = sSplits[1]; sParentTableName = sSplits[2]; valueTableTable_CP = new CValueTableTable ( sParentTableName, // IComparable. nKeyTT, sChildTableName, sParentTableName ); // Child-Parents if (this.m_runProperties.m_sdictChildParents.ContainsKey(valueTableTable_CP.GetKeyChildDelimParent())) { listTableTable = this.m_runProperties.m_sdictChildParents[valueTableTable_CP.GetKeyChildDelimParent()]; listTableTable.Add(valueTableTable_CP); // Also SORTED, by Parent, earlier during X++ time. } else // ! ContainsKey { listTableTable = new SysCollGen.List <CValueTableTable>(); listTableTable.Add(valueTableTable_CP); this.m_runProperties.m_sdictChildParents.Add ( valueTableTable_CP.GetKeyChildDelimParent(), listTableTable ); } // Parent-Childs // Clone vtt, need different IComparable string to sort by. valueTableTable_PC = valueTableTable_CP.CloneThis(valueTableTable_CP.GetTableNameChild()); if (this.m_runProperties.m_sdictParentChilds.ContainsKey(valueTableTable_PC.GetKeyParentDelimChild())) { listTableTable = this.m_runProperties.m_sdictParentChilds[valueTableTable_PC.GetKeyParentDelimChild()]; listTableTable.Add(valueTableTable_PC); // SORTED, by Child, by IComparable. } else // ! ContainsKey { listTableTable = new SysCollGen.List <CValueTableTable>(); listTableTable.Add(valueTableTable_PC); this.m_runProperties.m_sdictParentChilds.Add ( valueTableTable_PC.GetKeyParentDelimChild(), listTableTable ); } } catch (Exception e) { Console.WriteLine("Error_cys78: nLineReadCount={0}, sLine={1}", nLineReadCount, sLine); throw e; } } // EOWhile peek. } // EOUsing FileStream. LABEL_RETURN_msj58_LABEL :; if (null == this.m_runProperties.m_sdictChildParents) { this.m_runProperties.m_sdictChildParents = new SysCollGen.SortedDictionary <string, SysCollGen.List <CValueTableTable> >(); this.m_runProperties.m_sdictParentChilds = new SysCollGen.SortedDictionary <string, SysCollGen.List <CValueTableTable> >(); } return; }