Ejemplo n.º 1
0
 // Method to update user data
 private void FillUsers()
 {
     teamInfo = APICall.GetTeamInfo("UrbanCoder");
     // Listing Users
     if (SP_DGVHolder.Children.Count == 1 && teamInfo.Table != null)
     {
         userDataGrid      = new PaginatedDataGrid(teamInfo.Table);
         userDataGrid.Name = "userData";
         userDataGrid.DGV.MouseDoubleClick += DataGrid_DoubleClick;
         userDataGrid.B_Refresh.Click      += Refresh_Click;
         SP_DGVHolder.Children.Add(userDataGrid);
     }
     else if (teamInfo.Table != null)
     {
         userDataGrid.UpdateData(teamInfo.Table);
     }
 }
Ejemplo n.º 2
0
 private void Login()
 {
     try
     {
         ShowErrorMessage();
         // Validating Login Prerequisites
         if (string.IsNullOrEmpty(T_URI.Text) || string.IsNullOrEmpty(T_Username.Text) || string.IsNullOrEmpty(T_Password.Password))
         {
             ShowErrorMessage("Enter the URL, Username and Password !");
             return;
         }
         // Creating API Client
         APICall = new UCD_Client(T_URI.Text, T_Username.Text, T_Password.Password, CB_Cert.IsChecked.Value);
         // Fetching UrbanCoder team information
         teamInfo = APICall.GetTeamInfo("UrbanCoder");
         // Checking if user is part of UrbanCoder team
         bool addToTeam = true;
         foreach (UCD_Data.TeamInfo.RoleMapping userData in teamInfo.APIData.roleMappings)
         {
             if (userData.user.name == T_Username.Text)
             {
                 addToTeam = false;
                 break;
             }
         }
         // Adding user to Team
         if (addToTeam)
         {
             APICall.AddUserToTeam("UrbanCoder", T_Username.Text, "Administrator");
         }
         // Successfully Logged In
         IsLoggedIn(true);
         ShowErrorMessage();
         FillUsers();
         // Checking if UrbanCoder pre-requisites are met.(Resource data etc)
         resourceInfo = APICall.ListResources("UrbanCoder");
     }
     catch (UC_LoginFailed)
     {
         ShowErrorMessage("Invalid Username or Password !");
     }
     catch (UC_TeamNotFound)
     {
         // First Login detected, trying to create a Team
         CreateTeam();
     }
     catch (UC_UnknownUser)
     {
         ShowErrorMessage("You do not belong to the UrbanCoder Team in UCD !");
     }
     catch (UC_ResourceNotFound)
     {
         // Enabling create data options as the resource is not there.
         SP_CreateDataHolder.IsEnabled = true;
         CreateParentResource();
     }
     catch (Exception ex)
     {
         ShowErrorMessage("Error in Login: " + ex.Message);
     }
 }