Esempio n. 1
0
        /// <summary>
        /// Process the specified csv file.
        /// </summary>
        public void Process()
        {
            var filesList = Directory.GetFiles(_csvSettings.CsvFilePath);

            if (filesList.Length > 0)
            {
                foreach (var file in filesList)
                {
                    if (Path.GetFileName(file).StartsWith("TOU_"))
                    {
                        var touRecords = _touFileProcessor.GetAllRecords(file);
                        var touMedian  = _touFileProcessor.CalculateMedian(touRecords);
                        foreach (var record in touRecords)
                        {
                            if (record.Energy < (touMedian * 0.8M) || record.Energy > (touMedian * 1.2M))
                            {
                                this.PrintRecord(Path.GetFileName(file), record.DateTime, record.Energy, touMedian);
                            }
                        }
                    }
                    else if (Path.GetFileName(file).StartsWith("LP_"))
                    {
                        var lpRecords = _lpFileProcessor.GetAllRecords(file);
                        var lpMedian  = _lpFileProcessor.CalculateMedian(lpRecords);
                        foreach (var record in lpRecords)
                        {
                            if (record.Value < (lpMedian * 0.8M) || record.Value > (lpMedian * 1.2M))
                            {
                                this.PrintRecord(Path.GetFileName(file), record.DateTime, record.Value, lpMedian);
                            }
                        }
                    }
                }
            }
        }