Example #1
0
        private void CompleteLogin()
        {
            //make toast
            DependencyService.Get <INotification>().ShortAlert("Logged in as " + m_myusername);

            //set the API caller's token
            CondorAPI.getInstance().Token = m_config.Token;
            SetNavMenu(true);

            //determine whether to show or hide the member permissions menu item
            APICommand cmd = new CanModifyPermissionsCommand();

            cmd.OnResponseReceived += new APICommand.ResponseReceivedHandler((response) =>
            {
                if ((string)response.GetValue("result") != "success")
                {
                    DependencyService.Get <INotification>().ShortAlert("ERROR: " + (string)response.GetValue("msg"));
                    return;
                }
                m_cellMemberPerms.IsVisible = (bool)response.GetValue("haspermission");
                if (m_cellMemberPerms.IsVisible)
                {
                    m_mnuAdminTitle.IsVisible = true;
                }
            });
            CondorAPI.getInstance().Execute(cmd);

            //determine whether to show or hide the create project member item
            cmd = new CanCreateProjectsCommand();
            cmd.OnResponseReceived += new APICommand.ResponseReceivedHandler((response) =>
            {
                if ((string)response.GetValue("result") != "success")
                {
                    DependencyService.Get <INotification>().ShortAlert("ERROR: " + (string)response.GetValue("msg"));
                    return;
                }
                m_cellCreateProject.IsVisible = (bool)response.GetValue("haspermission");
                if (m_cellCreateProject.IsVisible)
                {
                    m_mnuAdminTitle.IsVisible = true;
                }
            });
            CondorAPI.getInstance().Execute(cmd);

            //set the user ID
            m_lblCurUserId.Text = m_myusername;

            //set the team
            cmd = new GetTeamCommand();
            cmd.OnResponseReceived += new APICommand.ResponseReceivedHandler((response) =>
            {
                m_team            = (string)response.GetValue("team");
                m_lblCurTeam.Text = m_team;
            });
            CondorAPI.getInstance().Execute(cmd);

            //fill the projects list
            FillProjectsList();
        }
Example #2
0
        private async Task GetTeamExecute(bool?b)
        {
            _isBusy = true;
            GetTeamCommand.ChangeCanExecute();
            if (b == null)
            {
                try
                {
                    if (TimetableService.Timetables == null)
                    {
                        await TimetableService.RefreshTimetables(DateTime.Today);
                    }
                }
                catch (Exception)
                {
                    await Application.Current.MainPage.Navigation.PopAllPopupAsync();

                    await Application.Current.MainPage.DisplayAlert(
                        "Произошла ошибка при загрузке данных",
                        "Убедитесь, что вы подключены к сети Сириуса (Sirius_free) и повторите попытку",
                        "Ок");

                    IsBusy = false;
                    GetTeamCommand.ChangeCanExecute();
                    return;
                }
            }
            else
            {
                try
                {
                    if (TimetableService.Timetables == null)
                    {
                        await Application.Current.MainPage.Navigation.PushPopupAsync(new LoadingView());

                        await TimetableService.RefreshTimetables(DateTime.Today);

                        await Application.Current.MainPage.Navigation.PopAllPopupAsync();
                    }
                }
                catch (Exception)
                {
                    await Application.Current.MainPage.Navigation.PopAllPopupAsync();

                    await Application.Current.MainPage.DisplayAlert(
                        "Произошла ошибка при загрузке данных",
                        "Убедитесь, что вы подключены к сети Сириуса (Sirius_free) и повторите попытку",
                        "Ок");

                    IsBusy = false;
                    GetTeamCommand.ChangeCanExecute();
                    return;
                }
            }
            var selectPage    = new TeamSelectPage();
            var selectedGroup = await selectPage.SelectTeamAsync();

            if (String.IsNullOrEmpty(selectedGroup))
            {
                IsBusy = false;
                GetTeamCommand.ChangeCanExecute();
                return;
            }
            Team = selectedGroup;
            ((TimetablePage)MasterDetailsServices.DetailPages[App.Detail.Timetable]).UpdateTeam();
            IsBusy = false;
            GetTeamCommand.ChangeCanExecute();
        }