using mseedChart.MainModule.Models;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;

namespace mseedChart.Core
{
    public static class RegionNames
    {
        public const string ContentRegion = "ContentRegion";

        public static string MseedFilePath="D:\\EwsCache\\Mseed";


        public static string TxtFilePath = "D:\\EwsCache\\Txt";


        public static string DataTypeString = "A";


        public static Dictionary<string, StationModel> StationDic { get; set; }


        public static Dictionary<string, StationModel> CreateStationFromCSV(string fn)
        {
            Dictionary<string, StationModel> stations = new Dictionary<string, StationModel>();

             var datas= File.ReadLines(fn);

            foreach (var item in datas)
            {
                if (item.Contains("net")) continue;
                string[] row = item.Split(',');
                StationModel model = new StationModel();
                model.Name = row[1].ToString();
                model.E = double.Parse(row[2].ToString());
                model.N = double.Parse(row[3].ToString());
                model.Z = double.Parse(row[4].ToString());
                model.Sens = double.Parse(row[5].ToString());
                model.BeginUseTime = DateTime.Parse(row[6].ToString());
                model.StopUseTime = DateTime.Parse(row[7].ToString());
                stations.Add(model.Name, model);
            }     
            return stations;
        }

    }

}
