public static RPRecording RPRecordingFromRecording(Recording mcrec) { RPRecording rprec = new RPRecording(); rprec.Id = mcrec.Id; if (mcrec.ScheduleEntry != null) { rprec.TVProgrammeID = mcrec.ScheduleEntry.Id; } if (mcrec.Request != null) { // Get the request that generated this - NB currently, this isn't ideal: there may be multiple - e.g. series and oneTime Request mcreq = mcrec.Request; rprec.RPRequestID = mcreq.Id; if (mcreq is SeriesRequest) { SeriesRequest sr = (SeriesRequest)mcreq; // Series? SeriesInfo si = sr.Series; if (si != null) { rprec.SeriesID = si.Id; } } if (mcreq is ManualRequest) { ManualRequest mr = (ManualRequest)mcreq; rprec.ManualRecordingDuration = mr.Duration.TotalSeconds; try { rprec.ManualRecordingServiceID = mr.Channel.Service.Id; } catch { } rprec.ManualRecordingStartTime = mr.StartTime; } // Helpers rprec.RequestType = RPRequestTypeForRequest(mcreq); if (!string.IsNullOrWhiteSpace(mcreq.Title)) { rprec.Title = string.Copy(mcreq.Title); } } rprec.State = (RPRecordingStates)Enum.Parse(typeof(RPRecordingStates), mcrec.State.ToString()); rprec.KeepUntil = (int)mcrec.KeepLength; rprec.Partial = mcrec.IsPartial; rprec.Quality = mcrec.Quality; return(rprec); }
public static RPRecording RPRecordingFromRecording(Recording mcrec) { RPRecording rprec = new RPRecording(); rprec.Id = mcrec.Id; if (mcrec.ScheduleEntry != null) rprec.TVProgrammeID = mcrec.ScheduleEntry.Id; if (mcrec.Request != null) { // Get the request that generated this - NB currently, this isn't ideal: there may be multiple - e.g. series and oneTime Request mcreq = mcrec.Request; rprec.RPRequestID = mcreq.Id; if (mcreq is SeriesRequest) { SeriesRequest sr = (SeriesRequest)mcreq; // Series? SeriesInfo si = sr.Series; if (si != null) rprec.SeriesID = si.Id; } if (mcreq is ManualRequest) { ManualRequest mr = (ManualRequest)mcreq; rprec.ManualRecordingDuration = mr.Duration.TotalSeconds; try { rprec.ManualRecordingServiceID = mr.Channel.Service.Id; } catch { } rprec.ManualRecordingStartTime = mr.StartTime; } // Helpers rprec.RequestType = RPRequestTypeForRequest(mcreq); if (! string.IsNullOrWhiteSpace( mcreq.Title )) rprec.Title = string.Copy ( mcreq.Title ); } rprec.State = (RPRecordingStates)Enum.Parse(typeof(RPRecordingStates), mcrec.State.ToString()); rprec.KeepUntil = (int)mcrec.KeepLength; rprec.Partial = mcrec.IsPartial; rprec.Quality = mcrec.Quality; return rprec; }