private string BuildShowText(RecordInfo recordInfo) { string day = recordInfo.GetStartDT().ToString("ddd"); if (recordInfo.GetStartDT().Day == DateTime.Now.Day) { day = "Today"; } string startTime = recordInfo.GetStartDT().ToString("HH:mm"); string endTime = recordInfo.GetEndDT().ToString("HH:mm"); return(String.Format($"{day} {startTime}-{endTime} {recordInfo.description} on channel/s {recordInfo.GetChannelString()}")); }
// // This is a key member function. This and 'CaptureStream' do the bulk of the work // // As such, I'll document this a bit more than usual so when I forget (tomorrow) I can read and remember some... // public List <RecordInfo> BuildRecordSchedule(List <ScheduleShow> scheduleShowList) { //Refresh keywords // //Reads keywords from the keywords.json file. This is data used to determine which entries in the schedule //we are interested in recording/capturing Keywords keywords = new Keywords(configuration); //Go through the shows and load up recordings if there's a match // //This loop compares keywords and schedule entires, when there's a match, it //adds creates a RecordInfo istance and adds it to a master Dictionary //of shows we thing we care about. Later we'll determine which ones we'll actually capture. foreach (ScheduleShow scheduleShow in scheduleShowList) { //Find any shows that match Tuple <KeywordInfo, int> tuple = keywords.FindMatch(scheduleShow); if (tuple != null) { //Build record info if already exists, otherwise, create new RecordInfo recordInfo = GetRecordInfo(BuildRecordInfoKeyValue(scheduleShow)); //Load the recordInfo object w/ the specific schedule recordInfo = BuildRecordInfoFromShedule(recordInfo, scheduleShow); //Load the recordInfo object w/ the specifics from keywords.json file recordInfo = BuildRecordInfoFromKeywords(recordInfo, tuple); //Update or add (assuming the show has not already ended) if (recordInfo.GetEndDT() > DateTime.Now) { AddUpdateRecordInfo(BuildRecordInfoKeyValue(recordInfo), recordInfo); } } } //Return shows that should actually be queued (omitted those already done, too far in the future, etc...) // //This is an important call. Please see remarks in this member function for more info. return(GetShowsToQueue()); }
private string BuildShowStartedText(RecordInfo recordInfo) { return(String.Format($"Started: {recordInfo.description}. Should be done by {recordInfo.GetEndDT().ToString("HH:mm")}")); }
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { RecordInfo recordInfo = value as RecordInfo; //ID writer.WriteStartObject(); writer.WritePropertyName("id"); serializer.Serialize(writer, recordInfo.id); //description writer.WritePropertyName("Description"); serializer.Serialize(writer, recordInfo.description); //category writer.WritePropertyName("Category"); serializer.Serialize(writer, recordInfo.category); //start date writer.WritePropertyName("StartDT"); serializer.Serialize(writer, recordInfo.GetStartDT().ToString("yy-MM-dd HH:mm")); //start time writer.WritePropertyName("StartTime"); serializer.Serialize(writer, recordInfo.GetStartDT().ToString("HH:mm")); //start day of the week writer.WritePropertyName("StartDay"); serializer.Serialize(writer, recordInfo.GetStartDT().ToString("dddd")); //end time writer.WritePropertyName("EndTime"); serializer.Serialize(writer, recordInfo.GetEndDT().ToString("HH:mm")); //Duration writer.WritePropertyName("Duration"); serializer.Serialize(writer, recordInfo.GetDuration()); //Scheduled Duration writer.WritePropertyName("ScheduledDuration"); serializer.Serialize(writer, recordInfo.GetScheduledDuration()); //too many flag writer.WritePropertyName("TooManyFlag"); serializer.Serialize(writer, recordInfo.tooManyFlag); //Selected flag writer.WritePropertyName("SelectedFlag"); serializer.Serialize(writer, recordInfo.selectedFlag); //Manual flag writer.WritePropertyName("ManualFlag"); serializer.Serialize(writer, recordInfo.manualFlag); //Queued flag writer.WritePropertyName("QueuedFlag"); serializer.Serialize(writer, recordInfo.queuedFlag); //started flag writer.WritePropertyName("StartedFlag"); serializer.Serialize(writer, recordInfo.captureStartedFlag); //Partial flag writer.WritePropertyName("PartialFlag"); serializer.Serialize(writer, recordInfo.partialFlag); //Completed flag writer.WritePropertyName("CompletedFlag"); serializer.Serialize(writer, recordInfo.completedFlag); //Ignored Flag writer.WritePropertyName("CancelledFlag"); serializer.Serialize(writer, recordInfo.cancelledFlag); //Keyword position writer.WritePropertyName("KeyWordPos"); serializer.Serialize(writer, recordInfo.keywordPos); writer.WriteEndObject(); }
//Checks to make sure we're not recording too many shows at once // //The approach taken is to try and add shows to this queued list one at a time *in keyword order*. //This way, shows matched on higher keywords, get higher priority. private bool IsConcurrencyOk(RecordInfo recordingToAdd, List <RecordInfo> recordingList) { //If a manual entry (by user from web interface), we're good if (recordingToAdd.manualFlag) { return(true); } //Temp list to test with List <RecordInfo> tempList = new List <RecordInfo>(); bool okToAddFlag = true; //Only add shows which are before show to add foreach (RecordInfo show in recordingList) { if (show.GetStartDT() < recordingToAdd.GetEndDT()) { tempList.Add(show); } } //Add to this temp list and then we'll check for concurrency tempList = AddToSortedList(recordingToAdd, tempList); //stack to keep track of end dates List <DateTime> endTimeStack = new List <DateTime>(); int concurrentBase = Convert.ToInt16(configuration["concurrentCaptures"]); int addtlConcurrent = Convert.ToInt16(configuration["additionalStarredCaptures"]); int concurrent = 0; RecordInfo[] recordInfoArray = tempList.ToArray(); for (int idx = 0; idx < recordInfoArray.Length; idx++) { concurrent++; //increment because it's a new record //Check if we can decrement DateTime[] endTimeArray = endTimeStack.ToArray(); for (int i = 0; i < endTimeArray.Length; i++) { if (recordInfoArray[idx].GetStartDT() >= endTimeArray[i]) { concurrent--; endTimeStack.Remove(endTimeArray[i]); } } endTimeStack.Add(recordInfoArray[idx].GetEndDT()); //Let's make sure we're not over max int maxConcurrent = concurrentBase; if (recordingToAdd.starredFlag) { maxConcurrent = concurrentBase + addtlConcurrent; } if (concurrent > maxConcurrent) { okToAddFlag = false; } //else // okToAddFlag = true; } return(okToAddFlag); }