Beispiel #1
0
        public bool ReloadEpgData()
        {
            try
            {
                if (rloadEpgDataFlg == false)
                {
                    return(true);
                }
                if (CommonManager.Instance.IsConnected == false)
                {
                    return(false);
                }

                Dictionary <UInt64, EpgServiceAllEventInfo> serviceDic;
                if (EpgTabInfo.SearchMode == false)
                {
                    ErrCode err = CommonManager.Instance.DB.ReloadEpgData();
                    if (CommonManager.CmdErrMsgTypical(err, "EPGデータの取得", err == ErrCode.CMD_ERR_BUSY ?
                                                       "EPGデータの読み込みを行える状態ではありません。\r\n(EPGデータ読み込み中など)" :
                                                       "エラーが発生しました。\r\nEPGデータが読み込まれていない可能性があります。") == false)
                    {
                        return(false);
                    }
                    serviceDic = CommonManager.Instance.DB.ServiceEventList;
                }
                else
                {
                    //番組情報の検索
                    var     list = new List <EpgEventInfo>();
                    ErrCode err  = CommonManager.CreateSrvCtrl().SendSearchPg(CommonUtil.ToList(EpgTabInfo.GetSearchKeyReloadEpg()), ref list);
                    if (CommonManager.CmdErrMsgTypical(err, "EPGデータの取得") == false)
                    {
                        return(false);
                    }

                    //サービス毎のリストに変換
                    serviceDic = list.GroupBy(info => info.Create64Key())
                                 .Where(gr => ChSet5.ChList.ContainsKey(gr.Key) == true)
                                 .ToDictionary(gr => gr.Key, gr => new EpgServiceAllEventInfo(ChSet5.ChList[gr.Key].ToInfo(), gr.ToList()));
                }

                //並び順はViewServiceListによる。eventListはこの後すぐ作り直すのでとりあえずそのままもらう。
                ServiceEventList = EpgTabInfo.ViewServiceList.Distinct()
                                   .Where(id => serviceDic.ContainsKey(id) == true).Select(id => serviceDic[id])
                                   .Select(info => new EpgServiceEventInfo {
                    serviceInfo = info.serviceInfo, eventList = info.eventMergeList
                }).ToList();

                var keyTime = DateTime.UtcNow.AddHours(9).AddDays(-Settings.Instance.EpgNoDisplayOldDays);
                var viewContentMatchingHash = new HashSet <UInt32>(EpgTabInfo.ViewContentList.Select(d => d.MatchingKeyList).SelectMany(x => x));
                foreach (EpgServiceEventInfo item in ServiceEventList)
                {
                    item.eventList = item.eventList.FindAll(eventInfo =>
                                                            //開始時間未定を除外
                                                            (eventInfo.StartTimeFlag != 0)

                                                            //自動登録されたりするので、サービス別番組表では表示させる
                                                            //&& (eventInfo.IsGroupMainEvent == true)

                                                            //過去番組表示抑制
                                                            && (Settings.Instance.EpgNoDisplayOld == false || eventInfo.IsOver(keyTime) == false)

                                                            //ジャンル絞り込み
                                                            && (ViewUtil.ContainsContent(eventInfo, viewContentMatchingHash, EpgTabInfo.ViewNotContentFlag) == true)
                                                            );
                }

                rloadEpgDataFlg = false;
                return(true);
            }
            catch (Exception ex) { CommonUtil.DispatcherMsgBoxShow(ex.Message + "\r\n" + ex.StackTrace); }
            return(false);
        }
Beispiel #2
0
        public bool ReloadEpgData(EpgViewPeriod newPeriod = null, bool noMsg = false)
        {
            try
            {
                newPeriod = newPeriod ?? DefPeriod.DefPeriod;
                if (Period.Equals(newPeriod) == true && IsEpgLoaded == true)
                {
                    return(true);
                }

                if (CommonManager.Instance.WaitingSrvReady == true)
                {
                    StatusManager.StatusNotifySet("EpgTimerSrv準備完了待ち");
                    return(false);
                }
                if (CommonManager.Instance.IsConnected == false)
                {
                    return(false);
                }

                ErrCode err;
                var     serviceDic = new Dictionary <UInt64, EpgServiceAllEventInfo>();
                if (EpgTabInfo.SearchMode == false)
                {
                    err = CommonManager.Instance.DB.LoadEpgData(ref serviceDic, newPeriod, EpgTabInfo.ViewServiceList);
                }
                else
                {
                    //番組情報の検索
                    err = CommonManager.Instance.DB.SearchPgLists(EpgTabInfo.GetSearchKeyReloadEpg().IntoList(), ref serviceDic, newPeriod);
                }
                if ((noMsg && err != ErrCode.CMD_SUCCESS) ||
                    CommonManager.CmdErrMsgTypical(err, "EPGデータの取得", err == ErrCode.CMD_ERR_BUSY ?
                                                   "EPGデータの読み込みを行える状態ではありません。\r\n(EPGデータ読み込み中など)" :
                                                   "エラーが発生しました。\r\nEPGデータが読み込まれていない可能性があります。") == false)
                {
                    return(false);
                }

                //並び順はViewServiceListによる。eventListはこの後すぐ作り直すのでとりあえずそのままもらう。
                ServiceEventList = CommonManager.Instance.DB.ExpandSpecialKey(EpgTabInfo.ViewServiceList, serviceDic.Values.Select(info => info.serviceInfo))
                                   .Where(id => serviceDic.ContainsKey(id)).Select(id => serviceDic[id])
                                   .Select(info => new EpgServiceEventInfo {
                    serviceInfo = info.serviceInfo, eventList = info.eventMergeList.ToList()
                }).ToList();

                EventUIDList      = new Dictionary <ulong, EpgEventInfo>();
                EventFilteredHash = new HashSet <ulong>();
                var viewContentMatchingHash = new HashSet <UInt32>(EpgTabInfo.ViewContentList.Select(d => d.MatchingKeyList).SelectMany(x => x));
                foreach (EpgServiceEventInfo item in ServiceEventList)
                {
                    item.eventList = item.eventList.FindAll(eventInfo =>
                    {
                        //開始時間未定を除外
                        bool ret = (eventInfo.StartTimeFlag != 0)

                                   //自動登録されたりするので、サービス別番組表では表示させる
                                   //&& (eventInfo.IsGroupMainEvent == true)

                                   //表示抑制
                                   && (eventInfo.IsOver(newPeriod.Start) == false && eventInfo.PgStartTime < newPeriod.End);

                        if (ret == false)
                        {
                            return(false);
                        }

                        //ジャンル絞り込み
                        bool filtered = !ViewUtil.ContainsContent(eventInfo, viewContentMatchingHash, EpgTabInfo.ViewNotContentFlag);
                        if (EpgTabInfo.HighlightContentKind && filtered)
                        {
                            EventFilteredHash.Add(eventInfo.CurrentPgUID());
                        }

                        return(EpgTabInfo.HighlightContentKind || !filtered);
                    });
                    item.eventList.ForEach(data => EventUIDList[data.CurrentPgUID()] = data);
                }

                IsEpgLoaded = true;
                Period      = newPeriod.DeepClone();
                IsDefPeriod = Period.Equals(DefPeriod.DefPeriod);
                return(true);
            }
            catch (Exception ex) { CommonUtil.DispatcherMsgBoxShow(ex.ToString()); }
            return(false);
        }