Exemple #1
0
        private OPAWrapperLib configure()
        {
            log($"configuring the {_rulebaseName} rulebase");
            string      xmlContent = File.ReadAllText(Path.Combine(_versionPath, _rulebaseXml.Root.Attribute("configFile").Value)).Replace("$(WorkingFolder)", _versionPath);
            XmlDocument config     = new XmlDocument();

            config.LoadXml(xmlContent);
            var wrapper = new OPAWrapperLib(config);

            wrapper.XslFile = Path.Combine(_versionPath, _rulebaseXml.Root.Attribute("xslFile").Value);
            wrapper.SetLoggingLevel(LoggingType.Error);
            wrapper.EnableTiming = false;
            wrapper.Log2Console  = false;
            if (!Directory.Exists(Path.Combine(AppContext.BaseDirectory, "XDS")))
            {
                Directory.CreateDirectory(Path.Combine(AppContext.BaseDirectory, "XDS"));
            }
            if (!Directory.Exists(Path.Combine(AppContext.BaseDirectory, "XDS", _rulebaseXml.Root.Attribute("shortName").Value)))
            {
                Directory.CreateDirectory(Path.Combine(AppContext.BaseDirectory, "XDS", _rulebaseXml.Root.Attribute("shortName").Value));
            }
            wrapper.DumpXdsFileName = "UKPRN@global,LearnRefNumber@Learner";
            wrapper.DumpXdsPath     = Path.Combine(AppContext.BaseDirectory, "XDS", _rulebaseXml.Root.Attribute("shortName").Value);
            wrapper.AddConString("LoggingDB", _loggingCon);
            wrapper.AddConString("ILR", _intraCon);
            wrapper.NumberOfThreads = 8;

            log($"{_rulebaseName} rulebase configured");
            return(wrapper);
        }
Exemple #2
0
        /// <summary>
        /// Builds the rules engine.
        /// </summary>
        /// <param name="session">The session.</param>
        /// <param name="context">The context.</param>
        /// <returns>the OPA rule engine wrapper</returns>
        public OPAWrapperLib BuildRulesEngine(IConnectionDetail context, IRulebaseConfiguration rulebase, bool depositXDSFiles)
        {
            var opaConfiguration = Configuration.GetOPAConfigurationFor(rulebase);

            var wrapper = new OPAWrapperLib(opaConfiguration.AsDocument());

            wrapper.XslFile = Configuration.GetOPATransformationPathFor(rulebase);
            wrapper.SetLoggingLevel(LoggingType.Error);
            wrapper.EnableTiming = false;
            wrapper.Log2Console  = false;

            if (depositXDSFiles)
            {
                var dumpPath = Manager.CreateOperatingFolder("Easy OPA Rulebase Files", rulebase.ShortName, rulebase.OperatingYear.AsString()).Result;
                wrapper.DumpXdsFileName = "UKPRN@global,LearnRefNumber@Learner";
                wrapper.DumpXdsPath     = dumpPath;
            }

            wrapper.AddConString("LoggingDB", context.SQLDetail);
            wrapper.AddConString("ILR", context.SQLDetail); // ???
            wrapper.NumberOfThreads = rulebase.DegreeOfParallelism;

            return(wrapper);
        }