示例#1
0
        static void Main(string[] args)
        {
            if (args.Length < 2)
            {
                Console.WriteLine($"Arguments missing - /path/to/data and /path/to/output are required.");
                Environment.Exit(1);
            }

            CollectedDataStruct collectedData = new CollectedDataStruct(
                new ConcurrentDictionary <string, ConcurrentDictionary <byte, ConcurrentBag <float> > >(),
                new ConcurrentDictionary <string, ConcurrentDictionary <byte, ConcurrentBag <float> > >(),
                new ConcurrentDictionary <string, ConcurrentDictionary <byte, ConcurrentBag <float> > >(),
                new ConcurrentDictionary <string, ConcurrentDictionary <byte, ConcurrentBag <bool> > >()
                );

            Console.WriteLine("FileBlaster6000 is starting. Reading files..");

            DateTime start            = DateTime.Now;
            var      fileListProvider = new FileListProvider(args[0]); // Source path
            var      reportProvider   = new ReportProvider(args[1]);   // target dir

            Parallel.ForEach(fileListProvider.FilePathList, filePath =>
            {
                FileDataProvider fileDataProvider = new FileDataProvider(ref collectedData);
                fileDataProvider.GetContents(filePath);
            });

            Console.WriteLine((DateTime.Now - start) + " ### Files parsed, calculating...");

            reportProvider.GenerateReportFile(ref collectedData);
            Console.WriteLine((DateTime.Now - start) + " ### ..finished! Press any key.");
            Console.ReadLine();
        }
        public void GenerateReportFile(ref CollectedDataStruct collectedDataRef)
        {
            DateTime time = DateTime.Now;
            string   FormattedFilename =
                $"report-{time.Year}-{time.Month}-{time.Day}_{time.Hour}{time.Minute}{time.Second}.csv";

            using (var file = new StreamWriter(_path + FormattedFilename))
            {
                file.WriteLine("BAND,PCL,AvgLow TxPower,AvgOK TxPower,AvgHi TxPower,PASS,FAIL");

                foreach (var band in collectedDataRef.PassData)
                {
                    foreach (var pcl in band.Value)
                    {
                        file.Write(band.Key + "," + pcl.Key + ",");
                        file.Write(collectedDataRef.MinTxPowerData[band.Key][pcl.Key].Average() + ",");
                        file.Write(collectedDataRef.OkTxPowerData[band.Key][pcl.Key].Average() + ",");
                        file.Write(collectedDataRef.MaxTxPowerData[band.Key][pcl.Key].Average() + ",");
                        file.WriteLine(pcl.Value.Count(c => c) + "," + pcl.Value.Count(c => !c));
                    }
                }
            }
        }
 public FileDataProvider(ref CollectedDataStruct collectedData)
 {
     _collectedDataRef = collectedData;
 }