示例#1
0
        protected virtual bool GetMatchedRecords(
            IOrderedEnumerable<IRecord> recordsFilteredByDate, 
            IModelInput modelInput,
            out IDictionary<string, IList<IRecord>> matchedRecords
        )
        {
            matchedRecords = new Dictionary<string, IList<IRecord>>();
            if (!recordsFilteredByDate.AnySave())
            {
                return false;
            }

            foreach (var record in recordsFilteredByDate)
            {
                foreach (var term in modelInput.FilterTerms)
                {
                    var distinctMatchedDescription = GetMatchedDistinctDescription(record.Description, term);
                    record.DistinctDescription = distinctMatchedDescription;
                    if (string.IsNullOrEmpty(distinctMatchedDescription))
                    {
                        continue;
                    }
                    if (matchedRecords.ContainsKey(distinctMatchedDescription))
                    {
                        matchedRecords[distinctMatchedDescription].Add(record);
                    }
                    else
                    {
                        matchedRecords.Add(distinctMatchedDescription, new List<IRecord>() { record });
                    }
                    break;
                }
            }
            return matchedRecords.Any();
        }
示例#2
0
        protected virtual bool GetMatchedRecords
        (
            IOrderedEnumerable <IRecord> recordsFilteredByDate,
            IModelInput modelInput,
            out IDictionary <string, IList <IRecord> > matchedRecords
        )
        {
            matchedRecords = new Dictionary <string, IList <IRecord> >();
            if (!recordsFilteredByDate.AnySave())
            {
                return(false);
            }

            foreach (var record in recordsFilteredByDate)
            {
                foreach (var term in modelInput.FilterTerms)
                {
                    var distinctMatchedDescription = GetMatchedDistinctDescription(record.Description, term);
                    record.DistinctDescription = distinctMatchedDescription;
                    if (string.IsNullOrEmpty(distinctMatchedDescription))
                    {
                        continue;
                    }
                    if (matchedRecords.ContainsKey(distinctMatchedDescription))
                    {
                        matchedRecords[distinctMatchedDescription].Add(record);
                    }
                    else
                    {
                        matchedRecords.Add(distinctMatchedDescription, new List <IRecord>()
                        {
                            record
                        });
                    }
                    break;
                }
            }
            return(matchedRecords.Any());
        }