public override async void OnNavigatingTo(INavigationParameters parameters)
        {
            base.OnNavigatingTo(parameters);

            LoadingData = true;

            _restService           = new RestService();
            _applicationProperties = new ApplicationProperties();

            //participantsDBにuidが存在するかどうか読み込み
            GetUserParam = await _restService.GetUserDataAsync(UserConstants.OpenUserEndPoint, _applicationProperties.GetFromProperties <string>("userId"));

            var uid = GetUserParam.User.Id;
            var mid = (int)parameters["mid"];

            CheckParticipantParam = await _restService.CheckParticipantDataAsync(MeetingConstants.OPENMeetingParticipantEndPoint, uid, mid);

            if (CheckParticipantParam.HasError == true)
            {
                return;
            }

            //対象の会議データ取得

            TargetMeetingId = (int)parameters["mid"];
            GetMeetingParam = await _restService.GetMeetingDataAsync(MeetingConstants.OpenMeetingEndPoint, TargetMeetingId);

            TargetMeetingData = GetMeetingParam.MeetingData;

            //会議が終了状態でないかどうか判定
            if (GetMeetingParam.MeetingData.IsVisible == false)
            {
                var p = new NavigationParameters
                {
                    { "ErrorPageType", ErrorPageType.FinishedMeeting }
                };
                //終了している会議なのでエラー画面に飛ばす
                await _navigationService.NavigateAsync("/NavigationPage/ErrorTemplatePage", p);
            }

            //会議管理者かどうか取得
            if (TargetMeetingData.Owner == GetUserParam.User.Id)
            {
                IsOwner = true;
            }
            else
            {
                IsGeneral = true;
            }

            LoadingData = false;

            Reload();

            //Participants全件取得
            Participants = await GetParticipants();
        }
        //更新処理
        public async void Reload()
        {
            LoadingData  = true;
            _restService = new RestService();

            //対象の会議データ取得
            GetMeetingParam = await _restService.GetMeetingDataAsync(MeetingConstants.OpenMeetingEndPoint, TargetMeetingId);

            TargetMeetingData = GetMeetingParam.MeetingData;

            //会議が終了状態でないかどうか判定
            if (GetMeetingParam.MeetingData.IsVisible == false)
            {
                var p = new NavigationParameters
                {
                    { "ErrorPageType", ErrorPageType.FinishedMeeting }
                };
                //終了している会議なのでエラー画面に飛ばす
                await _navigationService.NavigateAsync("/ErrorTemplatePage", p);
            }

            //ParticipantDBに対する最終更新時刻とIsDeleted状態の更新
            //ParticipantDBに既にユーザーが居ないかチェック
            CheckParticipantParam = await _restService.CheckParticipantDataAsync(MeetingConstants.OPENMeetingParticipantEndPoint, GetUserParam.User.Id, TargetMeetingData.Id);

            //ユーザーが既にParticipantDBに存在していた場合
            if (CheckParticipantParam.IsSuccessed == true)
            {
                //ParticipantsDBに存在するが、論理削除済の場合
                if (CheckParticipantParam.Participant.isDeleted == true)
                {
                    CheckParticipantParam.NoExistUser = true;

                    await _navigationService.NavigateAsync("MeetingDataTopPage");
                }
                else
                //ParticipantsDBに存在するが、論理削除がされていない場合
                {
                    var operateDateTime = new OperateDateTime();
                    CheckParticipantParam.Participant.LastUpdateTime = operateDateTime.CurrentDateTime;
                    var updateParticipant = CheckParticipantParam.Participant;

                    UpdateParticipantParam = await _restService.UpdateParticipantDataAsync(MeetingConstants.OPENMeetingParticipantEndPoint, updateParticipant);
                }
            }
            //既にユーザーが退室済の場合は更新エラーを出す
            else
            {
                CheckParticipantParam.NoExistUser = true;
                await _navigationService.NavigateAsync("MeetingDataTopPage");
            }

            LoadingData = false;
        }
