public override IEdmModel GetEdmModel() { var basemodel = base.GetEdmModel(); foreach (EntitySetConfiguration set in EntitySets) { Dictionary <string, ExternalSource> navdictionary; // If the referenced Model Type is not listed in the targetdictionary add it, otherwise set the targetdictionary //TODO [ap] Perhaps better to change it to entity set, as types may be used in multiple locations? if (!CustomNavigationReferences.TryGetValue(set.ClrType, out navdictionary)) { navdictionary = new Dictionary <string, ExternalSource>(); CustomNavigationReferences.Add(set.ClrType, navdictionary); } Dictionary <string, PropertyInfo> foreignKeys = new Dictionary <string, PropertyInfo>(); foreach (PropertyInfo pi in set.ClrType.GetProperties(BindingFlags.Instance | BindingFlags.Public)) { ForeignKeyAttribute fk = pi.GetCustomAttribute(typeof(ForeignKeyAttribute), true) as ForeignKeyAttribute; if (fk != null) { foreignKeys.Add(fk.Name, pi); } } string key = null; try { key = set.ClrType.GetProperties().FirstOrDefault(x => { return(x.GetCustomAttribute(typeof(KeyAttribute), true) != null); }).Name; } catch (Exception) { } // Get all expand source attributes foreach (PropertyInfo pi in set.ClrType.GetProperties(BindingFlags.Instance | BindingFlags.Public)) { foreach (ExpandSourceAttribute a in pi.GetCustomAttributes <ExpandSourceAttribute>(true)) { var exs = new ExternalSource { EntitySet = a.SourceEntitySet, IsLocal = a.IsLocal, NavigationProperty = pi, Key = key, ForeignKey = a.ForeignKey }; PropertyInfo fk; if (foreignKeys.TryGetValue(pi.Name, out fk)) { exs.ForeignKeyProperty = fk; try { exs.ForeignKey = pi.PropertyType.GetProperties().FirstOrDefault(x => x.GetCustomAttribute(typeof(KeyAttribute), true) != null).Name; } catch (Exception ex) { throw new ArgumentException(pi.PropertyType.Name + " has no KeyAttribute defined and, thus, cannot be used as ExpandSource.", pi.PropertyType.Name, ex); } } navdictionary.Add(pi.Name, exs); } } } return(basemodel); }
public async Task <FindResult> Find(string externalId, ExternalSource source) { var request = new Request($"find/{externalId}", BaseUri, HttpMethod.Get); request.FullUri = request.FullUri.AddQueryParameter("api_key", ApiToken); AddRetry(request); request.AddQueryString("external_source", source.ToString()); return(await Api.Request <FindResult>(request)); }
public void AddTournamentCouponURL(ExternalSource source, Tournament tournament, string couponURL) { var tournamentCoupon = new TournamentCouponURL { ExternalSource = source, Tournament = tournament, CouponURL = couponURL }; Add <TournamentCouponURL>(tournamentCoupon); SaveChanges(); }
public async Task FindByIdSmokeTest(string externalId, string language, ExternalSource externalSource) { var response = await Client.Find.GetAsync(new FindByIdRequest { ExternalId = externalId, LanguageAbbreviation = language, ExternalSource = externalSource }); Assert.IsType <FindByIdResponse>(response); Assert.True(response.MovieResults.Any()); }
private bool ValidData(string pcode, ExternalSource src, string flag) { return((src == ExternalSource.USGS && flag.IndexOf("A") == 0) || (src == ExternalSource.USGS && checkBoxProvisional.Checked) || pcode.Trim().ToUpper() == "WI" || pcode.Trim().ToUpper() == "WK" || pcode.Trim().ToUpper() == "WZ" || src == ExternalSource.Idwr && pcode.ToLower() == "qj" || src == ExternalSource.OWRD && flag == "Published" || src == ExternalSource.OWRD && checkBoxProvisional.Checked || src == ExternalSource.nrcs || src == ExternalSource.IDACORP); }
protected virtual IEnumerable <IChangeableData> GetExternalData() { logger.Debug(MethodBase.GetCurrentMethod().Name); logger.InfoFormat(Resources.Info_TimeOut, OperationHangTimeOut); using (HangWatcher watcher = new HangWatcher(OperationHangTimeOut)) { watcher.Token.Register(() => ExternalSource.Cancel()); ExternalSource.ViabilityObserver.SomeBodyStillAlive += (o, e) => watcher.PostPone(OperationHangTimeOut); return(ExternalSource.GetData()); } }
public Uri GetTournamentCouponUrl(Tournament tournament, ExternalSource externalSource) { var couponData = GetQuery <TournamentCouponURL>(c => c.Tournament.Id == tournament.Id && c.ExternalSource.Id == externalSource.Id) .FirstOrDefault(); if (couponData == null) { return(null); } else { return(new Uri(couponData.CouponURL)); } }
public TeamPlayerExternalSourceAlias CreateTeamPlayerExternalAlias(TeamPlayer teamPlayer, ExternalSource source, string alias) { var entity = new TeamPlayerExternalSourceAlias { TeamsPlayer = teamPlayer, ExternalSource = source, Alias = alias }; Add <TeamPlayerExternalSourceAlias>(entity); SaveChanges(); return(entity); }
/// <summary> /// Get the latest tempearture from external source /// </summary> /// <returns></returns> public void GetLatestTemperature() { ISourceData sourceData = ExternalSource.ConvertSourceToData(); if (sourceData.Unit == TemperatureUnit.Unknown) { throw new ThermometerUnknownUnitException(); } CurrentTemperature = new TemperatureUnitConvertor().ConvertToNewReading( sourceData.Reading, from: sourceData.Unit, to: CurrentTempUnit); // Populate to thresholds ThresholdsModel.PopulateTempUnitToSettings(CurrentTempUnit); }
public TeamPlayer GetAlias(string teamNameSource, ExternalSource source, ExternalSource destination, Sport sport) { if (sport.SportName == "Football") { return(GetAliasFootball(teamNameSource, source, destination)); } else if (sport.SportName == "Tennis") { return(GetAliasTennis(teamNameSource, source, destination)); } else { throw new ArgumentException(string.Format("Can't find sport named {0}", sport.SportName)); } }
public string GetTournamentAlias(string tournamentName, ExternalSource externalSource) { var tournamentAlias = GetQuery <TournamentExternalSourceAlias>() .Include(m => m.Tournament) .Where(a => a.Alias == tournamentName && a.ExternalSource.Source == externalSource.Source); if (tournamentAlias.Count() == 0) { return(null); } else { return(tournamentAlias.First().Tournament.TournamentName); } }
private TeamPlayer GetAliasTennis(string teamNameSource, ExternalSource source, ExternalSource destination) { var teamPlayerAliasLookup = GetQuery <TeamPlayerExternalSourceAlias>(t => t.Alias == teamNameSource && t.ExternalSource.Source == source.Source) .Include(t => t.TeamsPlayer) .FirstOrDefault(); if (teamPlayerAliasLookup != null) { return(teamPlayerAliasLookup.TeamsPlayer); } else { var lookup = StandardisePlayerName(source.Source, teamNameSource); TeamPlayer player = null; if (source.Source == "Best Betting") { player = First <TeamPlayer>(p => p.FirstName.ToLower().Substring(0, 1) + "-" + p.Name.ToLower().Replace(" ", "-").Replace(".", "") == lookup); if (player == null) { return(null); } } else if (source.Source == "Odds Checker Web" || source.Source == "Odds Checker Mobi") { player = First <TeamPlayer>(p => p.FirstName.ToLower().Replace(" ", "-").Replace(".", "") + "-" + p.Name.Replace(" ", "-").Replace(".", "").ToLower() == lookup); if (player == null) { return(null); } } else { throw new ArgumentException("source"); } var teamPlayerAlias = new TeamPlayerExternalSourceAlias { ExternalSource = source, Alias = teamNameSource, TeamsPlayer = player }; Add <TeamPlayerExternalSourceAlias>(teamPlayerAlias); SaveChanges(); return(player); } }
/// <summary> /// Gets all external sources. /// </summary> /// <returns>All external sources</returns> private List <ExternalSource> GetAllExternalSources() { var theMovieDb = new ExternalSource() { Name = "The Movie Database", ApiKey = string.Empty, Configuration = string.Empty, ConfigurationRefreshMinutes = 1440, ConfigurationTimestamp = new DateTime(1900, 01, 01), CreatedTimestamp = new DateTime(1900, 01, 01), Deleted = false }; return(new List <ExternalSource>() { theMovieDb }); }
public void FindAndNotify() { //Get Freash data var receivedData = ExternalSource.GetData(); //Get old data var presavedData = DataStorage.GetData(); if (presavedData != null) { Analyzer.Analyze(receivedData, presavedData); Notify(); } // Clear All old data DataStorage.CleanStorage(); // Save new data DataStorage.SaveData(receivedData); }
public string GetAlias(string bookmakerNameSource, ExternalSource source, ExternalSource destination) { var bookmakerNameDestination = string.Empty; var bookmakerAlias = GetQuery <BookmakerExternalSourceAlias>() .Include(t => t.Bookmaker) .Where(a => a.Alias == bookmakerNameSource && a.ExternalSource.Source == source.Source) .ToList(); if (bookmakerAlias.Count() == 0) { bookmakerNameDestination = bookmakerNameSource; } else { bookmakerNameDestination = bookmakerAlias.First().Bookmaker.BookmakerName; } return(bookmakerNameDestination); }
private TeamPlayer GetAliasFootball(string teamNameSource, ExternalSource source, ExternalSource destination) { //easy, we will know all of these upfront TeamPlayer teamNameDestination = null; var teamAlias = GetQuery <TeamPlayerExternalSourceAlias>() .Include(t => t.TeamsPlayer) .Where(a => a.Alias == teamNameSource && a.ExternalSource.Source == source.Source); if (teamAlias.Count() == 0) { teamNameDestination = GetTeamOrPlayerFromName(teamNameSource); } else { teamNameDestination = teamAlias.First().TeamsPlayer; } return(teamNameDestination); }
private int WriteArchivesImportFile(string cbtt, string pcode, string fileName, ExternalSource src) { StreamWriter output = new StreamWriter(fileName, true); output.WriteLine("MM/dd/yyyy cbtt PC NewValue OldValue "); int counter = 0; for (int i = 0; i < externalSeries.Count; i++) { DateTime t = externalSeries[i].DateTime; string flag = externalSeries[i].Flag; if (ValidData(pcode, src, flag)) { if (hmet.IndexOf(t) >= 0 && System.Math.Abs(hmet[t].Value - externalSeries[i].Value) > 0.01 && System.Math.Abs(externalSeries[i].Value - 998877) > .1) { // save to output file output.WriteLine(t.ToString("MM/dd/yyyy") + " " + cbtt.PadRight(12) + " " + pcode.PadRight(9) + " " + externalSeries[i].Value.ToString("F2").PadRight(13) + " " + hmet[t].Value.ToString("F2").PadRight(13)); counter++; } } } output.Close(); return(counter); }
public Producer(ExternalSource src) { src.OnData += externalSource_OnData; }
public void OnGet() { var obj = ExternalSource.MakeRequest("Blade+Runner", 2017); Message = obj.Title; }
public static TMDbFindResult TMDbFind(string aId, ExternalSource aSourceId) { string lResponse = GetFromTmdb(string.Format(TmdbURIs.apiFind, aId, aSourceId.ToString())); return(lResponse.FromJSON <TMDbFindResult>()); }
public static TMDbFindResult TMDbFind(string id, ExternalSource sourceId) { string response = GetJson(string.Format(apiFind, id, sourceId.ToString())); return response.FromJson<TMDbFindResult>(); }
private void ReadDailyExternalData(DateTime t1, DateTime t2) { var pc = textBoxPcode.Text.Trim().ToLower(); ExternalSource src = GetSourceType(); switch (src) { case ExternalSource.USGS: UsgsDailyParameter usgsParm = FindUsgsParameter(pc); externalSeries = new UsgsDailyValueSeries(this.textBoxUsgs.Text.Trim(), usgsParm); break; case ExternalSource.OWRD: if (pc == "qd" || pc == "qj") { externalSeries = new OwrdSeries(this.textBoxOwrd.Text.Trim(), OwrdSeries.OwrdDataSet.MDF, this.checkBoxProvisional.Checked); } else if (pc == "af") { externalSeries = new OwrdSeries(this.textBoxOwrd.Text.Trim(), OwrdSeries.OwrdDataSet.Midnight_Volume, this.checkBoxProvisional.Checked); } else { externalSeries = new Series(); } break; case ExternalSource.IDACORP: externalSeries = GetIdahoPowerSeries(); externalSeries.Units = "cfs"; break; case ExternalSource.nrcs: var snotelSiteID = NrcsSnotelSeries.LookupSiteID(textBoxSnotel.Text); string snotelParameter = NrcsSnotelSeries.SnotelParameterFromHydrometPcode(pc); externalSeries = new NrcsSnotelSeries(snotelSiteID, snotelParameter); externalSeries.Units = "in"; break; case ExternalSource.Idwr: externalSeries = new IDWRDailySeries(textBoxIdwr.Text.Trim()); break; default: updateStatus("Invalid Data Source. Missing data?", true); externalSeries = new Series("", TimeInterval.Daily); return; } externalSeries.Read(t1, t2); // convert units if needed if (externalSeries.Units == "degrees Celsius") { externalSeries.Units = "degrees C"; } if (externalSeries.Units == "degrees C") { Reclamation.TimeSeries.Math.ConvertUnits(externalSeries, "degrees F"); } externalSeries.Appearance.LegendText = GetSourceType().ToString() + " " + externalSeries.Name; }
public JsonResult OnGetFetchMovie(string title, int year) { var obj = ExternalSource.MakeRequest(title, year); return(new JsonResult(obj)); }
public ExternalSourceVm(ExternalSource externalSource) { _externalSource = externalSource; }
public static TMDbFindResult TMDbFind(string id, ExternalSource sourceId) { string response = GetJson(string.Format(apiFind, id, sourceId.ToString())); return(response.FromJson <TMDbFindResult>()); }