Exemplo n.º 1
0
        protected void InitializeGeneralTab()
        {
            // Populate the window
            tbPublisher.Text = _installedApplication.Publisher;
            tbName.Text      = _installedApplication.Name;
            tbVersion.Text   = _installedApplication.Version;

            // Determine if any applications have been aliased to this application as if so we cannot
            // alias this application to any other.
            ApplicationsDAO lwDataAccess = new ApplicationsDAO();

            if (lwDataAccess.GetAliasCount(_installedApplication.ApplicationID) != 0)
            {
                lblAliasDescription.Enabled  = false;
                lblAliasedTo.Enabled         = false;
                tbAliasedApplication.Enabled = false;
                bnBrowseAlias.Enabled        = false;
            }
        }
Exemplo n.º 2
0
        private void bnAlias_Click(object sender, EventArgs e)
        {
            InstalledApplication _targetApplication = selectTarget.GetSelectedApplication();

            foreach (int lApplicationId in _selectedApplicationIds)
            {
                if (_targetApplication == null)
                {
                    MessageBox.Show("Please select the target application to which these applications should be aliased", "Select Target Application");
                    DialogResult = DialogResult.None;
                    return;
                }

                // One last check to make sure that we don't have a single application selected in both lists and it is
                // the same as someone is bound to try it to catch us out
                if (_targetApplication.ApplicationID == lApplicationId)
                {
                    MessageBox.Show("You cannot alias an application to itself, please choose different applications", "Circular Alias");
                    DialogResult = DialogResult.None;
                    return;
                }

                // ...and we cannot alias an application which is itself already aliased by other applications
                if (lApplicationsDAO.GetAliasCount(lApplicationId) != 0)
                {
                    MessageBox.Show(
                        String.Format("You cannot alias an application which is itself already the target of an alias, please choose different applications"),
                        "Circular Alias");
                    DialogResult = DialogResult.None;
                    return;
                }
            }

            foreach (int lApplicationId in _selectedApplicationIds)
            {
                AliasApplications(lApplicationId, _targetApplication);
            }
        }
Exemplo n.º 3
0
        private void AliasApplications()
        {
            ApplicationsDAO          lwDataAccess = new ApplicationsDAO();
            ApplicationPublisherList listSelectedPublishers;
            InstalledApplicationList listSelectedApplications;

            selectToAlias.GetSelectedItems(out listSelectedPublishers, out listSelectedApplications);

            // Anything selected?
            // Note that the Publisher list will always be empty as we have requested multiple applications only
            if (listSelectedApplications.Count == 0)
            {
                MessageBox.Show("Please select one or more applications which are to be aliased", "Select Alias Application");
                DialogResult = DialogResult.None;
                return;
            }

            // OK - we must also have the 'target' application selected
            InstalledApplication targetApplication = selectTarget.GetSelectedApplication();

            if (targetApplication == null)
            {
                MessageBox.Show("Please select the target application to which these applications should be aliased", "Select Target Application");
                DialogResult = DialogResult.None;
                return;
            }

            // One last check to make sure that we don't have a single application selected in both lists and it is
            // the same as someone is bound to try it to catch us out
            if ((listSelectedApplications.Count == 1) &&
                (targetApplication.ApplicationID == listSelectedApplications[0].ApplicationID))
            {
                MessageBox.Show("You cannot alias an application to itself, please choose different applications", "Circular Alias");
                DialogResult = DialogResult.None;
                return;
            }

            // ...and we cannot alias an application which is itself already aliased by other applications
            if ((listSelectedApplications.Count == 1) &&
                (lwDataAccess.GetAliasCount(listSelectedApplications[0].ApplicationID) != 0))
            {
                MessageBox.Show("You cannot alias an application which is itself already the target of an alias, please choose different applications", "Circular Alias");
                DialogResult = DialogResult.None;
                return;
            }

            List <string> lAliasedApplications = new List <string>();

            // OK All validation complete - now we have to actually act on the selected applications
            foreach (InstalledApplication application in listSelectedApplications)
            {
                if (application.Version == "" || application.Name.EndsWith(application.Version))
                {
                    lAliasedApplications.Add(application.Name);
                }
                else
                {
                    lAliasedApplications.Add(application.Name + " (" + application.Version + ")");
                }

                if (application.ApplicationID != targetApplication.ApplicationID)
                {
                    lwDataAccess.ApplicationSetAlias(application.ApplicationID, targetApplication.ApplicationID);
                }
            }

            string targetApplicationDisplay = "";

            if (targetApplication.Version == "" || targetApplication.Name.EndsWith(targetApplication.Version))
            {
                targetApplicationDisplay = targetApplication.Name;
            }
            else
            {
                targetApplicationDisplay = targetApplication.Name + " (" + targetApplication.Version + ")";
            }

            MessageBox.Show(
                String.Format("The following application(s) have been successfully aliased to '{0}' "
                              + Environment.NewLine + Environment.NewLine + string.Join("\n", lAliasedApplications.ToArray()), targetApplicationDisplay),
                "Alias Applications",
                MessageBoxButtons.OK,
                MessageBoxIcon.Information);

            PopulatePublisherLists();
            RefreshGrid();
            tabControl1.SelectedTab = tabPage2;
        }