Пример #3
0
        public MeetingAttendPageViewModel(INavigationService navigationService) : base(navigationService)
        {
            _navigationService     = navigationService;
            _restService           = new RestService();
            _operateDateTime       = new OperateDateTime();
            _applicationProperties = new ApplicationProperties();

            _createMeetingLabelItemParam = new CreateMeetingLabelItemParam();
            _attendMeetingParam          = new AttendMeetingParam();
            _deleteMeetingLabelItemParam = new DeleteMeetingLabelItemParam();

            _createMeetingLabelItemValidation = new CreateMeetingLabelItemValidation();
            _tokenCheckValidation             = new TokenCheckValidation(_restService);
            _attendMeetingValidation          = new AttendMeetingValidation();


            //ラベルに関する項目を追加するページへ遷移するコマンド
            NavigateMeetingLabelItemDataCreatePage = new DelegateCommand <object>((meetingLabelData) =>
            {
                var targetMeetingLabelData = (MeetingLabelData)(meetingLabelData);

                var p = new NavigationParameters
                {
                    { "meetingLabelData", targetMeetingLabelData },
                };
                _navigationService.NavigateAsync("MeetingLabelItemDataCreatePage", p);
            });


            //会議に入室するコマンド
            EnterMeetingCommand = new DelegateCommand(async() =>
            {
                //バリデーション
                AttendMeetingParam = _attendMeetingValidation.ButtonPushedValidate(new List <MeetingLabelData>(TargetMeetingLabels));


                if (AttendMeetingParam.IsSuccessed == true)
                {
                    GetUserParam = await _restService.GetUserDataAsync(UserConstants.OpenUserEndPoint, _applicationProperties.GetFromProperties <string>("userId"));

                    var mid = GetMeetingParam.MeetingData.Id;
                    var uid = GetUserParam.User.Id;

                    //ParticipantDBに既にユーザーが居ないかチェック
                    CheckParticipantParam = await _restService.CheckParticipantDataAsync(MeetingConstants.OPENMeetingParticipantEndPoint, uid, mid);

                    //ユーザーが既にParticipantDBに存在していた場合
                    if (CheckParticipantParam.IsSuccessed == true)
                    {
                        //会議参加済みかつisDeletedがfalseの場合は最終更新時刻のみ更新し遷移する
                        if (CheckParticipantParam.Participant.isDeleted == false)
                        {
                            var operateDateTime = new OperateDateTime();
                            CheckParticipantParam.Participant.LastUpdateTime = operateDateTime.CurrentDateTime;
                            var updateParticipant = CheckParticipantParam.Participant;
                            await _restService.UpdateParticipantDataAsync(MeetingConstants.OPENMeetingParticipantEndPoint, updateParticipant);

                            var p = new NavigationParameters
                            {
                                { "mid", GetMeetingParam.MeetingData.Id }
                            };
                            await _navigationService.NavigateAsync("MeetingExecuteTopPage", p);
                        }
                        else
                        //参加済みかつ論理削除済みの場合はisDeletedをtrue→falseにして再入室
                        {
                            var operateDateTime = new OperateDateTime();
                            CheckParticipantParam.Participant.isDeleted      = false;
                            CheckParticipantParam.Participant.LastUpdateTime = operateDateTime.CurrentDateTime;
                            var updateParticipant = CheckParticipantParam.Participant;

                            await _restService.UpdateParticipantDataAsync(MeetingConstants.OPENMeetingParticipantEndPoint, updateParticipant);

                            var p = new NavigationParameters
                            {
                                { "mid", GetMeetingParam.MeetingData.Id }
                            };
                            await _navigationService.NavigateAsync("MeetingExecuteTopPage", p);
                        }
                    }
                    //ParticipantDBに該当者が居なければ追加
                    else
                    {
                        CreateParticipateParam = await _restService.CreateParticipateDataAsync(MeetingConstants.OPENMeetingParticipantEndPoint, uid, mid);

                        if (CreateParticipateParam.IsSuccessed == true)
                        {
                            var p = new NavigationParameters
                            {
                                { "mid", GetMeetingParam.MeetingData.Id }
                            };
                            await _navigationService.NavigateAsync("MeetingExecuteTopPage", p);
                        }
                    }
                }
            });

            //会議入室画面から退室するコマンド
            ExitMeetingCommand = new DelegateCommand(async() =>
            {
                //TargetMeetingLabelsが所持しているItemsを削除する
                foreach (MeetingLabelData l in TargetMeetingLabels)
                {
                    foreach (MeetingLabelItemData i in l.MeetingLabelItemDatas)
                    {
                        DeleteMeetingLabelItemParam = await _restService.DeleteMeetingLabelItemDataAsync(MeetingConstants.OPENMeetingLabelItemEndPoint, i.Id);
                    }
                }

                await _navigationService.NavigateAsync("/NavigationPage/MeetingDataTopPage");
            });
        }