private void button_add_reserve_Click(object sender, RoutedEventArgs e) { try { if (listView_result.SelectedItem != null) { SearchItem item = listView_result.SelectedItem as SearchItem; EpgEventInfo eventInfo = item.EventInfo; if (eventInfo.StartTimeFlag == 0) { MessageBox.Show("開始時間未定のため予約できません"); return; } ReserveData reserveInfo = new ReserveData(); if (eventInfo.ShortInfo != null) { reserveInfo.Title = eventInfo.ShortInfo.event_name; } reserveInfo.StartTime = eventInfo.start_time; reserveInfo.StartTimeEpg = eventInfo.start_time; if (eventInfo.DurationFlag == 0) { reserveInfo.DurationSecond = 10 * 60; } else { reserveInfo.DurationSecond = eventInfo.durationSec; } UInt64 key = CommonManager.Create64Key(eventInfo.original_network_id, eventInfo.transport_stream_id, eventInfo.service_id); if (ChSet5.Instance.ChList.ContainsKey(key) == true) { reserveInfo.StationName = ChSet5.Instance.ChList[key].ServiceName; } reserveInfo.OriginalNetworkID = eventInfo.original_network_id; reserveInfo.TransportStreamID = eventInfo.transport_stream_id; reserveInfo.ServiceID = eventInfo.service_id; reserveInfo.EventID = eventInfo.event_id; RecSettingData setInfo = new RecSettingData(); recSettingView.GetRecSetting(ref setInfo); reserveInfo.RecSetting = setInfo; List <ReserveData> list = new List <ReserveData>(); list.Add(reserveInfo); ErrCode err = (ErrCode)cmd.SendAddReserve(list); if (err == ErrCode.CMD_ERR_CONNECT) { MessageBox.Show("サーバー または EpgTimerSrv に接続できませんでした。"); } if (err == ErrCode.CMD_ERR_TIMEOUT) { MessageBox.Show("EpgTimerSrvとの接続にタイムアウトしました。"); } if (err != ErrCode.CMD_SUCCESS) { MessageBox.Show("予約登録でエラーが発生しました。終了時間がすでに過ぎている可能性があります。"); } CommonManager.Instance.DB.SetUpdateNotify((UInt32)UpdateNotifyItem.ReserveInfo); CommonManager.Instance.DB.ReloadReserveInfo(); SearchPg(); } } catch (Exception ex) { MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); } }
private void button_chg_reserve_Click(object sender, RoutedEventArgs e) { if (checkBox_program.IsChecked == true) { reserveInfo.Title = textBox_title.Text; ChSet5Item ch = comboBox_service.SelectedItem as ChSet5Item; reserveInfo.StationName = ch.ServiceName; reserveInfo.OriginalNetworkID = ch.ONID; reserveInfo.TransportStreamID = ch.TSID; reserveInfo.ServiceID = ch.SID; reserveInfo.EventID = 0xFFFF; reserveInfo.StartTime = new DateTime(datePicker_start.SelectedDate.Value.Year, datePicker_start.SelectedDate.Value.Month, datePicker_start.SelectedDate.Value.Day, comboBox_sh.SelectedIndex, comboBox_sm.SelectedIndex, comboBox_ss.SelectedIndex, 0, DateTimeKind.Utc ); DateTime endTime = new DateTime(datePicker_end.SelectedDate.Value.Year, datePicker_end.SelectedDate.Value.Month, datePicker_end.SelectedDate.Value.Day, comboBox_eh.SelectedIndex, comboBox_em.SelectedIndex, comboBox_es.SelectedIndex, 0, DateTimeKind.Utc ); if (reserveInfo.StartTime > endTime) { MessageBox.Show("終了日時が開始日時より前です"); return; } TimeSpan duration = endTime - reserveInfo.StartTime; reserveInfo.DurationSecond = (uint)duration.TotalSeconds; RecSettingData setInfo = new RecSettingData(); recSettingView.GetRecSetting(ref setInfo); setInfo.TuijyuuFlag = 0; setInfo.PittariFlag = 0; reserveInfo.RecSetting = setInfo; } else { RecSettingData setInfo = new RecSettingData(); recSettingView.GetRecSetting(ref setInfo); reserveInfo.RecSetting = setInfo; } List <ReserveData> list = new List <ReserveData>(); list.Add(reserveInfo); if (manualAddMode == false) { ErrCode err = (ErrCode)cmd.SendChgReserve(list); if (err == ErrCode.CMD_ERR_CONNECT) { MessageBox.Show("サーバー または EpgTimerSrv に接続できませんでした。"); } if (err == ErrCode.CMD_ERR_TIMEOUT) { MessageBox.Show("EpgTimerSrvとの接続にタイムアウトしました。"); } if (err != ErrCode.CMD_SUCCESS) { MessageBox.Show("予約変更でエラーが発生しました。"); } } else { reserveInfo.StartTimeEpg = reserveInfo.StartTime; ErrCode err = (ErrCode)cmd.SendAddReserve(list); if (err == ErrCode.CMD_ERR_CONNECT) { MessageBox.Show("サーバー または EpgTimerSrv に接続できませんでした。"); } if (err == ErrCode.CMD_ERR_TIMEOUT) { MessageBox.Show("EpgTimerSrvとの接続にタイムアウトしました。"); } if (err != ErrCode.CMD_SUCCESS) { MessageBox.Show("予約追加でエラーが発生しました。"); } } if (this.Visibility == System.Windows.Visibility.Visible) { DialogResult = true; } }