Beispiel #1
0
        public MainForm()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            try
            {
                WindowsPrincipal wp      = new WindowsPrincipal(WindowsIdentity.GetCurrent());
                Person           sPerson = new Person(wp.Identity.Name);
                if (sPerson.PersonID == -1)
                {
                    MessageBox.Show("Your Login ID is not associated with a person record in Arena.  In order to import tag members, you must have a valid person record in Arena.");
                    Application.Exit();
                }
                else
                {
                    ProfileCollection pColl = new ProfileCollection();

                    // Load Current User's Personal Tags
                    pColl.LoadPrivateProfiles(
                        Int32.Parse(ConfigurationSettings.AppSettings["Organization"]),
                        sPerson.PersonID,
                        true);

                    // Load Current User's Subscribed Tags
                    pColl.LoadSubscribedProfiles(
                        Int32.Parse(ConfigurationSettings.AppSettings["Organization"]),
                        sPerson.PersonID);

                    // Remove any duplicate tag names
                    for (int i = pColl.Count - 1; i >= 0; i--)
                    {
                        for (int j = 0; j < pColl.Count; j++)
                        {
                            if (j != i && pColl[j].ProfileID == pColl[i].ProfileID)
                            {
                                pColl.RemoveAt(i);
                                break;
                            }
                        }
                    }

                    // Add each tag to the checkbox list
                    foreach (Profile profile in pColl)
                    {
                        clbTags.Items.Add(new CheckItem(profile.Title, profile.ProfileID), CheckState.Checked);
                    }
                }
            }
            catch (SystemException ex)
            {
                MessageBox.Show("An error occurred while attempting to retrieve your private tags:\n\n" + ex.Message, "Import Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }