private void CreateClass()
        {
            if (GlobalData.Instance.ConfigManager?.AudioInfo?.AudioSammpleDevice == null)
            {
                MessageQueueManager.Instance.AddError(MessageManager.NoAudioDevice);
                return;
            }
            if (string.IsNullOrEmpty(GlobalData.Instance.ConfigManager?.MainVideoInfo?.VideoDevice))
            {
                MessageQueueManager.Instance.AddError(MessageManager.NoVideoDevice);
                return;
            }

            var invitees = from classroom in Classrooms
                           where classroom.Selected
                           select new MeetingSdk.Wpf.Participant(new AccountModel(int.Parse(classroom.Classroom.SchoolRoomNum), classroom.Classroom.SchoolRoomName));

            AppCache.AddOrUpdate(CacheKey.Invitees, invitees);
            AppCache.AddOrUpdate(CacheKey.HostId, _windowManager.Participant.Account.AccountId);

            var intoClassView = new IntoClassView(IntoClassType.Create);

            intoClassView.Show();

            _createClassView.Close();
        }
Exemple #2
0
        private void JoinMeeting()
        {
            var currentWindow = Application.Current.Windows;
            var window        = currentWindow[0];

            //判断当前是否在课堂中

            if (window is IntoClassView)
            {
                MessageQueueManager.Instance.AddError("已经在课堂中");
                return;
            }

            //预约会议
            var course = DoUpdateCurriculumMeetingN0(GlobalData.Instance.Courses);

            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();
            window?.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}");
            }
        }
Exemple #4
0
        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;
        }
Exemple #5
0
        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);
            }
        }