示例#1
0
 public void ReadEarthQuack()
 {
     using (StreamReader reader = File.OpenText(fileFullPath))
     {
         while (!reader.EndOfStream)
         {
             string line = reader.ReadLine();
             parts = line.Split(',');
             if (parts[0] != "time")
             {
                 SetFields  setFields  = new SetFields();
                 Earthquake earthquake = setFields.SetField(parts);
                 networkIdentifier = parts[11];
                 if (Count() == 0)
                 {
                     InsertEarthQuack insertEarthQuack = new InsertEarthQuack();
                     insertEarthQuack.InsertEarthQuackM(earthquake, _connectionString);
                 }
                 else
                 {
                     _logger.Record(ServiceName.EarthquakeService, $"Found existing record: {networkIdentifier}");
                 }
             }
         }
     }
 }
示例#2
0
        public Earthquake SetField(string[] parts)
        {
            Earthquake earthquake = new Earthquake();

            earthquake.EventTime           = Convert.ToDateTime(parts[0]);
            earthquake.Latitude            = SetDefaultDecimal(parts[1]);
            earthquake.Longitude           = SetDefaultDecimal(parts[2]);
            earthquake.Depth               = SetDefaultDecimal(parts[3]);
            earthquake.Magnitude           = SetDefaultDecimal(parts[4]);
            earthquake.MagnitudeType       = parts[5];
            earthquake.SeismicStations     = SetDefaultInt(parts[6]);
            earthquake.AzimuthalGap        = SetDefaultDecimal(parts[7]);
            earthquake.EpiCenterDistance   = SetDefaultDecimal(parts[8]);
            earthquake.RootMeanSquare      = SetDefaultDecimal(parts[9]);
            earthquake.DataContributorId   = parts[10];
            earthquake.NetworkIdentifier   = parts[11];
            earthquake.RecentUpdateTime    = Convert.ToDateTime(parts[12]);
            earthquake.GeographicRegion    = ($"{parts[13]},{parts[14]}");
            earthquake.SeismicEventType    = parts[15];
            earthquake.HorizontalError     = SetDefaultDecimal(parts[16]);
            earthquake.DepthError          = SetDefaultDecimal(parts[17]);
            earthquake.MagnitudeError      = SetDefaultDecimal(parts[18]);
            earthquake.MagniteOfEarthquake = SetDefaultInt(parts[19]);
            earthquake.EventsReviewed      = parts[20];
            earthquake.LocationSource      = parts[21];
            earthquake.MagnitudeSource     = parts[22];
            return(earthquake);
        }
示例#3
0
        public void InsertEarthQuackM(Earthquake earthquake, string connectionString)
        {
            Earthquake _earthquakeInt    = earthquake;
            string     _connectionString = connectionString;

            using (SqlConnection connection = new SqlConnection(_connectionString))
            {
                connection.Insert(_earthquakeInt);
            }
        }