// Use this inputs for testing // https://gist.githubusercontent.com/pgi-dev/0b7ae70fbd16a1aec0ad1f5404e79ec9/raw/ef7036a7cd55f3e7ca6351da46fb549874f346d7/ImportData.txt // D:\Projects\InventoryImporter\InventoryImporter.TestConsole\Sample\ImportData.txt static async Task Main(string[] args) { IDataProvider dataProvider = null; Console.WriteLine("Provide data source, web url or file path:"); var uri = Console.ReadLine(); if (Uri.IsWellFormedUriString(uri, UriKind.Absolute)) { dataProvider = new WebDataProvider(); Console.WriteLine("Processing Web content..."); } else if (File.Exists(uri)) { dataProvider = new FileDataProvider(); Console.WriteLine("Processing File content..."); } else { Console.WriteLine("Invalid resource..."); } Console.WriteLine(); if (dataProvider != null) { IParser parser = new RegexParser(); IRepository repository = new Repository(new DataContext()); var importer = new Importer(dataProvider, parser, repository); var result = await importer.Import(uri); Console.WriteLine(result.Message); Console.WriteLine(); if (result.Success) { var dump = repository.DumpContent(); Console.Write(dump); } } Console.WriteLine("Press any key to exit."); Console.ReadKey(); }
public void TestMulithreading() { const int callCount = 100; _scheduler = new DataProviderScheduler(); var dataProviderAsync = new WebDataProviderAsync(); var dataProvider = new WebDataProvider(); Console.WriteLine("Async data provider: {0}", MeasureScheduled(() => _scheduler.Schedule(dataProviderAsync, ""), callCount)); Console.WriteLine("Blocking data provider: {0}", MeasureScheduled(() => _scheduler.Schedule(dataProvider, ""), callCount)); Console.WriteLine("Sequential async data provider: {0}", MeasureSequential(() => { var task = dataProviderAsync.ProvideData(""); task.Wait(); }, callCount)); Console.WriteLine("Sequential blocking data provider: {0}", MeasureSequential(() => dataProvider.ProvideData(""), callCount)); }
protected void gv_credentials_RowCommand(object sender, GridViewCommandEventArgs e) { this.provider = new WebDataProvider(); this.provider.Port = 80; this.provider.Username = "******"; this.provider.Password = "******"; provider.Host = txt_ip.Text; provider.Username = txt_user.Text; provider.Password = txt_pass.Text; GetLocations(); ////First create a SystemConnection. //this.connection = new SystemConnection(); ////To receive session notifications, subscribe to the session protocol service. //this.connection.ServicesSubscribed.Add(JAVS.Protocol.Session.Service.Number); ////Events may fire from a background thread. When handling events within a System.Windows.Forms GUI, ////set the sync object to a control to avoid cross-threading issues. //this.connection.SyncObject = this; ////The Registered event will be triggered after a successful connection and the recorder ////is ready to handle commands. //this.connection.Registered += new EventHandler(connection_Registered); //this.connection.Disconnected += new EventHandler<DisconnectedEventArgs>(connection_Disconnected); ////Create an EventManagerSessionControl which provides session protocol commands and events. //this.sessionControl = new EventManagerSessionControl(this.connection); //this.sessionControl.SessionChanged += new EventHandler(sessionControl_SessionChanged); //this.sessionControl.RecordingChanged += new EventHandler(sessionControl_RecordingChanged); ////Connect to the recorder. //if (this.connection.Connect(this.textBoxIPAddress.Text, 6110)) //{ // this.buttonDisconnect.Enabled = true; //} //else //{ // MessageBox.Show("Failed to establish connection"); //} }