public void AddResult(ResultMatchObject resMatch) { resultMatchList.Add(resMatch); }
public List<Dictionary<string, object>> MatchOutputToResult(ResultHolder dataHolder) { ResultHolder.MultiRowResult multiResult = dataHolder.multiRows; List<Dictionary<string, object>> matchList = new List<Dictionary<string, object>>(); int listSize = Math.Max(multiResult.multiOutput.Count, multiResult.multiResult.Count); for (int nrOfResults = 0; nrOfResults < listSize; nrOfResults++) { matchList.Add(null); } List<Dictionary<string, object>> resultCopy = new List<Dictionary<string, object>>(); foreach (Dictionary<string, object> result in multiResult.multiResult) { resultCopy.Add(result); } List<ResultDicObject> defaultResultList = new List<ResultDicObject>(); int defaultIndex = 0; foreach (Dictionary<string, object> result in multiResult.multiResult) { defaultResultList.Add(new ResultDicObject(defaultIndex, result)); defaultIndex++; } List<OutMatchObject> rowOutMatch = new List<OutMatchObject>(); int outDicCount = 0; foreach (Dictionary<string, string> output in multiResult.multiOutput) { OutMatchObject outMatch = new OutMatchObject(outDicCount); int resultDicCounter = 0; bool fullMatchFound = false; int fullMatchResultIndex = 0; foreach (ResultDicObject resultDicObj in defaultResultList) { int nrOfMatches = 0; foreach (string key in dataHolder.multiRowKeys) { if (IsDataMatching(key, output, resultDicObj.resultDic, dataHolder.toleranceDic)) { nrOfMatches++; } } if (nrOfMatches == dataHolder.multiRowKeys.Count) { fullMatchFound = true; fullMatchResultIndex = resultDicObj.dicItemIndex; break; } ResultMatchObject resMatch = new ResultMatchObject(resultDicObj.dicItemIndex, nrOfMatches); outMatch.AddResult(resMatch); resultDicCounter++; } if (fullMatchFound) { matchList[outDicCount] = resultCopy[fullMatchResultIndex]; resultCopy[fullMatchResultIndex] = null; defaultResultList.RemoveAt(resultDicCounter); foreach (OutMatchObject outMatch2 in rowOutMatch) { outMatch2.RemoveResult(resultDicCounter); } } else { rowOutMatch.Add(outMatch); } outDicCount++; } PrintMatchMatrix(rowOutMatch); int rowSize = System.Math.Min(rowOutMatch.Count, defaultResultList.Count); for (int nrOfRows = 0; nrOfRows < rowSize; nrOfRows++) { int outItemIndex = 0; int highestOutItemIndex = 0; MatchObject highestMatchObject = null; foreach (OutMatchObject outMatch in rowOutMatch) { MatchObject matchObject = outMatch.GetHighestMatch(); if (highestMatchObject == null || matchObject.highestMatch > highestMatchObject.highestMatch) { highestMatchObject = matchObject; highestOutItemIndex = outItemIndex; } outItemIndex++; } if (highestMatchObject != null) { matchList[highestMatchObject.outIndex] = resultCopy[highestMatchObject.resultIndex]; resultCopy[highestMatchObject.resultIndex] = null; rowOutMatch.RemoveAt(highestOutItemIndex); foreach (OutMatchObject outMatch in rowOutMatch) { outMatch.RemoveResult(highestMatchObject.resultItemIndex); } } } if (multiResult.multiOutput.Count < listSize) { int matchIndex = multiResult.multiOutput.Count; foreach (Dictionary<string, object> resultDic in resultCopy) { if (resultDic != null) { matchList[matchIndex] = resultDic; matchIndex++; } } } return matchList; }