Exemplo 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);
        }
Exemplo 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>();

                var list = new List <EpgServiceEventInfo>();
                try { ret = CommonManager.CreateSrvCtrl().SendEnumPgAll(ref list); } catch { ret = ErrCode.CMD_ERR; }
                if (ret != ErrCode.CMD_SUCCESS)
                {
                    return ret;
                }

                var list2 = new List <EpgServiceEventInfo>();
                if (Settings.Instance.EpgLoadArcInfo == true)
                {
                    try { CommonManager.CreateSrvCtrl().SendEnumPgArcAll(ref list2); } catch { }
                }
                foreach (EpgServiceEventInfo info in list)
                {
                    UInt64 id = info.serviceInfo.Create64Key();
                    //対応する過去番組情報があれば付加する
                    int i = list2.FindIndex(info2 => id == info2.serviceInfo.Create64Key());
                    ServiceEventList[id] = new EpgServiceAllEventInfo(info.serviceInfo, info.eventList, i < 0 ? new List <EpgEventInfo>() : list2[i].eventList);
                }
                //過去番組情報が残っていればサービスリストに加える
                foreach (EpgServiceEventInfo info in list2)
                {
                    UInt64 id = info.serviceInfo.Create64Key();
                    if (ServiceEventList.ContainsKey(id) == false)
                    {
                        ServiceEventList[id] = new EpgServiceAllEventInfo(info.serviceInfo, new List <EpgEventInfo>(), info.eventList);
                    }
                }

                //リモコンIDの登録
                ChSet5.SetRemoconID(ServiceEventList);

                reserveEventList = null;
                reserveEventListCache = null;
                return ret;
            }));
        }
Exemplo n.º 3
0
 public static void AddArcEpgServiceDictionary(Dictionary <UInt64, EpgServiceAllEventInfo> dic, List <EpgServiceEventInfo> list2)
 {
     if (list2 == null)
     {
         return;
     }
     foreach (EpgServiceEventInfo info in list2)
     {
         UInt64 id = info.serviceInfo.Key;
         if (dic.ContainsKey(id))
         {
             dic[id].eventArcList = dic[id].eventArcList.Count == 0 ? info.eventList :
                                    info.eventList.Concat(dic[id].eventArcList).ToList();
         }
         else
         {
             dic[id] = new EpgServiceAllEventInfo(info.serviceInfo, new List <EpgEventInfo>(), info.eventList);
         }
     }
 }
Exemplo n.º 4
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;
            }));
        }
Exemplo n.º 5
0
        /// <summary>
        /// baseTimeから1週間分(EventBaseTimeをしきい値とし、このとき上限なし)のEPGデータを検索する
        /// </summary>
        public ErrCode SearchWeeklyEpgData(DateTime baseTime, EpgSearchKeyInfo key, out Dictionary <ulong, EpgServiceAllEventInfo> list)
        {
            list = null;
            List <EpgEventInfo> eventList;
            List <EpgEventInfo> arcList = null;
            ErrCode             ret     = SearchPg(new List <EpgSearchKeyInfo>()
            {
                key
            }, out eventList);

            if (ret == ErrCode.CMD_SUCCESS)
            {
                ret      = ErrCode.CMD_ERR;
                baseTime = baseTime > EventBaseTime ? EventBaseTime : baseTime;
                arcList  = new List <EpgEventInfo>();
                //1週間分の過去番組情報
                var param = new SearchPgParam();
                param.keyList = new List <EpgSearchKeyInfo>()
                {
                    key
                };
                param.enumStart = baseTime.ToFileTime();
                param.enumEnd   = baseTime.AddDays(baseTime < EventBaseTime ? 7 : 14).ToFileTime();
                try
                {
                    CommonManager.CreateSrvCtrl().SendSearchPgArc(param, ref arcList);
                    ret = ErrCode.CMD_SUCCESS;
                }
                catch { }
            }
            if (ret == ErrCode.CMD_SUCCESS)
            {
                list = new Dictionary <ulong, EpgServiceAllEventInfo>();
                //サービス毎のリストに変換
                foreach (EpgEventInfo info in eventList)
                {
                    if (baseTime < EventBaseTime ? (info.StartTimeFlag != 0 && info.start_time >= baseTime && info.start_time < baseTime.AddDays(7))
                                                 : (info.StartTimeFlag == 0 || info.start_time >= baseTime))
                    {
                        ulong id = CommonManager.Create64Key(info.original_network_id, info.transport_stream_id, info.service_id);
                        EpgServiceAllEventInfo allInfo;
                        if (list.TryGetValue(id, out allInfo) == false)
                        {
                            if (ChSet5.Instance.ChList.ContainsKey(id) == false)
                            {
                                //サービス情報ないので無効
                                continue;
                            }
                            allInfo = new EpgServiceAllEventInfo(CommonManager.ConvertChSet5To(ChSet5.Instance.ChList[id]));
                            if (serviceEventList.ContainsKey(id))
                            {
                                //リモコンキー情報を補完
                                allInfo.serviceInfo.remote_control_key_id = serviceEventList[id].serviceInfo.remote_control_key_id;
                            }
                            list.Add(id, allInfo);
                        }
                        allInfo.eventList.Add(info);
                    }
                }
                foreach (EpgEventInfo info in arcList)
                {
                    ulong id = CommonManager.Create64Key(info.original_network_id, info.transport_stream_id, info.service_id);
                    EpgServiceAllEventInfo allInfo;
                    if (list.TryGetValue(id, out allInfo) == false)
                    {
                        if (ChSet5.Instance.ChList.ContainsKey(id) == false)
                        {
                            //サービス情報ないので無効
                            continue;
                        }
                        allInfo = new EpgServiceAllEventInfo(CommonManager.ConvertChSet5To(ChSet5.Instance.ChList[id]));
                        if (serviceEventList.ContainsKey(id))
                        {
                            //リモコンキー情報を補完
                            allInfo.serviceInfo.remote_control_key_id = serviceEventList[id].serviceInfo.remote_control_key_id;
                        }
                        list.Add(id, allInfo);
                    }
                    allInfo.eventArcList.Add(info);
                }
            }
            return(ret);
        }
