예제 #1
0
        public bool ScheduleRecording(RecordingRequest rr, out RPRequest rpRequest, out RecordingResult earlyFailureResult)
        {
            EventWaitHandle ewhScheduleRecording = new EventWaitHandle(false, EventResetMode.AutoReset);

            storeManager.ScheduleRecording(rr, ewhScheduleRecording);
            ewhScheduleRecording.WaitOne(TimeSpan.FromSeconds(500));

            // Destroy the stargate
            ewhScheduleRecording = null;

            DebugNormal("MCData: schedulerecording finished, storeManager.ScheduleInitialSucceeded:" + storeManager.ScheduleInitialSucceeded);
            if (!storeManager.ScheduleInitialSucceeded)
            {
                rpRequest          = null;
                earlyFailureResult = storeManager.ScheduleInitialFailureResult;
                return(false);
            }
            else
            {
                // Retrieve the shared objects that were generated

                rpRequest = Conversion.RPRequestFromRequest(storeManager.requestInProgress);  // THIS IS ERRORING

                earlyFailureResult = null;
            }

            return(true);
        }
예제 #2
0
        public static RPRequest RPRequestFromRequest(Request rq)
        {
            RPRequest rpr = new RPRequest();

            rpr.ID          = rq.Id;
            rpr.RequestType = RPRequestTypeForRequest(rq);
            rpr.Priority    = rq.Priority;

            if (!String.IsNullOrEmpty(rq.Title))
            {
                rpr.Title = string.Copy(rq.Title);
            }

            if (rq is SeriesRequest)
            {
                SeriesRequest srq = (SeriesRequest)rq;
                if (srq.Series != null)
                {
                    rpr.SeriesID = srq.Series.Id;
                }
            }


            Channel ch = rq.Channel;

            if (ch != null)
            {
                Service svc = ch.Service;
                if (svc != null)
                {
                    rpr.ServiceID = svc.Id;
                }
            }

            return(rpr);
        }
        // DETERMINE SUCCESS
        public RecordingResult DetermineIfRequestSucceeded(RPRequest rpRequest)
        {
            // Asume failure
            RecordingResult recResult = new RecordingResult();
            recResult.Completed = true;
            recResult.ErrorMessage = "An unknown error occurred.";

            Request recRequest = GetRequestWithID(rpRequest.ID);
            if (recRequest == null)
            {
                recResult.RequestResult = RecordingResult.RequestResults.FailedWithError;
                recResult.ErrorMessage = "Could not re-located the recording request to determine success or failure.  It may have succeeded.";
                return recResult;
            }

            // No requested programmes were generated - so report failure and cancel; it's a useless request.
            if ((recRequest.RequestedPrograms == null) && (!(recRequest is WishListRequest))) // allow a keyword to continue
            {
                recResult.RequestResult = RecordingResult.RequestResults.NoProgrammesFound;
                return recResult;
            }

            // Let's compile some stats...
            //

            if (recRequest.HasConflictedRequestedPrograms)
            {
                DebugNormal("Request has conflicted requested programmes.  (only in EPG, there may yet be enough tuners.):");

                // We know that only one programme is requested.  Are there any recordings at all?
                bool FoundAnyRequestedProgrammesThatWillRecord = false;
                int numberOfRequestedProgrammes = 0;
                int numberOfRequestedProgrammesThatWillRecord = 0;
                DebugNormal("Enumerating all requested programmes to see which will record:");
                foreach (RequestedProgram rprog in recRequest.RequestedPrograms)
                {
                    numberOfRequestedProgrammes++;

                    DebugNormal("Program:  " + rprog.ToString());  // should work
                    DebugNormal("WillRecord: " + rprog.WillRecord);
                    //DebugNormal("IsAssigned: " + rprog.IsAssigned);
                    //DebugNormal("IsRequestFilled: " + rprog.IsRequestFilled);
                    //DebugNormal("IsReal: " + rprog.IsReal);
                    if (rprog.WillRecord)
                    {
                        numberOfRequestedProgrammesThatWillRecord++;
                        FoundAnyRequestedProgrammesThatWillRecord = true;  // dont bother checking first to speed up
                    }
                }

                // What kind of request?
                // ******************************** ONE TIME / MANUAL CONFLICTS ********************************
                if (
                    (recRequest is OneTimeRequest) ||
                    (recRequest is ManualRequest)
                    )
                {

                    if (!FoundAnyRequestedProgrammesThatWillRecord)
                    {
                        // No requested programmes will record... ...this is the end of the line
                        recResult.WereConflicts = true;   // not strictly necessary
                        recRequest.Cancel();
                        recResult.Completed = true;
                        recResult.RequestResult = RecordingResult.RequestResults.Conflicts;
                        return recResult;
                    }
                }

                // ******************************** SERIES / WISHLIST CONFLICTS ********************************
                if ((recRequest is SeriesRequest) || (recRequest is WishListRequest))
                {

                    // if !FoundAnyRequested...   Abandon if none will record ?  NOT FOR NOW

                    // Conflicts mean nothing, it comes down to what will actually record, so it's possible
                    // that everything is actually okay. Check now:
                    if (numberOfRequestedProgrammesThatWillRecord < numberOfRequestedProgrammes)
                    {
                        // Calculate how many are in conflict and warn user
                        recResult.ConflictInfo = "Out of " + numberOfRequestedProgrammes.ToString() + " shows found, " +
                            (numberOfRequestedProgrammes - numberOfRequestedProgrammesThatWillRecord).ToString() +
                            " will not record as they conflict with existing recordings.";

                        recResult.WereConflicts = true;
                    }
                    // else everything is Okay
                }
            }

            // *********************** SUCCESS *********************************

            // RECORDINGS / TV PROGRAMMES
            List<RPRecording> rprecordings = new List<RPRecording>();
            List<TVProgramme> tvprogrammes = new List<TVProgramme>();

            // Make a blob
            RPRecordingsBlob blob = new RPRecordingsBlob();

            // Store NEW request in blob.  (might have changed since the one that was passed to this method)
            RPRequest newRequest = Conversion.RPRequestFromRequest(recRequest);
            blob.RPRequests = new List<RPRequest>() { newRequest };

            // Don't store anything else inside the blob here - it's done in the main callback in EPGManager.cs when all recordings are refreshed.

            // Store the blob inside the record result
            recResult.GeneratedRecordingsBlob = blob;

            // Success!  (?)
            recResult.Success = true;
            recResult.Completed = true;
            recResult.RequestResult = RecordingResult.RequestResults.OK;

            // Return the result (to waitHandle etc)
            return recResult;
        }
