示例#1
0
        public void Execute(IActivityRequest request, IActivityResponse response)
        {
            SCCMServer = settings.SCCMSERVER;
            userName   = settings.UserName;
            password   = settings.Password;

            String folderName = request.Inputs["Folder Name"].AsString();
            String folderType = request.Inputs["Folder Type"].AsString();

            String searchFolder = String.Empty;
            String searchXML    = String.Empty;

            if (request.Inputs.Contains("Search Folder"))
            {
                searchFolder = request.Inputs["Search Folder"].AsString();
            }
            if (request.Inputs.Contains("Search Folder Query"))
            {
                searchXML = request.Inputs["Search Folder Query"].AsString();
            }

            int parentContainerID = request.Inputs["Parent Container ID"].AsInt32();

            //Setup WQL Connection and WMI Management Scope
            WqlConnectionManager connection = CMInterop.connectSCCMServer(SCCMServer, userName, password);

            using (connection)
            {
                IResultObject col = null;

                switch (folderType)
                {
                case "SMS_Package":
                    if (searchFolder.Equals("True") && !(searchXML.Equals(String.Empty)))
                    {
                        col = CMInterop.createSearchFolder(connection, folderName, CMInterop.folderType.SMS_Package, parentContainerID, searchXML);
                    }
                    else
                    {
                        col = CMInterop.createConsoleFolder(connection, folderName, CMInterop.folderType.SMS_Package, parentContainerID);
                    }
                    break;

                case "SMS_Advertisement":
                    if (searchFolder.Equals("True") && !(searchXML.Equals(String.Empty)))
                    {
                        col = CMInterop.createSearchFolder(connection, folderName, CMInterop.folderType.SMS_Advertisement, parentContainerID, searchXML);
                    }
                    else
                    {
                        col = CMInterop.createConsoleFolder(connection, folderName, CMInterop.folderType.SMS_Advertisement, parentContainerID);
                    }
                    break;

                case "SMS_Query":
                    if (searchFolder.Equals("True") && !(searchXML.Equals(String.Empty)))
                    {
                        col = CMInterop.createSearchFolder(connection, folderName, CMInterop.folderType.SMS_Query, parentContainerID, searchXML);
                    }
                    else
                    {
                        col = CMInterop.createConsoleFolder(connection, folderName, CMInterop.folderType.SMS_Query, parentContainerID);
                    }
                    break;

                case "SMS_Report":
                    if (searchFolder.Equals("True") && !(searchXML.Equals(String.Empty)))
                    {
                        col = CMInterop.createSearchFolder(connection, folderName, CMInterop.folderType.SMS_Report, parentContainerID, searchXML);
                    }
                    else
                    {
                        col = CMInterop.createConsoleFolder(connection, folderName, CMInterop.folderType.SMS_Report, parentContainerID);
                    }
                    break;

                case "SMS_MeteredProductRule":
                    if (searchFolder.Equals("True") && !(searchXML.Equals(String.Empty)))
                    {
                        col = CMInterop.createSearchFolder(connection, folderName, CMInterop.folderType.SMS_MeteredProductRule, parentContainerID, searchXML);
                    }
                    else
                    {
                        col = CMInterop.createConsoleFolder(connection, folderName, CMInterop.folderType.SMS_MeteredProductRule, parentContainerID);
                    }
                    break;

                case "SMS_ConfigurationItem":
                    if (searchFolder.Equals("True") && !(searchXML.Equals(String.Empty)))
                    {
                        col = CMInterop.createSearchFolder(connection, folderName, CMInterop.folderType.SMS_ConfigurationItem, parentContainerID, searchXML);
                    }
                    else
                    {
                        col = CMInterop.createConsoleFolder(connection, folderName, CMInterop.folderType.SMS_ConfigurationItem, parentContainerID);
                    }
                    break;

                case "SMS_OperatingSystemInstallPackage":
                    if (searchFolder.Equals("True") && !(searchXML.Equals(String.Empty)))
                    {
                        col = CMInterop.createSearchFolder(connection, folderName, CMInterop.folderType.SMS_OperatingSystemInstallPackage, parentContainerID, searchXML);
                    }
                    else
                    {
                        col = CMInterop.createConsoleFolder(connection, folderName, CMInterop.folderType.SMS_OperatingSystemInstallPackage, parentContainerID);
                    }
                    break;

                case "SMS_StateMigration":
                    if (searchFolder.Equals("True") && !(searchXML.Equals(String.Empty)))
                    {
                        col = CMInterop.createSearchFolder(connection, folderName, CMInterop.folderType.SMS_StateMigration, parentContainerID, searchXML);
                    }
                    else
                    {
                        col = CMInterop.createConsoleFolder(connection, folderName, CMInterop.folderType.SMS_StateMigration, parentContainerID);
                    }
                    break;

                case "SMS_ImagePackage": if (searchFolder.Equals("True") && !(searchXML.Equals(String.Empty)))
                    {
                        col = CMInterop.createSearchFolder(connection, folderName, CMInterop.folderType.SMS_ImagePackage, parentContainerID, searchXML);
                    }
                    else
                    {
                        col = CMInterop.createConsoleFolder(connection, folderName, CMInterop.folderType.SMS_ImagePackage, parentContainerID);
                    }
                    break;

                case "SMS_BootImagePackage":
                    if (searchFolder.Equals("True") && !(searchXML.Equals(String.Empty)))
                    {
                        col = CMInterop.createSearchFolder(connection, folderName, CMInterop.folderType.SMS_BootImagePackage, parentContainerID, searchXML);
                    }
                    else
                    {
                        col = CMInterop.createConsoleFolder(connection, folderName, CMInterop.folderType.SMS_BootImagePackage, parentContainerID);
                    }
                    break;

                case "SMS_TaskSequencePackage":
                    if (searchFolder.Equals("True") && !(searchXML.Equals(String.Empty)))
                    {
                        col = CMInterop.createSearchFolder(connection, folderName, CMInterop.folderType.SMS_TaskSequencePackage, parentContainerID, searchXML);
                    }
                    else
                    {
                        col = CMInterop.createConsoleFolder(connection, folderName, CMInterop.folderType.SMS_TaskSequencePackage, parentContainerID);
                    }
                    break;

                case "SMS_DeviceSettingPackage":
                    if (searchFolder.Equals("True") && !(searchXML.Equals(String.Empty)))
                    {
                        col = CMInterop.createSearchFolder(connection, folderName, CMInterop.folderType.SMS_DeviceSettingPackage, parentContainerID, searchXML);
                    }
                    else
                    {
                        col = CMInterop.createConsoleFolder(connection, folderName, CMInterop.folderType.SMS_DeviceSettingPackage, parentContainerID);
                    }
                    break;

                case "SMS_DriverPackage":
                    if (searchFolder.Equals("True") && !(searchXML.Equals(String.Empty)))
                    {
                        col = CMInterop.createSearchFolder(connection, folderName, CMInterop.folderType.SMS_DriverPackage, parentContainerID, searchXML);
                    }
                    else
                    {
                        col = CMInterop.createConsoleFolder(connection, folderName, CMInterop.folderType.SMS_DriverPackage, parentContainerID);
                    }
                    break;

                case "SMS_Driver":
                    if (searchFolder.Equals("True") && !(searchXML.Equals(String.Empty)))
                    {
                        col = CMInterop.createSearchFolder(connection, folderName, CMInterop.folderType.SMS_Driver, parentContainerID, searchXML);
                    }
                    else
                    {
                        col = CMInterop.createConsoleFolder(connection, folderName, CMInterop.folderType.SMS_Driver, parentContainerID);
                    }
                    break;

                case "SMS_SoftwareUpdate":
                    if (searchFolder.Equals("True") && !(searchXML.Equals(String.Empty)))
                    {
                        col = CMInterop.createSearchFolder(connection, folderName, CMInterop.folderType.SMS_SoftwareUpdate, parentContainerID, searchXML);
                    }
                    else
                    {
                        col = CMInterop.createConsoleFolder(connection, folderName, CMInterop.folderType.SMS_SoftwareUpdate, parentContainerID);
                    }
                    break;

                default:
                    break;
                }

                if (col != null)
                {
                    response.WithFiltering().PublishRange(getObjects(col));
                }
                response.Publish("Number of Object Container Nodes", ObjCount);
            }
        }