Example #1
0
        public void SetConfig(Config c)
        {
            _myConfig = c;

            TeamsCollection.Clear();
            TeamsCollection.Add("<unmapped>"); // Need to add <unmapped> to make this value legal.

            // Set TeamsRootNode base on RootNode
            // Ex. If team nodes are APT\A, APT\B - RootNode can be: APT or A or B (user choice)
            // but Teams root node will always be APT
            c.TeamsRootNode = c.RootNode;
            foreach (TeamConfig t in myConfig().Teams)
            {
                TeamsCollection.Add(t.GroupName);
                if (c.RootNode.Contains(t.GroupName))
                {
                    c.TeamsRootNode = c.RootNode.Substring(0, c.RootNode.IndexOf(t.GroupName));
                }
            }
        }
        private async Task DeleteTeamExecuted(Team team)
        {
            LoggingService.Trace("Executing TeamsListViewModel.DeleteTeamCommand");

            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            if (team.IsOwner is false)
            {
                return;
            }

            if (await _userDialogs.ConfirmAsync($"You're going to delete the team '{team.Name}'. Are you sure ?", "Danger zone", "Yes", "Cancel"))
            {
                if (await _userDialogs.ConfirmAsync("Are you REALLY sure ?", string.Empty, "Yes!", "Cancel"))
                {
                    if (await _userDialogs.ConfirmAsync("Please confirm one last time before deletion", string.Empty, "Delete", "Cancel"))
                    {
                        var result = await _wasabeeApiV1Service.Teams_DeleteTeam(team.Id);

                        _userDialogs.Toast(result ? $"Successfully deleted team '{team.Id}'" : "An error occured, team not deleted");

                        if (result)
                        {
                            await _teamsDatabase.DeleteTeam(team.Id);

                            TeamsCollection.Remove(team);
                            await RaisePropertyChanged(() => TeamsCollection);
                        }
                    }
                }
            }

            IsBusy = false;
        }
        private async Task RefreshExecuted()
        {
            LoggingService.Trace("Executing TeamsListViewModel.RefreshCommand");

            if (IsRefreshing)
            {
                return;
            }

            if (Connectivity.NetworkAccess != NetworkAccess.Internet)
            {
                _userDialogs.Toast("No Internet, please verify your network access");
                return;
            }

            try
            {
                IsRefreshing = true;

                var userModel = await _wasabeeApiV1Service.User_GetUserInformations();

                if (userModel != null)
                {
                    await _usersDatabase.SaveUserModel(userModel);

                    if (userModel.Teams != null && userModel.Teams.Any())
                    {
                        TeamsCollection = new MvxObservableCollection <Team>(userModel.Teams.Select(x =>
                                                                                                    new Team(x.Name, x.Id)
                        {
                            IsEnabled = x.State.Equals("On"),
                            IsOwner   = x.Owner.Equals(_userSettingsService.GetLoggedUserGoogleId())
                        }
                                                                                                    ));
                    }
                    else
                    {
                        TeamsCollection.Clear();
                        await RaisePropertyChanged(() => TeamsCollection);

                        await _operationsDatabase.DeleteAllExceptOwnedBy(_userSettingsService.GetLoggedUserGoogleId());

                        var operationsCount = await _operationsDatabase.CountLocalOperations();

                        if (operationsCount == 0)
                        {
                            // Leaves app
                            await _navigationService.Navigate(Mvx.IoCProvider.Resolve <SplashScreenViewModel>(), new SplashScreenNavigationParameter(doDataRefreshOnly : true));
                        }
                    }
                }
            }
            catch (Exception e)
            {
                LoggingService.Error(e, "Error Executing TeamsListViewModel.RefreshCommand");

                _userDialogs.Toast("Error occured while loading your teams");
            }
            finally
            {
                IsRefreshing = false;
            }
        }
 public static TeamsCollection GetAll() {
     resourceSchema.Dal.Teams dbo = null;
     try {
         dbo = new resourceSchema.Dal.Teams();
         System.Data.DataSet ds = dbo.Teams_Select_All();
         TeamsCollection collection = new TeamsCollection();
         if (GlobalTools.IsSafeDataSet(ds)) {
             for (int i = 0; (i < ds.Tables[0].Rows.Count); i = (i + 1)) {
                 Teams obj = new Teams();
                 obj.Fill(ds.Tables[0].Rows[i]);
                 if ((obj != null)) {
                     collection.Add(obj);
                 }
             }
         }
         return collection;
     }
     catch (System.Exception ) {
         throw;
     }
     finally {
         if ((dbo != null)) {
             dbo.Dispose();
         }
     }
 }
 private void Clean() {
     this.Sysid = null;
     this.Publicid = null;
     this.Path = string.Empty;
     this.Createdate = null;
     this.Lastmodifieddate = null;
     this.Active = null;
     this._teamsCollection = null;
 }