public async Task <AsyncResult <IProgram[]> > GetNowNextProgramAsync(IChannel channel)
        {
            ProgramNowNextValue programs;

            IProgram[] programNowNext = new IProgram[2];

            _programCache.ClearCache(channel);
            if (_programCache.TryGetPrograms(channel, out programs))
            {
                programNowNext[0] = programs.ProgramNow;
                programNowNext[1] = programs.ProgramNext;
                return(new AsyncResult <IProgram[]>(true, programNowNext));
            }
            try
            {
                CpAction       action       = GetAction(Consts.ACTION_GET_NOW_NEXT_PROGRAM);
                IList <object> inParameters = new List <object>
                {
                    channel.ChannelId
                };

                IList <object> outParameters = await action.InvokeAsync(inParameters);

                bool success = (bool)outParameters[0];
                if (success)
                {
                    programNowNext[0] = (Program)outParameters[1];
                    programNowNext[1] = (Program)outParameters[2];
                    _programCache.TryAdd(channel, programNowNext[0], programNowNext[1]);
                    return(new AsyncResult <IProgram[]>(true, programNowNext));
                }
            }
            catch (Exception ex)
            {
                NotifyException(ex);
            }
            return(new AsyncResult <IProgram[]>(false, null));
        }
Exemple #2
0
        public bool GetNowNextProgram(IChannel channel, out IProgram programNow, out IProgram programNext)
        {
            ProgramNowNextValue programs;

            _programCache.ClearCache(channel);
            if (_programCache.TryGetPrograms(channel, out programs))
            {
                programNow  = programs.ProgramNow;
                programNext = programs.ProgramNext;
                return(true);
            }
            try
            {
                CpAction       action       = GetAction(Consts.ACTION_GET_NOW_NEXT_PROGRAM);
                IList <object> inParameters = new List <object>
                {
                    channel.ChannelId
                };

                IList <object> outParameters = action.InvokeAction(inParameters);
                bool           success       = (bool)outParameters[0];
                if (success)
                {
                    programNow  = (Program)outParameters[1];
                    programNext = (Program)outParameters[2];
                    _programCache.TryAdd(channel, programNow, programNext);
                    return(true);
                }
            }
            catch (Exception ex)
            {
                NotifyException(ex);
            }
            programNow  = null;
            programNext = null;
            return(false);
        }