/// <summary> /// Get Usage Trend Data from the Sense API /// </summary> /// <param name="monitorId">Monitor ID to get the trend data from</param> /// <param name="granularity">Granularity to use, valid uses are Hour, Day, Month and Year</param> /// <param name="startDateTime">Start Date and Time to start the trend data retrieval from</param> /// <returns>TrendData object</returns> public async Task <TrendData> GetUsageTrendData(int monitorId, Granularity granularity, DateTime startDateTime) { if (granularity != Granularity.Hour && granularity != Granularity.Day && granularity != Granularity.Month && granularity != Granularity.Year) { throw new InvalidEnumArgumentException($"{granularity.ToString()} is not a valid granularity for this call."); } using (var httpClient = new HttpClient()) { httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Config["accesstoken"]); var callData = $"{apiAddress}/app/history/trends?monitor_id={monitorId}&device_id=usage&scale={granularity.ToString().ToLowerInvariant()}&start={startDateTime.ToUniversalTime().ToString("yyyy-MM-ddThh:mm:ssZ", CultureInfo.InvariantCulture)}"; var response = await httpClient.GetAsync(callData); await CheckResponseStatus(response, httpClient, callData); var json = await response.Content.ReadAsStringAsync(); var trendData = JsonConvert.DeserializeObject <TrendData>(json); return(trendData); } }
public IHttpQueryString GetQueryString() { // Initialize the query string SocialHttpQueryString query = new SocialHttpQueryString(); // Set required parameters query.Set("lat", Latitude); query.Set("long", Longitude); // Set optional parameters if (Accurary != null && Accurary != "0m") { query.Set("accuracy", Accurary); } if (Granularity != default(TwitterGranularity)) { query.Set("granularity", Granularity.ToString().ToLower()); } if (MaxResults > 0) { query.Set("max_results", MaxResults); } return(query); }
/// <summary> /// Generate the necessary parameters /// </summary> public override List <KeyValuePair <string, string> > GetParams() { var p = new List <KeyValuePair <string, string> >(); if (Sim != null) { p.Add(new KeyValuePair <string, string>("Sim", Sim.ToString())); } if (Granularity != null) { p.Add(new KeyValuePair <string, string>("Granularity", Granularity.ToString())); } if (StartTime != null) { p.Add(new KeyValuePair <string, string>("StartTime", Serializers.DateTimeIso8601(StartTime))); } if (EndTime != null) { p.Add(new KeyValuePair <string, string>("EndTime", Serializers.DateTimeIso8601(EndTime))); } if (PageSize != null) { p.Add(new KeyValuePair <string, string>("PageSize", PageSize.ToString())); } return(p); }
/// <summary> /// Get the history samples for a specific device from the Sense monitor /// </summary> /// <param name="monitorId">Monitor ID to get the history sampling from</param> /// <param name="deviceId">Device ID to get the history sampling for</param> /// <param name="granularity">Granularity to use, valid uses are Second, Minute, Hour and Day</param> /// <param name="startDateTime">Start Date and Time to start the sample retrieval from</param> /// <param name="sampleCount">Number of samples to retrieve.</param> /// <returns>HistoryRecord object with a list sampling values for the monitor in the chosen granularity interval</returns> public async Task <HistoryRecord> GetDeviceHistory(int monitorId, string deviceId, Granularity granularity, DateTime startDateTime, int sampleCount) { if (granularity != Granularity.Second && granularity != Granularity.Minute && granularity != Granularity.Hour && granularity != Granularity.Day) { throw new InvalidEnumArgumentException($"{granularity.ToString()} is not a valid granularity for this call."); } using (var httpClient = new HttpClient()) { httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Config["accesstoken"]); var callData = $"{apiAddress}/app/history/usage?monitor_id={monitorId}&device_id={deviceId}&granularity={granularity.ToString().ToLowerInvariant()}&start={startDateTime.ToUniversalTime().ToString("yyyy-MM-ddThh:mm:ssZ", CultureInfo.InvariantCulture)}&frames={sampleCount}"; var response = await httpClient.GetAsync(callData); await CheckResponseStatus(response, httpClient, callData); var json = await response.Content.ReadAsStringAsync(); var history = JsonConvert.DeserializeObject <HistoryRecord>(json); return(history); } }
private async Task <T[]> GetCandlesImpl <T>( string instrument, Granularity granularity, int count, DateTime?start, DateTime?end, bool includeFirst, int dailyAlignment, string alignmentTimezone, string weeklyAlignment) { var query = new StringBuilder(); query.Append($"/v1/candles?instrument={instrument}"); if (typeof(T) == typeof(BidAskCandle)) { query.Append("&candleFormat=bidask"); } if (typeof(T) == typeof(MidpointCandle)) { query.Append("&candleFormat=midpoint"); } if (granularity != Granularity.S5) { query.Append($"&granularity={granularity.ToString()}"); } if (count != 500) { query.Append($"&count={count}"); } if (start != null) { query.Append($"&start={Uri.EscapeUriString(XmlConvert.ToString(start.Value, XmlDateTimeSerializationMode.Utc))}"); } if (end != null) { query.Append($"&end={Uri.EscapeUriString(XmlConvert.ToString(end.Value, XmlDateTimeSerializationMode.Utc))}"); } if (!includeFirst) { query.Append($"&includeFirst={includeFirst}"); } if (dailyAlignment != 0) { query.Append($"&dailyAlignment={dailyAlignment}"); } if (alignmentTimezone != "America/New_York") { query.Append($"&alignmentTimezone={Uri.EscapeUriString(alignmentTimezone)}"); } if (weeklyAlignment != "Friday") { query.Append($"&weeklyAlignment={weeklyAlignment}"); } return((await GetResponse <CandlesResponse <T> >(query.ToString())).Candles); }
private static void ShowUsage() { string exe = Process.GetCurrentProcess().ProcessName; Console.WriteLine(ProductText + " v" + VersionText); Console.WriteLine(); Console.WriteLine("Usage:"); Console.WriteLine($"{exe} [/fussy] [/g:<granularity>] [/i:<ext>] [/k] [/logtag] [/out:<mirror>] [/p:<n>] [/safety:<n>] [/sig:<signature>] [/verify[:web]] <directory>"); Console.WriteLine(); Console.WriteLine("Where <directory> is a relative or absolute directory name without wildcards."); Console.Write("Where <granularity> from "); for (Granularity gx = Granularity.Detail; gx < maxGranularity; ++gx) { Console.Write(gx.ToString()); Console.Write(", "); } Console.Write(maxGranularity.ToString()); Console.WriteLine("."); Console.WriteLine(); Console.WriteLine("Use /fussy to escalate rip acceptability issues."); Console.WriteLine(); Console.WriteLine("Use /g:verbose to get more feedback."); Console.WriteLine(); Console.WriteLine("Use /i:.foo to ignore directories containing any file ending with .foo."); Console.WriteLine(); Console.WriteLine("Use /k to wait for keypress before exiting."); Console.WriteLine(); Console.WriteLine("Use /logtag to insert compression profile into EAC .log name."); Console.WriteLine(); Console.WriteLine("Use /out:results.txt to mirror output to results.txt."); Console.WriteLine(); Console.WriteLine("Use /p:0 to suppress the progress counter."); Console.WriteLine(); Console.WriteLine("Use /safety:0 to disable prompting after consecutive rip invalidations."); Console.WriteLine(); Console.WriteLine("Use /sig:SIG to sign (rename) EAC .log and create .sha1x digest."); Console.WriteLine(); Console.WriteLine("Use /verify:web to verify EAC 1.x .log self-hashes online."); Console.WriteLine(); Console.WriteLine("Description:"); Console.WriteLine(); foreach (var line in helpText) { Console.WriteLine(line); } }
/// <summary> /// Generate the necessary parameters /// </summary> public override List <KeyValuePair <string, string> > GetParams() { var p = new List <KeyValuePair <string, string> >(); if (Sim != null) { p.Add(new KeyValuePair <string, string>("Sim", Sim.ToString())); } if (Fleet != null) { p.Add(new KeyValuePair <string, string>("Fleet", Fleet.ToString())); } if (Network != null) { p.Add(new KeyValuePair <string, string>("Network", Network.ToString())); } if (IsoCountry != null) { p.Add(new KeyValuePair <string, string>("IsoCountry", IsoCountry.ToString())); } if (Group != null) { p.Add(new KeyValuePair <string, string>("Group", Group.ToString())); } if (Granularity != null) { p.Add(new KeyValuePair <string, string>("Granularity", Granularity.ToString())); } if (StartTime != null) { p.Add(new KeyValuePair <string, string>("StartTime", Serializers.DateTimeIso8601(StartTime))); } if (EndTime != null) { p.Add(new KeyValuePair <string, string>("EndTime", Serializers.DateTimeIso8601(EndTime))); } if (PageSize != null) { p.Add(new KeyValuePair <string, string>("PageSize", PageSize.ToString())); } return(p); }
/// <summary> /// Get Usage Trend Data from the Sense API /// </summary> /// <param name="monitorId">Monitor ID to get the trend data from</param> /// <param name="granularity">Granularity to use, valid uses are Hour, Day, Month and Year</param> /// <param name="startDateTime">Start Date and Time to start the trend data retrieval from</param> /// <returns>TrendData object</returns> public async Task <TrendData> GetUsageTrendData(int monitorId, Granularity granularity, DateTime startDateTime) { if (granularity != Granularity.Hour && granularity != Granularity.Day && granularity != Granularity.Month && granularity != Granularity.Year) { throw new InvalidEnumArgumentException($"{granularity.ToString()} is not a valid granularity for this call."); } var callData = $"{apiAddress}/app/history/trends?monitor_id={monitorId}&device_id=usage&scale={granularity.ToString().ToLowerInvariant()}&start={startDateTime.ToUniversalTime().ToString("yyyy-MM-ddThh:mm:ssZ", CultureInfo.InvariantCulture)}"; var trendData = await ApiCallAsync <TrendData>(callData); return(trendData); }
/// <summary> /// Get the history samples for a specific device from the Sense monitor /// </summary> /// <param name="monitorId">Monitor ID to get the history sampling from</param> /// <param name="deviceId">Device ID to get the history sampling for</param> /// <param name="granularity">Granularity to use, valid uses are Second, Minute, Hour and Day</param> /// <param name="startDateTime">Start Date and Time to start the sample retrieval from</param> /// <param name="sampleCount">Number of samples to retrieve.</param> /// <returns>HistoryRecord object with a list sampling values for the monitor in the chosen granularity interval</returns> public async Task <HistoryRecord> GetDeviceHistory(int monitorId, string deviceId, Granularity granularity, DateTime startDateTime, int sampleCount) { if (granularity != Granularity.Second && granularity != Granularity.Minute && granularity != Granularity.Hour && granularity != Granularity.Day) { throw new InvalidEnumArgumentException($"{granularity.ToString()} is not a valid granularity for this call."); } var callData = $"{apiAddress}/app/history/usage?monitor_id={monitorId}&device_id={deviceId}&granularity={granularity.ToString().ToLowerInvariant()}&start={startDateTime.ToUniversalTime().ToString("yyyy-MM-ddThh:mm:ssZ", CultureInfo.InvariantCulture)}&frames={sampleCount}"; var history = await ApiCallAsync <HistoryRecord>(callData); return(history); }
/// <summary> /// Get the generic monitor history samples from the Sense monitor /// </summary> /// <param name="monitorId">Monitor ID to get the history sampling from</param> /// <param name="granularity">Granularity to use, valid uses are Second, Minute, Hour and Day</param> /// <param name="startDateTime">Start Date and Time to start the sample retrieval from</param> /// <param name="sampleCount">Number of samples to retrieve.</param> /// <returns>HistoryRecord object with a list sampling values for the monitor in the chosen granularity interval</returns> public async Task <HistoryRecord> GetMonitorHistory(int monitorId, Granularity granularity, DateTime startDateTime, int sampleCount) { var callData = $"{apiAddress}/app/history/usage?monitor_id={monitorId}&granularity={granularity.ToString().ToLowerInvariant()}&start={startDateTime.ToUniversalTime().ToString("yyyy-MM-ddThh:mm:ssZ", CultureInfo.InvariantCulture)}&frames={sampleCount}"; var history = await ApiCallAsync <HistoryRecord>(callData); return(history); }
public RuleSet(Granularity granularity) : this(granularity.ToString(), granularity) { }
private static void ShowUsage() { string exe = Process.GetCurrentProcess().ProcessName; Console.WriteLine($"{ProductText} v{VersionText}"); Console.WriteLine(); Console.WriteLine("Usage:"); Console.WriteLine($"{exe} [/autoname[:<strategy>]] [/fussy] [/g:<granularity>] [/k] [/md5] [/out:<mirror>] [/p:<n>] [/prove[:web]] [/rg] [/safety:<n>] [/sig:<signature>] [/ubertags] <directory>"); Console.WriteLine(); Console.WriteLine("Where <directory> is a relative or absolute directory name without wildcards."); Console.WriteLine("Where <strategy> from " + String.Join(", ", Enum.GetNames(typeof(NamingStrategy))) + "."); Console.Write("Where <granularity> from "); for (Granularity gx = Granularity.Detail; gx < maxGranularity; ++gx) { Console.Write(gx.ToString()); Console.Write(", "); } Console.Write(maxGranularity.ToString()); Console.WriteLine("."); Console.WriteLine(); Console.WriteLine("Use /autoname to rename directory and files based on tags."); Console.WriteLine(); Console.WriteLine("Use /fussy to escalate rip acceptability issues."); Console.WriteLine(); Console.WriteLine("Use /g:verbose to get more feedback."); Console.WriteLine(); Console.WriteLine("Use /k to wait for keypress before exiting."); Console.WriteLine(); Console.WriteLine("Use /md5 to additionally perform MD5 checks of FLACs."); Console.WriteLine(); Console.WriteLine("Use /out:results.txt to mirror output to results.txt."); Console.WriteLine(); Console.WriteLine("Use /p:0 to suppress the progress counter."); Console.WriteLine(); Console.WriteLine("Use /prove to escalate rip integrity issues."); Console.WriteLine(); Console.WriteLine("Use /prove:web to escalate rip issues and verify EAC 1.x log self-hashes online."); Console.WriteLine(); Console.WriteLine("Use /rg to add ReplayGain (using metaflac.exe) on first signing."); Console.WriteLine(); Console.WriteLine("Use /safety:0 to disable prompting after consecutive invalidations."); Console.WriteLine(); Console.WriteLine("Use /sig:SIG to sign (rename) EAC .log and create .md5 digest."); Console.WriteLine(); Console.WriteLine("Use /ubertags to escalate substandard tagging issues."); Console.WriteLine(); Console.WriteLine("Description:"); Console.WriteLine(); foreach (var line in helpText) { Console.WriteLine(line); } }
/// <summary> /// Validate multiple granularities to ensure no overlapping ranges, etc. /// </summary> public void ValidatePartitioningConfigurations() { if (this.PartitioningConfigurations.Count > 1) { this.PartitioningConfigurations.Sort(); //Sorts by LowerBoundary value DateTime previousUpperBoundary = DateTime.MinValue; Granularity previousGranularity = Granularity.Daily; bool foundDaily = false, foundMonthly = false, foundYearly = false; foreach (PartitioningConfiguration partitioningConfiguration in this.PartitioningConfigurations) { #region Check don't have multiple partitioning configurations with same granularity string multiSameGrainErrorMessage = $"Table {this.AnalysisServicesTable} contains multiple {{0}} partitioning configurations, which is not allowed."; switch (partitioningConfiguration.Granularity) { case Granularity.Daily: if (foundDaily) { throw new InvalidOperationException(string.Format(multiSameGrainErrorMessage, "daily")); } else { foundDaily = true; } break; case Granularity.Monthly: if (foundMonthly) { throw new InvalidOperationException(string.Format(multiSameGrainErrorMessage, "monthly")); } else { foundMonthly = true; } break; case Granularity.Yearly: if (foundYearly) { throw new InvalidOperationException(string.Format(multiSameGrainErrorMessage, "yearly")); } else { foundYearly = true; } break; default: break; } #endregion #region Check don't have overlapping date ranges if (partitioningConfiguration.LowerBoundary <= previousUpperBoundary) { throw new InvalidOperationException($"Table {this.AnalysisServicesTable} contains partitioning configurations with overlapping date ranges, which is not allowed. {previousGranularity.ToString()} upper boundary is {previousUpperBoundary.ToString("yyyy-MM-dd")}; {partitioningConfiguration.Granularity.ToString()} lower boundary is {partitioningConfiguration.LowerBoundary.ToString("yyyy-MM-dd")}."); } else { previousUpperBoundary = partitioningConfiguration.UpperBoundary; previousGranularity = partitioningConfiguration.Granularity; } #endregion } } }
/// <summary> /// Get the generic monitor history samples from the Sense monitor /// </summary> /// <param name="monitorId">Monitor ID to get the history sampling from</param> /// <param name="granularity">Granularity to use, valid uses are Second, Minute, Hour and Day</param> /// <param name="startDateTime">Start Date and Time to start the sample retrieval from</param> /// <param name="sampleCount">Number of samples to retrieve.</param> /// <returns>HistoryRecord object with a list sampling values for the monitor in the chosen granularity interval</returns> public async Task <HistoryRecord> GetMonitorHistory(int monitorId, Granularity granularity, DateTime startDateTime, int sampleCount) { using (var httpClient = new HttpClient()) { httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Config["accesstoken"]); var callData = $"{apiAddress}/app/history/usage?monitor_id={monitorId}&granularity={granularity.ToString().ToLowerInvariant()}&start={startDateTime.ToUniversalTime().ToString("yyyy-MM-ddThh:mm:ssZ",CultureInfo.InvariantCulture)}&frames={sampleCount}"; var response = await httpClient.GetAsync(callData); await CheckResponseStatus(response, httpClient, callData); var json = await response.Content.ReadAsStringAsync(); var history = JsonConvert.DeserializeObject <HistoryRecord>(json); return(history); } }
/// <summary> /// Get the instrument and granularity based blob folder /// </summary> /// <param name="instrument"></param> /// <param name="granularity"></param> /// <returns></returns> private string GetInstrumentFolder(InstrumentName instrument, Granularity granularity) => $"{instrument.ToString().ToUpper()}/{granularity.ToString().ToUpper()}";