Esempio n. 1
0
        private void UpdateMeeting(MeetingList meetingList, string creatorName, string createTime)
        {
            var currentMeeting =
                meetingList.MeetingInfos.FirstOrDefault(o => o.MeetingId == (int)AppCache.TryGet(CacheKey.MeetingId));

            if (currentMeeting == null)
            {
                MeetingItem meetingItem = new MeetingItem()
                {
                    LastActivityTime = DateTime.Now,
                    MeetingId        = (int)AppCache.TryGet(CacheKey.MeetingId),
                    CreatorName      = creatorName,
                    IsClose          = false,
                    CreatorId        = AppCache.TryGet(CacheKey.HostId).ToString(),
                };

                if (!string.IsNullOrEmpty(createTime))
                {
                    meetingItem.CreateTime = DateTime.Parse(createTime);
                }

                meetingList.MeetingInfos.Add(meetingItem);
            }
            else
            {
                currentMeeting.LastActivityTime = DateTime.Now;
            }
            _localDataManager.SaveMeetingList(meetingList);
        }
Esempio n. 2
0
        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}");
            }
        }
Esempio n. 4
0
        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);
            }
        }