public static void LogRelatedArticles(IProcessConfigLogger logger, IPayrollArticle article, IPayrollArticle[] articles, string testName) { if (logger != null) { logger.LogRelatedArticles(article, articles, testName); } }
public static void LogArticlesNames(IProcessConfigLogger logger, IPayrollArticle[] articles, IDictionary <uint, IPayrollConcept> concepts, string testName) { if (logger != null) { logger.LogArticlesNames(articles, concepts, testName); } }
public static void LogDependentCodeArticlesInfo(IProcessConfigLogger logger, uint articleCode, IPayrollArticle[] articles, string testName) { if (logger != null) { logger.LogDependentCodeArticlesInfo(articleCode, articles, testName); } }
public static void LogPendingArticles(IProcessConfigLogger logger, IPayrollArticle article, SymbolName[] callings, IPayrollArticle[] articles, string testName) { if (logger != null) { logger.LogPendingArticles(article, callings, articles, testName); } }
public static void LogRelatedArticlesInModels(IProcessConfigLogger logger, IDictionary <uint, IPayrollArticle> models, string testName) { if (logger != null) { logger.LogRelatedArticlesInModels(models, testName); } }
public static void LogDependentArticlesCollection(IProcessConfigLogger logger, IDictionary <uint, IPayrollArticle[]> collection, string testName) { if (logger != null) { logger.LogDependentArticlesCollection(collection, testName); } }
public static void LogListArticlesUnderArticle(IProcessConfigLogger logger, IPayrollArticle article, IPayrollArticle[] articles, string testName) { if (logger != null) { logger.LogListArticlesUnderArticle(article, articles, testName); } }
public static void CloseLogStream(IProcessConfigLogger logger) { if (logger != null) { logger.CloseLogStream(); } }
public static void OpenLogStream(IProcessConfigLogger logger, string testName) { if (logger != null) { logger.OpenLogStream(testName); } }
public static void LogAppendMessageInfo(IProcessConfigLogger logger, string message, string testName) { if (logger != null) { logger.LogAppendMessageInfo(message, testName); } }
public void TestSetup() { logger = new TestConfigLogger("TestArticleCollection"); testConfig = ProcessConfigSetCzModule.CreateModule(logger); testConfig.InitModule(); logger.CloseLogStream(); }
private static IPayrollArticle[] CollectRelatedArticles(IDictionary <uint, IPayrollArticle[]> initialDict, uint articleCode, IPayrollArticle[] pendingArticles, IDictionary <uint, IPayrollArticle[]> pendingDict, IProcessConfigLogger logger) { var callingArticles = new SymbolName[0]; var relatedList = pendingArticles.Aggregate(new IPayrollArticle[0], (agr, article) => agr.Concat(ResolveArticleDependency(initialDict, article, callingArticles, pendingDict, logger)).ToArray()); var articleList = relatedList.Distinct().OrderBy(x => x.ArticleSymbol()).ToArray(); return(articleList); }
public void InitRelatedArticles(IProcessConfigLogger logger) { var pendingArticles = ArticleCodeListBuilder <AIDX> .BuildPendingCodesDict(this); var initialArticles = ArticleCodeListBuilder <AIDX> .BuildRelatedCodesDict(this); var relatedArticles = ArticleDependencyBuilder.CollectArticles(pendingArticles, initialArticles, logger); var relatedInitList = ArticleObjectListBuilder <AIDX> .BuildRelatedArticleDict(relatedArticles, this); var relatedSortList = ArticleSortoutBuilder.BuildSortedArticleDict(relatedInitList); UpdateRelatedArticles(relatedSortList, logger); }
private static IDictionary <uint, IPayrollArticle[]> CollectDependentArticles( IDictionary <uint, IPayrollArticle[]> initialDict, uint articleCode, IPayrollArticle[] pendingArticles, IDictionary <uint, IPayrollArticle[]> pendingDict, IProcessConfigLogger logger) { LoggerWrapper.LogAppendMessageInfo(logger, ">>>>>", "CollectRelated"); var resultList = CollectRelatedArticles(initialDict, articleCode, pendingArticles, pendingDict, logger); LoggerWrapper.LogAppendMessageInfo(logger, "<<<<<", "CollectRelated"); LoggerWrapper.LogDependentCodeArticlesInfo(logger, articleCode, resultList, "ConceptArticles"); var relatedDict = SortAndMergeIntoDictionary(initialDict, articleCode, resultList); return(relatedDict); }
private static IDictionary <uint, uint[]> CollectRelatedArticles( IDictionary <uint, uint[]> relatedInit, uint articleCode, uint[] callingList, uint pendingCode, uint[] pendingList, IDictionary <uint, uint[]> dependencyDict, IProcessConfigLogger logger) { if (articleCode == 0) { uint[] initialList = (uint[])pendingList.Clone(); var composeList = pendingList.Aggregate(initialList, (agrList, article) => ComposeRelatedArticles(agrList, article, relatedInit)).ToArray(); return(MergeIntoDictionary(relatedInit, pendingCode, composeList)); } bool relatedExists = relatedInit.ContainsKey(articleCode); if (relatedExists == true) { return(relatedInit); } uint[] articleList = dependencyDict.FirstOrDefault(x => x.Key == articleCode).Value; if (articleList == null || articleList.Length == 0) { return(MergeIntoDictionary(relatedInit, articleCode, EMPTY_ARTICLE_CODE_LIST)); } VerifyCircularDependency(articleCode, callingList); uint[] callingPath = callingList.Concat(new uint[] { articleCode }).ToArray(); uint[] articleCodes = articleList.Select(x => x).Concat(new uint[] { 0 }).ToArray(); var collectedDict = articleCodes.Aggregate(relatedInit, (agr, code) => CollectRelatedArticles(agr, code, callingPath, articleCode, articleList, dependencyDict, logger). ToDictionary(key => key.Key, val => val.Value)); return(collectedDict); }
protected ProcessConfigModule(IProcessConfigLogger logger) { Logger = logger; }
private ProcessConfigSetCzModule(IProcessConfigLogger logger) : base(logger) { ArticlesCollection = new ConfigSetCzArticleCollection(); ConceptsCollection = new ConfigSetCzConceptCollection(); }
public static IDictionary <uint, uint[]> CollectArticles( IDictionary <uint, uint[]> dependencyDict, IDictionary <uint, uint[]> initialDict, IProcessConfigLogger logger) { var relatedDict = initialDict.ToDictionary(key => key.Key, val => val.Value); var articleCodes = dependencyDict.Keys; uint pendingCode = 0; uint[] pendingList = EMPTY_ARTICLE_CODE_LIST; uint[] callingList = EMPTY_ARTICLE_CODE_LIST; var collectedDict = articleCodes.Aggregate(relatedDict, (agr, code) => CollectRelatedArticles(agr, code, callingList, pendingCode, pendingList, dependencyDict, logger). ToDictionary(key => key.Key, val => val.Value)); return(collectedDict); }
public static IProcessConfig CreateModule(IProcessConfigLogger logger) { IProcessConfig module = new ProcessConfigSetCzModule(logger); return(module); }
private static IPayrollArticle[] ResolveArticleDependency(IDictionary <uint, IPayrollArticle[]> initialDict, IPayrollArticle article, SymbolName[] callingArticles, IDictionary <uint, IPayrollArticle[]> pendingDict, IProcessConfigLogger logger) { var relatedArticles = CollectFromRelated(initialDict, article, pendingDict); bool foundInRelated = relatedArticles != null; if (foundInRelated) { LoggerWrapper.LogRelatedArticles(logger, article, relatedArticles, "CollectRelated"); return(relatedArticles); } else { relatedArticles = CollectFromPending(initialDict, article, callingArticles, pendingDict, logger); LoggerWrapper.LogPendingArticles(logger, article, callingArticles, relatedArticles, "CollectRelated"); return(relatedArticles); } }
private void UpdateRelatedArticles(IDictionary <uint, IPayrollArticle[]> relatedDict, IProcessConfigLogger logger) { foreach (var article in Models) { var articleCode = article.Key; var articleItem = article.Value; IPayrollArticle[] relatedArticles = null; bool existInDictionary = relatedDict.TryGetValue(articleCode, out relatedArticles); if (existInDictionary) { articleItem.UpdateRelatedArticles(relatedArticles); } else { articleItem.UpdateRelatedArticles(EMPTY_ARTICLE_LIST); } LoggerWrapper.LogListArticlesUnderArticle(logger, articleItem, relatedArticles, "UpdateRelatedArticles"); } }
private static IPayrollArticle[] CollectFromPending(IDictionary <uint, IPayrollArticle[]> relatedDict, IPayrollArticle article, SymbolName[] articlePath, IDictionary <uint, IPayrollArticle[]> pendingDict, IProcessConfigLogger logger) { uint articleCode = article.ArticleCode(); bool skipExecToRelated = relatedDict.ContainsKey(articleCode); if (skipExecToRelated) { return(null); } VerifyCircularDependency(article, articlePath, articleCode); var initialArticles = new IPayrollArticle[] { article }; var callingArticles = articlePath.Concat(new SymbolName[] { article.ArticleSymbol() }).ToArray(); var pendingArticles = FindArticlesInDictionary(pendingDict, article); var collectArticles = pendingArticles.Aggregate(initialArticles, (agr, articleSource) => agr.Concat(ResolveArticleDependency(relatedDict, articleSource, callingArticles, pendingDict, logger)).ToArray()); var relatedArticles = collectArticles.Distinct().OrderBy(x => x.ArticleSymbol()).ToArray(); return(relatedArticles); }
public static IDictionary <uint, IPayrollArticle[]> CollectArticles( IDictionary <uint, IPayrollArticle[]> pendingDict, IDictionary <uint, IPayrollArticle[]> initialDict, IProcessConfigLogger logger) { var relatedDict = pendingDict.Aggregate(initialDict, (agr, pair) => CollectDependentArticles(agr, pair.Key, pair.Value, pendingDict, logger). ToDictionary(key => key.Key, val => val.Value)); LoggerWrapper.LogDependentArticlesCollection(logger, relatedDict, "CollectRelatedCollection"); return(relatedDict); }