public async Task <IEnumerable <int> > GetMissingDates(IEnumerable <IPost> posts, Schedule schedule) { var tempList = posts.ToList(); var missing = new List <int>(); await Task.Run(() => { var firstDate = DateTime.Now; var nextDate = firstDate; int totalCount = tempList.Count(); while (totalCount < MAX_POSTPONED + RESERVE) { var thisDayDate = nextDate; var thisDayPosts = tempList.Where(i => UnixTimeConverter.ToDateTime(i.Date).Date == thisDayDate.Date).ToList(); foreach (var scheduleItem in schedule.Items) { if (totalCount >= MAX_POSTPONED + RESERVE) { break; } var scheduledDate = ConvertScheduleItemToDateTime(new DateTime(thisDayDate.Year, thisDayDate.Month, thisDayDate.Day), scheduleItem); if (scheduledDate <= DateTime.Now) { continue; } var isTimeCorrectlyScheduled = thisDayPosts.Any(i => IsTimeCorrectlyScheduled(i.Date, scheduleItem)); if (isTimeCorrectlyScheduled == false) { totalCount++; missing.Add(UnixTimeConverter.ToUnix(scheduledDate)); } } nextDate = nextDate.AddDays(1); } missing.Sort((a, b) => a.CompareTo(b)); return(missing); }); return(missing); }
//private static QueryParameters makeAQuery(int wallId, string message, int date, [NotNull] Attachments attachments) { // if (attachments == null) throw new ArgumentNullException(nameof(attachments)); // if (message == null) { // message = ""; // } // var parameters = QueryParameters.New() // .Add("owner_id", wallId) // .Add("filter", "postponed") // .Add("publish_date", date) // .Add("signed", 0) // .Add("from_group", 1) // .Add("message", message); // parameters.Append(attachments.GetAsParameters()); // return parameters; //} protected virtual void OnPostSuccessful(WallPostInfo e) { e.PublishingDate = UnixTimeConverter.ToUnix(DateTimeOffset.Now.DateTime); PostSuccessful?.Invoke(this, e); }