Exemplo n.º 6
0
        public ErrCode LoadEpgData(ref Dictionary <UInt64, EpgServiceAllEventInfo> serviceDic, EpgViewPeriod period = null, IEnumerable <ulong> keys = null)
        {
            ErrCode err = ReloadEpgData();

            if (err != ErrCode.CMD_SUCCESS)
            {
                return(err);
            }

            bool noCurrent = period != null && IsEpgLoaded && period.End <= EventTimeMinCurrent;
            bool noArc     = period == null || EventTimeBaseArc != DateTime.MaxValue && period.End <= EventTimeBaseArc;

            serviceDic = ServiceEventList.ToDictionary(item => item.Key,
                                                       item => new EpgServiceAllEventInfo(item.Value.serviceInfo
                                                                                          , noCurrent ? null : item.Value.eventList, noArc ? null : item.Value.eventArcList));

            var list = new List <EpgServiceEventInfo>();

            if (period != null && period.StartLoad < EventTimeBaseArc)
            {
                EpgViewPeriod prLoad = new EpgViewPeriod(period.StartLoad, CommonUtil.Min(period.End, EventTimeBaseArc));

                //DB更新の判定
                DateTime EventTimeBaseArcMin = Settings.Instance.EpgSettingList.Min(set => new EpgViewPeriodDef(set).DefPeriod.StartLoad);
                bool     addDB = prLoad.End > EventTimeBaseArcMin;
                if (addDB)
                {
                    prLoad.Start = Settings.Instance.PrebuildEpg ? CommonUtil.Min(EventTimeBaseArcMin, prLoad.Start) : prLoad.Start;
                    prLoad.End   = EventTimeBaseArc;
                }

                err = LoadEpgArcData(prLoad.Start, prLoad.End, ref list, addDB ? null : keys);
                if (err != ErrCode.CMD_SUCCESS)
                {
                    return(err);
                }

                //リモコンIDの登録、サービス名の補正
                ChSet5.SetRemoconID(list.Select(info => info.serviceInfo), true);
                CorrectServiceInfo(list);
                EpgServiceAllEventInfo.AddArcEpgServiceDictionary(serviceDic, list);

                //DB更新。EventTimeBaseArcが毎回固定でなくて良いなら、この回の取得を全てキャッシュする手もある。
                ReloadWork(UpdateNotifyItem.EpgDataAdd, addDB, false, ret =>
                {
                    EventTimeBaseArc = CommonUtil.Max(EventTimeBaseArcMin, prLoad.Start);
                    if (prLoad.Start < EventTimeBaseArcMin)
                    {
                        foreach (var info in list)
                        {
                            info.eventList = info.eventList.FindAll(d => d.start_time >= EventTimeBaseArc);
                        }
                    }
                    EpgServiceAllEventInfo.AddArcEpgServiceDictionary(ServiceEventList, list);
                    foreach (var data in list.SelectMany(info => info.eventList))
                    {
                        EventUIDList[data.CurrentPgUID()] = data;//通常あり得ないがUID被りは後優先。
                    }
                    return(ret);
                });
            }

            //必要なら期間を適用。未適用でもリストは再作成される。
            foreach (var info in serviceDic.Values)
            {
                info.eventList    = PeriodApplied(info.eventList, period.StrictLoad ? period : null);
                info.eventArcList = PeriodApplied(info.eventArcList, period.StrictLoad ? period : null);
            }

            //イベントリストが空の場合もあるが、そのまま返す。
            return(err);
        }