/// <summary> /// Initializes a new instance of the ClusterGetProperties class. /// </summary> /// <param name="clusterDefinition">The cluster definition.</param> /// <param name="clusterVersion">The version of the cluster.</param> /// <param name="clusterHdpVersion">The hdp version of the /// cluster.</param> /// <param name="osType">The type of operating system. Possible values /// include: 'Windows', 'Linux'</param> /// <param name="tier">The cluster tier. Possible values include: /// 'Standard', 'Premium'</param> /// <param name="clusterId">The cluster id.</param> /// <param name="kafkaRestProperties">The cluster kafka rest proxy /// configuration.</param> /// <param name="securityProfile">The security profile.</param> /// <param name="computeProfile">The compute profile.</param> /// <param name="provisioningState">The provisioning state, which only /// appears in the response. Possible values include: 'InProgress', /// 'Failed', 'Succeeded', 'Canceled', 'Deleting'</param> /// <param name="createdDate">The date on which the cluster was /// created.</param> /// <param name="clusterState">The state of the cluster.</param> /// <param name="quotaInfo">The quota information.</param> /// <param name="errors">The list of errors.</param> /// <param name="connectivityEndpoints">The list of connectivity /// endpoints.</param> /// <param name="diskEncryptionProperties">The disk encryption /// properties.</param> /// <param name="encryptionInTransitProperties">The /// encryption-in-transit properties.</param> /// <param name="storageProfile">The storage profile.</param> /// <param name="minSupportedTlsVersion">The minimal supported tls /// version.</param> /// <param name="excludedServicesConfig">The excluded services /// config.</param> /// <param name="networkProperties">The network properties.</param> /// <param name="computeIsolationProperties">The compute isolation /// properties.</param> public ClusterGetProperties(ClusterDefinition clusterDefinition, string clusterVersion = default(string), string clusterHdpVersion = default(string), OSType?osType = default(OSType?), Tier?tier = default(Tier?), string clusterId = default(string), KafkaRestProperties kafkaRestProperties = default(KafkaRestProperties), SecurityProfile securityProfile = default(SecurityProfile), ComputeProfile computeProfile = default(ComputeProfile), HDInsightClusterProvisioningState?provisioningState = default(HDInsightClusterProvisioningState?), string createdDate = default(string), string clusterState = default(string), QuotaInfo quotaInfo = default(QuotaInfo), IList <Errors> errors = default(IList <Errors>), IList <ConnectivityEndpoint> connectivityEndpoints = default(IList <ConnectivityEndpoint>), DiskEncryptionProperties diskEncryptionProperties = default(DiskEncryptionProperties), EncryptionInTransitProperties encryptionInTransitProperties = default(EncryptionInTransitProperties), StorageProfile storageProfile = default(StorageProfile), string minSupportedTlsVersion = default(string), ExcludedServicesConfig excludedServicesConfig = default(ExcludedServicesConfig), NetworkProperties networkProperties = default(NetworkProperties), ComputeIsolationProperties computeIsolationProperties = default(ComputeIsolationProperties)) { ClusterVersion = clusterVersion; ClusterHdpVersion = clusterHdpVersion; OsType = osType; Tier = tier; ClusterId = clusterId; ClusterDefinition = clusterDefinition; KafkaRestProperties = kafkaRestProperties; SecurityProfile = securityProfile; ComputeProfile = computeProfile; ProvisioningState = provisioningState; CreatedDate = createdDate; ClusterState = clusterState; QuotaInfo = quotaInfo; Errors = errors; ConnectivityEndpoints = connectivityEndpoints; DiskEncryptionProperties = diskEncryptionProperties; EncryptionInTransitProperties = encryptionInTransitProperties; StorageProfile = storageProfile; MinSupportedTlsVersion = minSupportedTlsVersion; ExcludedServicesConfig = excludedServicesConfig; NetworkProperties = networkProperties; ComputeIsolationProperties = computeIsolationProperties; CustomInit(); }
/// <summary> /// Initializes a new instance of the DiskBillingMeters class. /// </summary> /// <param name="diskRpMeter">The managed disk meter guid.</param> /// <param name="sku">The managed disk billing sku, P30 or S30.</param> /// <param name="tier">The managed disk billing tier, Standard or /// Premium. Possible values include: 'Standard', 'Premium'</param> public DiskBillingMeters(string diskRpMeter = default(string), string sku = default(string), Tier?tier = default(Tier?)) { DiskRpMeter = diskRpMeter; Sku = sku; Tier = tier; CustomInit(); }
public ScoreboardFilterInfo(Division?divFilter, Tier?tierFilter, ServiceCategory?categoryFilter, string locationFilter) { Division = divFilter; Tier = tierFilter; Category = categoryFilter; Location = locationFilter; }
public async Task GetServiceLeaderboardImplementationAsync(string category, Tier?tier, int pageNumber) { using (Context.Channel.EnterTypingState()) { CompleteScoreboardSummary teamScore = await ScoreRetrievalService.GetScoreboardAsync(new ScoreboardFilterInfo(Division.AllService, tier)).ConfigureAwait(false); if (teamScore == null) { throw new Exception("Error obtaining scoreboard."); } // validate category string realCategory = teamScore.TeamList.Where(t => CategoryEquals(t, category)).Select(t => t.Category).Distinct().SingleIfOne(); if (realCategory == null) { throw new ArgumentException("The given category was not found - it was either ambiguous or invalid.", nameof(category)); } await ReplyAsync(ScoreEmbedBuilder.CreateTopLeaderboardEmbed(teamScore, pageNumber: pageNumber, customFilter: new ScoreboardMessageBuilderService.CustomFiltrationInfo() { Predicate = t => t.Category == realCategory, FilterDescription = realCategory }, timeZone: await Preferences.GetTimeZoneAsync(Context.Guild, Context.User).ConfigureAwait(false))).ConfigureAwait(false); } }
/// <summary> /// Initializes a new instance of the ClusterCreateProperties class. /// </summary> /// <param name="clusterVersion">The version of the cluster.</param> /// <param name="osType">The type of operating system. Possible values /// include: 'Windows', 'Linux'</param> /// <param name="tier">The cluster tier. Possible values include: /// 'Standard', 'Premium'</param> /// <param name="clusterDefinition">The cluster definition.</param> /// <param name="securityProfile">The security profile.</param> /// <param name="computeProfile">The compute profile.</param> /// <param name="storageProfile">The storage profile.</param> /// <param name="diskEncryptionProperties">The disk encryption /// properties.</param> public ClusterCreateProperties(string clusterVersion = default(string), OSType?osType = default(OSType?), Tier?tier = default(Tier?), ClusterDefinition clusterDefinition = default(ClusterDefinition), SecurityProfile securityProfile = default(SecurityProfile), ComputeProfile computeProfile = default(ComputeProfile), StorageProfile storageProfile = default(StorageProfile), DiskEncryptionProperties diskEncryptionProperties = default(DiskEncryptionProperties)) { ClusterVersion = clusterVersion; OsType = osType; Tier = tier; ClusterDefinition = clusterDefinition; SecurityProfile = securityProfile; ComputeProfile = computeProfile; StorageProfile = storageProfile; DiskEncryptionProperties = diskEncryptionProperties; CustomInit(); }
/// <summary> /// Initializes a new instance of the ClusterCreateProperties class. /// </summary> /// <param name="clusterVersion">The version of the cluster.</param> /// <param name="osType">The type of operating system. Possible values /// include: 'Windows', 'Linux'</param> /// <param name="tier">The cluster tier. Possible values include: /// 'Standard', 'Premium'</param> /// <param name="clusterDefinition">The cluster definition.</param> /// <param name="kafkaRestProperties">The cluster kafka rest proxy /// configuration.</param> /// <param name="securityProfile">The security profile.</param> /// <param name="computeProfile">The compute profile.</param> /// <param name="storageProfile">The storage profile.</param> /// <param name="diskEncryptionProperties">The disk encryption /// properties.</param> /// <param name="encryptionInTransitProperties">The /// encryption-in-transit properties.</param> /// <param name="minSupportedTlsVersion">The minimal supported tls /// version.</param> /// <param name="networkProperties">The network properties.</param> public ClusterCreateProperties(string clusterVersion = default(string), OSType?osType = default(OSType?), Tier?tier = default(Tier?), ClusterDefinition clusterDefinition = default(ClusterDefinition), KafkaRestProperties kafkaRestProperties = default(KafkaRestProperties), SecurityProfile securityProfile = default(SecurityProfile), ComputeProfile computeProfile = default(ComputeProfile), StorageProfile storageProfile = default(StorageProfile), DiskEncryptionProperties diskEncryptionProperties = default(DiskEncryptionProperties), EncryptionInTransitProperties encryptionInTransitProperties = default(EncryptionInTransitProperties), string minSupportedTlsVersion = default(string), NetworkProperties networkProperties = default(NetworkProperties)) { ClusterVersion = clusterVersion; OsType = osType; Tier = tier; ClusterDefinition = clusterDefinition; KafkaRestProperties = kafkaRestProperties; SecurityProfile = securityProfile; ComputeProfile = computeProfile; StorageProfile = storageProfile; DiskEncryptionProperties = diskEncryptionProperties; EncryptionInTransitProperties = encryptionInTransitProperties; MinSupportedTlsVersion = minSupportedTlsVersion; NetworkProperties = networkProperties; CustomInit(); }
public override ScoreboardFilterInfo GetPeerFilter(CompetitionRound round, ScoreboardSummaryEntry teamDetails) { if (teamDetails.Division == Division.MiddleSchool) { // middle school doesn't have tiers or categories return(new ScoreboardFilterInfo(Division.MiddleSchool, null)); } // open/service if ((teamDetails.Division == Division.Open && round > CompetitionRound.Round2) || (teamDetails.Division == Division.AllService && round == CompetitionRound.Round3)) { // In open past R2, tier matters, but that's it // In all service R3, category doesn't* matter, just tier // See issue #14 return(new ScoreboardFilterInfo(teamDetails.Division, teamDetails.Tier)); } // open/service, service: category matters; open: no tiers if (teamDetails.Division == Division.Open) { // unknown round - if our candidate team has a tier, filter by tier, otherwise return the whole division if (round == 0 && teamDetails.Tier != null) { return(new ScoreboardFilterInfo(teamDetails.Division, teamDetails.Tier)); } // either R1 or R2 // safe to return the whole division as a peer list return(new ScoreboardFilterInfo(Division.Open, null)); } // all-service round where category matters ("R0" we default to factoring in category) Tier?tierFilter = null; // filter by tier, where available if (round > CompetitionRound.Round2) { tierFilter = teamDetails.Tier; } // there might be some A.S. teams whose categories we don't know // they get treated as not-my-problem, that is, not part of my category // unknown category -> null -> no filtering on that, a good enough fallback return(new ScoreboardFilterInfo(Division.AllService, tierFilter, teamDetails.Category, null)); }
/// <summary> /// Initializes a new instance of the ClusterGetProperties class. /// </summary> /// <param name="clusterDefinition">The cluster definition.</param> /// <param name="clusterVersion">The version of the cluster.</param> /// <param name="osType">The type of operating system. Possible values /// include: 'Windows', 'Linux'</param> /// <param name="tier">The cluster tier. Possible values include: /// 'Standard', 'Premium'</param> /// <param name="securityProfile">The security profile.</param> /// <param name="computeProfile">The compute profile.</param> /// <param name="provisioningState">The provisioning state, which only /// appears in the response. Possible values include: 'InProgress', /// 'Failed', 'Succeeded', 'Canceled', 'Deleting'</param> /// <param name="createdDate">The date on which the cluster was /// created.</param> /// <param name="clusterState">The state of the cluster.</param> /// <param name="quotaInfo">The quota information.</param> /// <param name="errors">The list of errors.</param> /// <param name="connectivityEndpoints">The list of connectivity /// endpoints.</param> /// <param name="diskEncryptionProperties">The disk encryption /// properties.</param> public ClusterGetProperties(ClusterDefinition clusterDefinition, string clusterVersion = default(string), OSType?osType = default(OSType?), Tier?tier = default(Tier?), SecurityProfile securityProfile = default(SecurityProfile), ComputeProfile computeProfile = default(ComputeProfile), HDInsightClusterProvisioningState?provisioningState = default(HDInsightClusterProvisioningState?), string createdDate = default(string), string clusterState = default(string), QuotaInfo quotaInfo = default(QuotaInfo), IList <Errors> errors = default(IList <Errors>), IList <ConnectivityEndpoint> connectivityEndpoints = default(IList <ConnectivityEndpoint>), DiskEncryptionProperties diskEncryptionProperties = default(DiskEncryptionProperties)) { ClusterVersion = clusterVersion; OsType = osType; Tier = tier; ClusterDefinition = clusterDefinition; SecurityProfile = securityProfile; ComputeProfile = computeProfile; ProvisioningState = provisioningState; CreatedDate = createdDate; ClusterState = clusterState; QuotaInfo = quotaInfo; Errors = errors; ConnectivityEndpoints = connectivityEndpoints; DiskEncryptionProperties = diskEncryptionProperties; CustomInit(); }
public async Task GetTeamWithRankAsync(int rank, Division?division = null, Tier?tier = null) { using (Context.Channel.EnterTypingState()) { if (rank < 1) { throw new ArgumentOutOfRangeException(nameof(rank)); } var teams = await ScoreRetrievalService.GetScoreboardAsync(new ScoreboardFilterInfo(division, tier)).ConfigureAwait(false); var team = teams.TeamList[rank - 1]; ScoreboardDetails teamScore = await ScoreRetrievalService.GetDetailsAsync(team.TeamId).ConfigureAwait(false); if (teamScore == null) { throw new Exception("Error obtaining team score."); } await ReplyAsync(string.Empty, embed : ScoreEmbedBuilder.CreateTeamDetailsEmbed(teamScore, CompetitionRoundLogicService.GetRankingInformation(ScoreRetrievalService.Round, await ScoreRetrievalService.GetScoreboardAsync(new ScoreboardFilterInfo(teamScore.Summary.Division, null)).ConfigureAwait(false), teamScore.Summary)).Build()).ConfigureAwait(false); } }
protected virtual Uri BuildScoreboardUri(Division?divisionFilter, Tier?tierFilter) { var builder = new UriBuilder(); builder.Scheme = "http"; builder.Host = Hostname; builder.Path = "/"; // there doesn't appear to be a terribly clean way to do this List <string> queryList = new List <string>(2); if (divisionFilter.HasValue) { queryList.Add("division=" + WebUtility.UrlEncode(divisionFilter.Value.ToStringCamelCaseToSpace())); } if (tierFilter.HasValue) { queryList.Add("tier=" + WebUtility.UrlEncode(tierFilter.Value.ToString())); } builder.Query = string.Join("&", queryList); return(builder.Uri); }
public CompleteScoreboardSummary WithFilter(Division?newDivisionFilter, Tier?newTierFilter) { if (Filter.Division.HasValue && Filter.Division != newDivisionFilter) { throw new ArgumentException("Cannot change an existing DivisionFilter."); } if (Filter.Tier.HasValue && Filter.Tier != newTierFilter) { throw new ArgumentException("Cannot change an existing TierFilter."); } IEnumerable <ScoreboardSummaryEntry> newTeamList = TeamList; if (newDivisionFilter.HasValue) { newTeamList = newTeamList.Where(summary => summary.Division == newDivisionFilter.Value); } if (newTierFilter.HasValue) { newTeamList = newTeamList.Where(summary => summary.Tier == newTierFilter.Value); } Filter = new ScoreboardFilterInfo(newDivisionFilter, newTierFilter); TeamList = newTeamList as IList <ScoreboardSummaryEntry> ?? newTeamList.ToList(); return(this); }
protected override Uri BuildScoreboardUri(Division?divisionFilter, Tier?tierFilter) => new Uri($"https://{Hostname}/cpix/r4_html_scoreboard/");
public abstract double GetCiscoPointsPossible(CompetitionRound round, Division division, Tier?tier);
public override double GetCiscoPointsPossible(CompetitionRound round, Division division, Tier?tier) { // http://www.uscyberpatriot.org/competition/competition-challenges-by-round switch (round) { case CompetitionRound.Round1: return(division == Division.MiddleSchool ? 0 : 20); case CompetitionRound.Round2: return(division == Division.MiddleSchool ? 0 : 30); case CompetitionRound.Round3: return(division == Division.MiddleSchool ? 30 : 100); case CompetitionRound.Semifinals: return(division == Division.MiddleSchool ? 30 : 100); } throw new ArgumentException("Unknown round."); }
public override double GetCiscoPointsPossible(CompetitionRound round, Division division, Tier?tier) { throw new NotImplementedException("CP-X Cisco totals are not implemented."); }
private void Application_Startup(object sender, StartupEventArgs e) { if (m_mutex.WaitOne(TimeSpan.Zero, true)) { Application.Current.ShutdownMode = ShutdownMode.OnExplicitShutdown; HtmlNode.ElementsFlags.Remove("form"); HtmlNode.ElementsFlags.Remove("option"); System.Net.ServicePointManager.Expect100Continue = false; ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12; LicenseManagerViewModel licenseManagerViewModel = new LicenseManagerViewModel() { Model = LicenseInfo.GetForCurrentDevice() }; LicenseChecker licenseChecker = new LicenseChecker() { DataContext = licenseManagerViewModel }; licenseChecker.ShowDialog(); if (!(licenseManagerViewModel.IsLicenseValid ?? false) && licenseManagerViewModel.IsCheckingFinished && licenseManagerViewModel.IsLicenseServerReachable) { LicenseManager lm = new LicenseManager() { DataContext = licenseManagerViewModel }; lm.ShowDialog(); } if (licenseManagerViewModel.IsLicenseValid ?? false) { using (StreamWriter writer = new StreamWriter("license.key")) { writer.WriteLine(licenseManagerViewModel.Model.Key); } string tierStr = licenseManagerViewModel.LicenseKey.Substring(14, 1); Tier?tier = null; if (tierStr == "N") { tier = Tier.Novice; } else if (tierStr == "S") { tier = Tier.Standart; } else if (tierStr == "U") { tier = Tier.Ultimate; } if (tier != null) { TierControl.Init((Tier)tier); AutoUpdater.AppTitle = "Project Destroyer"; AutoUpdater.Start("https://projectdestroyer.com/update/ui.xml"); CefSharp.Cef.Initialize(); Cef.GetGlobalCookieManager() .SetCookie("https://www.google.com", new Cookie() { Name = "NID", Value = "114=VmK5Yof_gASwTsA4f9mDhik59gO5ivFGNdwRFZ5eqb13IrO4y_oc7cqKOjD4d8VTeHqlSFtXecyGVpHTHCzi3H56q67Wic82SSme36ed0eSFnLAbZ7TzEMyMT83YvPTXDSB_UMNus_iOrgmpz2h1UHE5qMHImEeKqTNfJ-ufhJs", Domain = ".google.com", Secure = true, Expires = DateTime.Now.AddDays(364), Path = "/" }); Cef.GetGlobalCookieManager() .SetCookie("https://www.google.com", new Cookie() { Name = "SID", Value = "RQUZKqa2lvg8bV2MOpudssKUIM1m4ePTnSHRw8vJdLi5s6OqsMm-nauRbe30Pvd6E04m4g.", Domain = ".google.com", Secure = true, Expires = DateTime.Now.AddDays(364), Path = "/" }); Cef.GetGlobalCookieManager() .SetCookie("https://www.google.com", new Cookie() { Name = "HSID", Value = "AmU2jxCL2p_HH0ZPd", Domain = ".google.com", Secure = true, Expires = DateTime.Now.AddDays(364), Path = "/" }); Cef.GetGlobalCookieManager() .SetCookie("https://www.google.com", new Cookie() { Name = "SSID", Value = "A-zucxjV69YuQrG9R", Domain = ".google.com", Secure = true, Expires = DateTime.Now.AddDays(364), Path = "/" }); Cef.GetGlobalCookieManager() .SetCookie("https://www.google.com", new Cookie() { Name = "APISID", Value = "kKGH9LEmsKlHE1z5/AHkUX3rAZaMPSmMZI", Domain = ".google.com", Secure = true, Expires = DateTime.Now.AddDays(364), Path = "/" }); Cef.GetGlobalCookieManager() .SetCookie("https://www.google.com", new Cookie() { Name = "SAPISID", Value = "IbeC7mNDggiLVl1C/APfpkXK9im_Fx6R75", Domain = ".google.com", Secure = true, Expires = DateTime.Now.AddDays(364), Path = "/" }); //var ccm = CefSharp.Cef.GetGlobalCookieManager(); //foreach (string line in str.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries)) //{ // string[] fields = line.Split(new[] { '\t' }); // CefSharp.Cookie cookie = new CefSharp.Cookie() // { // Domain = fields[0], // Path = fields[2], // Secure = bool.Parse(fields[3]), // Expires = TimeHelper.UnixTimeStampToDateTime(double.Parse(fields[4]) < uint.MaxValue // ? double.Parse(fields[4]) // : int.MaxValue), // Name = fields[5], // Value = fields[6] // }; // string url = cookie.Secure ? "https://" : "http://"; // url = $"{url}{(cookie.Domain[0] != '.' ? cookie.Domain : cookie.Domain.Substring(1))}/"; // bool ress = ccm.SetCookie(url, cookie); //} MainWindow appWindow = new MainWindow() { DataContext = new AppViewModel() }; appWindow.ShowDialog(); CefSharp.Cef.Shutdown(); } else { MessageBox.Show("Your tier does not exists. Contact with support."); } } Application.Current?.Shutdown(); m_mutex.ReleaseMutex(); } else { MessageBox.Show("Only one instance of Project Destroyer at a time"); Application.Current?.Shutdown(); } }
internal static string ToSerializedValue(this Tier?value) { return(value == null ? null : ((Tier)value).ToSerializedValue()); }
public async Task GetTeamWithRankAsync(int rank, string location, DivisionWithCategory?divisionAndCat, Tier?tier) { using (Context.Channel.EnterTypingState()) { if (rank < 1) { throw new ArgumentOutOfRangeException(nameof(rank)); } var filter = new ScoreboardFilterInfo(divisionAndCat?.Division, tier, divisionAndCat?.Category, location); var teams = await ScoreRetrievalService.GetScoreboardAsync(filter).ConfigureAwait(false); System.Collections.Generic.IEnumerable <ScoreboardSummaryEntry> teamList = teams.TeamList; var team = teamList.Skip(rank - 1).First(); ScoreboardDetails teamScore = await ScoreRetrievalService.GetDetailsAsync(team.TeamId).ConfigureAwait(false); if (teamScore == null) { throw new Exception("Error obtaining team score."); } string classSpec = Utilities.JoinNonNullNonEmpty(", ", LocationResolutionService.GetFullNameOrNull(location), filter.Division.HasValue ? (filter.Division.Value.ToStringCamelCaseToSpace() + " Division") : null, filter.Category?.ToCanonicalName(), tier.HasValue ? (tier.Value.ToStringCamelCaseToSpace() + " Tier") : null); await ReplyAsync( "**" + Utilities.AppendOrdinalSuffix(rank) + " place " + (classSpec.Length == 0 ? "overall" : "in " + classSpec) + ": " + team.TeamId + "**", embed : ScoreEmbedBuilder.CreateTeamDetailsEmbed(teamScore, completeScoreboard : await ScoreRetrievalService.GetScoreboardAsync(new ScoreboardFilterInfo(null, null)).ConfigureAwait(false), peerFilter : CompetitionRoundLogicService.GetPeerFilter(ScoreRetrievalService.Round, team), timeZone : await Preferences.GetTimeZoneAsync(Context.Guild, Context.User).ConfigureAwait(false)).Build()).ConfigureAwait(false); } }
public async Task GetTeamWithPercentileAsync(double rank, DivisionWithCategory?divAndCat = null, Tier?tier = null) { using (Context.Channel.EnterTypingState()) { if (rank < 1) { throw new ArgumentOutOfRangeException(nameof(rank)); } var teams = await ScoreRetrievalService.GetScoreboardAsync(new ScoreboardFilterInfo(divAndCat?.Division, tier, divAndCat?.Category, null)).ConfigureAwait(false); // teams list in descending order int expectedIndex = ((int)Math.Round(((100 - rank) / 100) * teams.TeamList.Count)).Clamp(0, teams.TeamList.Count); ScoreboardDetails teamScore = await ScoreRetrievalService.GetDetailsAsync(teams.TeamList[expectedIndex].TeamId).ConfigureAwait(false); if (teamScore == null) { throw new Exception("Error obtaining team score."); } await ReplyAsync(string.Empty, embed : ScoreEmbedBuilder.CreateTeamDetailsEmbed(teamScore, completeScoreboard : await ScoreRetrievalService.GetScoreboardAsync(new ScoreboardFilterInfo(null, null)).ConfigureAwait(false), peerFilter : CompetitionRoundLogicService.GetPeerFilter(ScoreRetrievalService.Round, teamScore.Summary), timeZone : await Preferences.GetTimeZoneAsync(Context.Guild, Context.User).ConfigureAwait(false)).Build()).ConfigureAwait(false); } }
public async Task GetLeaderboardImplementationAsync(string location, ServiceCategory?category, Division?divFilter, Tier?tierFilter, int pageNumber) { using (Context.Channel.EnterTypingState()) { CompleteScoreboardSummary teamScore = await ScoreRetrievalService.GetScoreboardAsync(new ScoreboardFilterInfo(divFilter, tierFilter, category, location)).ConfigureAwait(false); if (teamScore == null) { throw new Exception("Error obtaining scoreboard."); } await ReplyAsync(ScoreEmbedBuilder.CreateTopLeaderboardEmbed(teamScore, pageNumber: pageNumber, timeZone: await Preferences.GetTimeZoneAsync(Context.Guild, Context.User).ConfigureAwait(false))).ConfigureAwait(false); } }
double ICompetitionRoundLogicService.GetCiscoPointsPossible(CompetitionRound round, Division division, Tier?tier) => underlyingService.GetCiscoPointsPossible(round, division, tier);
public async Task GenerateHistogramAsync(DivisionWithCategory?divisionWithCategory, Tier?tier, string imageName, string locCode) { using (Context.Channel.EnterTypingState()) { if (imageName != null && !ScoreRetrievalService.Metadata.SupportsInexpensiveDetailQueries) { throw new InvalidOperationException("Per-image histograms are not supported on online score providers. Use the `datasource` command to select an offline score provider."); } CompleteScoreboardSummary scoreboard = await ScoreRetrievalService.GetScoreboardAsync(new ScoreboardFilterInfo(divisionWithCategory?.Division, tier)).ConfigureAwait(false); decimal[] data = await scoreboard.TeamList .Conditionally(locCode != null, tle => tle.Where(t => t.Location == locCode)) .Conditionally(divisionWithCategory?.Category != null, tle => tle.Where(t => t.Category == divisionWithCategory.Value.Category)) .TernaryAsync(imageName == null, x => x.Select(datum => (decimal)datum.TotalScore).ToAsyncEnumerable(), x => x.Select(t => ScoreRetrievalService.GetDetailsAsync(t.TeamId)) .ToTaskResultEnumerable() .Select(t => t.Images.SingleOrDefault(i => i.ImageName == imageName)) .Where(i => i != null) .Select(i => (decimal)i.Score)) .ToArrayAsync().ConfigureAwait(false); Array.Sort(data); Models.User userSettings = await Preferences.Database.FindOneAsync <Models.User>(u => u.Id == Context.User.Id).ConfigureAwait(false); ColorPresets.HistogramColorPreset histogramColorScheme = (userSettings?.DiscordTheme ?? "dark") == "light" ? ColorPresets.DiscordLight : ColorPresets.DiscordDark; using (var memStr = new System.IO.MemoryStream()) { await GraphProvider.WriteHistogramPngAsync(data, "Score", "Frequency", datum => datum.ToString("0.0#"), histogramColorScheme, memStr).ConfigureAwait(false); memStr.Position = 0; var histogramEmbed = new EmbedBuilder() .WithTitle("CyberPatriot Score Analysis") .WithDescription(Utilities.JoinNonNullNonEmpty(" | ", imageName.AppendPrependIfNonEmpty("`"), divisionWithCategory?.Division.ToStringCamelCaseToSpace(), tier, divisionWithCategory?.Category?.ToCanonicalName(), LocationResolutionService.GetFullNameOrNull(locCode)) .CoalesceBlank("All Teams")) .AddInlineField("Teams", data.Length) .AddInlineField("Mean", $"{data.Average():0.##}") .AddInlineField("Standard Deviation", $"{data.StandardDeviation():0.##}") .AddInlineField("First Quartile", $"{data.Take(data.Length / 2).ToArray().Median():0.##}") .AddInlineField("Median", $"{data.Median():0.##}") .AddInlineField("Third Quartile", $"{data.Skip(data.Length / 2).ToArray().Median():0.##}") .AddInlineField("Min Score", $"{data.Min()}") .AddInlineField("Max Score", $"{data.Max()}") .WithTimestamp(scoreboard.SnapshotTimestamp) .WithFooter(ScoreRetrievalService.Metadata.StaticSummaryLine) .WithImageUrl("attachment://histogram.png"); // Discord API requirement to use the uploaded histogram await Context.Channel.SendFileAsync(memStr, "histogram.png", embed : histogramEmbed.Build()).ConfigureAwait(false); } } }
public async Task GetImageLeaderboardImplementationAsync(string image, string location, ServiceCategory?category, Division?division, Tier?tier, int pageNumber) { using (Context.Channel.EnterTypingState()) { if (!ScoreRetrievalService.Metadata.SupportsInexpensiveDetailQueries) { throw new InvalidOperationException("Image-specific queries cannot be performed on online score providers. Please use datasource to specify an offline score provider."); } System.Collections.Generic.IEnumerable <ScoreboardSummaryEntry> teams = (await ScoreRetrievalService.GetScoreboardAsync(new ScoreboardFilterInfo(division, tier)).ConfigureAwait(false))?.TeamList; if (teams == null) { throw new Exception("Error obtaining scoreboard."); } if (category.HasValue) { var catVal = category.Value; teams = teams.Where(t => t.Category == catVal); } if (location != null) { teams = teams.Where(t => t.Location == location); } string filterDesc = Utilities.JoinNonNullNonEmpty(", ", !division.HasValue ? null : division.Value.ToStringCamelCaseToSpace() + " Division", !tier.HasValue ? null : tier.Value.ToStringCamelCaseToSpace() + " Tier", !category.HasValue ? null : category.Value.ToCanonicalName(), LocationResolutionService.GetFullNameOrNull(location)); var downloadTasks = teams.Select(t => ScoreRetrievalService.GetDetailsAsync(t.TeamId)).ToArray(); try { await Task.WhenAll(downloadTasks).ConfigureAwait(false); } catch { // oh well? } await ReplyAsync( message : ScoreEmbedBuilder.CreateImageLeaderboardEmbed(downloadTasks.Where(t => t.IsCompletedSuccessfully).Select( t => new System.Collections.Generic.KeyValuePair <ScoreboardSummaryEntry, ScoreboardImageDetails>(t.Result.Summary, t.Result.Images.SingleOrDefault(i => i.ImageName.Equals(image, StringComparison.InvariantCultureIgnoreCase)))) .Where(kvp => kvp.Value != null).OrderByDescending(kvp => kvp.Value.Score).ThenBy(kvp => kvp.Value.PlayTime), filterDescription: filterDesc, pageNumber: pageNumber)).ConfigureAwait(false); } }
public ScoreboardFilterInfo(Division?divFilter, Tier?tierFilter) : this(divFilter, tierFilter, null, null) { }
public ScoreboardFilterInfo(Division?divFilter, Tier?tierFilter) { Division = divFilter; Tier = tierFilter; }