示例#1
0
        // Deletes the business rule and publishes to remove the rule from the validation process.
        private static void DeleteAndPublishBR(string modelName, string entityName, string ruleName)
        {
            try
            {
                // Set Model and Entity objects.
                Identifier modelId = new Identifier {
                    Name = modelName
                };
                Identifier entityId = new Identifier {
                    Name = entityName
                };

                // Create the request object.
                MDSTestService.BusinessRulesGetRequest ruleGetRequest = new MDSTestService.BusinessRulesGetRequest();
                ruleGetRequest.ResultOptions = new BRResultOptions();
                ruleGetRequest.ResultOptions.BusinessRules = ResultType.Details;
                ruleGetRequest.GetCriteria                 = new BRGetCriteria();
                ruleGetRequest.GetCriteria.ModelId         = modelId;
                ruleGetRequest.GetCriteria.EntityId        = entityId;
                ruleGetRequest.GetCriteria.MemberType      = BREntityMemberType.Leaf;
                ruleGetRequest.GetCriteria.BusinessRuleIds = new System.Collections.ObjectModel.Collection <Identifier> {
                };
                ruleGetRequest.GetCriteria.BusinessRuleIds.Add(new Identifier {
                    Name = ruleName
                });

                // Get the business rules.
                MDSTestService.BusinessRulesGetResponse ruleGetResponse = clientProxy.BusinessRulesGet(ruleGetRequest);
                HandleOperationErrors(ruleGetResponse.OperationResult);

                BusinessRule selectedBusinessRule = ruleGetResponse.BusinessRuleSet.BusinessRulesMember[0];

                // Create the request object.
                MDSTestService.BusinessRulesDeleteRequest ruleDeleteRequest = new MDSTestService.BusinessRulesDeleteRequest();
                ruleDeleteRequest.DeleteCriteria = new BRDeleteCriteria();
                ruleDeleteRequest.DeleteCriteria.BusinessRules = new System.Collections.ObjectModel.Collection <Guid> {
                };
                ruleDeleteRequest.DeleteCriteria.BusinessRules.Add(selectedBusinessRule.Identifier.Id);

                // Delete the business rule.
                MDSTestService.MessageResponse ruleDeleteResponse = clientProxy.BusinessRulesDelete(ruleDeleteRequest);
                HandleOperationErrors(ruleDeleteResponse.OperationResult);

                // Create the request object.
                MDSTestService.BusinessRulesPublishRequest rulePublishRequest = new MDSTestService.BusinessRulesPublishRequest();
                rulePublishRequest.BRPublishCriteria            = new BRPublishCriteria();
                rulePublishRequest.BRPublishCriteria.EntityId   = entityId;
                rulePublishRequest.BRPublishCriteria.ModelId    = modelId;
                rulePublishRequest.BRPublishCriteria.MemberType = BREntityMemberType.Leaf;

                // Publish the business rule.
                MDSTestService.MessageResponse rulePublishResponse = clientProxy.BusinessRulesPublish(rulePublishRequest);
                HandleOperationErrors(rulePublishResponse.OperationResult);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: {0}", ex);
            }
        }
        // Excludes the business rule and publishes it to remove the rule from the validation process.
        private static void ExcludeAndPublishBR(string modelName, string entityName, string ruleName)
        {
            try
            {
                // Set Model and Entity objects.
                Identifier modelId = new Identifier { Name = modelName };
                Identifier entityId = new Identifier { Name = entityName };

                // Create the request object.
                MDSTestService.BusinessRulesGetRequest ruleGetRequest = new MDSTestService.BusinessRulesGetRequest();
                ruleGetRequest.ResultOptions = new BRResultOptions();
                ruleGetRequest.ResultOptions.BusinessRules = ResultType.Details;
                ruleGetRequest.GetCriteria = new BRGetCriteria();
                ruleGetRequest.GetCriteria.ModelId = modelId;
                ruleGetRequest.GetCriteria.EntityId = entityId;
                ruleGetRequest.GetCriteria.MemberType = BREntityMemberType.Leaf;
                ruleGetRequest.GetCriteria.BusinessRuleIds = new System.Collections.ObjectModel.Collection<Identifier> { };
                ruleGetRequest.GetCriteria.BusinessRuleIds.Add(new Identifier { Name = ruleName });

                // Get the business rules.
                MDSTestService.BusinessRulesGetResponse ruleGetResponse = clientProxy.BusinessRulesGet(ruleGetRequest);
                HandleOperationErrors(ruleGetResponse.OperationResult);

                BusinessRule selectedBusinessRule = ruleGetResponse.BusinessRuleSet.BusinessRulesMember[0];

                // Set the status to pending exclusion.
                selectedBusinessRule.Status = BRStatus.PendingExclusion;

                // Create the request object.
                MDSTestService.BusinessRulesUpdateRequest ruleUpdateRequest = new MDSTestService.BusinessRulesUpdateRequest();
                ruleUpdateRequest.BusinessRuleSet = new BusinessRules();
                ruleUpdateRequest.BusinessRuleSet.BusinessRulesMember = new System.Collections.ObjectModel.Collection<BusinessRule> { };
                ruleUpdateRequest.BusinessRuleSet.BusinessRulesMember.Add(selectedBusinessRule);

                // Update the business rule's status to pending exclusion.
                MDSTestService.MessageResponse ruleUpdateResponse = clientProxy.BusinessRulesUpdate(ruleUpdateRequest);

                HandleOperationErrors(ruleUpdateResponse.OperationResult);

                // Create the request object.
                MDSTestService.BusinessRulesPublishRequest rulePublishRequest = new MDSTestService.BusinessRulesPublishRequest();
                rulePublishRequest.BRPublishCriteria = new BRPublishCriteria();
                rulePublishRequest.BRPublishCriteria.EntityId = entityId;
                rulePublishRequest.BRPublishCriteria.ModelId = modelId;
                rulePublishRequest.BRPublishCriteria.MemberType = BREntityMemberType.Leaf;

                // Publish the business rule.
                MDSTestService.MessageResponse rulePublishResponse = clientProxy.BusinessRulesPublish(rulePublishRequest);

                HandleOperationErrors(rulePublishResponse.OperationResult);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: {0}", ex);
            }
        }
        // Edits the business rule and publish to enable the changes in the validation process.
        private static void EditAndPublishBR(string modelName, string entityName, string ruleName)
        {
            try
            {
                // Set Model and Entity objects.
                Identifier modelId = new Identifier { Name = modelName };
                Identifier entityId = new Identifier { Name = entityName };

                // Create the request object.
                MDSTestService.BusinessRulesGetRequest ruleGetRequest = new MDSTestService.BusinessRulesGetRequest();
                ruleGetRequest.ResultOptions = new BRResultOptions();
                ruleGetRequest.ResultOptions.BusinessRules = ResultType.Details;
                ruleGetRequest.GetCriteria = new BRGetCriteria();
                ruleGetRequest.GetCriteria.ModelId = modelId;
                ruleGetRequest.GetCriteria.EntityId = entityId;
                ruleGetRequest.GetCriteria.MemberType = BREntityMemberType.Leaf;
                ruleGetRequest.GetCriteria.BusinessRuleIds = new System.Collections.ObjectModel.Collection<Identifier> { };
                ruleGetRequest.GetCriteria.BusinessRuleIds.Add(new Identifier { Name = ruleName });

                // Get the business rules.
                MDSTestService.BusinessRulesGetResponse ruleGetResponse = clientProxy.BusinessRulesGet(ruleGetRequest);
                HandleOperationErrors(ruleGetResponse.OperationResult);

                BusinessRule selectedBusinessRule = ruleGetResponse.BusinessRuleSet.BusinessRulesMember[0];

                // Change the condition to "Code starts with Test".
                BRCondition ruleCondition = selectedBusinessRule.BRConditionTree.BRConditions[0];

                // Set the attribute name as "Code".
                BRAttributeArgument conditionPrefix = (BRAttributeArgument)ruleCondition.PrefixArgument;
                conditionPrefix.PropertyName = BRPropertyName.Anchor;
                conditionPrefix.AttributeId = new Identifier { Name = "Code" };

                // Set the condition operator.
                ruleCondition.Operator = BRItemType.StartsWith;

                // Set the postfix argument "Test".
                BRFreeformArgument conditionPostfix = (BRFreeformArgument)ruleCondition.PostfixArguments[0];

                conditionPostfix.PropertyName = BRPropertyName.Value;
                conditionPostfix.Value = "Test";

                // Create the request object.
                MDSTestService.BusinessRulesUpdateRequest ruleUpdateRequest = new MDSTestService.BusinessRulesUpdateRequest();
                ruleUpdateRequest.BusinessRuleSet = ruleGetResponse.BusinessRuleSet;

                // Update the business rule.
                MDSTestService.MessageResponse ruleUpdateResponse = clientProxy.BusinessRulesUpdate(ruleUpdateRequest);
                HandleOperationErrors(ruleUpdateResponse.OperationResult);

                // Create the request object.
                MDSTestService.BusinessRulesPublishRequest rulePublishRequest = new MDSTestService.BusinessRulesPublishRequest();
                rulePublishRequest.BRPublishCriteria = new BRPublishCriteria();
                rulePublishRequest.BRPublishCriteria.EntityId = entityId;
                rulePublishRequest.BRPublishCriteria.ModelId = modelId;
                rulePublishRequest.BRPublishCriteria.MemberType = BREntityMemberType.Leaf;

                // Publish the business rule.
                MDSTestService.MessageResponse rulePublishResponse = clientProxy.BusinessRulesPublish(rulePublishRequest);
                HandleOperationErrors(rulePublishResponse.OperationResult);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: {0}", ex);
            }
        }
