private async void WindowKeyDownHandler(object obj) { try { var keyEventArgs = obj as KeyEventArgs; switch (keyEventArgs?.Key) { case Key.Return: if (BtnEnable) { var reuslt = await _meetingService.IsMeetingExist(_meetingId); if (reuslt.StatusCode != 0) { MessageQueueManager.Instance.AddError(MessageManager.MeetingNoExistError); return; } var meetingList = _localDataManager.GetMeetingList() ?? new MeetingList() { MeetingInfos = new List <MeetingItem>() }; var localMeeting = meetingList.MeetingInfos.FirstOrDefault(o => o.MeetingId == _meetingId); var meeting = GlobalData.Instance.MeetingList?.FirstOrDefault(o => o.MeetingId == _meetingId); if (localMeeting == null && meeting != null) { meetingList.MeetingInfos.Add(new MeetingItem() { LastActivityTime = DateTime.Now, MeetingId = _meetingId, IsClose = false, CreatorId = meeting.Account.AccountId.ToString(), CreateTime = DateTime.Parse(meeting.StartTime), CreatorName = GlobalData.Instance.Classrooms.FirstOrDefault(cls => cls.SchoolRoomNum == meeting.HostId.ToString())?.SchoolRoomName, }); AppCache.AddOrUpdate(CacheKey.HostId, meeting.Account.AccountId); } else { if (localMeeting != null) { localMeeting.LastActivityTime = DateTime.Now; AppCache.AddOrUpdate(CacheKey.HostId, localMeeting?.CreatorId); } } _localDataManager.SaveMeetingList(meetingList); //此处跳转到课堂窗口 AppCache.AddOrUpdate(CacheKey.MeetingId, _meetingId); GlobalData.Instance.Course = new Course(); var intoClassView = new IntoClassView(IntoClassType.Join); intoClassView.Show(); _view.Close(); } keyEventArgs.Handled = true; break; case Key.Left: keyEventArgs.Handled = true; break; case Key.PageUp: InputSimulatorManager.Instance.InputSimu.Keyboard.ModifiedKeyStroke(VirtualKeyCode.SHIFT, VirtualKeyCode.TAB); break; case Key.PageDown: InputSimulatorManager.Instance.InputSimu.Keyboard.KeyPress(VirtualKeyCode.TAB); break; } } catch (Exception ex) { Log.Logger.Error($"加入课堂监听键盘事件发生异常 exception:{ex}"); } }
public async void JoinClass() { //1.判断课堂号是否存在 try { if (string.IsNullOrEmpty(ClassNo)) { MessageQueueManager.Instance.AddError("请输入课堂号!"); return; } int meetingId; var isNumber = int.TryParse(ClassNo, out meetingId); if (!isNumber) { MessageQueueManager.Instance.AddError(MessageManager.MeetingNoExistError); } else { if (meetingId <= 0) { MessageQueueManager.Instance.AddError(MessageManager.MeetingNoExistError); return; } //判断课堂是否存在 var reuslt = await _meetingSdkAgent.IsMeetingExist(meetingId); if (reuslt.StatusCode != 0) { MessageQueueManager.Instance.AddError(MessageManager.MeetingNoExistError); } else { var meetingList = _localDataManager.GetMeetingList() ?? new MeetingList() { MeetingInfos = new List <MeetingItem>() }; var localMeeting = meetingList.MeetingInfos.FirstOrDefault(o => o.MeetingId == meetingId); var meeting = GlobalData.Instance.MeetingList?.FirstOrDefault(o => o.MeetingId == meetingId); if (localMeeting == null && meeting != null) { meetingList.MeetingInfos.Add(new MeetingItem() { LastActivityTime = DateTime.Now, MeetingId = meetingId, IsClose = false, CreatorId = meeting.Account.AccountId.ToString() }); AppCache.AddOrUpdate(CacheKey.HostId, meeting.Account.AccountId); //_meetingService.CreatorPhoneId = meeting.CreatorId; } else { if (localMeeting != null) { localMeeting.LastActivityTime = DateTime.Now; AppCache.AddOrUpdate(CacheKey.HostId, localMeeting.CreatorId); //_meetingService.CreatorPhoneId = localMeeting.CreatorId; } else { MeetingResult <MeetingModel> meetingInfo = await _meetingSdkAgent.GetMeetingInfo(meetingId); if (meetingInfo.StatusCode != 0) { MessageQueueManager.Instance.AddError("获取会议信息时出错!"); return; } AppCache.AddOrUpdate(CacheKey.HostId, meetingInfo.Result.HostId); meetingList.MeetingInfos.Add(new MeetingItem() { LastActivityTime = DateTime.Now, MeetingId = meetingId, IsClose = false, CreatorId = meetingInfo.Result.HostId.ToString(), CreateTime = DateTime.Parse(meetingInfo.Result.StartTime), CreatorName = GlobalData.Instance.Classrooms.FirstOrDefault(cls => cls.SchoolRoomNum == meetingInfo.Result.HostId.ToString())?.SchoolRoomName, }); } } _localDataManager.SaveMeetingList(meetingList); //进入课堂 AppCache.AddOrUpdate(CacheKey.MeetingId, meetingId); //_meetingService.MeetingId = meetingId; GlobalData.Instance.Course = new Course(); var intoClassView = new IntoClassView(IntoClassType.Join); intoClassView.Show(); _view.Close(); ClassNo = string.Empty; } } } catch (Exception ex) { Log.Logger.Error($"加入课堂发生异常 exception:{ex}"); MessageQueueManager.Instance.AddError(MessageManager.JoinClassError); } }