예제 #1
0
        static async Task LoadStates(RiverRepository azureRepo)
        {
            var states = GetStateCodes();

            foreach (var state in states)
            {
                IDictionary <string, RiverEntity> stateRivers = new Dictionary <string, RiverEntity>();
                var data = azureRepo.GetRiverData(state.Value).Result;
                foreach (var ts in data.Value.TimeSeries)
                {
                    var river = new RiverEntity()
                    {
                        Name         = ts.SourceInfo.SiteName,
                        Latitude     = ts.SourceInfo.Geolocation.GeogLocation.Latitude,
                        Longitude    = ts.SourceInfo.Geolocation.GeogLocation.Longitude,
                        Srs          = ts.SourceInfo.Geolocation.GeogLocation.SRS,
                        RiverId      = ts.SourceInfo.SiteCode[0].Value,
                        State        = state.Key,
                        StateCode    = state.Value,
                        PartitionKey = "search",
                        ETag         = "river_Insert",
                        RowKey       = ts.SourceInfo.SiteCode[0].Value,
                        Date         = DateTime.Now
                    };
                    if (!stateRivers.ContainsKey(river.RiverId))
                    {
                        stateRivers.Add(river.RiverId, river);
                        await azureRepo.InsertRiverData(river);

                        Console.WriteLine($"{river.Name}, {river.RiverId} {river.State}");
                    }
                }
                // Console.WriteLine(state.Value);
            }
        }
 public async Task InsertRiverData(RiverEntity aRiver)
 {
     await folders.PostStorageTableAsync(aRiver);
 }