Beispiel #1
0
        public IEnumerable <ITransformationResult> Transform(IExtractionResult <FormatObject> extract)
        {
            var fileNameExtract = (FileNameExtractionResult)extract;

            if (!(TempLocation.Exists))
            {
                TempLocation.Create();
            }

            var extractedFiles = new List <FileInfo>();

            foreach (var file in Compression.UnZip(new FileInfo(fileNameExtract.FileFullName), TempLocation))
            {
                extractedFiles.Add(file);
            }

            var binnedOneMinute = Cleaner.CleanToOneMinute(extractedFiles);

            foreach (var pair in binnedOneMinute.Keys)
            {
                yield return(new OneMinuteTransformationResult
                {
                    OneMinuteData = binnedOneMinute[pair],
                    Pair = pair,
                    ExtractedFiles = extractedFiles,
                });
            }
        }
Beispiel #2
0
        public override IEnumerable <ITransformationResult> TransformFileExtract(IFileNameExtractionResult fileNameExtract)
        {
            if (!(TempLocation.Exists))
            {
                TempLocation.Create();
            }

            var extractedFiles = new List <FileInfo>();

            foreach (string fileName in fileNameExtract.FileFullNames)
            {
                foreach (var file in Compression.UnZip(new FileInfo(fileName), TempLocation))
                {
                    extractedFiles.Add(file);
                }
            }

            var binnedOneMinute = Cleaner.CleanToOneMinute(extractedFiles);

            // get all the results at once to avoid unecessary d/b access
            var data = new List <TransformationData>();

            foreach (var period in Enum.GetValues(typeof(Periods)).Cast <Periods>().Where(x => ((x != Periods.NotSet))))
            {
                foreach (var pair in binnedOneMinute.Keys)
                {
                    foreach (var offset in AlignedIntervals.Instance.GetMinimumDistinctOffsets(_offsets, PeriodIntervals.Instance[period]))
                    {
                        data.Add(new TransformationData()
                        {
                            Data          = Binner.Bin(binnedOneMinute[pair], period, TimeZoneInfo.Utc, offset),
                            OffsetInHours = offset.Hours,
                            Pair          = pair,
                            Period        = period
                        });
                    }
                }
            }

            yield return(new TransformationResult()
            {
                Data = data, ExtractedFiles = extractedFiles
            });
        }