Skip to content
Browse files

Add support for timer enable/disable of individual programs in a Seri…

…es schedule

This adds/removed programs from the CanceledSchedule table in the database
  • Loading branch information...
1 parent 9e2718b commit 9df11193b76083ecabb8ddae6491f24be42aa710 @margro committed Nov 4, 2012
View
3 TVServerXBMC/Changelog.txt
@@ -1,3 +1,6 @@
+1.2.3.118:
+- Add support for timer enable/disable of individual programs in a Series schedule
+
1.2.3.117:
- Add support for retrieving and updating the recording "timesWatched" property
- Fixed: postRecordInterval retrieval for schedules
View
7 TVServerXBMC/Commands/UpdateSchedule.cs
@@ -23,6 +23,7 @@ public override void handleCommand(string command, string[] arguments, ref TvCon
int scheduleType = (int)TvDatabase.ScheduleRecordingType.Once;
int priority = -1; // Use MediaPortal default
int keepmethod = -1; // Use MediaPortal default
+ int program_id = -1;
DateTime keepdate;
int schedindex = int.Parse(arguments[0]);
@@ -62,13 +63,17 @@ public override void handleCommand(string command, string[] arguments, ref TvCon
preRecordInterval = Int32.Parse(arguments[25]);
postRecordInterval = Int32.Parse(arguments[26]);
+ if (arguments.Length >= 28)
+ {
+ program_id = int.Parse(arguments[27]);
+ }
}
else
{
keepdate = new DateTime(2000, 01, 01, 0, 0, 0); //MediaPortal default value 2000-01-01 00:00:00
}
- bool result = TVServerConnection.UpdateSchedule(schedindex, channelid, active, title, starttime, endtime, scheduleType, priority, keepmethod, keepdate, preRecordInterval, postRecordInterval);
+ bool result = TVServerConnection.UpdateSchedule(schedindex, channelid, active, title, starttime, endtime, scheduleType, priority, keepmethod, keepdate, preRecordInterval, postRecordInterval, program_id);
Console.WriteLine("UpdateSchedule result : " + result.ToString());
writer.write(result.ToString());
}
View
4 TVServerXBMC/Properties/AssemblyInfo.cs
@@ -30,8 +30,8 @@
// Build Number
// Revision
//
-[assembly: AssemblyVersion("1.2.3.117")]
-[assembly: AssemblyFileVersion("1.2.3.117")]
+[assembly: AssemblyVersion("1.2.3.118")]
+[assembly: AssemblyFileVersion("1.2.3.118")]
// Set usage and compatibility information
[assembly: CompatibleVersion("1.1.7.0", "1.1.6.27644")]
View
75 TVServerXBMC/TV/ServerInterface.cs
@@ -1171,7 +1171,7 @@ public List<ScheduleInfo> getSchedules()
}
return schedInfos;
}
- private string FormatSchedule(string strSchedId, string strStartTime, string strEndTime, string strIdChannel, string strchannelname, string strProgramName, Schedule sched, string strIsRecording, string stridProgram)
+ private string FormatSchedule(string strSchedId, string strStartTime, string strEndTime, string strIdChannel, string strchannelname, string strProgramName, Schedule sched, string strIsRecording, string stridProgram, DateTime Canceled)
{
string schedule;
schedule = strSchedId + "|"
@@ -1189,7 +1189,7 @@ private string FormatSchedule(string strSchedId, string strStartTime, string str
+ sched.KeepDate.ToString("u") + "|"
+ sched.PreRecordInterval.ToString() + "|"
+ sched.PostRecordInterval.ToString() + "|"
- + sched.Canceled.ToString("u") + "|"
+ + Canceled.ToString("u") + "|"
+ sched.Series.ToString() + "|"
+ strIsRecording + "|"
+ stridProgram;
@@ -1255,8 +1255,11 @@ public List<String> GetSchedules()
try
{
IList<Program> progs = Schedule.GetProgramsForSchedule(sched);
+ IList<CanceledSchedule> canceled_progs = sched.ReferringCanceledSchedule();
foreach (Program pr in progs)
{
+ DateTime dtCanceled = sched.Canceled;
+
strStartTime = pr.StartTime.ToString("u");
strEndTime = pr.EndTime.ToString("u");
strIdChannel = pr.IdChannel.ToString();
@@ -1267,8 +1270,19 @@ public List<String> GetSchedules()
strIsRecording = "True";
else strIsRecording = "False";
idProgram = pr.IdProgram;
+
+ // Check if this program is in the CanceledSchedule list
+ foreach (CanceledSchedule cs in canceled_progs)
+ {
+ if (cs.CancelDateTime == pr.StartTime)
+ {
+ dtCanceled = cs.CancelDateTime;
+ break;
+ }
+ }
+
schedule = FormatSchedule(strSchedId, strStartTime, strEndTime, strIdChannel, channelname.Replace("|", ""),
- strProgramName.Replace("|", ""), sched, strIsRecording, idProgram.ToString());
+ strProgramName.Replace("|", ""), sched, strIsRecording, idProgram.ToString(), dtCanceled);
schedlist.Add(schedule);
}
@@ -1286,7 +1300,7 @@ public List<String> GetSchedules()
strIsRecording = "True";
idProgram = -1;
schedule=FormatSchedule(strSchedId, strStartTime, strEndTime, strIdChannel, channelname.Replace("|", ""),
- strProgramName.Replace("|", ""), sched, strIsRecording, idProgram.ToString());
+ strProgramName.Replace("|", ""), sched, strIsRecording, idProgram.ToString(), sched.Canceled);
schedlist.Add(schedule);
}
}
@@ -1457,14 +1471,65 @@ public bool AddSchedule(int channelId, String programName, DateTime startTime, D
}
}
- public bool UpdateSchedule(int scheduleindex, int channelId, int active, String programName, DateTime startTime, DateTime endTime, int scheduleType, Int32 priority, Int32 keepmethod, DateTime keepdate, Int32 preRecordInterval, Int32 postRecordInterval)
+ public bool UpdateSchedule(int scheduleindex, int channelId, int active, String programName, DateTime startTime, DateTime endTime, int scheduleType, Int32 priority, Int32 keepmethod, DateTime keepdate, Int32 preRecordInterval, Int32 postRecordInterval, Int32 programId)
{
try
{
TvBusinessLayer layer = new TvBusinessLayer();
Schedule updatedSchedule = Schedule.Retrieve(scheduleindex);
DateTime defaultCanceled = new DateTime(2000, 01, 01, 0, 0, 0); //Active
+ if ((scheduleType != (int)TvDatabase.ScheduleRecordingType.Once) && (programId != -1))
+ {
+ // Series schedule, retrieve the canceled programs list
+ Program program = Program.Retrieve(programId);
+
+ //program.
+
+ IList<CanceledSchedule> canceledSched = updatedSchedule.ReferringCanceledSchedule();
+
+ if (active == 1)
+ {
+ // Check if this schedule is deactivated and remove it from the CanceledSchedule list
+ foreach (CanceledSchedule cs in canceledSched)
+ {
+ if (cs.CancelDateTime == program.StartTime)
+ {
+ cs.Remove();
+ break;
+ }
+ }
+ }
+ else
+ {
+ Boolean found = false;
+ // Add this schedule to the CanceledSchedule list if not already in the list
+ foreach (CanceledSchedule cs in canceledSched)
+ {
+ if (cs.CancelDateTime == program.StartTime)
+ {
+ found = true;
+ break;
+ }
+ }
+
+ if (!found)
+ {
+ CanceledSchedule newCs = new CanceledSchedule(scheduleindex, program.IdChannel, program.StartTime);
+ newCs.Persist();
+ }
+ }
+
+ // if (!found)
+ // {
+ // Program.ProgramState
+ // }
+ //}
+ return true;
+ }
+
+
+
updatedSchedule.ProgramName = programName;
updatedSchedule.StartTime = startTime;
updatedSchedule.EndTime = endTime;
View
4 TVServerXBMC/TVServerConnection.cs
@@ -321,9 +321,9 @@ public static bool AddSchedule(int channelId, String programName, DateTime start
return serverIntf.AddSchedule(channelId, programName, startTime, endTime, scheduleType, priority, keepmethod, keepdate, preRecordInterval, postRecordInterval);
}
- public static bool UpdateSchedule(int scheduleindex, int channelId, int active, String programName, DateTime startTime, DateTime endTime, int scheduleType, Int32 priority, Int32 keepmethod, DateTime keepdate, Int32 preRecordInterval, Int32 postRecordInterval)
+ public static bool UpdateSchedule(int scheduleindex, int channelId, int active, String programName, DateTime startTime, DateTime endTime, int scheduleType, Int32 priority, Int32 keepmethod, DateTime keepdate, Int32 preRecordInterval, Int32 postRecordInterval, Int32 program_id)
{
- return serverIntf.UpdateSchedule(scheduleindex, channelId, active, programName, startTime, endTime, scheduleType, priority, keepmethod, keepdate, preRecordInterval, postRecordInterval);
+ return serverIntf.UpdateSchedule(scheduleindex, channelId, active, programName, startTime, endTime, scheduleType, priority, keepmethod, keepdate, preRecordInterval, postRecordInterval, program_id);
}
public static void disconnect()
View
2 TVServerXBMC/TVServerXBMC.csproj
@@ -5,7 +5,7 @@
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{CE292E6A-53E2-459D-8C87-673073182152}</ProjectGuid>
- <OutputType>Library</OutputType>
+ <OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>TVServerXBMC</RootNamespace>
<AssemblyName>TVServerXBMC</AssemblyName>

0 comments on commit 9df1119

Please sign in to comment.
Something went wrong with that request. Please try again.