private static List <ServiceRelationships> QueryToServiceRelationships(List <dynamic> In)
        {
            var Out = new List <ServiceRelationships>();

            foreach (var Releation in In)
            {
                try
                {
                    Out.Add(new ServiceRelationships()
                    {
                        Name           = Utility.ToString(Releation.NAME),
                        ApplicableRule = SimpleRuleParser.GetRule(Utility.ToString(Releation.APPLICABLE_RULE)),
                        Services       = AllowedServicesToList(Releation.ALLOWED_SERVICES),
                        Minimum        = Utility.ToString(Releation.MIN_QUANTITY),
                        Maximum        = Utility.ToString(Releation.MAX_QUANTITY),
                        ReverseName    = new ReverseNameDescription(Utility.ToString(Releation.REVERSE_NAME)),
                        FilterRule     = Utility.ToString(Releation.FILTER_RULE)
                    });
                }
                catch (Exception e)
                {
                    // throw new ApplicationException();
                }
            }
            return(Out);
        }
示例#2
0
        public static Dictionary <string, AttributeDefinition> Get(long id, DateTime effectiveDate)
        {
            var definitions = new Dictionary <string, AttributeDefinition>();

            using (var connection = new OracleConnection(FscApplication.Current.Settings.FscConnectionString))
            {
                connection.Open();

                var attributes = connection.Query(
                    "select sa.* " +
                    "   from service_attributes sa " +
                    "      inner join service_configuration sc on sa.service_id = sc.service_id and sa.version = sc.version" +
                    "   where sc.service_id = :id and (sc.from_eff_date <= :effectiveDate and (sc.to_eff_date is null or sc.to_eff_date > :effectiveDate)) " +
                    "union " +
                    "select sa.* " +
                    "   from service_attributes sa " +
                    "      inner join service_inheritance si on sa.service_id = si.inherited_service_id" +
                    "      inner join service_configuration sc on sc.service_id = si.inherited_service_id and sa.version = sc.version" +
                    "   where si.service_id = :id and (sc.from_eff_date <= :effectiveDate and (sc.to_eff_date is null or sc.to_eff_date > :effectiveDate)) ", new { id, effectiveDate });

                foreach (var attribute in attributes)
                {
                    try
                    {
                        definitions.Add(attribute.NAME, new AttributeDefinition()
                        {
                            Key                 = Utility.ToString(attribute.NAME),
                            Name                = Utility.ToString(attribute.NAME),
                            HelpText            = Utility.ToString(attribute.HELP_TEXT),
                            ApplicableRule      = SimpleRuleParser.GetRule(Utility.ToString(attribute.IS_APPLICABLE)) ?? new SimpleConstantRule(true),
                            RequiredRule        = SimpleRuleParser.GetRule(Utility.ToString(attribute.IS_REQUIRED)) ?? new SimpleConstantRule(false),
                            Type                = new AttributeType(Utility.ToString(attribute.ATTRIBUTE_TYPE)),
                            RequiredElements    = new List <string>(Parser.Split(Utility.ToString(attribute.REQUIRED_ELEMENTS), ',')),
                            DefaultValue        = Utility.ToString(attribute.DEFAULT_VALUE),
                            Sequence            = Utility.ToInt(attribute.SEQUENCE),
                            Label               = Utility.ToString(attribute.LABEL),
                            MaxRepeats          = Utility.ToInt(attribute.MAX_REPEATS),
                            ReadOnlyRule        = SimpleRuleParser.GetRule(Utility.ToString(attribute.READ_ONLY_RULE)),
                            HiddenRule          = SimpleRuleParser.GetRule(Utility.ToChar(attribute.HIDDEN) == 'Y' ? "true" : "false"),
                            ComplexType         = Utility.ToInt(attribute.REFERENCE_TYPE_ID),
                            Mask                = Utility.ToString(attribute.MASK),
                            DataConstraint      = DataConstraintParser.GetConstraint(Utility.ToString(attribute.DATA_CONSTRAINT)),
                            RequiresRefresh     = !("N".Equals(Utility.ToString(attribute.REQUIRES_REFRESH), StringComparison.CurrentCultureIgnoreCase)),
                            TechRole            = Utility.ToString(attribute.TECH_ROLE),
                            ApplicableForChange = ("Y".Equals(Utility.ToString(attribute.APPLICABLE_FOR_CHANGE), StringComparison.CurrentCultureIgnoreCase)),
                            AffectsChildren     = ("Y".Equals(Utility.ToString(attribute.AFFECTS_CHILDREN), StringComparison.CurrentCultureIgnoreCase)),
                            AffectsRelation     = ("Y".Equals(Utility.ToString(attribute.AFFECTS_RELATION), StringComparison.CurrentCultureIgnoreCase)),
                            DesignImpact        = SimpleRuleParser.GetRule(Utility.ToString(attribute.DESIGN_IMPACT)),
                            ProvisioningImpact  = SimpleRuleParser.GetRule(Utility.ToString(attribute.PROVISIONING_IMPACT))
                        });
                    }
                    catch (Exception e)
                    {
                        throw new ApplicationException($"Error loading attribute {attribute.NAME} for service {id}: {e.Message}", e);
                    }
                }
            }

            return(definitions);
        }
示例#3
0
        public IRule TryParse(string ruleText, IParser parser)
        {
            if (ruleText.StartsWith("if"))
            {
                var parameters = Parser.GetParameters(ruleText);
                if (parameters.Length != 3)
                {
                    throw new ApplicationException("GetConditionalRule expects 3 parameters.");
                }

                SimpleRule cond             = SimpleRuleParser.GetRule(parameters[1]);
                OffnetServiceMappingRule sr = (OffnetServiceMappingRule)parser.ParseLine(parameters[2]);
                return(new OffnetConditionalServiceRule(parameters[0].Trim(), cond, sr));
            }

            return(null);
        }