Exemplo n.º 1
0
        public void PerformRemovalActions(string packID)
        {
            tabControl1.SelectedTab = tabControl1.TabPages[1];
            StringBuilder sb = new StringBuilder();

            LoggingWindowText = String.Empty;
            sb.AppendLine("");
            sb.AppendLine("Starting removal of selected items...");
            sb.AppendLine("");
            Dictionary <string, string> activitiesList = IPUtilities.GetActivitesInIP(packID);

            LoggingWindowText = sb.ToString();

            bool removeOnlyDeletedJobHistory = (radioRemoveDeletedJobHistory.Checked);

            if (!radioRemoveNoJobHistory.Checked)
            {
                // actions start at the lowest level first to avoid any dependency / foreign key errors
                if (radioRemoveAllJobHistory.Checked)
                {
                    sb.AppendLine("Deleting job history for all activities in the IP...");
                }
                else if (radioRemoveDeletedJobHistory.Checked)
                {
                    sb.AppendLine("Deleting job history for all deleted activities in the IP...");
                }
                sb.AppendLine("");
                LoggingWindowText = sb.ToString();
                foreach (string activityName in activitiesList.Keys)
                {
                    sb.AppendLine(string.Format("   Activity: {0}", activityName));
                    string activityID = string.Empty;
                    if (activitiesList.TryGetValue(activityName, out activityID))
                    {
                        sb.AppendLine(string.Format("    Table: [OBJECTINSTANCEDATA]   Records deleted: {0}", IPUtilities.RemoveJobDataForActivityType(activityID, _myConnection, removeOnlyDeletedJobHistory).ToString()));
                        LoggingWindowText = sb.ToString();
                        sb.AppendLine(string.Format("    Table: [OBJECTINSTANCES]      Records deleted: {0}", IPUtilities.RemoveInstancesOfActivityType(activityID, _myConnection, removeOnlyDeletedJobHistory).ToString()));
                        LoggingWindowText = sb.ToString();
                        sb.AppendLine("");
                    }
                }
            }
            else
            {
                sb.AppendLine("Skipping job history deletion...");
                sb.AppendLine("");
            }


            bool removeOnlyDeletedActivities = (radioRemoveDeletedActivities.Checked);

            if (!radioRemoveNoActivities.Checked)
            {
                //TODO:  Add code to validate that any dependent table data has already been removed before doing this.

                if (radioRemoveAllActivities.Checked)
                {
                    sb.AppendLine("Deleting all activities in the IP from all runbooks...");
                }
                else if (radioRemoveDeletedActivities.Checked)
                {
                    sb.AppendLine("Deleting all activities in the IP that are marked 'Deleted'...");
                }
                sb.AppendLine("");
                LoggingWindowText = sb.ToString();
                foreach (string activityName in activitiesList.Keys)
                {
                    sb.AppendLine(string.Format("   Activity: {0}", activityName));
                    string activityID = string.Empty;
                    if (activitiesList.TryGetValue(activityName, out activityID))
                    {
                        sb.AppendLine(string.Format("    Table: [LINKTRIGGERS]   Records deleted: {0}", IPUtilities.RemoveJobDataForActivityType(activityID, _myConnection, removeOnlyDeletedActivities).ToString()));
                        LoggingWindowText = sb.ToString();
                        sb.AppendLine(string.Format("    Table: [LINKS]          Records deleted: {0}", IPUtilities.RemoveInstancesOfActivityType(activityID, _myConnection, removeOnlyDeletedActivities).ToString()));
                        LoggingWindowText = sb.ToString();
                        sb.AppendLine(string.Format("    Table: [OBJECT_AUDIT]   Records deleted: {0}", IPUtilities.RemoveInstancesOfActivityType(activityID, _myConnection, removeOnlyDeletedActivities).ToString()));
                        LoggingWindowText = sb.ToString();
                        sb.AppendLine(string.Format("    Table: [OBJECTLOOPING]  Records deleted: {0}", IPUtilities.RemoveInstancesOfActivityType(activityID, _myConnection, removeOnlyDeletedActivities).ToString()));
                        LoggingWindowText = sb.ToString();
                        sb.AppendLine(string.Format("    Table: [OBJECTS]        Records deleted: {0}", IPUtilities.RemoveInstancesOfActivityType(activityID, _myConnection, removeOnlyDeletedActivities).ToString()));
                        LoggingWindowText = sb.ToString();
                        sb.AppendLine(string.Format("    Table: [CONFIGURATION]  Records deleted: {0}", IPUtilities.RemoveInstancesOfActivityType(activityID, _myConnection, removeOnlyDeletedActivities).ToString()));
                        LoggingWindowText = sb.ToString();
                        sb.AppendLine("");
                    }
                }
            }
            else
            {
                sb.AppendLine("Skipping activity deletion...");
                sb.AppendLine("");
            }
            LoggingWindowText = sb.ToString();



            //if (checkBoxCleanAll.Checked)
            //{
            //    sb.AppendLine("Remove all data related to the IP.");
            //    sb.AppendLine("");
            //}
            //if (checkBoxUnregisterIP.Checked)
            //{
            //    sb.AppendLine("Unregister the IP");
            //    sb.AppendLine("");
            //}
            //if (checkBoxUndeployIP.Checked)
            //{
            //    sb.AppendLine("Undeploy the IP");
            //    sb.AppendLine("");
            //}
        }
