Exemplo n.º 1
0
        async public Task <RecStatus> GetStatusUpdate()
        {
            RecStatus recStatus = new RecStatus();
            MS_Status msStatus  = new MS_Status();

            recStatus.ErrorMsg = await DoRequest(msStatus);

            if (string.IsNullOrEmpty(recStatus.ErrorMsg) == false)
            {
                recStatus.Status   = RecStatus.eRecording.Error;
                recStatus.WaitTime = NextPollOnError;
                return(recStatus);
            }
            recStatus.NextRecording = msStatus.NextTimer;
            if (msStatus.ActiveRecordings)
            {
                if (actualRecording == false)
                {
                    // new recording detected
                    recStatus.Status   = RecStatus.eRecording.Started;
                    recStatus.WaitTime = NextPollOnRecording;
                    actualRecording    = true;
                    return(recStatus);
                }
                else
                {
                    // on going recording
                    recStatus.Status   = RecStatus.eRecording.Recording;
                    recStatus.WaitTime = NextPollOnWaiting;
                    return(recStatus);
                }
            }
            // no ActiveRecordings
            recStatus.Status   = RecStatus.eRecording.None;
            recStatus.WaitTime = NextPollOnWaiting;
            if (actualRecording == true)
            {
                // recording has ended
                recStatus.Status = RecStatus.eRecording.Stopped;
                actualRecording  = false;
            }
            if (msStatus.ActiveTimers == false)
            {
                // we also have not timers so we have time
                recStatus.WaitTime = NextPollOnWaiting;
                return(recStatus);
            }

            if (msStatus.NextTimer < NextPollOnWaiting)
            {
                recStatus.WaitTime = msStatus.NextTimer + 2;
            }
            return(recStatus);
        }
Exemplo n.º 2
0
        async public Task <string> DoRequest(MS_Status msStatus)
        {
            string errMsg = string.Empty;

            try {
                string url       = msService.MS_Url(MS_Status.Endpoint);
                string xmlString = await msService.GetStringAsync(msService.MS_Url(MS_Status.Endpoint));

                if (msStatus.Parse(xmlString) == false)
                {
                    errMsg = "Xml Parse error";
                }
            } catch (Exception ex) {
                errMsg = ex.Message;
            }
            return(errMsg);
        }