/// <summary>EPGデータの更新があれば再読み込みする</summary> public ErrCode ReloadEpgData(bool immediately = false) { if (immediately == true) { SetUpdateNotify(UpdateNotifyItem.EpgData); } var ret = ErrCode.CMD_SUCCESS; try { if (updateEpgData == true && (noAutoReloadEpg == false || oneTimeReloadEpg == true)) { ServiceEventList = new Dictionary <ulong, EpgServiceAllEventInfo>(); var list = new List <EpgServiceEventInfo>(); ret = CommonManager.CreateSrvCtrl().SendEnumPgAll(ref list); if (ret != ErrCode.CMD_SUCCESS) { return(ret); } var list2 = new List <EpgServiceEventInfo>(); if (Settings.Instance.EpgLoadArcInfo == true) { CommonManager.CreateSrvCtrl().SendEnumPgArcAll(ref list2); } foreach (EpgServiceEventInfo info in list) { UInt64 id = info.serviceInfo.Create64Key(); //対応する過去番組情報があれば付加する int i = list2.FindIndex(info2 => id == info2.serviceInfo.Create64Key()); ServiceEventList.Add(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.Add(id, new EpgServiceAllEventInfo(info.serviceInfo, new List <EpgEventInfo>(), info.eventList)); } } //リモコンIDの登録 ChSet5.SetRemoconID(ServiceEventList); updateEpgData = false; oneTimeReloadEpg = false; } } catch (Exception ex) { MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); } return(ret); }
/// <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; })); }
/// <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; })); }
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); }