async Task task_pullMeteo(int start, int finish) { //uncomment this to download the csv file from nasa, it will cause a huge delay in opening the window though WebClient client = new WebClient(); client.DownloadFile("https://data.nasa.gov/api/views/gh4g-9sfh/rows.csv?accessType=DOWNLOAD", "Meteorites.csv"); MeteoLoadedTextBlock.Text = "Loading..."; System.Diagnostics.Debug.Write("\nInitializing data...\n"); ExternalReader read = new ExternalReader("Meteorites.csv"); List <Meteorite> currList = meteoDB.MeteoTable.ToList(); meteoDB.MeteoTable.DeleteAllOnSubmit(currList); List <Meteorite> meteorites = read.ReturnList(); meteoDB.SubmitChanges(); List <Meteorite> appendedList = appendList(meteorites, start, finish); Task <bool> updatingMeteoDb = updateMeteoDatabase(appendedList); bool done = await updatingMeteoDb; if (done) { meteoCollection = new ObservableCollection <Meteorite>(meteoDB.MeteoTable.ToList()); MeteoDataGrid.ItemsSource = meteoCollection; MeteoDataGrid.Items.Refresh(); System.Diagnostics.Debug.Write("\nSuccessfully pulled\n"); MeteoLoadedTextBlock.Text = finish.ToString() + " meteorites loaded."; } }
/// <summary> /// Returns an object from the pipe. If pipe is empty returns null. /// This will try the ExternalReader if there are no queued objects. /// </summary> /// <returns> /// object that is retrieved, or AutomationNull.Value if none /// </returns> internal object Retrieve() { if (ObjectQueue != null && ObjectQueue.Count != 0) { return(ObjectQueue.Dequeue()); } else if (_enumeratorToProcess != null) { if (_enumeratorToProcessIsEmpty) { return(AutomationNull.Value); } if (!ParserOps.MoveNext(_context, null, _enumeratorToProcess)) { _enumeratorToProcessIsEmpty = true; return(AutomationNull.Value); } return(ParserOps.Current(null, _enumeratorToProcess)); } else if (ExternalReader != null) { try { object o = ExternalReader.Read(); if (AutomationNull.Value == o) { // NOTICE-2004/06/08-JonN 963367 // The fix to this bug involves making one last // attempt to read from the pipeline in DoComplete. // We should be sure to not hit the ExternalReader // again if it already reported completion. ExternalReader = null; } return(o); } catch (PipelineClosedException) { return(AutomationNull.Value); } catch (ObjectDisposedException) { return(AutomationNull.Value); } } else { return(AutomationNull.Value); } }
private static void Main(string[] args) { bool existsExternalFiles = args.Length != 0; IFileReader fileReader; if (existsExternalFiles) { fileReader = new ExternalReader(); } else { fileReader = new EmbeddedReader(); } ExecuteFiles(fileReader, existsExternalFiles ? args : EmbeddedFiles); }
public void ReadMeteoriteTest() { List <Meteorite> list = new List <Meteorite>(); Meteorite m; WebClient client = new WebClient(); client.DownloadFile("https://data.nasa.gov/api/views/y77d-th95/rows.csv?accessType=DOWNLOAD&bom=true&query=select+*", "Meteorites.csv"); using (ExternalReader read = new ExternalReader("Meteorites.csv")) { while (read.EndOfStream != true) { m = read.ReadMeteorite(); list.Add(m); } } Assert.AreEqual(100, list.Count); }
public ExternalWebSocketNetworkServer(ExternalReader reader, Int32 port) : base(IPAddress.Loopback, port) { _reader = reader; }
public ExternalWebSocketSession(ExternalReader reader, WebSocketNetworkServer server) : base(server) { _reader = reader; }