protected void Page_Load(object sender, EventArgs e) { string id; // Create a new ARulesXL engine arxl = new ARulesXL(); // Get a unique session id for us id = "arulesxl_" + Session.SessionID; log("ARulesXL SessionID = " + Session.SessionID + " "); // Log a bunch of details about our state and configuration if (Session.IsNewSession) { log(" NewSession"); } log("Postback = " + IsPostBack.ToString()); // IsPostBack is set when the user submits the form // So this is the second time through Page_Load // and we run the query if (IsPostBack) { // Run the ruleset log("PostBack"); AnswerLabel.Visible = true; AnswerText.Visible = true; runRuleset(id, Session.IsNewSession); } // This is the first time through Page_Load // Set default values for some of the controls else { RulesetFilename.Text = "advice.axl"; Ruleset.Text = "ShaftRules"; Query.Text = "FIND .advice"; AnswerLabel.Visible = false; AnswerText.Visible = false; } }
private void GoButton_Click(object sender, EventArgs e) { string path; string ans; // Determine where we are path = Application.StartupPath + "\\"; try { // Get an ARulesXL engine ARulesXL arxl = new ARulesXL(); // Load the ARulesXL engine and ruleset file arxl.OpenRules(path + "advice.axl", path); // Load the user inputs, first clear the .in vector, then load it up arxl.ClearVector("ShaftRules", ".in"); arxl.AddToVector("ShaftRules", ".in", "Favor", Favor.SelectedItem.ToString()); arxl.AddToVector("ShaftRules", ".in", "Swing Speed", SwingSpeed.Text); arxl.AddToVector("ShaftRules", ".in", "Club Type", ClubType.SelectedItem.ToString()); arxl.AddToVector("ShaftRules", ".in", "Ball Flight", BallFlight.SelectedItem.ToString()); // Query the rule set ans = arxl.QueryRules("ShaftRules", "FIND .advice"); // Display the answer Advice.Text = ans; arxl.CloseRules(); } catch (Exception ex) { MessageBox.Show(ex.Message, "ERROR"); } }