Example #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);
        }