public void GetFrontFeaturedListingsTest() { EtsyContext etsyContext = new EtsyContext(Constants.DummyEtsyApiKey); MockFixedDataRequestGenerator requestGenerator = new MockFixedDataRequestGenerator(GetFrontFeaturedListingsRawResults); DataRetriever dataRetriever = new DataRetriever(new NullDataCache(), requestGenerator); IListingsService etsyListingsService = new ListingsService(etsyContext, dataRetriever); using (AutoResetEvent waitEvent = new AutoResetEvent(false)) { ResultEventArgs<Listings> result = null; etsyListingsService.GetFrontFeaturedListingsCompleted += (s, e) => { result = e; waitEvent.Set(); }; // ACT etsyListingsService.GetFrontFeaturedListings(0, 10, DetailLevel.Low); bool signalled = waitEvent.WaitOne(Constants.WaitTimeout); // ASSERT // check that the event was fired, did not time out Assert.IsTrue(signalled, "Not signalled"); TestHelpers.CheckResultSuccess(result); } }
public void GetTopCategoriesTest() { EtsyContext etsyContext = new EtsyContext(Constants.DummyEtsyApiKey); MockFixedDataRequestGenerator requestGenerator = new MockFixedDataRequestGenerator(GetTopCategoriesRawResults); DataRetriever dataRetriever = new DataRetriever(new NullDataCache(), requestGenerator); ITagCategoryService etsyTagCategoryService = new TagCategoryService(etsyContext, dataRetriever); using (AutoResetEvent waitEvent = new AutoResetEvent(false)) { ResultEventArgs<StringResults> result = null; etsyTagCategoryService.GetTopCategoriesCompleted += (s, e) => { result = e; waitEvent.Set(); }; // ACT etsyTagCategoryService.GetTopCategories(); bool signalled = waitEvent.WaitOne(Constants.WaitTimeout); // ASSERT // check that the event was fired, did not time out Assert.IsTrue(signalled, "Not signalled"); // check the data TestHelpers.CheckResultSuccess(result); } }
public void DataRetrieverRetrieveFailTest() { IDataCache dataCache = new NullDataCache(); IRequestGenerator requestGenerator = new WebRequestGenerator(); ResultEventArgs<Listings> resultEventArgs = null; using (AutoResetEvent waitEvent = new AutoResetEvent(false)) { DataRetriever dataRetriever = new DataRetriever(dataCache, requestGenerator); EventHandler<ResultEventArgs<Listings>> completedHandler = (sender, res) => { resultEventArgs = res; waitEvent.Set(); }; dataRetriever.StartRetrieve(new Uri(TestUri + "bad"), completedHandler); bool signalled = waitEvent.WaitOne(Constants.WaitTimeout); Assert.IsTrue(signalled); } Assert.IsNotNull(resultEventArgs); Assert.IsFalse(resultEventArgs.ResultStatus.Success); }
public MainViewModel() { //listX = new List<double> { 7, 9, 10.5, 9.5, 13, 11.5, 14, 14, 9, 7.5, 9.5, 7.5, 9, 7.5, 7.5, 7 }; //listY = new List<double> { -12, -9.5, -7.5, -5.5, -3.5, -1.5, 0.5, 8, 2, -1, -3.5, -5, -7, -7.5, -10, -12 }; //listZ = new List<double> { 7.5, 7.5, 7, 6, 5, 6, 6.5, 7, 7, 6.5, 6, 5, 4.5, 8, 5, 8, 13, 11, 7, 3, 1, -1, -3, -5, -7, -11, -13.5, -11.5, -10, -6, -7.5, -10, -7.5, -8, -8.5, -8.5, -8, -7.5, -6, -7.5, -8, -8.5, -8.5, -7.5, -7, -6, -5, -3.5, -5, -5.5, -5, -4, -2.5, 0 }; //listW = new List<double> { -7.5, -5, -3, -1.5, -2.5, -1.5, -1, 0, 1, 3, 4, 5.5, 7, 6.5, 5.5, 6.5, 9.5, 10, 9.5, 8.5, 9, 9, 8.5, 8, 10, 12, 13, 10, 8, 7, 5.5, 8, 5.5, 3, 1, -1, -2, -2.5, -3, -2.5, -5, -8, -10, -12, -13, -14, -14.5, -14.5, -14.5, -16, -16.5, -17, -14.5, -14}; listX = new List<DateTime> { new DateTime(2015, 1, 1), new DateTime(2015, 2, 1), new DateTime(2015, 3, 1), new DateTime(2015, 4, 1), new DateTime(2015, 5, 1), new DateTime(2015, 6, 1) }; listY = new List<double> { 0, 2000, 3000, 10000, 6000 }; listZ = new List<DateTime> { new DateTime(2015, 1, 1), new DateTime(2015, 2, 1), new DateTime(2015, 3, 1), new DateTime(2015, 4, 1), new DateTime(2015, 5, 1), new DateTime(2015, 6, 1) }; listW = new List<double> { 0, 3000, 3125, 9005, 10000 }; test = new DataRetriever(); this.Title = "Example 2"; this.Points = test.RetrieveData(listX, listY); this.Points2 = test.RetrieveData(listZ, listW); //var xAxis = new DateTimeAxis //{ // Position = AxisPosition.Bottom, // StringFormat = "dd/MM/yyyy", // Title = "End of Day", // IntervalLength = 75, // MinorIntervalType = DateTimeIntervalType.Days, // IntervalType = DateTimeIntervalType.Days, // MajorGridlineStyle = LineStyle.Solid, // MinorGridlineStyle = LineStyle.None, //}; //Plot = new PlotModel(); //Plot.Axes.Add(xAxis); }
public void DataRetrieverCreateWithParamsTest() { IDataCache dataCache = new NullDataCache(); IRequestGenerator requestGenerator = new WebRequestGenerator(); DataRetriever dataRetriever = new DataRetriever(dataCache, requestGenerator); Assert.IsNotNull(dataRetriever); }
public void CreateWithMockRequestTest() { EtsyContext etsyContext = new EtsyContext(string.Empty); IRequestGenerator requestGenerator = new MockFixedDataRequestGenerator(string.Empty); DataRetriever dataRetriever = new DataRetriever(new NullDataCache(), requestGenerator); IListingsService service = new ListingsService(etsyContext, dataRetriever); Assert.IsNotNull(service); }
public bool Refresh(DataStoreContext store, Action afterUpdate) { var retriever = new DataRetriever { Status = new AppStatus { UseToast = true } }; retriever.Callback = () => { UpdateLiveTile(); afterUpdate.Invoke(); }; bool canLoad = retriever.CanLoadData; if (canLoad) retriever.LoadData(); return canLoad; }
public async void MakeTransaction() { var retriever = new DataRetriever { Status = CurrentApp.Status }; if (retriever.CanTransferMoney) { var receipt = await retriever.TransferMoney(FromAccount.Id, ToAccount.Id, Description, Amount); if (string.IsNullOrEmpty(receipt)) MessageBox.Show("Transfer failed"); else { MessageBox.Show("Money Transfered.\r\nReceipt:" + receipt); Navigator.GoBack(4); } } }
public void DataRetrieverSimpleCreateTest() { DataRetriever dataRetriever = new DataRetriever(); Assert.IsNotNull(dataRetriever); }
protected override void OnLoad(EventArgs e) { // Initialize the form. this.AutoSize = true; this.Controls.Add(this.dataGridView1); this.Text = "DataGridView virtual-mode just-in-time demo"; // Create a DataRetriever and use it to create a Cache object // and to initialize the DataGridView columns and rows. try { DataRetriever retriever = new DataRetriever(connectionString, table); memoryCache = new Cache(retriever, 16); foreach (DataColumn column in retriever.Columns) { dataGridView1.Columns.Add( column.ColumnName, column.ColumnName); } this.dataGridView1.RowCount = retriever.RowCount; } catch (SqlException) { MessageBox.Show("Connection could not be established. " + "Verify that the connection string is valid."); Application.Exit(); } // Complete the initialization of the DataGridView. this.dataGridView1.Size = new Size(800, 250); this.dataGridView1.Dock = DockStyle.Fill; this.dataGridView1.VirtualMode = true; this.dataGridView1.ReadOnly = true; this.dataGridView1.AllowUserToAddRows = false; this.dataGridView1.AllowUserToOrderColumns = false; this.dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect; this.dataGridView1.CellValueNeeded += new DataGridViewCellValueEventHandler(dataGridView1_CellValueNeeded); // Adjust the column widths based on the displayed values. this.dataGridView1.AutoResizeColumns( DataGridViewAutoSizeColumnsMode.DisplayedCells); base.OnLoad(e); }
public virtual async Task MessageReceivedAsync(IDialogContext context, IAwaitable <IMessageActivity> msg) { try { IMessageActivity message = await msg; string tag = "@Fineas"; message.Text = message.Text.IndexOf(tag) >= 0 ? message.Text.Remove(message.Text.IndexOf(tag), tag.Length).Trim() : message.Text.Trim(); if (string.Equals(message.Text, "help", StringComparison.OrdinalIgnoreCase)) { // Give list of options // Post response and end this dialog await context.PostAsync(string.Format("Ask me a question about your budget, and I will do my best to give you the answer you need. {0}", INSTRUCTIONS)); context.Wait(MessageReceivedAsync); } else if (string.Equals(message.Text, "logout", StringComparison.OrdinalIgnoreCase)) { // Make sure nothing is "cached" DataRetriever.DeleteAllData(); // Logout and end this dialog await context.Logout(); context.Wait(MessageReceivedAsync); } else if (string.Equals(message.Text, "login", StringComparison.OrdinalIgnoreCase)) { // Check to see if user token is filled, meaning they're logged in string userToken = await context.GetAccessToken(AuthSettings.Scopes); if (string.IsNullOrEmpty(userToken)) { // Take user to login thread await context.Forward(new AzureAuthDialog(AuthSettings.Scopes), ResumeAfterAuth, message, CancellationToken.None); } else { // Can't login if already logged in // Post response and end this dialog await context.PostAsync("You are already logged in."); context.Wait(MessageReceivedAsync); } } else if (string.Equals(message.Text, "who", StringComparison.OrdinalIgnoreCase)) { // context is handled inside this method await TryGiveUsername(context, message.Text); } else if (string.Equals(message.Text, "query", StringComparison.OrdinalIgnoreCase)) { timeRange = DateTime.Parse("June, 2016"); // context is handled inside this method await TryQueryDatabase(context, message); } else if (message.Text.StartsWith("query", StringComparison.OrdinalIgnoreCase)) { if (!DateTime.TryParse(message.Text.Substring(message.Text.IndexOf(' ')), out timeRange)) { timeRange = DateTime.Now; } // context is handled inside this method await TryQueryDatabase(context, message); } else if (string.Equals(message.Text, "refresh", StringComparison.OrdinalIgnoreCase)) { await Refresh(context, message.ToString(), true); // End this dialog context.Wait(MessageReceivedAsync); } else if (IsPreviousButton(message.Text)) { // That request is out of date, try starting a new query await context.PostAsync(string.Format("Sorry, that question is outdated. Try querying again.", INSTRUCTIONS)); context.Wait(MessageReceivedAsync); } else { //await PrintCards(context, (Activity)message); // TODO: LUIS GOES HERE // Tell user we don't know what to do here, and end this dialog await context.PostAsync(string.Format("Sorry, '{0}' is not a choice. {1}", message.Text, INSTRUCTIONS)); context.Wait(MessageReceivedAsync); } } catch (Exception e) { // Tell user something broke, and end this dialog await context.PostAsync(string.Format("My life is in shambles. Something crashed. Hint: {0}", e.Message)); context.Wait(MessageReceivedAsync); } }
private async Task <IEnumerable <VersionInfoConsumer> > GetOldestAndRecentSupportedReleases() { return(await DataRetriever.GetRecentAndOldestSupported()); }
private async Task <IEnumerable <VersionInfoConsumer> > GetMajorReleases() { return(await DataRetriever.GetMajorReleases()); }
public AuthorProfilePage(int?authorId) : this() { Title = "Author " + authorId + "'s Profile"; _dataRetriever = new DataRetriever(); LoadUser(authorId); }
/// <summary> /// Make a mock data retriever /// </summary> /// <returns>the Data retriever</returns> private static IDataRetriever MakeDataRetriever() { IDataRetriever dataRetriever = new DataRetriever(new NullDataCache(), new MockFixedDataRequestGenerator(string.Empty)); return dataRetriever; }
public GalleryCategoryPage() { GalleryCatRetriever = new DataRetriever(UrlForData); GalleryCategories = new List <GalleryCategory>(); InitializeComponent(); }
/// <summary> /// Used for pulling the data that has been selected in the configuration /// </summary> /// <param name="state"></param> public void ServiceExporter(object state = null) { try { log.Info("Starting Module"); string AppConfig = dc.Config + ac.AppConfig; string ServerConfig = dc.Config + ac.ServerConfig; log.Debug("AppConfig and ServerConfig set"); log.Debug(string.Format("Last Aggregation Date: {0}", GetLastAggregateRegistry())); if (GetLastAggregateRegistry() == DateTime.Now.ToString("d-MM-yyyy")) { log.Info("Exporter has already ran today, skipping run to prevent possible duplication."); } else { #region Set Variables bool DataUpdateJobStatus = Convert.ToBoolean(Utilities.ReadXMLValue(AppConfig, "DataUpdateJobStatus")); log.Debug("DataUpdateJobStatus bool value set"); bool Office365AdobeImportTables = Convert.ToBoolean(Utilities.ReadXMLValue(AppConfig, "Office365AdobeImportTables")); log.Debug("Office365AdobeImportTables bool value set"); bool SRSImportDate = Convert.ToBoolean(Utilities.ReadXMLValue(AppConfig, "SRSImportDate")); log.Debug("SRSImportDate bool value set"); bool LogInterrogator = Convert.ToBoolean(Utilities.ReadXMLValue(AppConfig, "LogInterrogator")); log.Debug("LogInterrogator bool value set"); bool PlatformVersionCheck = Convert.ToBoolean(Utilities.ReadXMLValue(AppConfig, "PlatformVersionCheck")); log.Debug("PlatformVersionCheck bool value set"); bool LicenseManagerServices = Convert.ToBoolean(Utilities.ReadXMLValue(AppConfig, "LicenseManagerServices")); log.Debug("LicenseManagerServices bool value set"); bool LicenseManagerDeviceReporting = Convert.ToBoolean(Utilities.ReadXMLValue(AppConfig, "LicenseManagerDeviceReporting")); log.Debug("LicenseManagerDeviceReporting bool value set"); bool LicenseManagerStorage = Convert.ToBoolean(Utilities.ReadXMLValue(AppConfig, "LicenseManagerStorage")); log.Debug("LicenseManagerStorage bool value set"); bool InventoryServerServices = Convert.ToBoolean(Utilities.ReadXMLValue(AppConfig, "InventoryServerServices")); log.Debug("InventoryServerServices bool value set"); bool InventoryServerStorage = Convert.ToBoolean(Utilities.ReadXMLValue(AppConfig, "InventoryServerStorage")); log.Debug("InventoryServerStorage bool value set"); bool InventoryServerDeviceReporting = Convert.ToBoolean(Utilities.ReadXMLValue(AppConfig, "InventoryServerDeviceReporting")); log.Debug("InventoryServerDeviceReporting bool value set"); bool InventoryServerProcessing = Convert.ToBoolean(Utilities.ReadXMLValue(AppConfig, "InventoryServerProcessing")); log.Debug("InventoryServerProcessing bool value set"); string LicenseManagerServer = Utilities.ReadXMLValue(ServerConfig, "LicenseManager"); log.Debug("LicenseManagerServer string value set"); string InventoryServer = Utilities.ReadXMLValue(ServerConfig, "InventoryServer"); log.Debug("InventoryServer string value set"); #endregion log.Info("Configuration files loaded"); DataRetriever dataRetriever = new DataRetriever(); log.Info("Data Retriever loaded"); #region Garbage Collector log.Info("Export garbage collector starting..."); int exportCounter = 0; foreach (var file in Directory.GetFiles(dc.Export)) { if (File.Exists(file)) { File.Delete(file); exportCounter += 1; log.Debug(string.Format("{0} deleted!", file)); } } log.Info(exportCounter + " left over export deleted"); log.Info("Export garbage collector finished..."); #endregion #region Log Retention log.Info("Log Retention module starting..."); Utilities.LogRetention(dc.Logs, Convert.ToInt32(LogConfig.SelectSingleNode("//log4net/custom/retentionDays").Attributes["value"].Value)); log.Info("Log Retention module finished..."); #endregion #region Exporters // DUJ Status try { if (DataUpdateJobStatus) { if (dataRetriever.GetDataUpdateJob()) { log.Info("Data Update Job information exported"); } } } catch (Exception ex) { log.Error(ex); } // License Manager Services try { if (LicenseManagerServices) { if (dataRetriever.GetWindowsServices("License Manager", LicenseManagerServer)) { log.Info("Windows Services information exported for LicenseManager"); } } } catch (Exception ex) { log.Error(ex); } // Inventory Service Services try { if (InventoryServerServices) { if (dataRetriever.GetWindowsServices("Inventory Server", InventoryServer)) { log.Info("Windows Services information exported for InventoryServer"); } } } catch (Exception ex) { log.Error(ex); } // Inventory Server Storage try { if (InventoryServerStorage) { if (dataRetriever.GetWindowsStorage("Inventory Server", InventoryServer)) { log.Info("Windows Storage information exported for InventoryServer"); } } } catch (Exception ex) { log.Error(ex); } // License Manager Storage try { if (LicenseManagerStorage) { if (dataRetriever.GetWindowsStorage("License Manager", LicenseManagerServer)) { log.Info("Windows Storage information exported for LicenseManager"); } } } catch (Exception ex) { log.Error(ex); } // Office365 Adobe Import Tables try { if (Office365AdobeImportTables) { if (dataRetriever.GetConnectorImportTables()) { log.Info("Office 365 and Adobe Import tables exported"); } } } catch (Exception ex) { log.Error(ex); } // Log Interrogator try { if (LogInterrogator) { if (dataRetriever.GetSnowLogHealth()) { log.Info("Snow Log Health exported"); } } } catch (Exception ex) { log.Error(ex); } // Platform Version Check try { if (PlatformVersionCheck) { if (dataRetriever.GetProductVersions()) { log.Info("Product Versions exported"); } } } catch (Exception ex) { log.Error(ex); } // License Manager Device Reporting try { if (LicenseManagerDeviceReporting) { if (dataRetriever.GetReportedToday(slm: true)) { log.Info("LicenseManager Device Reporting exported"); } } } catch (Exception ex) { log.Error(ex); } // Inventory Server Device Reporting try { if (InventoryServerDeviceReporting) { if (dataRetriever.GetReportedToday(sinv: true)) { log.Info("SnowInventory Device Reporting exported"); } } } catch (Exception ex) { log.Error(ex); } // SRS Import Date and Inventory Server Processing try { if (SRSImportDate == true || InventoryServerProcessing == true) { if (dataRetriever.GetExtras(SRSImportDate, InventoryServerProcessing)) { log.Info("GetExtras exported"); } } } catch (Exception ex) { log.Error(ex); } #endregion #region Mailer if (GetLastAggregateRegistry() == DateTime.Now.ToString("d-MM-yyyy")) { log.Info("Export mailer has already ran today, skipping run to prevent possible duplication."); } else { Mailer m = new Mailer(); string filename = dc.Export + dataRetriever.ExportName; log.Debug("New mailer initialized"); m.SendEmail(filename, Assembly.GetExecutingAssembly().GetName().Version.ToString()); log.Debug("Email command sent"); } #endregion log.Info("Schedule will now be refreshed for next run!"); if (state != null) { _timer.Dispose(); } SetLastAggregateRegistry(); InitializeSchedule(); } } catch (Exception ex) { log.Fatal(ex); Mailer m = new Mailer(); m.SendFailureAlert("Failure to export" + Environment.NewLine + ex.Message + ex.StackTrace + Environment.NewLine + " Please investigate!"); } }
public Info() { hInfoRetriever = new DataRetriever(UrlOfData); infoItems = new List <InfoItem>(); }
public void TestMethod1() { DataRetriever dr = new DataRetriever(); }
public Blog1Model(IOrchardHelper orchard, DataRetriever dataRetriever) { _orchard = orchard; _dataRetriever = dataRetriever; }
/// <summary> /// Will compare upcoming letters to those stored in given font folder /// </summary> /// <param name="font"></param> public FixedLetterRecognizer(string font) { capitals = DataRetriever.Size_Font_Type_All(DATA.fixedSizeFolderNode, font, DATA.capitalsFolderNode); normals = DataRetriever.Size_Font_Type_All(DATA.fixedSizeFolderNode, font, DATA.normalsFolderNode); }
protected override void BeforeConnect() { DataRetriever.WaitForFirstMessageToArrive(); }