/// <summary> /// Argument Constructor /// </summary> /// <param name="eventHandler">Event handler which will receive requested data</param> /// <param name="localPersistance">Indicates whether the data to be saved locally on initial request</param> public DataHandler(IEventHandler <MarketDataObject>[] eventHandler, bool localPersistance = false) { try { _classLogger = new AsyncClassLogger("SimulatedDataHandler"); // Set logging level _classLogger.SetLoggingLevel(); //set logging path _classLogger.LogDirectory(DirectoryStructure.CLIENT_LOGS_LOCATION); _persistanceDataCount = 0; _localPersistance = localPersistance; _localPersistanceData = new SortedDictionary <int, MarketDataObject>(); _tasksCollection = new ConcurrentBag <Task>(); _fetchMarketData = new FetchData(new ReadMarketData(_classLogger), _classLogger); // Initialize Lists BarSubscriptionList = new List <string>(); TickSubscriptionList = new List <string>(); _fetchMarketData.InitializeDisruptor(eventHandler); _fetchMarketData.HistoricalDataFired += HistoricDataArrived; } catch (Exception exception) { _classLogger.Error(exception, _type.FullName, "DataHandler"); } }
private async Task <ICollection <MetricValueSet> > Fetch(FetchData data) { CloudException thrown = null; try { var values = await MetricsClientFacade.ListValuesAsync( _credentials, data.ResourceId, data.MetricNames, "", data.TimeGrain, data.From, data.Till); return(values.MetricValueSetCollection.Value); } catch (CloudException e) { thrown = e; } if (thrown.Response.StatusCode == System.Net.HttpStatusCode.BadRequest && thrown.Message.Contains(TooManyValuesErrorMessage)) { if (!data.PartitionTresholdReached()) { return(await PartitionAndFetch(data)); } } throw thrown; }
protected void Page_Load(object sender, EventArgs e) { //查看是否有用户级语言辅助器,没有则用公共的 LangHelper = FetchData.GetLanguageHelper(Session); if (IsPostBack) { f_Submit(); } Dictionary <string, string> langLst = Common.LanguageHelper.GetLanguageList(); Common.Language = Common.readConfig("Default_Language", "chs"); edtHomgePageTitle.Text = Common.readConfig("Home_Page_Title", "Dashboard"); imgLogo.ImageUrl = Common.readConfig("Logo_Picture", "../images/logo-white-no-back.png"); chkMustLogin.Checked = Cvt.ToBoolean(Common.readConfig("Must_Login", "false")); string sDBType = Common.readConfig("DAL_Assembly", "DAL_SqlServer"); edtDbServer.Text = Common.readConfig("DBServer", "localhost"); edtPort.Text = Common.readConfig("DBPort", "1433"); edtUser.Text = Common.readConfig("DBUser", "sa"); lstLanguage.Items.Clear(); foreach (KeyValuePair <string, string> itm in langLst) { ListItem LstItm = new ListItem(itm.Value, itm.Key); LstItm.Selected = itm.Key.Equals(Common.Language, StringComparison.OrdinalIgnoreCase); lstLanguage.Items.Add(LstItm); } lstDatabaseType.Items.Clear(); DALBase[] DalLst = Common.LoadAllSubClass <DALBase>(); foreach (DALBase dal in DalLst) { ListItem LstItm = new ListItem(dal.DALName, dal.GetType().Name); LstItm.Selected = dal.GetType().Name.Equals(sDBType, StringComparison.OrdinalIgnoreCase); lstDatabaseType.Items.Add(LstItm); } lstDatabaseType.Enabled = false; lblLanguage.Text = LangHelper.GetText("Default Language:"); lblGenericSetting.Text = LangHelper.GetText("Generic Setting:"); lblHomePageTitle.Text = LangHelper.GetText("Home Page Title:"); lblMustLogin.Text = LangHelper.GetText("Must Login:"******"Home Page Logo:"); lblDatabaseSetting.Text = LangHelper.GetText("Database:"); lblDatabaseType.Text = LangHelper.GetText("Type:"); lblDbServer.Text = LangHelper.GetText("Server:"); lblPort.Text = LangHelper.GetText("Port:"); lblUser.Text = LangHelper.GetText("User:"******"Password:"******"Database:"); btnInitDatabase.Text = LangHelper.GetText("Create Tables For Init Database"); btnTestConnection.Text = LangHelper.GetText("Test Connection"); btnSubmit.Text = LangHelper.GetText("Submit"); }
public static async Task <WeatherData> PopulateWeatherModel(string city) { FetchData fetch = new FetchData(); WeatherData weatherData = await fetch.GetAPIResponse(city, GrabWeatherData); return(weatherData); }
/// <summary> /// Default Constructor /// </summary> public DataHandler() { try { _classLogger = new AsyncClassLogger("DataHandler"); _classLogger.SetLoggingLevel(); //set logging path string path = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\TradeHub Logs\\Client"; _classLogger.LogDirectory(path); _fetchMarketData = new FetchData(new ReadMarketData(_classLogger), _classLogger); // Initialize Lists BarSubscriptionList = new List <string>(); TickSubscriptionList = new List <string>(); _fetchMarketData.InitializeDisruptor(new IEventHandler <MarketDataObject>[] { this }); _fetchMarketData.HistoricalDataFired += HistoricDataArrived; } catch (Exception exception) { _classLogger.Error(exception, _type.FullName, "DataHandler"); } }
public void ReadTestData() { Args args = new Args("Test.txt", ";", "Test.txt"); FetchData fd = new FetchData(args); Assert.IsTrue(fd.Execute() != null); }
protected void Page_Load(object sender, EventArgs e) { //查看是否有用户级语言辅助器,没有则用公共的 LangHelper = FetchData.GetLanguageHelper(Session); DateTime dtEnd = Common.DAL.GetCurrentdateTime(Request["line"]); string sTime = Request["time"]; if (!string.IsNullOrEmpty(sTime)) { dtEnd = DateTime.Parse(sTime).AddMinutes(1); } DateTime dtStart = dtEnd.AddDays(-30); //dtEnd.AddHours(-2); // edtStartTime.Text = dtStart.ToString("yyyy-MM-dd HH:mm"); edtEndTime.Text = dtEnd.ToString("yyyy-MM-dd HH:mm"); edtStation.Text = Request["line"]; string test = Request["Remain"]; }
IEnumerable <Flot> GetFlotData(DateTime aStart, DateTime aEnd) { var tObjects = new List <Flot>(); FetchData data = Helper.RrdDb.createFetchRequest(ConsolFuns.CF_AVERAGE, aStart.ToTimestamp(), aEnd.ToTimestamp(), 1).fetchData(); Int64[] times = data.getTimestamps(); double[][] values = data.getValues(); for (int a = 1; a <= Snapshot.SnapshotCount; a++) { var obj = new Flot(); var list = new List <double[]>(); for (int b = 0; b < times.Length; b++) { double[] current = { times[b] * 1000, values[a][b] }; list.Add(current); } obj.Data = list.ToArray(); obj.Type = a; tObjects.Add(obj); } return(tObjects.ToArray()); }
protected void btnStudentInfo_Click(object sender, EventArgs e) { var fetchData = new FetchData(); var studentData = fetchData.GetStudentData(); //UI logic to bind the student data obtained above with UI elements. //I've skipped it as UI binding logic isn't of much relevance here. }
protected void Page_Load(object sender, EventArgs e) { FetchData data = new FetchData(); List <Orders> fetchedOrder = new List <Orders>(); fetchedOrder = data.getOrders(); List <Country> countryList = new List <Country>(); countryList = fetchedOrder.GroupBy(l => l.Country).Select(cl => new Country { CountryName = cl.First().Country, Percentage = cl.Sum(c => c.Percentage) }).ToList(); StringBuilder dataSource = new StringBuilder(); string str = ""; dataSource.Append("{'chart': {'theme': 'fusion', 'caption': 'Order percentage based on countries', 'pieRadius':'180', 'numbersuffix':'%', 'enableMultiSlicing': '0', 'paletteColors': '#0075c2,#1aaf5d,#f2c500,#f45b00,#8e0000', 'bgColor': '#ffffff', 'showBorder': '0', 'use3DLighting': '1', 'showShadow': '0', 'enableSmartLabels': '1', 'startingAngle': '310', 'showLabels': '0', 'showPercentValues': '1', 'showLegend': '0', 'captionFontSize': '14', 'toolTipColor': '#ffffff', 'toolTipBorderThickness': '0', 'toolTipBgColor': '#000000', 'toolTipBgAlpha': '80', 'toolTipBorderRadius': '2', 'toolTipPadding': '5', },'data': ["); foreach (Country newCountry in countryList) { //Response.Write(newCountry.CountryName + "</br>" + newCountry.Percentage + "</br>"); str += "{'label': '" + newCountry.CountryName.Trim() + "' , 'value':'" + newCountry.Percentage + "' },"; } dataSource.Append(str); dataSource.Append("] }"); FusionCharts.Charts.Chart newChart = new FusionCharts.Charts.Chart("doughnut3d", "myChart", "500", "500", "json", dataSource.ToString()); newChart.AddEvent("dataplotclick", "clickHandler"); lit.Text = newChart.Render(); }
private async Task<ICollection<MetricValueSet>> Fetch(FetchData data) { CloudException thrown = null; try { var values = await MetricsClientFacade.ListValuesAsync( _credentials, data.ResourceId, data.MetricNames, "", data.TimeGrain, data.From, data.Till); return values.MetricValueSetCollection.Value; } catch(CloudException e) { thrown = e; } if(thrown.Response.StatusCode == System.Net.HttpStatusCode.BadRequest && thrown.Message.Contains(TooManyValuesErrorMessage)) { if(!data.PartitionTresholdReached()) { return await PartitionAndFetch(data); } } throw thrown; }
protected void Page_Load(object sender, EventArgs e) { //查看是否有用户级语言辅助器,没有则用公共的 LangHelper = FetchData.GetLanguageHelper(Session); return; }
public override async Task <Stream> OnRequest(byte[] requestData) { var fetchData = new FetchData(); fetchData.resource = ServerDataBase.Instance.GetResource(LoginedAccount.Id); return(new MemoryStream(MessagePackSerializer.Serialize <FetchData>(fetchData))); }
public BuddyRequest(FetchData fetch, SignManager sign, int seq, string sender, string rece) { _fetch = fetch; _sign = sign; Sequence = seq; Sender = sender; Receiver = rece; }
public void NullOnMissingFile() { FetchData fd1 = new FetchData(new Args("Missing.txt", ";", "Test.txt")); FetchData fd2 = new FetchData(new Args("/fake/path.txt", ";", "Test.txt")); Assert.Throws(typeof(CommandException), () => fd1.Execute()); Assert.Throws(typeof(CommandException), () => fd2.Execute()); }
protected void Page_Load(object sender, EventArgs e) { //查看是否有用户级语言辅助器,没有则用公共的 LangHelper = FetchData.GetLanguageHelper(Session); sEditableInfo = Request["ei"]; if (sEditableInfo == null) { sEditableInfo = "_Employee"; } if (sEditableInfo != null) { EditableInfo selEI = Common.SelectEditableInfo(sEditableInfo); if (selEI != null) { //先为选择编辑字段创建初始的Json列表 string sJosn = ""; JsonList = new List <string>(); //再生成网格上的字段列表 bool bReadOnlyTable = ((selEI.Option & Option.ReadOnly) != Option.None); string sHtml = ""; FilledFieldList = new List <string>(); foreach (Field fld in selEI.MasterTable.Fields) { CreateJSForColumn(fld, bReadOnlyTable, ref sHtml); GetJson(fld, ref sJosn); } foreach (EditableTable tbl in selEI.SlaveTables) { foreach (Field fld in tbl.Fields) { CreateJSForColumn(fld, bReadOnlyTable, ref sHtml); GetJson(fld, ref sJosn); } } if ((selEI.Option & Option.ReadOnly) == Option.None) { sHtml += "\n, { display: '" + LangHelper.GetText("Operate") + "', isSort: false, width: 120, render: " + ((selEI.Option & Option.ManualSort) != Option.None ? "f_OperateUpDown" : "f_Operate") + " }"; } ListHolder.Controls.Add(new LiteralControl("<script type=\"text/javascript\">\n var gColumns=[" + sHtml + "];\n" + "var gList = {};\n" + sJosn + "var gUrl= '../FetchData.ashx?fn=TableEdit&rp=get&ei=" + sEditableInfo + "'; \n" + "var gUpUrl='../FetchData.ashx?fn=TableEdit&rp=update&ei=" + sEditableInfo + "'; \n" + "var gEnabledSort=" + ((selEI.Option & Option.ManualSort) != Option.None ? "false" : "true") + "; \n" + "var gEnabledEdit=" + (bReadOnlyTable ? "false" : "true") + "; \n" + "var gSelEI= '" + sEditableInfo + "'; \n" + "</script>")); } } }
public IActionResult Pokemon(int id) { PokemonInfo pokemon = new PokemonInfo(); Task.Run(async() => { pokemon = await FetchData.GetPokemonInfo(id); }).GetAwaiter().GetResult(); return(View(pokemon)); }
public void BeginFetchRecentChanges(RecentChangesFetched callback, Object callerData=null) { FetchData data = new FetchData(); data.callback = callback; data.isItWatchlistQuery = false; data.callerData = callerData; String uri = "http://en.wikipedia.org/w/api.php?action=query&format=xml&list=recentchanges&rcprop=title|ids|sizes|flags|user|comment|timestamp&rclimit=50"; httpFetcher.BeginExecuteQuery(uri, new HttpFetcher.QueryExecutedCallback(this.HttpQueryExecutedCallback), data); }
public IActionResult Index() { List <Pokemon> list = new List <Pokemon>(); Task.Run(async() => { list = await FetchData.GetPokemon(); }).GetAwaiter().GetResult(); return(View(list)); }
public static async Task <List <WeatherData> > PopulateByRandValues() { FetchData fetch = new FetchData(); List <WeatherData> listWithWeather = new List <WeatherData>(); for (int i = 0; i < 5; i++) { listWithWeather.Add(await fetch.GetRandomCity()); } return(listWithWeather); }
public JToken simulateJTokenInstance(string pathParam, string eventParam, int data) { FetchData fetchInstance = new FetchData { path = pathParam, // For path = "6014/01" (f.e.) Event = eventParam, // For event = "add" || "change" || "fetch" value = data, }; return(JToken.FromObject(fetchInstance)); }
public void BeginFetchWatchlistChanges(String user, String token, RecentChangesFetched callback) { FetchData data = new FetchData(); data.callback = callback; data.isItWatchlistQuery = true; data.watchlistUser = user; data.watchlistToken = token; String uri = "http://en.wikipedia.org/w/api.php?action=query&format=xml&list=watchlist&wllimit=50&wlowner="+user+"&wltoken="+token+"&wlprop=user|comment|timestamp|title|ids|sizes|flags&wlallrev"; httpFetcher.BeginExecuteQuery(uri, new HttpFetcher.QueryExecutedCallback(this.HttpQueryExecutedCallback), data); }
public void LoadJson_GivePathToJSONFile() { // Arange var path = "C:\\Users\\kater\\Documents\\dot-net\\CurrencyExchangeRate\\CurrencyExchangeRate\\Data\\ExchangeRates.json"; FetchData fetchData = new FetchData(); //Act var result = fetchData.LoadJson(path); //Assert result.Should().NotBeEmpty(); }
void CatClick(object sender, EventArgs e) { //see what you wanna do when someone *clicks* f.CurrentMode = Form2.Mode.Explore; Button btn = (Button)sender; List <ItemDisc> catItems = new List <ItemDisc>(); catItems = FetchData.Category(btn.Text); f.CleanUp(); f.ListItems(catItems.ToArray()); }
public async Task GetStudentProfilesAsync_ShouldReturnValidList_WhenURLIsValid() { //Arrange FetchData fetchData = new FetchData(SertifiURLs.urlGET); //Act var results = await fetchData.GetStudentProfilesAsync(); //Assert Assert.That(results, Is.InstanceOf <List <StudentProfile> >()); }
private void button11_Click(object sender, EventArgs e) //loging in { if (FetchData.CheckPass(Login_user_txt.Text, Login_pass_txt.Text)) // checking user and pass match from data base { Login_Label.ForeColor = Color.Green; Login_Label.Text = "Welcome"; } else { Login_Label.ForeColor = Color.Red; Login_Label.Text = "Invalid Username or Password"; } }
private void fetchRrdData() { long tEndFixed = (tEnd == 0) ? Util.getTimestamp() : tEnd; for (int i = 0; i < defSources.Length; i++) { if (!defSources[i].isLoaded()) { // not fetched yet List <String> dsNames = new List <String>(); dsNames.Add(defSources[i].getDsName()); // look for all other datasources with the same path and the same consolidation function for (int j = i + 1; j < defSources.Length; j++) { if (defSources[i].isCompatibleWith(defSources[j])) { dsNames.Add(defSources[j].getDsName()); } } // now we have everything FetchRequest req = null; if (defSources[i].StartTime == long.MinValue) { req = new FetchRequest(defSources[i].getPath(), defSources[i].getConsolFun().Name, tStart, tEndFixed, FetchRequestResolution); } else { long step = Math.Max(1, defSources[i].Step); string reduceFunctionName = defSources[i].ReduceCfName; if (string.IsNullOrEmpty(reduceFunctionName)) { reduceFunctionName = defSources[i].getConsolFun().Name; } req = new FetchRequest(defSources[i].getPath(), reduceFunctionName, defSources[i].StartTime, defSources[i].EndTime, step); } req.setFilter(dsNames); FetchData data = DbAccessInterface.GetData(req); defSources[i].setFetchData(data); for (int j = i + 1; j < defSources.Length; j++) { if (defSources[i].isCompatibleWith(defSources[j])) { defSources[j].setFetchData(data); } } } } }
public void DatasourceArchiveSelected(DatabaseData database, object datasource, object archiveDefinition) { if (!model.IsDatabase(database.Definition.Path)) { return; } DsDef dsDef = datasource as DsDef; ArcDef selectedArchive = archiveDefinition as ArcDef; FetchData fetchedData = model.GetArchiveData(database, dsDef.DsName, selectedArchive); rrdDbForm.SetArchiveDumpData(fetchedData); rrdDbForm.SetDocumentName(Path.GetFileNameWithoutExtension(database.Definition.getPath())); }
private void UpdateTimer_Tick(object sender, EventArgs e) { OnPropertyChanged(nameof(TimeLeft)); OnPropertyChanged(nameof(TimeFetchLeft)); OnPropertyChanged(nameof(DeviceSerial)); OnPropertyChanged(nameof(ImitatorSerial)); if (DateTime.Now - lastMeasurment > FetchSpan) { lastMeasurment = DateTime.Now; if (!IsFetching) { FetchData.Execute(null); } } }
public JsonResult fetchExcelData() { FetchData obj = new FetchData(); DataSet ds = obj.ReadExcelFile(); //var val = ds.Tables[0].Rows[0]["Name"]; //object op = ds; //IEnumerable<DataRow> sequence = null; //foreach (DataTable t in ds.Tables){ // sequence = t.AsEnumerable(); //} var json = new JavaScriptSerializer().Serialize(getListFromDataSet(ds)); return(Json(getListFromDataSet(ds), JsonRequestBehavior.AllowGet)); }
public User Get() { User aUser = new User(); aUser.Username = "******"; aUser.Address = "Central SYD"; aUser.Email = "*****@*****.**"; aUser.Age = "25"; FetchData afUser = new FetchData(); afUser.Username = "******"; return(aUser); }
public Form2() { InitializeComponent(); SuspendLayout(); ListItems(Receiver.ReadFromProduct("SELECT * FROM Product;")); List <string> CL = FetchData.AllCategories(); ViewedCategories = new List <CategoriesView>(); timer.Interval = 50; timer.Tick += Timer_Tick; timer.Start(); foreach (string s in CL) { CategoriesView C = new CategoriesView(s, Categories, this); ViewedCategories.Add(C); } ResumeLayout(); }
static void Main(string[] args) { var path = "C:\\Users\\kater\\Documents\\dot-net\\CurrencyExchangeRate\\CurrencyExchangeRate\\Data\\ExchangeRates.json"; ILogger logger = new ConsoleLogger(); DisplayMessageService displayMessageService = new DisplayMessageService(logger); displayMessageService.WriteCommand("Usage: Exchange <currency pair> <amount to exchange>"); var userResponse = displayMessageService.ReadCommand(); FetchData fetchData = new FetchData(); var exchangeRates = fetchData.LoadJson(path); InputProcessingService inputProcessingService = new InputProcessingService(); ParseInputService parseInput = new ParseInputService(inputProcessingService, exchangeRates); var userCurrencyInputObject = parseInput.ParseInput(userResponse); ExchangeRateCalculationService exchangeRateCalculationService = new ExchangeRateCalculationService(); var result = exchangeRateCalculationService.CalculateExchangeRate(userCurrencyInputObject); displayMessageService.WriteCommand($"The result is {result}"); displayMessageService.ReadCommand(); }
public FetchData GetArchiveData(DatabaseData databaseData, string dataSourceName, ArcDef archiveDefinition) { RrdDb database = null; try { database = new RrdDb(databaseData.Definition.getPath(), true); int datasourceIndex = database.getDsIndex(dataSourceName); Archive archive = database.getArchive(new ConsolFun(archiveDefinition.getConsolFun().Name), archiveDefinition.Steps); Robin robin = archive.getRobin(datasourceIndex); double[] values = robin.getValues(); DateTime archiveStartTime = archive.getStartDateTime(); TimeSpan tick = new TimeSpan(archive.getArcStep() * TimeSpan.TicksPerSecond); FetchData fetchedData = new FetchData(archive.getArcStep(), archive.getEndTime(), new string[] { dataSourceName }); long[] timestamps = new long[archive.getRows()]; long offset = archive.getStartTime(); for (var i = 0; i < archive.getRows(); i++) { timestamps[i] = offset; offset += archive.getArcStep(); } fetchedData.setTimestamps(timestamps); double[][] value = new double[1][]; value[0] = values; fetchedData.setValues(value); return fetchedData; } finally { if (database != null) database.close(); } }
private async Task<ICollection<MetricValueSet>> PartitionAndFetch(FetchData data) { var results = data.Partition().Select(_=>Fetch(_)).ToArray(); return Join(await Task.WhenAll(results)); }
public FetchData fetchData(FetchRequest request) { long arcStep = getArcStep(); long fetchStart = Util.normalize(request.FetchStart, arcStep); long fetchEnd = Util.normalize(request.FetchEnd, arcStep); if (fetchEnd < request.FetchEnd) { fetchEnd += arcStep; } long startTime = getStartTime(); long endTime = getEndTime(); String[] dsToFetch = request.getFilter(); if (dsToFetch == null) { dsToFetch = parentDb.getDsNames(); } int dsCount = dsToFetch.Length; int ptsCount = (int)((fetchEnd - fetchStart) / arcStep + 1); long[] timestamps = new long[ptsCount]; double[][] values = new double[dsCount][]; for (int i = 0; i < dsCount; i++) values[i] = new double[ptsCount]; long matchStartTime = Math.Max(fetchStart, startTime); long matchEndTime = Math.Min(fetchEnd, endTime); double[][] robinValues = null; if (matchStartTime <= matchEndTime) { // preload robin values int matchCount = (int)((matchEndTime - matchStartTime) / arcStep + 1); int matchStartIndex = (int)((matchStartTime - startTime) / arcStep); robinValues = new double[dsCount][]; for (int i = 0; i < dsCount; i++) { int dsIndex = parentDb.getDsIndex(dsToFetch[i]); robinValues[i] = robins[dsIndex].getValues(matchStartIndex, matchCount); } } for (int ptIndex = 0; ptIndex < ptsCount; ptIndex++) { long time = fetchStart + ptIndex * arcStep; timestamps[ptIndex] = time; for (int i = 0; i < dsCount; i++) { double value = Double.NaN; if (time >= matchStartTime && time <= matchEndTime) { // inbound time int robinValueIndex = (int)((time - matchStartTime) / arcStep); Debug.Assert(robinValues != null); value = robinValues[i][robinValueIndex]; } values[i][ptIndex] = value; } } FetchData fetchData = new FetchData(steps.get(),endTime, parentDb.getDsNames()); fetchData.setTimestamps(timestamps); fetchData.setValues(values); return fetchData; }
public void SetArchiveDumpData(FetchData data) { DataListView.Items.Clear(); DataListView.BeginUpdate(); DateTime[] dates = data.getDateTimestamps(); int count = dates.Length; double[] values = data.getValues()[0]; for (var i = 0; i < count; i++) { if (double.IsNaN(data.getValues()[0][i])) continue; ListViewItem lvi = DataListView.Items.Add(dates[i].ToString()); lvi.SubItems.Add(values[i].ToString()); } DataListView.EndUpdate(); }