示例#4
0
        // Edits the business rule and publish to enable the changes in the validation process.
        private static void EditAndPublishBR(string modelName, string entityName, string ruleName)
        {
            try
            {
                // Set Model and Entity objects.
                Identifier modelId = new Identifier {
                    Name = modelName
                };
                Identifier entityId = new Identifier {
                    Name = entityName
                };

                // Create the request object.
                MDSTestService.BusinessRulesGetRequest ruleGetRequest = new MDSTestService.BusinessRulesGetRequest();
                ruleGetRequest.ResultOptions = new BRResultOptions();
                ruleGetRequest.ResultOptions.BusinessRules = ResultType.Details;
                ruleGetRequest.GetCriteria                 = new BRGetCriteria();
                ruleGetRequest.GetCriteria.ModelId         = modelId;
                ruleGetRequest.GetCriteria.EntityId        = entityId;
                ruleGetRequest.GetCriteria.MemberType      = BREntityMemberType.Leaf;
                ruleGetRequest.GetCriteria.BusinessRuleIds = new System.Collections.ObjectModel.Collection <Identifier> {
                };
                ruleGetRequest.GetCriteria.BusinessRuleIds.Add(new Identifier {
                    Name = ruleName
                });

                // Get the business rules.
                MDSTestService.BusinessRulesGetResponse ruleGetResponse = clientProxy.BusinessRulesGet(ruleGetRequest);
                HandleOperationErrors(ruleGetResponse.OperationResult);

                BusinessRule selectedBusinessRule = ruleGetResponse.BusinessRuleSet.BusinessRulesMember[0];

                // Change the condition to "Code starts with Test".
                BRCondition ruleCondition = selectedBusinessRule.BRConditionTree.BRConditions[0];

                // Set the attribute name as "Code".
                BRAttributeArgument conditionPrefix = (BRAttributeArgument)ruleCondition.PrefixArgument;
                conditionPrefix.PropertyName = BRPropertyName.Anchor;
                conditionPrefix.AttributeId  = new Identifier {
                    Name = "Code"
                };

                // Set the condition operator.
                ruleCondition.Operator = BRItemType.StartsWith;

                // Set the postfix argument "Test".
                BRFreeformArgument conditionPostfix = (BRFreeformArgument)ruleCondition.PostfixArguments[0];

                conditionPostfix.PropertyName = BRPropertyName.Value;
                conditionPostfix.Value        = "Test";

                // Create the request object.
                MDSTestService.BusinessRulesUpdateRequest ruleUpdateRequest = new MDSTestService.BusinessRulesUpdateRequest();
                ruleUpdateRequest.BusinessRuleSet = ruleGetResponse.BusinessRuleSet;

                // Update the business rule.
                MDSTestService.MessageResponse ruleUpdateResponse = clientProxy.BusinessRulesUpdate(ruleUpdateRequest);
                HandleOperationErrors(ruleUpdateResponse.OperationResult);

                // Create the request object.
                MDSTestService.BusinessRulesPublishRequest rulePublishRequest = new MDSTestService.BusinessRulesPublishRequest();
                rulePublishRequest.BRPublishCriteria            = new BRPublishCriteria();
                rulePublishRequest.BRPublishCriteria.EntityId   = entityId;
                rulePublishRequest.BRPublishCriteria.ModelId    = modelId;
                rulePublishRequest.BRPublishCriteria.MemberType = BREntityMemberType.Leaf;

                // Publish the business rule.
                MDSTestService.MessageResponse rulePublishResponse = clientProxy.BusinessRulesPublish(rulePublishRequest);
                HandleOperationErrors(rulePublishResponse.OperationResult);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: {0}", ex);
            }
        }