Beispiel #1
0
        private void Submit(object obj)
        {
            try
            {
                //var ruleApp = new FileSystemRuleApplicationReference(Properties.Settings.Default.RuleappFilePath);
                RuleApplicationDef ruleApp = RuleApplicationService.RuleApplicationDef;
                //using (var session = new RuleSession(ruleApp))
                //{
                var entityName  = string.Empty;
                var rulesetName = string.Empty;

                if (SelectionManager.SelectedItem as RuleSetDef != null)
                {
                    RuleSetDef rulesetDef = (RuleSetDef)SelectionManager.SelectedItem;
                    //System.Windows.Forms.MessageBox.Show(rulesetDef.Name);

                    //var rootEntity = session.CreateEntity(rulesetDef.ThisEntity.Name);
                    string executionFlow = RuleEngineUtil.GetRuleExecutionFlowXml(rulesetDef);

                    XmlDocument xmlExecutionFlow = new XmlDocument();
                    xmlExecutionFlow.LoadXml(executionFlow);

                    StringWriter sw = new StringWriter();
                    XmlToJson(xmlExecutionFlow, sw);

                    string curDir = System.IO.Path.GetDirectoryName(RuleApplicationService.EditorAssembly.Location);
                    //File.WriteAllText(curDir + @"\FlowVisualizer_files\ruleapp_data.js", "var ruleapp_data = " + sw.ToString());

                    //byte[] bytes = ReadBytesFromStream(InRule.Authoring.Extensions.RuleAppFlowVisualizer.Properties.Resources.FlowVisualizer1);
                    //string s = GetResourceStream("FlowVisualizer1.htm");
                    //string s = Encoding.UTF8.GetString(bytes, 0, bytes.Length);
                    //Uri uri = new Uri(@"pack://*****:*****@"C:\Temp\InRuleRuleAppFlowVisualizer.htm"));
                    userControl2.webReport.Loaded += delegate
                    {
                        //userControl2.webReport.NavigateToStream(source);
                        userControl2.webReport.NavigateToString(s);
                    };

                    userControl2.SelectionChanged += delegate
                    {
                        //userControl2.webReport.NavigateToStream(source);
                        RuleSetDef selectedRuleset = null;
                        EntityDef  entity          = null;
                        if (userControl2.SelectedRuleset.Contains("_ForEach_"))
                        {
                            entity          = ruleApp.Entities[userControl2.SelectedRuleset.Substring(userControl2.SelectedRuleset.IndexOf("_ForEach_") + 9)];
                            selectedRuleset = entity.GetRuleSet(userControl2.SelectedRuleset.Substring(0, userControl2.SelectedRuleset.IndexOf("_ForEach_")));
                        }
                        else
                        {
                            entity          = rulesetDef.ThisEntity;
                            selectedRuleset = entity.GetRuleSet(userControl2.SelectedRuleset);
                            //System.Windows.Forms.MessageBox.Show(userControl2.SelectedRuleset);
                        }

                        if (selectedRuleset != null)
                        {
                            SelectionManager.SelectedItem = selectedRuleset;
                        }
                    };

                    //userControl2.webReport.Document.
                    //userControl2.webReport.NavigateToString(s);
                    //userControl2.webReport.Navigate(new Uri(@".\FlowVisualizer.htm"));

                    userControl2.Title = "Rule Execution Flow: " + rulesetDef.Name;
                    //SelectionManager.SelectedItem = ruleApp.GetRuleSet("GetFinalQuote");

                    userControl2.Show();

                    //var window = WindowFactory.CreateWindow("Execution Flow", userControl2, true);
                    //window.Show();



                    //mshtml.HTMLDocument doc;
                    //doc = (mshtml.HTMLDocument)userControl2.webReport.Document;

                    //mshtml.HTMLDocumentEvents2_Event iEvent;
                }
                else
                {
                    System.Windows.Forms.MessageBox.Show("You must select a ruleset for this report!");
                }
                //}
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
            }
        }
Beispiel #2
0
 public ScriptingHelper(UserControl2 w)
 {
     this.mExternalWPF = w;
 }