Exemplo n.º 2
0
        private void DisplayIPDetails()
        {
            textBoxSelectedIPInfo.Enabled = true;
            SelectionWindowText           = "Loading IP Detail Information...";

            StringBuilder sb          = new StringBuilder();
            string        ipName      = dataGridView1.SelectedCells[0].Value.ToString();
            string        packID      = GetSelectedPackID();
            string        productCode = IPUtilities.GetProductCodeForIP(packID, _myConnection);
            IPType        ipType      = (IPType)Enum.Parse(typeof(IPType), dataGridView1.SelectedCells[1].Value.ToString());

            sb.AppendLine("IP Name            : " + ipName);
            sb.AppendLine("Registered Version : " + IPUtilities.GetRegisteredIPVersion(packID, _myConnection));
            sb.AppendLine("IP Type            : " + ipType.ToString());
            if (dataGridView1.SelectedCells[5].Value.ToString() == "True")
            {
                sb.AppendLine("IP Registered?     : Yes");
                checkBoxUnregisterIP.Enabled = true;
            }
            else
            {
                sb.AppendLine("IP Registered?     : No");
            }

            sb.AppendLine("Runbook Designers  :");
            List <string> designers = Infrastructure.GetRunbookDesigners(_myConnection);

            foreach (string designer in designers)
            {
                string ipVersion = IPUtilities.GetDeployedIpVersion(productCode, designer);
                if (!string.IsNullOrEmpty(ipVersion))
                {
                    sb.AppendLine("\t" + designer.PadRight(20) + "\tVersion " + ipVersion + " deployed");
                    checkBoxUndeployIP.Enabled = true;
                }
                else
                {
                    sb.AppendLine("\t" + designer.PadRight(20) + "\tIP not deployed");
                }
            }
            sb.AppendLine("Runbook Servers:");
            List <string> rbServers = Infrastructure.GetRunbookDesigners(_myConnection);

            foreach (string rbServer in rbServers)
            {
                string ipVersion = IPUtilities.GetDeployedIpVersion(productCode, rbServer);
                if (!string.IsNullOrEmpty(ipVersion))
                {
                    sb.AppendLine("\t" + rbServer.PadRight(20) + "\tVersion " + ipVersion + " deployed");
                    checkBoxUndeployIP.Enabled = true;
                }
                else
                {
                    sb.AppendLine("\t" + rbServer.PadRight(20) + "\tIP not deployed");
                }
            }

            sb.AppendLine("");
            int numActivities = IPUtilities.GetNumberOfActivitiesInIP(packID, _myConnection, ipType);

            sb.AppendLine("Number of Activities in the IP                   : " + numActivities);


            int numActivitiesInRunbooks = IPUtilities.GetActivityInstancesCountForIP(packID, _myConnection, ipType);

            sb.AppendLine("# of Times the Activities are Used in Runbooks   : " + numActivitiesInRunbooks);
            radioRemoveAllActivities.Enabled = (numActivitiesInRunbooks > 0);

            int numActivitiesInJobs = IPUtilities.GetActivityInstanceDataCountForIP(packID, _myConnection, ipType);

            sb.AppendLine("# of Times the Activities were Run in Jobs       : " + numActivitiesInJobs);
            radioRemoveAllJobHistory.Enabled = (numActivitiesInJobs > 0);
            sb.AppendLine("");

            int numDeletedActivitiesInRunbooks = IPUtilities.GetActivityInstancesCountForIP(packID, _myConnection, ipType, true);

            sb.AppendLine("# of 'Deleted' Activities in Runbooks            : " + numDeletedActivitiesInRunbooks);
            radioRemoveDeletedActivities.Enabled = (numDeletedActivitiesInRunbooks > 0);

            int numDeletedActivitiesInJobs = IPUtilities.GetActivityInstanceDataCountForIP(packID, _myConnection, ipType, true);

            sb.AppendLine("# of Job Data Items for 'Deleted' Activities     : " + numDeletedActivitiesInJobs);
            radioRemoveDeletedJobHistory.Enabled = (numDeletedActivitiesInJobs > 0);

            //only get list of activities for Toolkit-based IPs.
            sb.AppendLine("");
            sb.AppendLine("");
            sb.AppendLine("List of Activities in the IP and the runbooks where they are used:");
            sb.AppendLine("");
            Dictionary <string, string> activitiesList = IPUtilities.GetActivitesInIP(packID);

            sb.AppendLine("   Activity Name    /   Runbooks Where Used");
            sb.AppendLine("-------------------------------------------------------------------------");
            if (null != activitiesList)
            {
                foreach (string activity in activitiesList.Keys)
                {
                    sb.AppendLine("  " + activity);
                    string activityType = string.Empty;
                    if (activitiesList.TryGetValue(activity, out activityType))
                    {
                        List <string> runbookNames = IPUtilities.GetRunbookNamesWhereActivityTypeIsUsed(activityType, _myConnection);
                        if (runbookNames.Count > 0)
                        {
                            foreach (string name in runbookNames)
                            {
                                sb.AppendLine("                 " + name);
                            }
                            sb.AppendLine("");
                        }
                    }
                }
            }

            sb.AppendLine("");
            SelectionWindowText = sb.ToString();
        }