Пример #1
0
        public static int RemoveActivityType(string typeID, SqlConnection scoConnection, bool replaceWithUnknown, bool deletedOnly)
        {
            //TODO: Also need to remove QIKOBJECT instances
            int    numAffected = 0;
            string whereClause = string.Empty;

            if (deletedOnly)
            {
                whereClause = string.Format("WHERE obj.ObjectType = '{0}' AND obj.Deleted = 1)", typeID);
            }
            else
            {
                whereClause = string.Format("WHERE obj.ObjectType = '{0}')", typeID);
            }

            StringBuilder sb = new StringBuilder();

            typeID = GuidUtilities.RemoveBracesFromGuid(typeID);
            if (replaceWithUnknown)
            {
                sb.Append("UPDATE [Orchestrator].[dbo].[OBJECTS] obj");
                sb.Append("SET obj.ObjectType = 'DDDDDDDD-DDDD-DDDD-DDDD-DDDDDDDDDDDD', set obj.Enabled = 0");
                sb.Append(whereClause);
            }
            else
            {
                sb.Append("DELETE FROM [Orchestrator].[dbo].[OBJECTS]");
                sb.Append(whereClause);
            }
            numAffected += SQLUtilities.RunDeleteQuery(sb.ToString(), scoConnection);
            return(numAffected);
        }
Пример #2
0
        public static int RemoveConfigurationDataForIP(string packID, SqlConnection scoConnection)
        {
            packID = GuidUtilities.RemoveBracesFromGuid(packID);
            string queryString = string.Format("DELETE FROM [Orchestrator].[dbo].[CONFIGURATION] Where AND DataValue like '%{0}%' ", packID);

            return(SQLUtilities.RunDeleteQuery(queryString, scoConnection));
        }
Пример #3
0
        public static int RemoveCapDataForIP(string packID, SqlConnection scoConnection)
        {
            packID = GuidUtilities.RemoveBracesFromGuid(packID);
            string queryString = string.Format("DELETE FROM [Orchestrator].[dbo].[CAPS] Where UniqueID = '{0}'", packID);

            return(SQLUtilities.RunDeleteQuery(queryString, scoConnection));
        }
Пример #4
0
        public static int RemoveLinkTriggersForActivityType(string typeID, SqlConnection scoConnection, bool deletedOnly)
        {
            StringBuilder sb = new StringBuilder();

            typeID = GuidUtilities.RemoveBracesFromGuid(typeID);

            sb.Append("DELETE FROM [Orchestrator].[dbo].[TRIGGERS]");
            sb.Append("WHERE ParentID IN");
            sb.Append(GetSelectObjectTypeSubQueryString(typeID, deletedOnly));

            return(SQLUtilities.RunDeleteQuery(sb.ToString(), scoConnection));
        }
Пример #5
0
        public static int RemoveJobDataForActivityType(string typeID, SqlConnection scoConnection, bool deletedOnly)
        {
            StringBuilder sb = new StringBuilder();

            typeID = GuidUtilities.RemoveBracesFromGuid(typeID);

            sb.Append(" DELETE FROM [Orchestrator].[dbo].[OBJECTINSTANCEDATA] ");
            sb.Append(" WHERE ObjectInstanceID IN ");
            sb.Append(" (SELECT UniqueID FROM [Orchestrator].[dbo].[OBJECTINSTANCES] ");
            sb.Append("  WHERE ObjectID IN ");
            sb.Append(GetSelectObjectTypeSubQueryString(typeID, deletedOnly));
            sb.Append(string.Format(")", typeID));
            return(SQLUtilities.RunDeleteQuery(sb.ToString(), scoConnection));
        }
Пример #6
0
        private static string GetSelectObjectTypeSubQueryString(string typeID, bool deletedOnly)
        {
            StringBuilder sb = new StringBuilder();

            typeID = GuidUtilities.RemoveBracesFromGuid(typeID);

            sb.Append("(SELECT obj.UniqueID FROM [Orchestrator].[dbo].[OBJECTS] obj");

            if (deletedOnly)
            {
                sb.Append(string.Format("WHERE obj.ObjectType = '{0}' AND obj.Deleted = 1)", typeID));
            }
            else
            {
                sb.Append(string.Format("WHERE obj.ObjectType = '{0}')", typeID));
            }
            return(sb.ToString());
        }
Пример #7
0
        public static string BuildActivityTypesListForQuery(string packID)
        {
            StringBuilder queryString = new StringBuilder();

            Dictionary <string, string> activitiesList = new Dictionary <string, string>();

            activitiesList = GetActivitesInIP(packID);
            if (activitiesList != null)
            {
                int i = 0;
                queryString.Append(" (");
                foreach (string activityID in activitiesList.Values)
                {
                    if (i > 0)
                    {
                        queryString.Append(", ");
                    }
                    queryString.Append(string.Format("'{0}'", GuidUtilities.RemoveBracesFromGuid(activityID)));
                    i++;
                }
                queryString.Append(")");
                return(queryString.ToString());
            }
            else
            {
                Dictionary <string, string> aList = new Dictionary <string, string>();
                aList = GetActivitesInIP(packID);
                int i = 0;
                queryString.Append(" (");
                foreach (string activityID in aList.Values)
                {
                    if (i > 0)
                    {
                        queryString.Append(", ");
                    }
                    queryString.Append(string.Format("'{0}'", GuidUtilities.RemoveBracesFromGuid(activityID)));
                    i++;
                }
                queryString.Append(")");
                return(queryString.ToString());
            }
        }
Пример #8
0
        public static List <string> GetRunbookNamesWhereActivityTypeIsUsed(string typeID, SqlConnection scoConnection)
        {
            List <string> runbookList = new List <string>();
            StringBuilder queryString = new StringBuilder();

            queryString.Append("Select DISTINCT Name FROM [Orchestrator].[dbo].[POLICIES] WHERE UniqueID IN ");
            queryString.Append("(Select ParentID from [Orchestrator].[dbo].[OBJECTS] ");
            queryString.Append(string.Format("Where ObjectType = '{0}')", GuidUtilities.RemoveBracesFromGuid(typeID)));

            SqlDataReader myReader  = null;
            SqlCommand    myCommand = new SqlCommand(queryString.ToString(), scoConnection);

            myReader = myCommand.ExecuteReader();

            //read the list
            while (myReader.Read())
            {
                //insert into list
                runbookList.Add(myReader[0].ToString());
            }
            myReader.Close();
            return(runbookList);
        }