public void ExportRule(Rule rule, Stream outputStream)
 {
     using (var writer = new StreamWriter(outputStream))
     {
         new IniParser.StreamIniDataParser().WriteData(writer, ConvertRuleToIniData(rule));
         writer.Flush();
     }
 }
 public void ExportRule(Rule rule, Stream outputStream)
 {
     using (var writer = new StreamWriter(outputStream))
     {
         rule.Dump("rule", writer);
         writer.Flush();
     }            
 }
 public void ExportRule(Rule rule, Stream outputStream)
 {
     string output = JsonConvert.SerializeObject(rule);
     using (var writer = new StreamWriter(outputStream))
     {
         writer.Write(output);
         writer.Flush();
     }
 }
 private string GetRuleAsString(Rule rule)
 {
     return
         string.Format(
             "Name: {1}{0}Content:{0}-----------------{0}{2}{0}-----------------{0}Language: {3}{0}Schedule: {4}{0}Action: {5}{0}Action value: {0}-----------------{0}{6}{0}-----------------",
             Environment.NewLine,
             rule.Name, rule.Content, rule.RuleLanguage, rule.Schedule.ToString("dd/MM/yyyy hh:mm"), rule.Action,
             rule.ActionValue);
 }
 public void SetRule(Entities.Rule rule)
 {
     tbName.Text        = rule.Name;
     tbRule.Text        = rule.Content;
     comboLanguage.Text = rule.RuleLanguage.Humanize();
     dateSchedule.Value = rule.Schedule;
     comboActions.Text  = rule.Action.Humanize();
     tbActionValue.Text = rule.ActionValue;
 }
        public void ExportRule(Rule rule, Stream outputStream)
        {
            Document doc = new Document();
            var writer = PdfWriter.GetInstance(doc, outputStream);

            doc.Open();            
            doc.Add(Paragraph.GetInstance(GetRuleAsString(rule)));

            doc.Close();
        }
        public void SaveRule(Rule rule)
        {
            using (var connection = new SqlConnection(ConnectionString))
            {
                connection.Open();

                connection.Insert(rule);

                connection.Close();
            }
        }
        private void ShowRuleDialog(Entities.Rule rule = null)
        {
            CreateRule ruleDialog = new CreateRule();

            if (rule != null)
            {
                ruleDialog.SetRule(rule);
            }

            ruleDialog.ShowDialog();

            RefreshRuleList();
        }
        public void ExportRule(Rule rule, ExportTargets target)
        {
            var dialog = new SaveFileDialog();

            if (dialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            using (var stream = new FileStream(dialog.FileName, FileMode.Create, FileAccess.ReadWrite))
            {
                Globals.Exporters.First(e => e.Target == target).ExportRule(rule, stream);
            }
        }
Ejemplo n.º 10
0
        private IniData ConvertRuleToIniData(Rule rule)
        {
            var data = new IniData();

            data.Sections = new SectionDataCollection();
            data.Sections.AddSection("rule");
            var section = data.Sections["rule"];
            section.AddKey("name", rule.Name);
            section.AddKey("content", rule.Content);
            section.AddKey("language", rule.RuleLanguage.ToString());
            section.AddKey("schedule", rule.Schedule.ToString("dd/MM/yyyy hh:mm"));
            section.AddKey("action", rule.Action.ToString());
            section.AddKey("action-value", rule.ActionValue);

            return data;
        }
        public void ExportRule(Rule rule, Stream outputStream)
        {
            Ensure.That(rule, "rule").IsNotNull();

            var package = new ExcelPackage(outputStream);
            var worksheet = package.Workbook.Worksheets.Add("Rules");
            worksheet.Cells["B1"].Value = "Name";
            worksheet.Cells["C1"].Value = "Content";
            worksheet.Cells["D1"].Value = "Language";
            worksheet.Cells["E1"].Value = "Schedule";
            worksheet.Cells["F1"].Value = "Action";
            worksheet.Cells["G1"].Value = "Action Value";
            worksheet.Cells["B1:G1"].Style.Font.Bold = true;

            worksheet.Cells["B2"].Value = rule.Name;
            worksheet.Cells["C2"].Value = rule.Content;
            worksheet.Cells["D2"].Value = rule.RuleLanguage.ToString();
            worksheet.Cells["E2"].Value = rule.Schedule.ToString("dd/MM/yyyy hh:mm");
            worksheet.Cells["F2"].Value = rule.Action.ToString();
            worksheet.Cells["G2"].Value = rule.ActionValue;

            package.Save();            
        }
 public void SaveRule(Rule rule)
 {
     _rules.Add(rule);
 }
Ejemplo n.º 13
0
 public void RunRuleAction(Rule rule)
 {
     Globals.Actions.First(action => action.Action == rule.Action).ExecuteAction(rule.ActionValue);
 }
Ejemplo n.º 14
0
 public bool RunRule(Rule rule)
 {
     return Globals.RuleRunners.First(
         runner =>
             runner.RuleLanguage == rule.RuleLanguage).RunRule(rule.Content);
 }