public void GetTopLinks(string name, FromTime ft, int howMany) { imageUrlDict = new Dictionary <string, Uri>(); WriteToDebugLog($"Searching {name} for {howMany} top posts from past {ft} ago"); Reddit reddit = new Reddit(); Subreddit subreddit = reddit.GetSubreddit(name); int count = 1; int newItems = 0; foreach (Post post in subreddit.GetTop(ft)) { breakLinkSearching = false; var findNewItems_IsChecked = false; this.Dispatcher.Invoke(() => { findNewItems_IsChecked = checkBox_FindNewItems.IsChecked ?? false; }); AddPostToList(ref count, ref newItems, post, findNewItems_IsChecked, howMany); if (breakLinkSearching) { break; } } TheGreatImageFilter(imageUrlDict); WriteToDebugLog("\n"); }
private void listBox_FromTime_SelectionChanged(object sender, SelectionChangedEventArgs e) { string selectedTime = ((ListBoxItem)listBox_FromTime.SelectedValue).Content.ToString(); switch (selectedTime) { case "Day": fromtime = FromTime.Day; break; case "Week": fromtime = FromTime.Week; break; case "Month": fromtime = FromTime.Month; break; case "Year": fromtime = FromTime.Year; break; case "All": fromtime = FromTime.All; break; default: break; } }
/// <summary> /// Get a listing of posts from the user sorted by <paramref name="sorting"/>, from time <paramref name="fromTime"/> /// and limited to <paramref name="limit"/>. /// </summary> /// <param name="sorting">How to sort the posts (hot, new, top, controversial).</param> /// <param name="limit">How many posts to fetch per request. Max is 100.</param> /// <param name="fromTime">What time frame of posts to show (hour, day, week, month, year, all).</param> /// <returns>The listing of posts requested.</returns> public Listing <Post> GetPosts(Sort sorting = Sort.New, int limit = 25, FromTime fromTime = FromTime.All) { CheckRange(limit, 100); string linksUrl = LinksUrl + QueryString(sorting, limit, fromTime); return(new Listing <Post>(WebAgent, linksUrl)); }
public bool Contains(DateTime time, DateTime periodStart, DateTime periodEnd) { int startHour = int.Parse(FromTime.Substring(0, 2)); int startMinute = int.Parse(FromTime.Substring(3, 2)); int endHour = int.Parse(ToTime.Substring(0, 2)); int endMinute = int.Parse(ToTime.Substring(3, 2)); while (periodStart <= periodEnd) { if (DaysOfWeek.Contains(periodStart.DayOfWeek)) { var dayPartStart = new DateTime(periodStart.Year, periodStart.Month, periodStart.Day, startHour, startMinute, 0); var dayPartEnd = new DateTime(periodStart.Year, periodStart.Month, periodStart.Day, endHour, endMinute, 59); var result = time >= dayPartStart && time <= dayPartEnd; if (result) { return(true); } } periodStart = periodStart.AddDays(1); } return(false); }
public override string ToString() { return(string.Format("[{0} -> {1}]/{2}: {3}", FromTime.ToString("HH:mm"), ToTime.ToString("HH:mm"), this.TotalHours(), this.TimeSheetType.ToString())); }
public Listing <Post> GetTop(FromTime timePeriod) { if (Name == "/") { return(new Listing <Post>(Reddit, "/top.json?t=" + Enum.GetName(typeof(FromTime), timePeriod).ToLower(), WebAgent)); } return(new Listing <Post>(Reddit, string.Format(SubredditTopUrl, Name, Enum.GetName(typeof(FromTime), timePeriod)).ToLower(), WebAgent)); }
public override string ToString() { if (!String.IsNullOrEmpty(Hospital)) { return(FromTime.ToString("hh\\:mm") + " até " + ToTime.ToString("hh\\:mm") + " no " + Hospital); } return(FromTime.ToString("hh\\:mm") + " até " + ToTime.ToString("hh\\:mm")); }
private void UpdateTimespan() { Properties.Settings.Default.FromTime = FromTime.ToString("o"); Properties.Settings.Default.ToTime = ToTime.ToString("o"); Properties.Settings.Default.Save(); overviewPage.UpdateTimespan(FromTime, ToTime); }
public Listing<Post> GetTop(FromTime timePeriod) { if (Name == "/") { return new Listing<Post>(Reddit, "/top.json?t=" + Enum.GetName(typeof(FromTime), timePeriod).ToLower(), WebAgent); } return new Listing<Post>(Reddit, string.Format(SubredditConstants.SubredditTopUrl, Name, Enum.GetName(typeof(FromTime), timePeriod)).ToLower(), WebAgent); }
public override void Initialize() { base.Initialize(); Events = (from date in FromTime.GetDateRange(ToTime) select new DailyMarketCloseEvent { EventTime = date }).ToArray(); }
public override string ToString() { return(string.Format( "{0}\n{1} - {2}\n{3}", Subject, FromTime.ToString("HH:mm"), ToTime.ToString("HH:mm"), Teacher )); }
public override string ToString() { if (Every == 1) { return("every hour between " + FromTime.ToString(@"H\:mm") + " and " + ToTime.ToString(@"H\:mm")); } else { return("every " + Every.ToString() + " hours between " + FromTime.ToString(@"H\:mm") + " and " + ToTime.ToString(@"H\:mm")); } }
public override List <DateTime> GetPeriodStartDates() { var dates = new List <DateTime>(NumPeriods); for (int i = 0; i < NumPeriods; i++) { dates.Add(FromTime.AddDays(i)); } return(dates); }
/// <summary> /// Top of the subreddit from a particular time. /// </summary> /// <param name="timePeriod">Timeperiod you want to start at <seealso cref="FromTime"/></param> /// <param name="max">Maximum number of records to return.</param> /// <returns>The top of the subreddit from a specific time</returns> public Listing <Post> GetTop(FromTime timePeriod, int max = -1) { var period = timePeriod.ToString("g").ToLower(); if (Name == "/") { return(Listing <Post> .Create(WebAgent, "/top.json?t=" + period, max, 100)); } return(Listing <Post> .Create(WebAgent, $"{SubredditTopUrl}?t={period}", max, 100)); }
/// <summary> /// Get a listing of comments from the user sorted by <paramref name="sorting"/>, from time <paramref name="fromTime"/> /// and limited to <paramref name="limit"/>. /// </summary> /// <param name="sorting">How to sort the comments (hot, new, top, controversial).</param> /// <param name="limit">How many comments to fetch per request. Max is 100.</param> /// <param name="fromTime">What time frame of comments to show (hour, day, week, month, year, all).</param> /// <returns>The listing of comments requested.</returns> public Listing <Comment> GetComments(Sort sorting, int limit, FromTime fromTime) { if ((limit < 1) || (limit > MAX_LIMIT)) { throw new ArgumentOutOfRangeException("limit", "Valid range: [1," + MAX_LIMIT + "]"); } string commentsUrl = string.Format(CommentsUrl, Name); commentsUrl += string.Format("?sort={0}&limit={1}&t={2}", Enum.GetName(typeof(Sort), sorting), limit, Enum.GetName(typeof(FromTime), fromTime)); return(new Listing <Comment>(Reddit, commentsUrl, WebAgent)); }
/// <summary> /// Get a listing of posts from the user sorted by <paramref name="sorting"/>, from time <paramref name="fromTime"/> /// and limited to <paramref name="limit"/>. /// </summary> /// <param name="sorting">How to sort the posts (hot, new, top, controversial).</param> /// <param name="limit">How many posts to fetch per request. Max is 100.</param> /// <param name="fromTime">What time frame of posts to show (hour, day, week, month, year, all).</param> /// <returns>The listing of posts requested.</returns> public Listing <Post> GetPosts(Sort sorting = Sort.New, int limit = 25, FromTime fromTime = FromTime.All) { if ((limit < 1) || (limit > 100)) { throw new ArgumentOutOfRangeException("limit", "Valid range: [1,100]"); } string linksUrl = string.Format(LinksUrl, Name); linksUrl += string.Format("?sort={0}&limit={1}&t={2}", Enum.GetName(typeof(Sort), sorting), limit, Enum.GetName(typeof(FromTime), fromTime)); return(new Listing <Post>(Reddit, linksUrl, WebAgent)); }
private void UpdateToTimes() { ToDateTimes.Clear(); int i = 1; for (var x = FromTime.Hour; x <= (FromTime.Hour + 24); x++) { ToDateTimes.Add(FromTime.AddHours(i++)); } if (ToTime <= FromTime) { ToTime = FromTime.AddHours(1); } }
/// <summary> /// Validate the object. /// </summary> /// <exception cref="ValidationException"> /// Thrown if validation fails /// </exception> public virtual void Validate() { if (FromTime == null) { throw new ValidationException(ValidationRules.CannotBeNull, "FromTime"); } if (ToTime == null) { throw new ValidationException(ValidationRules.CannotBeNull, "ToTime"); } if (FromTime != null) { FromTime.Validate(); } if (ToTime != null) { ToTime.Validate(); } }
private Boolean InputSettingsAreValid() { if (FromTime.Value.HasValue == false) { FromTime.Focus(); MessageBox.Show("please select a start time", "Invalid Settings", MessageBoxButton.OK, MessageBoxImage.Information); return(false); } if (ToTime.Value.HasValue == false) { ToTime.Focus(); MessageBox.Show("please select a end time", "Invalid Settings", MessageBoxButton.OK, MessageBoxImage.Information); return(false); } if (FromTime.Value.Value == ToTime.Value.Value) { MessageBox.Show("selected timespans are not valid", "Invalid Settings", MessageBoxButton.OK, MessageBoxImage.Information); return(false); } if (RunUntil.SelectedDate.HasValue == false) { RunUntil.Focus(); MessageBox.Show("please select an end date", "Invalid Settings", MessageBoxButton.OK, MessageBoxImage.Information); return(false); } if (RunUntil.SelectedDate.Value.Date < DateTime.Now.Date) { RunUntil.Focus(); MessageBox.Show("end date must be greater than today", "Invalid Settings", MessageBoxButton.OK, MessageBoxImage.Information); return(false); } return(true); }
public ArrayList getTopByKeyword(string subName, int maxPostsToSearch, FromTime time, string keyword) { Subreddit sub = reddit.GetSubreddit(subName); Listing<Post> top = sub.GetTop(time); return searchTitles(top, keyword, maxPostsToSearch); }
/// <summary> /// Get a listing of comments and posts saved by the user sorted by <paramref name="sorting"/>, from time <paramref name="fromTime"/> /// and limited to <paramref name="limit"/>. /// </summary> /// <param name="sorting">How to sort the comments (hot, new, top, controversial).</param> /// <param name="limit">How many comments to fetch per request. Max is 100.</param> /// <param name="fromTime">What time frame of comments to show (hour, day, week, month, year, all).</param> /// <returns>The listing of posts and/or comments requested that the user saved.</returns> public Listing <VotableThing> GetSaved(Sort sorting = Sort.New, int limit = 25, FromTime fromTime = FromTime.All) { if ((limit < 1) || (limit > MAX_LIMIT)) { throw new ArgumentOutOfRangeException("limit", "Valid range: [1," + MAX_LIMIT + "]"); } string savedUrl = string.Format(SavedUrl, Name); savedUrl += string.Format("?sort={0}&limit={1}&t={2}", Enum.GetName(typeof(Sort), sorting), limit, Enum.GetName(typeof(FromTime), fromTime)); return(new Listing <VotableThing>(Reddit, savedUrl, WebAgent)); }
public override string ToString() { return(string.Concat(FromTime.ToString("h:mm"), " - ", ToTime.ToString("h:mm"))); }
public static Listing <Post> GetPosts(Reddit reddit, IWebAgent webagent, string name, Sort sorting, int limit, FromTime fromTime) { if ((limit < 1) || (limit > 100)) { throw new ArgumentOutOfRangeException("limit", "Valid range: [1,100]"); } string linksUrl = string.Format(LinksUrl, name); linksUrl += string.Format("?sort={0}&limit={1}&t={2}", Enum.GetName(typeof(Sort), sorting), limit, Enum.GetName(typeof(FromTime), fromTime)); return(new Listing <Post>(reddit, linksUrl, webagent)); }
/// <summary> /// Get a listing of comments and posts from the user sorted by <paramref name="sorting"/>, from time <paramref name="fromTime"/> /// and limited to <paramref name="limit"/>. /// </summary> /// <param name="sorting">How to sort the comments and posts (hot, new, top, controversial).</param> /// <param name="limit">How many comments and posts to fetch per request. Max is 100.</param> /// <param name="fromTime">What time frame of comments and posts to show (hour, day, week, month, year, all).</param> /// <returns>The listing of comments and posts requested.</returns> public Listing<VotableThing> GetOverview(Sort sorting, int limit, FromTime fromTime) { if ((limit < 1) || (limit > MAX_LIMIT)) throw new ArgumentOutOfRangeException("limit", "Valid range: [1," + MAX_LIMIT + "]"); string overviewUrl = string.Format(OverviewUrl, Name); overviewUrl += string.Format("?sort={0}&limit={1}&t={2}", Enum.GetName(typeof(Sort), sorting), limit, Enum.GetName(typeof(FromTime), fromTime)); return new Listing<VotableThing>(Reddit, overviewUrl, WebAgent); }
/// <summary> /// Get a listing of comments and posts saved by the user sorted by <paramref name="sorting"/>, from time <paramref name="fromTime"/> /// and limited to <paramref name="limit"/>. /// </summary> /// <param name="sorting">How to sort the comments (hot, new, top, controversial).</param> /// <param name="limit">How many comments to fetch per request. Max is 100.</param> /// <param name="fromTime">What time frame of comments to show (hour, day, week, month, year, all).</param> /// <returns>The listing of posts and/or comments requested that the user saved.</returns> public Listing <VotableThing> GetSaved(Sort sorting = Sort.New, int limit = 25, FromTime fromTime = FromTime.All) { CheckRange(limit, 100); string savedUrl = SavedUrl + QueryString(sorting, limit, fromTime); return(new Listing <VotableThing>(WebAgent, savedUrl)); }
/// <summary> /// Get a listing of comments and posts from the user sorted by <paramref name="sorting"/>, from time <paramref name="fromTime"/> /// and limited to <paramref name="limit"/>. /// </summary> /// <param name="sorting">How to sort the comments (hot, new, top, controversial).</param> /// <param name="limit">How many comments to fetch per request. Max is 100.</param> /// <param name="fromTime">What time frame of comments to show (hour, day, week, month, year, all).</param> /// <returns>The listing of comments requested.</returns> public Listing <VotableThing> GetOverview(Sort sorting = Sort.New, int limit = 25, FromTime fromTime = FromTime.All) { CheckRange(limit, MAX_LIMIT); string overviewUrl = OverviewUrl + QueryString(sorting, limit, fromTime); return(new Listing <VotableThing>(WebAgent, overviewUrl)); }
/// <summary> /// Get a listing of comments from the user sorted by <paramref name="sorting"/>, from time <paramref name="fromTime"/> /// and limited to <paramref name="limit"/>. /// </summary> /// <param name="sorting">How to sort the comments (hot, new, top, controversial).</param> /// <param name="limit">How many comments to fetch per request. Max is 100.</param> /// <param name="fromTime">What time frame of comments to show (hour, day, week, month, year, all).</param> /// <returns>The listing of comments requested.</returns> public Listing <Comment> GetComments(Sort sorting = Sort.New, int limit = 25, FromTime fromTime = FromTime.All) { CheckRange(limit, MAX_LIMIT); string commentsUrl = CommentsUrl + QueryString(sorting, limit, fromTime); return(new Listing <Comment>(WebAgent, commentsUrl)); }
public static Listing<Post> GetPosts(Reddit reddit, IWebAgent webagent, string name, Sort sorting, int limit, FromTime fromTime) { if ((limit < 1) || (limit > 100)) throw new ArgumentOutOfRangeException("limit", "Valid range: [1,100]"); string linksUrl = string.Format(LinksUrl, name); linksUrl += string.Format("?sort={0}&limit={1}&t={2}", Enum.GetName(typeof(Sort), sorting), limit, Enum.GetName(typeof(FromTime), fromTime)); return new Listing<Post>(reddit, linksUrl, webagent); }
static string QueryString(Sort sort, int limit, FromTime time) => $"?sort={sort.ToString("g")}&limit={limit}&t={time.ToString("g")}";
public async Task <List <DataPoint> > FetchDataAsync(TimeShift timeShift) { return(await FetchData(FromTime.GetTime(), ToTime.GetTime())); }
public IMeasurement Clone() { return(new RandomTimeSeriesMeasurement { Low = Low, High = High, FromTime = FromTime.Clone(), ToTime = ToTime.Clone(), TimeResolution = TimeResolution, MaxFetchSize = MaxFetchSize }); }
public string GetDisplayText() { return($"{Low} (Low), {High} (High), {FromTime.GetTime()} to {ToTime.GetTime()}"); }
private static void GetUserInput(string[] args) { // Check for command line arguments passed if (args.Length > 0) { for (int i = 0; i < args.Length; i++) { if (!(i + 1 < args.Length)) { break; } // Subreddit if (args[i].Equals("-sr")) { _inputSubreddit = args[i + 1]; } // Amount if (args[i].Equals("-a")) { if (!int.TryParse(args[i + 1], out _amount)) { _amount = 25; } } // Time frame if (args[i].Equals("-t")) { if (!Enum.TryParse(args[i + 1], out _time)) { _time = FromTime.Week; } } } } // The Subreddit we are looking at if (string.IsNullOrWhiteSpace(_inputSubreddit)) { Show(new[] { "Which subreddit would you like to scrape? [EarthPorn]" }); _inputSubreddit = GetInput("subreddit: ", "EarthPorn"); } // The amount to download if (_amount == default) { Show(new[] { "How many posts would you like to try to download? [25]" }); if (!int.TryParse(GetInput("amount: ", "25"), out _amount)) { _amount = 25; } } // The time line we are looking at if (!args.Any(x => x.Equals("-t"))) { Show(new[] { "Time Period? [Week]", "0 = All Time", "1 = Past Year", "2 = Past Month", "3 = Past Week", "4 = Past Day", "5 = Past Hour", }); if (Enum.TryParse(GetInput("from: ", "3"), out _time)) { Console.SetCursorPosition(6, Console.CursorTop - 2); } Console.WriteLine(_time); Console.WriteLine(); } }
/// <summary> /// Get a listing of comments from the user sorted by <paramref name="sorting"/>, from time <paramref name="fromTime"/> /// and limited to <paramref name="limit"/>. /// </summary> /// <param name="sorting">How to sort the comments (hot, new, top, controversial).</param> /// <param name="limit">How many comments to fetch per request. Max is 100.</param> /// <param name="fromTime">What time frame of comments to show (hour, day, week, month, year, all).</param> /// <returns>The listing of comments requested.</returns> public Listing<Comment> GetComments(Sort sorting = Sort.New, int limit = 25, FromTime fromTime = FromTime.All) { if ((limit < 1) || (limit > MAX_LIMIT)) throw new ArgumentOutOfRangeException("limit", "Valid range: [1," + MAX_LIMIT + "]"); string commentsUrl = string.Format(CommentsUrl, Name); commentsUrl += string.Format("?sort={0}&limit={1}&t={2}", Enum.GetName(typeof(Sort), sorting), limit, Enum.GetName(typeof(FromTime), fromTime)); return new Listing<Comment>(Reddit, commentsUrl, WebAgent); }
/// <summary> /// Get a listing of posts from the user sorted by <paramref name="sorting"/>, from time <paramref name="fromTime"/> /// and limited to <paramref name="limit"/>. /// </summary> /// <param name="sorting">How to sort the posts (hot, new, top, controversial).</param> /// <param name="limit">How many posts to fetch per request. Max is 100.</param> /// <param name="fromTime">What time frame of posts to show (hour, day, week, month, year, all).</param> /// <returns>The listing of posts requested.</returns> public Listing<Post> GetPosts(Sort sorting = Sort.New, int limit = 25, FromTime fromTime = FromTime.All) { if ((limit < 1) || (limit > 100)) throw new ArgumentOutOfRangeException("limit", "Valid range: [1,100]"); string linksUrl = string.Format(LinksUrl, Name); linksUrl += string.Format("?sort={0}&limit={1}&t={2}", Enum.GetName(typeof(Sort), sorting), limit, Enum.GetName(typeof(FromTime), fromTime)); return new Listing<Post>(Reddit, linksUrl, WebAgent); }
public Task GetTopLinksAsync(string name, FromTime ft, int howMany) { return(Task.Run(() => GetTopLinks(name, ft, howMany))); }