private void BindData() { var meetinglist = _localDataManager.GetMeetingList(); var currentClassNo = GlobalData.Instance.Classroom.SchoolRoomNum; if (meetinglist != null && meetinglist.MeetingInfos.Count > 0) { meetinglist.MeetingInfos.ForEach(m => { //如果该课堂创建者是班级创建者,传true //m.MeetingNo应该是creatorId var joinControl = new JoinClassControl(_view, m); _view.stack_join.Children.Add(joinControl); }); } }
private async void IntoBtn_OnClick(object sender, RoutedEventArgs e) { var btn = (Button)sender; var course = (Course)btn.Tag; AppCache.AddOrUpdate(CacheKey.MeetingId, course.MeetingId); GlobalData.Instance.Course = course; //判断该课堂视讯号与当前登录人的视讯号是否相同,如果相同,设置为主讲 var mainclassroom = GlobalData.Instance.Classrooms.ToList().FirstOrDefault(o => o.Id == course.MainClassroomId.ToString()); if (mainclassroom != null) { AppCache.AddOrUpdate(CacheKey.HostId, mainclassroom.SchoolRoomNum); } var intoClassView = new IntoClassView(IntoClassType.Join); intoClassView.Show(); var meetingInfoResult = await _meetingService.GetMeetingInfo(course.MeetingId); var meetingList = _localDataManager.GetMeetingList() ?? new MeetingList() { MeetingInfos = new List <MeetingItem>() }; var cachedMeeting = meetingList.MeetingInfos.FirstOrDefault(meeting => meeting.MeetingId == course.MeetingId); if (cachedMeeting != null) { cachedMeeting.LastActivityTime = DateTime.Now; } else { meetingList.MeetingInfos.Add(new MeetingItem() { LastActivityTime = DateTime.Now, MeetingId = course.MeetingId, CreatorName = mainclassroom?.SchoolRoomName, IsClose = false, CreatorId = mainclassroom?.SchoolRoomNum, CreateTime = DateTime.Parse(meetingInfoResult.Result.StartTime), }); } _localDataManager.SaveMeetingList(meetingList); _view.Close(); }
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(string classNo) { //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 _meetingService.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(), 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); } else { MeetingResult <MeetingModel> meetingModelResult = await _meetingService.GetMeetingInfo(meetingId); meeting = meetingModelResult.Result; 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, meetingModelResult.Result.HostId); } } _localDataManager.SaveMeetingList(meetingList); //进入课堂 AppCache.AddOrUpdate(CacheKey.MeetingId, meetingId); GlobalData.Instance.Course = new Course(); var intoClassView = new IntoClassView(IntoClassType.Join); intoClassView.Show(); txt_classNo.Text = string.Empty; _view.Close(); } } } catch (Exception ex) { Log.Logger.Error($"加入课堂发生异常 exception:{ex}"); MessageQueueManager.Instance.AddError(MessageManager.JoinClassError); } }
public void _meetingManagerService_InvitationReceivedEvent(MeetingInvitationModel invitation) { Application.Current.Dispatcher.BeginInvoke(new Action(async() => { string creatorName; var currentWindows = Application.Current.Windows; Window window = currentWindows[0]; if (_exitDialog != null) { return; } var trueInvitor = GlobalData.Instance.Classrooms.FirstOrDefault(o => o.SchoolRoomNum == invitation.SenderId.ToString()); var inClass = false; //判断是否再课堂中,如果在课堂中,需要判断新邀请与当前课堂是否是同一个,如果是,则不需要处理,否则退出当前课堂,进入新课堂 int curMeetingId; object curMeetingIdObj = AppCache.TryGet(CacheKey.MeetingId); if (curMeetingIdObj != null && int.TryParse(curMeetingIdObj.ToString(), out curMeetingId)) { if (curMeetingId == invitation.MeetingId) { return; } //在课堂中 _exitDialog = new Dialog($"您当前正在课堂中,是否要结束当前课堂,加入到新课堂?", "加入新课堂", "留在当前课堂"); inClass = true; } else { _exitDialog = new Dialog($"{trueInvitor?.SchoolRoomName},邀请您听课", "去听课", "稍后"); } var result = _exitDialog.ShowDialog(); if (!result.HasValue || !result.Value) { return; } bool isSettingsValid = DeviceSettingsChecker.Instance.IsVideoAudioSettingsValid(window); if (!isSettingsValid) { return; } //判断课堂是否存在 var reuslt = await _meetingSdkAgent.IsMeetingExist(invitation.MeetingId); if (reuslt.StatusCode != 0) { MessageQueueManager.Instance.AddError(MessageManager.MeetingNoExistError); return; } if (inClass) { //退出当前课堂 //var clearResult = await ClearMeeting(); //if (!clearResult) //{ // MessageQueueManager.Instance.AddError(MessageManager.ExitMeetingError); // return; //} var exitMessage = await _meetingSdkAgent.LeaveMeeting(); await _windowManager.Leave(); if (exitMessage.StatusCode != 0) { MessageQueueManager.Instance.AddError(MessageManager.ExitMeetingError); return; } } var meetingList = _localDataManager.GetMeetingList() ?? new MeetingList() { MeetingInfos = new List <MeetingItem>() }; var localMeetingInfo = meetingList.MeetingInfos.FirstOrDefault(o => o.MeetingId == invitation.MeetingId); string createTime = string.Empty; if (localMeetingInfo != null && localMeetingInfo.CreatorId == GlobalData.Instance.Classroom.SchoolRoomNum) { createTime = localMeetingInfo.CreateTime.ToString(); AppCache.AddOrUpdate(CacheKey.HostId, GlobalData.Instance.Classroom.SchoolRoomNum); creatorName = GlobalData.Instance.Classroom.SchoolRoomName; } else { MeetingResult <MeetingModel> meetingInfo = await _meetingSdkAgent.GetMeetingInfo(invitation.MeetingId); if (meetingInfo.StatusCode != 0) { MessageQueueManager.Instance.AddError("获取会议信息时出错!"); return; } if (meetingInfo.Result.MeetingType == MeetingType.DatedMeeting && meetingInfo.Result.HostId == 0) { } AppCache.AddOrUpdate(CacheKey.HostId, meetingInfo.Result.HostId); createTime = meetingInfo.Result.StartTime; creatorName = GlobalData.Instance.Classrooms.FirstOrDefault(cls => cls.SchoolRoomNum == meetingInfo.Result.HostId.ToString())?.SchoolRoomName; } AppCache.AddOrUpdate(CacheKey.MeetingId, invitation.MeetingId); GlobalData.Instance.Course = new Course(); if (inClass) { //var mainView = new MainView(); //mainView.Show(); var wd = SetWindowsTop.FindWindow(null, "IntoClassView"); await Application.Current.Dispatcher.BeginInvoke(new Action(() => { //if (_viewLayoutService.IsDoubleScreenOn) //{ // _viewLayoutService.IsDoubleScreenOn = false; // _viewLayoutService.StopExtendedViewAsync(); // _viewLayoutService.ExtenedViewFrameList?.Clear(); // _viewLayoutService.ResetAsInitialStatus(); // Thread.Sleep(20); // foreach (Window item in Application.Current.Windows) // { // if (item is ExtendedScreenView) // { // item.Close(); // } // } // SetWindowsTop.SetWindowPos(wd, 0, int.MaxValue, int.MaxValue, 0, 0, 0); //} var intoClassView = new IntoClassView(IntoClassType.Join); intoClassView.Show(); //foreach (Window item in Application.Current.Windows) //{ // if (item is MainView) // { // item.Close(); // } //} Application.Current.Dispatcher.BeginInvoke(new Action(() => { SetWindowsTop.SendMessage(wd, WM_CLOSE, 0, 0); })); })); } else { var intoClassView = new IntoClassView(IntoClassType.Join); intoClassView.Show(); foreach (Window item in Application.Current.Windows) { if (!(item is IntoClassView || item is ExtendedScreenView)) { item.Close(); } } } UpdateMeeting(meetingList, creatorName, createTime); })); _exitDialog = null; }