コード例 #1
0
        private static void RunFromRuleSet()
        {
            // get list of lofic files
            var list = new[] { "CarsDiscountFlow.xml", "YearDiscount.xml" };

            // create a set of file
            var ruleFiles = list.Select(x => new RuleSetFactory.RuleFile(x, null, File.ReadAllBytes(x)));

            var rs     = RuleSetFactory.FromRuleFiles(ruleFiles);
            var engine = RuntimeEngine.FromRuleSet(rs, "CarsDiscountFlow.xml");

            var result = engine.Run(ConnectionString);
            var cars   = result.Context.VariableContainer["cars"] as IEnumerable;

            foreach (IDictionary <string, object> car in cars)
            {
                Console.WriteLine("{0} {1} {2} Discount: {3}", car["Made"], car["Model"], car["Year"], car["Discount"]);
            }
        }
コード例 #2
0
        /// Initializing the Workflow engine
        public static void Initialize()
        {
            if (_engine != null)
            {
                return;
            }

            // loading the models/ruleset
            var rs = ModelLoaderUtility.LoadRuleSet();

            // create a workflow engine
            _engine = RuntimeEngine.FromRuleSet(rs, FlowAddress);
            var config = new LongRunningProcessConfig(ConfigurationManager.ConnectionStrings["ProcessStateStore"].ConnectionString)
            {
                TimeoutNodeExpiredCallback = timeout_node_expired,
                TimeoutCheckCycle          = TimeSpan.FromMinutes(1)
            };

            _engine.Workflow.EnableLongRunningProcess(config);

            FillTypeIdRegistry();
        }