예제 #1
0
        protected override void Execute(IRuleContext context)
        {
            var customerId = (int)ReadProperty(context.Target, RuleBaseClassesRoot.CustomerIdProperty);

            switch (customerId)
            {
            case 4:
                context.AddErrorResult(RuleBaseClassesRoot.NameProperty, "customer name required");
                context.AddErrorResult(RuleBaseClassesRoot.CountryProperty, "country required");
                context.AddErrorResult(RuleBaseClassesRoot.StateProperty, "state required");
                break;

            case 5:
                context.AddWarningResult(RuleBaseClassesRoot.NameProperty, "customer name required");
                context.AddWarningResult(RuleBaseClassesRoot.CountryProperty, "country required");
                context.AddWarningResult(RuleBaseClassesRoot.StateProperty, "state required");
                break;

            case 6:
                context.AddInformationResult(RuleBaseClassesRoot.NameProperty, "customer name required");
                context.AddInformationResult(RuleBaseClassesRoot.CountryProperty, "country required");
                context.AddInformationResult(RuleBaseClassesRoot.StateProperty, "state required");
                break;
            }
        }
예제 #2
0
            protected override void Execute(IRuleContext context)
            {
                int _errors = 0;

                var target = (RoadmapGroupEdit)context.Target;

                if (string.IsNullOrEmpty(target.ReadProperty(XmlProperty)))
                {
                    return;
                }

                var xml = (string)ReadProperty(target, RoadmapGroupEdit.XmlProperty);

                Console.WriteLine($"Start time getting vehicles: {DateTime.Now.ToString("hh:mm:ss fff")}");
                var vehicles = VehiclesInfo.GetVehicles(xml); // target.Xml);  // target.ReadProperty(XmlProperty));

                Console.WriteLine($"End time getting vehicles: {DateTime.Now.ToString("hh:mm:ss fff")}");
                var components = ComponentList.GetComponents();

                Console.WriteLine($"End time getting components: {DateTime.Now.ToString("hh:mm:ss fff")}");
                var pdNumbers = new HashSet <string>(new PDComparer());

                foreach (var item in components)
                {
                    pdNumbers.Add(item.PDNumber);
                }

                Console.WriteLine($"End time setting PDNumbers: {DateTime.Now.ToString("hh:mm:ss fff")}");

                foreach (var vehicle in vehicles?.Vehicles.Vehicle)
                {
                    _errors += GetComponentErrors(vehicle.Components.Engine.EnginePD, pdNumbers);
                    _errors += GetComponentErrors(vehicle.Components.GearBoxPD, pdNumbers);
                    _errors += GetComponentErrors(vehicle.Components.AxleGearPD, pdNumbers);
                    _errors += GetComponentErrors(vehicle.Components.RetarderPD, pdNumbers);
                    _errors += GetComponentErrors(vehicle.Components.TorqueConverterPD, pdNumbers);

                    foreach (var axle in vehicle.Components.AxleWheels.Data.Axles.Axle)
                    {
                        _errors += GetComponentErrors(axle.TyrePD, pdNumbers);
                    }
                }

                Console.WriteLine($"End time for component validation: {DateTime.Now.ToString("hh:mm:ss.fff")}");

                if (_errors != 0)
                {
                    context.AddInformationResult($"Missing Components in database. Found {_errors} error{(_errors > 1 ? "s" : string.Empty)} in Xml-file." +
                                                 "\nRoadmap Group created but no Xml uploaded");
                    LoadProperty(target, XmlProperty, string.Empty);
                    LoadProperty(target, ValidationStatusValueProperty, ValidationStatus.ValidatedWithFailures);
                }
                else
                {
                    target.ValidationStatusValue = ValidationStatus.ValidatedWithSuccess;
                    context.AddInformationResult($"Components validated successfully!!");
                    context.AddSuccessResult(true);
                }
            }
예제 #3
0
    protected override void Execute(IRuleContext context)
    {
        var value = (string)context.InputPropertyValues[PrimaryProperty];

        if (string.IsNullOrWhiteSpace(value))
        {
            context.AddInformationResult("Name is required");
        }
    }
예제 #4
0
        protected override async Task ExecuteAsync(IRuleContext context)
        {
            var result = await MyExpensiveCommand.DoCommandAsync();

            if (result == null)
            {
                context.AddErrorResult("Command failed to run");
            }
            else if (result.Result)
            {
                context.AddInformationResult(result.ResultText);
            }
            else
            {
                context.AddErrorResult(result.ResultText);
            }
            context.Complete();
        }
예제 #5
0
        protected override async Task ExecuteAsync(IRuleContext context)
        {
            await Task.Delay(3000);

            string val = (string)context.InputPropertyValues[PrimaryProperty];

            if (val == "Error")
            {
                context.AddErrorResult("Invalid data!");
            }
            else if (val == "Warning")
            {
                context.AddWarningResult("This might not be a great idea!");
            }
            else if (val == "Information")
            {
                context.AddInformationResult("Just an FYI!");
            }
        }
예제 #6
0
        protected override async Task ExecuteAsync(IRuleContext context)
        {
            var portal = context.ApplicationContext.GetRequiredService <IDataPortal <MyExpensiveCommand> >();
            var cmd    = portal.Create();
            var result = await portal.ExecuteAsync(cmd);

            if (result == null)
            {
                context.AddErrorResult("Command failed to run");
            }
            else if (result.Result)
            {
                context.AddInformationResult(result.ResultText);
            }
            else
            {
                context.AddErrorResult(result.ResultText);
            }
        }
예제 #7
0
 protected override void Execute(IRuleContext context)
 {
     context.AddInformationResult(Text);
 }