Ejemplo n.º 1
0
        /// <summary>
        /// Add an operating system requirement to an existing deployment type
        /// </summary>
        public static void AddRequirement(string applicationName, OperatingSystemValues os, string server)
        {
            Application    app            = CMApplication.GetApplicationByName(applicationName, server);
            DeploymentType deploymentType = app.DeploymentTypes[0];

            string ruleExpressionText = string.Empty;
            string ruleAnnotationText = string.Empty;

            switch (os)
            {
            case OperatingSystemValues.Windows81x86:
                ruleExpressionText = "Windows/All_x86_Windows_8.1_Client";
                ruleAnnotationText = "Operating system One of {All Windows 8.1(32 - bit)}";
                break;

            case OperatingSystemValues.Windows81x64:
                ruleExpressionText = "Windows/All_x64_Windows_8.1_Client";
                ruleAnnotationText = "Operating system One of {All Windows 8.1(64 - bit)}";
                break;

            case OperatingSystemValues.Windows10x86:
                ruleExpressionText = "Windows/All_x86_Windows_10_and_higher_Clients";
                ruleAnnotationText = "Operating system One of {All Windows 10 Professional/Enterprise and higher (32 - bit)}";
                break;

            case OperatingSystemValues.Windows10x64:
                ruleExpressionText = "Windows/All_x64_Windows_10_and_higher_Clients";
                ruleAnnotationText = "Operating system One of {All Windows 10 Professional/Enterprise and higher (64 - bit)}";
                break;
            }

            CustomCollection <RuleExpression> ruleCollection = new CustomCollection <RuleExpression>();
            RuleExpression ruleExpression = new RuleExpression(ruleExpressionText);

            ruleCollection.Add(ruleExpression);

            OperatingSystemExpression osExpression = new OperatingSystemExpression(ExpressionOperator.OneOf, ruleCollection);

            Rule rule = new Rule(Guid.NewGuid().ToString("N"), NoncomplianceSeverity.None, new Annotation(ruleAnnotationText, null, null, null), osExpression);

            deploymentType.Requirements.Add(rule);
            CMApplication.Save(app, server);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Add an operating system requirement to an existing deployment type
        /// </summary>
        public static void AddRequirement(string applicationName, OperatingSystemValues os, string server)
        {
            Application app = CMApplication.GetApplicationByName(applicationName, server);
            DeploymentType deploymentType = app.DeploymentTypes[0];

            string ruleExpressionText = string.Empty;
            string ruleAnnotationText = string.Empty;

            switch (os)
            {
                case OperatingSystemValues.Windows81x86:
                    ruleExpressionText = "Windows/All_x86_Windows_8.1_Client";
                    ruleAnnotationText = "Operating system One of {All Windows 8.1(32 - bit)}";
                    break;
                case OperatingSystemValues.Windows81x64:
                    ruleExpressionText = "Windows/All_x64_Windows_8.1_Client";
                    ruleAnnotationText = "Operating system One of {All Windows 8.1(64 - bit)}";
                    break;
                case OperatingSystemValues.Windows10x86:
                    ruleExpressionText = "Windows/All_x86_Windows_10_and_higher_Clients";
                    ruleAnnotationText = "Operating system One of {All Windows 10 Professional/Enterprise and higher (32 - bit)}";
                    break;
                case OperatingSystemValues.Windows10x64:
                    ruleExpressionText = "Windows/All_x64_Windows_10_and_higher_Clients";
                    ruleAnnotationText = "Operating system One of {All Windows 10 Professional/Enterprise and higher (64 - bit)}";
                    break;
            }

            CustomCollection<RuleExpression> ruleCollection = new CustomCollection<RuleExpression>();
            RuleExpression ruleExpression = new RuleExpression(ruleExpressionText);
            ruleCollection.Add(ruleExpression);

            OperatingSystemExpression osExpression = new OperatingSystemExpression(ExpressionOperator.OneOf, ruleCollection);

            Rule rule = new Rule(Guid.NewGuid().ToString("N"), NoncomplianceSeverity.None, new Annotation(ruleAnnotationText, null, null, null), osExpression);

            deploymentType.Requirements.Add(rule);
            CMApplication.Save(app, server);
        }