/// <summary> /// 番組表取得処理 /// </summary> /// <param name="stationId"></param> /// <returns></returns> private List <Entities.Program> RefreshPrograms(string stationId) { using (SqliteConnection) { var sModel = new StationModel(SqliteConnection); var station = sModel.GetById(stationId); var programs = new List <Entities.Program>(); if (station == null) { return(programs); } switch (station.Type) { case Define.Radiko.TypeName: programs = Radiko.GetPrograms(station).Result; break; case Define.Nhk.TypeName: programs = Nhk.GetPrograms(station, DateTime.Now, DateTime.Now.AddDays(1)).Result; break; } var pModel = new ProgramModel(SqliteConnection); pModel.Refresh(programs); return(programs); } }
/// <summary> /// 全番組表再取得 /// </summary> private void RefreshTimeTable() { using (var con = new SqliteConnection($"Data Source={Define.File.DbFile}")) { var sw = new Stopwatch(); sw.Start(); con.Open(); var sModel = new StationModel(con); var pModel = new ProgramModel(con); foreach (var station in sModel.Get(Define.Radiko.TypeName)) { try { var programs = Radiko.GetPrograms(station).Result; pModel.Refresh(programs); } catch (Exception e) { Global.Logger.Error($"{e.Message}¥r¥n{e.StackTrace}"); } } _refreshTimetableDate = DateTime.Now; _timetableLock = false; sw.Stop(); Global.Logger.Info($"番組表全更新:{sw.Elapsed}"); } }