private void btnUpdate_Click(object sender, EventArgs e)
        {
            int creditLimit = 0;

            foreach (TTUSAPI.DataObjects.User user in m_Users.Values)  //Loop through all users that have been downloaded
            {
                if (user.UserName == cbUser.SelectedItem.ToString() && Int32.TryParse(txtCreditLimit.Text, out creditLimit))
                {
                    TTUSAPI.DataObjects.UserProfile userUpdate = new TTUSAPI.DataObjects.UserProfile(user); // Create a copy of the user
                    userUpdate.UserRiskSettings.Credit = creditLimit;                                       // Update the user credit limit
                    ResultStatus res = m_TTUSAPI.UpdateUser(userUpdate);                                    // Send update to TTUS server
                    if (res.Result == ResultType.SentToServer)                                              // On Success
                    {
                        UpdateStatusBar("Credit updated for " + user.UserName + " to " + creditLimit + " " + userUpdate.UserRiskSettings.Currency.Name);
                    }
                    else if (res.Result == ResultType.ValuesUnchanged)     // On No Change
                    {
                        UpdateStatusBar("Credit for " + user.UserName + " unchanged at " + creditLimit + " " + userUpdate.UserRiskSettings.Currency.Name);
                    }
                    else     //On Failure
                    {
                        UpdateStatusBar("Failed to update credit for user " + user.UserName + ", " + res.ErrorMessage);
                    }
                }
            }
        }
Пример #2
0
 private void btnDisable_Click(object sender, EventArgs e)
 {
     foreach (TTUSAPI.DataObjects.User user in m_Users.Values)  //Loop through all users that have been downloaded
     {
         if (user.UserName == cbUser.SelectedItem.ToString())
         {
             TTUSAPI.DataObjects.UserProfile userP = new TTUSAPI.DataObjects.UserProfile(user);                                           // Create copy of User
             foreach (TTUSAPI.DataObjects.UserGatewayLogin gwLogin in userP.UserGatewayLogins.Values)                                     // Loop through GW Logins associated with the User
             {
                 TTUSAPI.DataObjects.UserGatewayLoginProfile UserGWP = new TTUSAPI.DataObjects.UserGatewayLoginProfile(gwLogin);          // Create a copy of the GW Login
                 foreach (TTUSAPI.DataObjects.UserGatewayCredential cred in UserGWP.UserGatewayCredentials.Values)                        // Loop through User GW Credentials
                 {
                     TTUSAPI.DataObjects.UserGatewayCredentialProfile credP = new TTUSAPI.DataObjects.UserGatewayCredentialProfile(cred); // Create copy of User GW Credential
                     credP.Accessibility = TTUSAPI.DataObjects.UserGatewayCredential.AccessibilityMode.NotAvailable;                      // Change GW Login Accessibility to "Not Available"
                     UserGWP.UpdateGateway(credP);                                                                                        // Update the GW Login with the new User credentials
                 }
                 userP.UpdateUserGatewayLogin(UserGWP);                                                                                   // Update the User with the new GW Login
             }
             ResultStatus res = m_TTUSAPI.UpdateUser(userP);                                                                              // Send the updated user to the TTUS Server
             if (res.Result == ResultType.SentToServer)                                                                                   //On Success
             {
                 UpdateStatusBar("GW Logins disabled for " + user.UserName);
             }
             else if (res.Result == ResultType.ValuesUnchanged) //On No Change
             {
                 UpdateStatusBar("GW Logins already disabled for " + user.UserName);
             }
             else //On Failure
             {
                 UpdateStatusBar("ERROR:  Failed to disable GW Logins for " + user.UserName + ", " + res.ErrorMessage);
             }
             break;
         }
     }
 }