예제 #1
0
        void m_TTUSAPI_OnAccountGroupUpdate(object sender, AccountGroupUpdateEventArgs e)
        {
            try
            {
                object previousItem = cbAccount.SelectedItem;
                cbAccount.Items.Clear();
                // Populate dictionary with Account Groups
                if (e.Type == UpdateType.Download)
                {
                    m_accountGroups = e.AccountGroups;
                }
                // Add Account Group
                else if (e.Type == UpdateType.Added)
                {
                    foreach (KeyValuePair <int, TTUSAPI.DataObjects.AccountGroup> acctGroup in e.AccountGroups)
                    {
                        m_accountGroups[acctGroup.Key] = acctGroup.Value;
                    }
                }
                // Update Account Group
                else if ((e.Type == UpdateType.Changed || e.Type == UpdateType.Relationship))
                {
                    foreach (KeyValuePair <int, TTUSAPI.DataObjects.AccountGroup> acctGroup in e.AccountGroups)
                    {
                        m_accountGroups[acctGroup.Key] = acctGroup.Value;
                    }
                }
                // Delete Account Group
                else if (e.Type == UpdateType.Deleted)
                {
                    foreach (KeyValuePair <int, TTUSAPI.DataObjects.AccountGroup> acctGroup in e.AccountGroups)
                    {
                        m_accountGroups.Remove(acctGroup.Key);
                    }
                }

                foreach (TTUSAPI.DataObjects.AccountGroup acct in m_accountGroups.Values)
                {
                    cbAccount.Items.Add(acct.Name);
                }
                if (previousItem != null && cbAccount.Items.Contains(previousItem))
                {
                    cbAccount.SelectedItem = previousItem;
                }
                else if (previousItem == null)
                {
                    cbAccount.SelectedIndex = 1;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("There was an exception in the OnAccountGroupUpdate callback: " + ex.Message);
            }
        }
예제 #2
0
        void m_TTUSAPI_OnAccountGroupUpdate(object sender, AccountGroupUpdateEventArgs e)
        {
            try
            {
                // Populate dictionary with Account Groups
                if (e.Type == UpdateType.Download)
                {
                    m_accountGroups = e.AccountGroups;
                }
                // Add Account Group
                else if (e.Type == UpdateType.Added)
                {
                    foreach (KeyValuePair <int, TTUSAPI.DataObjects.AccountGroup> acctGroup in e.AccountGroups)
                    {
                        m_accountGroups[acctGroup.Key] = acctGroup.Value;
                    }
                }
                // Update Account Group
                else if ((e.Type == UpdateType.Changed || e.Type == UpdateType.Relationship))
                {
                    foreach (KeyValuePair <int, TTUSAPI.DataObjects.AccountGroup> acctGroup in e.AccountGroups)
                    {
                        m_accountGroups[acctGroup.Key] = acctGroup.Value;
                    }
                }
                // Delete Account Group
                else if (e.Type == UpdateType.Deleted)
                {
                    foreach (KeyValuePair <int, TTUSAPI.DataObjects.AccountGroup> acctGroup in e.AccountGroups)
                    {
                        m_accountGroups.Remove(acctGroup.Key);
                    }
                }

                //foreach (TTUSAPI.DataObjects.AccountGroup acct in m_accountGroups.Values)
                //{
                //}
            }
            catch (Exception ex)
            {
                MessageBox.Show("There was an exception in the OnAccountGroupUpdate callback: " + ex.Message);
            }
        }
 //Callback for downloading and updating account groups
 void m_TTUSAPI_OnAccountGroupUpdate(object sender, AccountGroupUpdateEventArgs e)
 {
     try
     {
         object previousItem = cbAccount.SelectedItem;
         cbAccount.Items.Clear();
         //Populate dictionary with downloaded accounts
         if (e.Type == UpdateType.Download)
         {
             m_accountGroups = e.AccountGroups;
         }
         //Update dictionary with any user updates
         else if (e.Type == UpdateType.Added || e.Type == UpdateType.Changed || e.Type == UpdateType.Relationship)
         {
             foreach (KeyValuePair<int, TTUSAPI.DataObjects.AccountGroup> acctItem in e.AccountGroups)
             {
                 m_accountGroups[acctItem.Key] = acctItem.Value;
             }
         }
         //Remove user from dictionary
         else if (e.Type == UpdateType.Deleted)
         {
             foreach (KeyValuePair<int, TTUSAPI.DataObjects.AccountGroup> acctItem in e.AccountGroups)
             {
                 m_accountGroups.Remove(acctItem.Key);
             }
         }
         //Display all users
         foreach (TTUSAPI.DataObjects.AccountGroup acct in m_accountGroups.Values)
         {
             cbAccount.Items.Add(acct.Name);
         }
         if (previousItem != null && cbAccount.Items.Contains(previousItem))
             cbAccount.SelectedItem = previousItem;
         else if (previousItem == null)
             cbAccount.SelectedIndex = 1;
     }
     catch (Exception ex)
     {
         MessageBox.Show("There was an exception in the OnAccountGroupUpdate callback: " + ex.Message);
     }
 }