예제 #4
0
파일: MCData.cs 프로젝트: piet5211/RPLiveTV
 public RecordingResult DetermineRecordingResultForRequest(RPRequest rpreq)
 {
     return storeManager.DetermineIfRequestSucceeded(rpreq);
 }
예제 #5
0
파일: MCData.cs 프로젝트: piet5211/RPLiveTV
        public bool ScheduleRecording(RecordingRequest rr, out RPRequest rpRequest, out RecordingResult earlyFailureResult)
        {
            EventWaitHandle ewhScheduleRecording = new EventWaitHandle(false, EventResetMode.AutoReset);
            storeManager.ScheduleRecording(rr, ewhScheduleRecording);
            ewhScheduleRecording.WaitOne(TimeSpan.FromSeconds(500));

            // Destroy the stargate
            ewhScheduleRecording = null;

            DebugNormal("MCData: schedulerecording finished, storeManager.ScheduleInitialSucceeded:" + storeManager.ScheduleInitialSucceeded);
            if (!storeManager.ScheduleInitialSucceeded)
            {
                rpRequest = null;
                earlyFailureResult = storeManager.ScheduleInitialFailureResult;
                return false;
            }
            else
            {
                // Retrieve the shared objects that were generated

                rpRequest = Conversion.RPRequestFromRequest(storeManager.requestInProgress);  // THIS IS ERRORING

                earlyFailureResult = null;
            }

            return true;
        }
예제 #6
0
 public RecordingResult DetermineRecordingResultForRequest(RPRequest rpreq)
 {
     return(storeManager.DetermineIfRequestSucceeded(rpreq));
 }
예제 #7
0
        public static RPRequest RPRequestFromRequest(Request rq)
        {
            RPRequest rpr = new RPRequest();

            rpr.ID = rq.Id;
            rpr.RequestType = RPRequestTypeForRequest(rq);
            rpr.Priority = rq.Priority;

            if (!String.IsNullOrEmpty(rq.Title))
                rpr.Title = string.Copy ( rq.Title );

            if (rq is SeriesRequest)
            {
                SeriesRequest srq = (SeriesRequest)rq;
                if (srq.Series != null)
                    rpr.SeriesID = srq.Series.Id;
            }

            Channel ch = rq.Channel;
            if (ch != null)
            {
                Service svc = ch.Service;
                if (svc != null)
                    rpr.ServiceID = svc.Id;
            }

            return rpr;
        }