private void CrossesYesterdayValueComparison(CriteriaSetObj criteriaObj, ThresholdComparison compare)
        {
            int    rawDataChunkIndex;
            int    stockDataIndex;
            double columnValue = 0.0, thresholdCrossed = 0.0;
            ThresholdComparison    comparison = compare;
            CriteriaSetObj         criteria = criteriaObj;
            ThresholdColumn        crossesColumn = criteria.postAggObj.thresholdColumn;
            IReadOnlyList <double> thresholds = criteria.postAggObj.GetRefToThresholdValues();
            IReadOnlyDictionary <string, AggValues> todaysParsedDataDictionary = criteria.GetRefToAggResults();
            IReadOnlyDictionary <string, AggValues> yesterdaysParsedDataDictionary = criteria.GetRefToYesterdayAggResults();
            AggValues todaysAgg;
            AggValues yestedayAgg;
            bool      keyExistsYesterday, todayGreaterYesterday;

            if (crossesColumn == ThresholdColumn.Undefiend)
            {
                // TODO: do something else
                return;
            }

            WriteThresholdHeader(criteria);

            foreach (string key in todaysParsedDataDictionary.Keys)
            {
                todaysParsedDataDictionary.TryGetValue(key, out todaysAgg); // should always find something
                keyExistsYesterday = yesterdaysParsedDataDictionary.TryGetValue(key, out yestedayAgg);
                if (!keyExistsYesterday)
                {
                    yestedayAgg = new AggValues(); // all values are 0 then.
                }

                switch (crossesColumn)
                {
                case ThresholdColumn.PrecentageSharesHeld:
                {
                    columnValue = todaysAgg.percentageSharesHeld;
                    if (columnValue > yestedayAgg.percentageSharesHeld)
                    {
                        todayGreaterYesterday = true;
                    }
                    else
                    {
                        todayGreaterYesterday = false;
                    }
                    thresholdCrossed = PreciseThresholdCrossed(todayGreaterYesterday, columnValue, thresholds);
                    break;
                }

                case ThresholdColumn.SharesHeld:
                {
                    columnValue = todaysAgg.sharesHeld;
                    if (columnValue > yestedayAgg.sharesHeld)
                    {
                        todayGreaterYesterday = true;
                    }
                    else
                    {
                        todayGreaterYesterday = false;
                    }
                    thresholdCrossed = PreciseThresholdCrossed(todayGreaterYesterday, columnValue, thresholds);
                    break;
                }

                case ThresholdColumn.Value:
                {
                    columnValue = todaysAgg.value;
                    if (columnValue > yestedayAgg.value)
                    {
                        todayGreaterYesterday = true;
                    }
                    else
                    {
                        todayGreaterYesterday = false;
                    }
                    thresholdCrossed = PreciseThresholdCrossed(todayGreaterYesterday, columnValue, thresholds);
                    break;
                }

                default:
                {
                    break;
                }
                }

                // TODO: write to files
                criteriaFilterWriter.WriteLine(GetAggValuesCommaSeparatedString(key, todaysAgg));

                IReadOnlyList <uint> unaggregatedDictEntry = todaysAgg.GetRefToRowsInChunk();
                for (int i = 0; i < unaggregatedDictEntry.Count; i++)
                {
                    rawDataChunkIndex = (int)unaggregatedDictEntry[i] >> 16;
                    stockDataIndex    = (int)unaggregatedDictEntry[i] & 0xffff;
                    StockDataEntry sde = Global.parsedRawData[rawDataChunkIndex].chunkDataParsed[stockDataIndex];
                    criteriaFilterDetailsWriter.WriteLine(GetCommaSeparatedStockDataEntryWithKey(sde, key));
                }

                criteriaThresholdWriter.WriteLine(GetCommaSeparatedThresholdEntry(key, columnValue, thresholdCrossed));
            }

            criteriaFilterWriter.Dispose();
            criteriaFilterDetailsWriter.Dispose();
            criteriaThresholdWriter.Dispose();
        }
        private void ValueOfColumnComparison(CriteriaSetObj criteriaObj, ThresholdComparison compare)
        {
            int rawDataChunkIndex;
            int stockDataIndex;
            ThresholdComparison comparison = compare;
            CriteriaSetObj      criteria   = criteriaObj;
            ThresholdColumn     column     = criteria.postAggObj.thresholdColumn;
            IReadOnlyDictionary <string, AggValues> readOnlyAggResults = criteria.GetRefToAggResults();
            AggValues aggValue;
            IReadOnlyList <double> thresholdValues = criteria.postAggObj.GetRefToThresholdValues(); // should only contain 1 value.
            double thresholdValue = thresholdValues[0];                                             // should be only 1 value here'
            double columnValue    = 0.0;
            bool   thresholdCheck = false;

            if (column == ThresholdColumn.Undefiend)
            {
                // TODO: Do something if it is undefined, shouldn't be.
                return;
            }

            WriteThresholdHeader(criteria);

            foreach (string key in readOnlyAggResults.Keys)
            {
                readOnlyAggResults.TryGetValue(key, out aggValue);

                switch (column)
                {
                case ThresholdColumn.PrecentageSharesHeld:
                {
                    columnValue    = aggValue.percentageSharesHeld;
                    thresholdCheck = ValuePassesComparison(columnValue, thresholdValue, comparison);
                    break;
                }

                case ThresholdColumn.SharesHeld:
                {
                    columnValue    = aggValue.sharesHeld;
                    thresholdCheck = ValuePassesComparison(columnValue, thresholdValue, comparison);
                    break;
                }

                case ThresholdColumn.Value:
                {
                    columnValue    = aggValue.value;
                    thresholdCheck = ValuePassesComparison(columnValue, thresholdValue, comparison);
                    break;
                }

                default:
                {
                    break;
                }
                }

                if (thresholdCheck)
                {
                    criteriaFilterWriter.WriteLine(GetAggValuesCommaSeparatedString(key, aggValue));

                    IReadOnlyList <uint> unaggregatedDictEntry = aggValue.GetRefToRowsInChunk();
                    for (int i = 0; i < unaggregatedDictEntry.Count; i++)
                    {
                        rawDataChunkIndex = (int)unaggregatedDictEntry[i] >> 16;
                        stockDataIndex    = (int)unaggregatedDictEntry[i] & 0xffff;
                        StockDataEntry sde = Global.parsedRawData[rawDataChunkIndex].chunkDataParsed[stockDataIndex];
                        criteriaFilterDetailsWriter.WriteLine(GetCommaSeparatedStockDataEntryWithKey(sde, key));
                    }
                    criteriaThresholdWriter.WriteLine(GetCommaSeparatedThresholdEntry(key, columnValue, thresholdValue));
                }
            }

            criteriaFilterWriter.Dispose();
            criteriaFilterDetailsWriter.Dispose();
            criteriaThresholdWriter.Dispose();
        }