예제 #1
0
        private void LoadGridView()
        {
            //format grid header
            dataGridView1.Columns[1].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
            dataGridView1.Columns[2].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
            dataGridView1.Columns[3].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
            dataGridView1.Columns[4].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
            dataGridView1.Columns[5].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
            dataGridView1.Columns[6].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
            dataGridView1.Rows.Clear();

            try
            {
                _ipList = IPUtilities.GetAllIpInfo(_myConnection);

                foreach (string key in _ipList.Keys)
                {
                    //create new instances of the objects to create the row
                    DataGridViewRow          row                 = new DataGridViewRow();
                    DataGridViewTextBoxCell  ipNameCell          = new DataGridViewTextBoxCell();
                    DataGridViewTextBoxCell  ipTypeCell          = new DataGridViewTextBoxCell();
                    DataGridViewTextBoxCell  activitiesCell      = new DataGridViewTextBoxCell();
                    DataGridViewTextBoxCell  runbookInstanceCell = new DataGridViewTextBoxCell();
                    DataGridViewTextBoxCell  dataInstanceCell    = new DataGridViewTextBoxCell();
                    DataGridViewCheckBoxCell isRegistered        = new DataGridViewCheckBoxCell();
                    DataGridViewCheckBoxCell isDeployed          = new DataGridViewCheckBoxCell();

                    string value = string.Empty;
                    ipNameCell.Value = key;
                    _ipList.TryGetValue(key, out value);
                    ipNameCell.Tag = value;

                    //add formatting
                    ipTypeCell.Style.Alignment          = DataGridViewContentAlignment.MiddleCenter;
                    activitiesCell.Style.Alignment      = DataGridViewContentAlignment.MiddleCenter;
                    runbookInstanceCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
                    dataInstanceCell.Style.Alignment    = DataGridViewContentAlignment.MiddleCenter;

                    //add the cells to the row
                    row.Cells.Add(ipNameCell);
                    row.Cells.Add(ipTypeCell);
                    row.Cells.Add(activitiesCell);
                    row.Cells.Add(runbookInstanceCell);
                    row.Cells.Add(dataInstanceCell);
                    row.Cells.Add(isRegistered);
                    row.Cells.Add(isDeployed);

                    //add the row to the gridview
                    dataGridView1.Rows.Add(row);
                }


                foreach (DataGridViewRow row in dataGridView1.Rows)
                {
                    try
                    {
                        string packId = row.Cells[0].Tag.ToString();
                        IPType ipType = IPUtilities.GetIPType(packId, _myConnection);

                        row.Cells[1].Value = ipType.ToString();
                        row.Cells[2].Value = IPUtilities.GetNumberOfActivitiesInIP(packId, _myConnection, ipType).ToString();
                        row.Cells[3].Value = IPUtilities.GetActivityInstancesCountForIP(packId, _myConnection, ipType).ToString();
                        row.Cells[4].Value = IPUtilities.GetActivityInstanceDataCountForIP(packId, _myConnection, ipType).ToString();

                        if (ipType == IPType.Toolkit)
                        {
                        }
                        else if (ipType == IPType.Native)
                        {
                            row.DefaultCellStyle.BackColor = Color.LightGray;
                        }
                        else  //unknown type
                        {
                            row.DefaultCellStyle.BackColor = Color.Cornsilk;
                        }
                        string productCode  = IPUtilities.GetProductCodeForIP(packId, _myConnection);
                        bool   isDeployed   = IPUtilities.IpIsDeployed(productCode, _computerName);
                        bool   isRegistered = IPUtilities.IpIsRegistered(packId);

                        row.Cells[5].Value = isRegistered;
                        row.Cells[6].Value = isDeployed;

                        if ((isRegistered == false) && (isDeployed == false))
                        {
                            row.DefaultCellStyle.BackColor = Color.LightSalmon;
                        }
                    }
                    catch { }
                }
                //re-sort columns to prioritize non-deployed, non-registered IPs
                dataGridView1.Sort(dataGridView1.Columns[1], ListSortDirection.Descending);
                dataGridView1.Sort(dataGridView1.Columns[6], ListSortDirection.Ascending);
                dataGridView1.Sort(dataGridView1.Columns[5], ListSortDirection.Ascending);

                //prevent the first row from being selected by default
                dataGridView1.SelectedRows[0].Selected = false;
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
예제 #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();
        }