Ejemplo n.º 1
0
        public ErrCode SearchPgLists(List <EpgSearchKeyInfo> key, ref Dictionary <UInt64, EpgServiceAllEventInfo> serviceDic, EpgViewPeriod period = null)
        {
            ErrCode err = ErrCode.CMD_SUCCESS;

            //Epgデータ未取得時、SendSearchPg()の最古データは取得してみないと分からない。
            var  list            = new List <EpgEventInfo>();
            bool noSearchCurrent = period != null && IsEpgLoaded && period.End <= EventTimeMinCurrent;

            if (noSearchCurrent == false)
            {
                try { err = CommonManager.CreateSrvCtrl().SendSearchPg(key, ref list); } catch { err = ErrCode.CMD_ERR; }
                if (err != ErrCode.CMD_SUCCESS)
                {
                    return(err);
                }
                if (period != null && period.StrictLoad)
                {
                    list = PeriodApplied(list, period);
                }
            }

            var  list2       = new List <EpgEventInfo>();
            bool noSearchArc = period == null || EventTimeMaxArc != DateTime.MinValue && period.StartLoad > EventTimeMaxArc;

            if (noSearchArc == false)
            {
                try
                {
                    var pram = new SearchPgParam();
                    pram.keyList   = key;
                    pram.enumStart = period.StartLoad.ToFileTimeUtc();
                    pram.enumEnd   = period.End == DateTime.MaxValue ? long.MaxValue : period.End.ToFileTimeUtc();
                    CommonManager.CreateSrvCtrl().SendSearchPgArc(pram, ref list2);
                }
                catch { }
            }

            //サービス毎のリストに変換
            var sList = list.GroupBy(info => info.Create64Key()).Select(gr => new EpgServiceEventInfo {
                serviceInfo = EpgServiceInfo.FromKey(gr.Key), eventList = gr.ToList()
            }).ToList();
            var sList2 = list2.GroupBy(info => info.Create64Key()).Select(gr => new EpgServiceEventInfo {
                serviceInfo = EpgServiceInfo.FromKey(gr.Key), eventList = gr.ToList()
            }).ToList();

            serviceDic = EpgServiceAllEventInfo.CreateEpgServiceDictionary(sList, sList2);

            //サービス名の補正、イベントデータの再使用
            CorrectServiceInfo(serviceDic.Values, period == null || EventTimeBaseArc < period.End || EventTimeMinCurrent < period.End);

            return(err);
        }
Ejemplo n.º 2
0
        /// <summary>EPGデータの更新があれば再読み込みする</summary>
        public ErrCode ReloadEpgData(bool immediately = false, bool noRaiseChanged = false)
        {
            return(ReloadWork(UpdateNotifyItem.EpgData, immediately, noRaiseChanged, ret =>
            {
                ServiceEventList = new Dictionary <ulong, EpgServiceAllEventInfo>();
                EventUIDList = new Dictionary <ulong, EpgEventInfo>();
                EventTimeBaseArc = DateTime.MaxValue;

                var list = new List <EpgServiceEventInfo>();
                try { ret = CommonManager.CreateSrvCtrl().SendEnumPgAll(ref list); } catch { ret = ErrCode.CMD_ERR; }
                //SendEnumPgAll()は番組情報未取得状態でCMD_ERRを返す。従来エラー扱いだったが、取得数0の成功とみなす
                if (ret != ErrCode.CMD_SUCCESS && ret != ErrCode.CMD_ERR)
                {
                    return ret;
                }

                //リストの作成
                ServiceEventList = EpgServiceAllEventInfo.CreateEpgServiceDictionary(list);
                CorrectServiceInfo(list);
                foreach (var data in list.SelectMany(info => info.eventList))
                {
                    EventUIDList[data.CurrentPgUID()] = data;//通常あり得ないがUID被りは後優先。
                }
                if (EventUIDList.Any())
                {
                    EventTimeMinCurrent = EventUIDList.Values.Min(data => data.PgStartTime);
                }

                //リモコンIDの登録
                ChSet5.SetRemoconID(ServiceEventList.Select(item => item.Value.serviceInfo));

                reserveEventList = null;
                reserveEventListCache = null;

                return ErrCode.CMD_SUCCESS;
            }));
        }