示例#1
0
        public bool?ShowWindow(UCD_Client APIClient)
        {
            APICall = APIClient;
            // Centering Window
            double sWidth       = SystemParameters.PrimaryScreenWidth;
            double sHeight      = SystemParameters.PrimaryScreenHeight;
            double windowWidth  = Width;
            double windowHeight = Height;

            Left = (sWidth / 2) - (windowWidth / 2);
            Top  = (sHeight / 2) - (windowHeight / 2);
            ShowDialog();
            return(output);
        }
示例#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);
     }
 }