Example #1
0
        public static Recorder GetRecorder(Config config, ReserveTask task)
        {
            Recorder res = null;

            switch (task.Station.Type)
            {
            case Define.Radiko.TypeName:
                res = new RadikoRecorder(config, task);
                break;
            }

            return(res);
        }
Example #2
0
        /// <summary>
        /// タイマー処理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TimerElapsed(object sender, ElapsedEventArgs e)
        {
            if (!_recorderLock)
            {
                _recorderLock = true;
                using (var con = new SqliteConnection($"Data Source={Define.File.DbFile}"))
                {
                    con.Open();
                    var cModel = new ConfigModel(con);
                    var config = cModel.Get();

                    var rModel = new ReserveModel(con);
                    var tasks  = rModel.GetTasks(true);
                    if (tasks.Any())
                    {
                        tasks.ForEach(t =>
                        {
                            // 予約実行
                            if (_recorders.All(r => r.Id != t.Id))
                            {
                                //    var recorder = Recorder.GetRecorder(config, t);
                                var recorder = new RadikoRecorder(config, t);
                                _recorders.Add(recorder);
                                recorder.Start().Wait();
                                var logger = NLog.LogManager.GetCurrentClassLogger();
                                logger.Info("録音開始");
                            }
                        });
                    }
                }

                // 終了タスクを削除する
                _recorders.RemoveAll(r => r.Status == Recorder.RecorderStatus.End);

                _recorderLock = false;
            }

            if (!_timetableLock && (DateTime.Now - _refreshTimetableDate).TotalDays > 6)
            {
                _timetableLock = true;
                RefreshTimeTable();
            }
        }