Example #1
0
        private void RefreshGrid()
        {
            DataTable aliasTable = new PublisherAliasDAO().GetAllPublisherAliases();

            ultraGrid1.DataSource = aliasTable;
            ultraGrid1.DataBind();
            ultraGrid1.DisplayLayout.Bands[0].SortedColumns.Add("Aliased To Publisher", false);
        }
Example #2
0
        private void PopulatePublisherNodes(string publisherFilter, bool showIncluded, bool showIgnored, UltraTreeNode rootNode, bool showAliasedPublishers)
        {
            rootNode.Override.NodeStyle = NodeStyle.Standard;

            PublisherAliasDAO lPublisherAliasDao       = new PublisherAliasDAO();
            List <string>     existingTargetPublishers = lPublisherAliasDao.SelectAliasedToPublishers();

            // Add the publishers to the tree
            try
            {
                UltraTreeNode publisherNode;

                //DataTable dt = new ApplicationsDAO().GetAllPublisherNamesAsDataTable(publisherFilter);
                DataTable dt = new ApplicationsDAO().GetAllPublisherNamesAsDataTable(publisherFilter, _showIncluded, _showIgnored);

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    string lPublisher = dt.Rows[i][0].ToString();

                    publisherNode = new UltraTreeNode(rootNode.Key + @"|" + lPublisher, lPublisher);
                    publisherNode.Override.NodeStyle = _selectionType == eSelectionType.all ? NodeStyle.CheckBox : NodeStyle.Standard;
                    publisherNode.Tag = rootNode.Tag;

                    if (!showAliasedPublishers)
                    {
                        if (!existingTargetPublishers.Contains(publisherNode.Text))
                        {
                            rootNode.Nodes.Add(publisherNode);
                        }
                    }
                    else
                    {
                        rootNode.Nodes.Add(publisherNode);
                    }
                }

                rootNode.Expanded = true;
            }

            catch (Exception)
            {
                // JML TODO log this error
            }

            // Expand the root node to show the publishers
            rootNode.Expanded = true;
        }
Example #3
0
        private bool CheckSourceTargetPublisherDifferent()
        {
            UltraTreeNode     rootNode           = sourcePublishersTree.Nodes[0];
            PublisherAliasDAO lPublisherAliasDAO = new PublisherAliasDAO();

            foreach (UltraTreeNode applicationNode in rootNode.Nodes)
            {
                if (applicationNode.CheckedState == CheckState.Checked)
                {
                    if (applicationNode.Text == targetPublishersTree.SelectedNodes[0].Text)
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
Example #4
0
        private List <string> CheckPublisherNotAlreadyAliased()
        {
            List <string> lAliasedPublishers = new List <string>();

            UltraTreeNode     rootNode           = sourcePublishersTree.Nodes[0];
            PublisherAliasDAO lPublisherAliasDAO = new PublisherAliasDAO();

            foreach (UltraTreeNode applicationNode in rootNode.Nodes)
            {
                if (applicationNode.CheckedState == CheckState.Checked)
                {
                    if (lPublisherAliasDAO.CheckPublisherExists(applicationNode.Text) > 0)
                    {
                        lAliasedPublishers.Add(applicationNode.Text);
                    }
                }
            }

            return(lAliasedPublishers);
        }
Example #5
0
        private void AliasPublisher(List <string> aSourcePublisher, string aTargetPublisher)
        {
            ApplicationsDAO        lApplicationsDAO        = new ApplicationsDAO();
            ApplicationInstanceDAO lApplicationInstanceDAO = new ApplicationInstanceDAO();

            // insert a record into the PUBLISHER_ALIAS table
            foreach (string lSourcePublisher in aSourcePublisher)
            {
                int lPublisherAliasID = new PublisherAliasDAO().Insert(lSourcePublisher, aTargetPublisher);

                // confirm record entered ok?
                if (lPublisherAliasID != -1)
                {
                    DataTable sourcePublisherApplicationsDataTable = lApplicationsDAO.SelectApplicationByPublisherName(lSourcePublisher);

                    foreach (DataRow applicationRow in sourcePublisherApplicationsDataTable.Rows)
                    {
                        // check if the proposed new application already exists
                        // it is possible (but unlikely) that an application name and version combo already exist
                        int    lSourceApplicationId = (int)applicationRow.ItemArray[0];
                        string lApplicationName     = applicationRow.ItemArray[2].ToString();
                        string lApplicationVersion  = applicationRow.ItemArray[3].ToString();

                        int lExisitingApplicationId = lApplicationsDAO.SelectIdByPublisherNameVersion(aTargetPublisher, lApplicationName, lApplicationVersion);

                        if (lExisitingApplicationId > 0)
                        {
                            // found a match
                            // need to get the original applicationid and update all of the application_instances for this application

                            // one final issue is whether the application is aliased
                            // if it is, we need to update the application_instances so that the base applicationid is the original app id
                            // and the _applicationid is the aliased_toid
                            int lBaseApplicationId = 0;
                            int lAliasedToId       = lApplicationsDAO.SelectAliasedToIdByApplicationId(lExisitingApplicationId);

                            if (lAliasedToId != 0)
                            {
                                lBaseApplicationId      = lExisitingApplicationId;
                                lExisitingApplicationId = lAliasedToId;
                            }

                            lApplicationInstanceDAO.UpdateApplicationInstanceByApplicationId(lExisitingApplicationId, lBaseApplicationId, lSourceApplicationId);

                            // final step will be to delete the application we are aliasing. This will mean that if the user tries to revert
                            // this alias they won't be able to do so
                            lApplicationsDAO.DeleteByApplicationId(lSourceApplicationId);
                        }
                        else
                        {
                            // publiser, name, version combo doesn;t already exist so we can just update the publisher name
                            // enter a record into the PUBLISHER_ALIAS_APP table, this will allow us to revert the alias later if needed
                            new PublisherAliasAppDAO().Insert(lSourceApplicationId, lPublisherAliasID);

                            // finally updated the application to reflect the new publisher
                            lApplicationsDAO.UpdateAliasedPublishers(aTargetPublisher, lSourceApplicationId);
                        }
                    }
                }
            }
        }