Esempio n. 1
0
        public static void add(bool enabled, string type, string expression)
        {
            DBExpression r1 = new DBExpression();

            r1.Enabled    = enabled;
            r1.Expression = expression;
            r1.Type       = type;
            r1.Commit();
        }
Esempio n. 2
0
        public static void Exchange(int i, int x)
        {
            DBExpression db1 = Get(i);
            DBExpression db2 = Get(x);

            if (db1 == null || db2 == null)
            {
                return;
            }
            DBExpression tdb = new DBExpression();

            tdb.Enabled    = db1.Enabled;
            tdb.Type       = db1.Type;
            tdb.Expression = db1.Expression;
            db1.Enabled    = db2.Enabled;
            db1.Type       = db2.Type;
            db1.Expression = db2.Expression;
            db1.Commit();
            db2.Enabled    = tdb.Enabled;
            db2.Type       = tdb.Type;
            db2.Expression = tdb.Expression;
            db2.Commit();
        }
Esempio n. 3
0
 public static void Exchange(int i, int x)
 {
     DBExpression db1 = Get(i);
       DBExpression db2 = Get(x);
       if (db1 == null || db2 == null) return;
       DBExpression tdb = new DBExpression();
       tdb.Enabled = db1.Enabled;
       tdb.Type = db1.Type;
       tdb.Expression = db1.Expression;
       db1.Enabled = db2.Enabled;
       db1.Type = db2.Type;
       db1.Expression = db2.Expression;
       db1.Commit();
       db2.Enabled = tdb.Enabled;
       db2.Type = tdb.Type;
       db2.Expression = tdb.Expression;
       db2.Commit();
 }
Esempio n. 4
0
 public static void add(bool enabled, string type, string expression)
 {
     DBExpression r1 = new DBExpression();
       r1.Enabled = enabled;
       r1.Expression = expression;
       r1.Type = type;
       r1.Commit();
 }
Esempio n. 5
0
        private void SaveAllExpressions()
        {
            if (dgvExpressions.RowCount == 0)
            return;

              // need to save back all the rows
              DBExpression.ClearAll();

              foreach (DataGridViewRow row in dgvExpressions.Rows)
              {
            if (row.Index != dgvExpressions.NewRowIndex)
            {
              DBExpression expression = new DBExpression();
              foreach (DataGridViewCell cell in row.Cells)
              {
            if (cell.Value == null)
              return;
            if (cell.OwningColumn.Name == "enabled") { expression.Enabled = (bool)cell.Value; }
            if (cell.OwningColumn.Name == "type") { expression.Type = (string)cell.Value; }
            if (cell.OwningColumn.Name == "expression") { expression.Expression = (string)cell.Value; }
              }
              expression.Commit();
            }
              }
              FilenameParser.reLoadExpressions();
        }
Esempio n. 6
0
        private void linkImpParsingExpressions_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            OpenFileDialog fd = new OpenFileDialog();
              fd.Filter = "Exported Parsing Expressions (*.expr)|*.expr";
              if (fd.ShowDialog() == DialogResult.OK && System.IO.File.Exists(fd.FileName))
              {
            StreamReader r = new StreamReader(fd.FileName);
            DBExpression expr;

            //Dialog box to make sure they want to clear out current expressions to import new ones.
            DialogResult result = MessageBox.Show("Press Yes to delete all current parsing expressions," + Environment.NewLine +
                "and replace them with the imported file." + Environment.NewLine + Environment.NewLine +
                "Press No to append the import parsing expressions." + Environment.NewLine + Environment.NewLine +
                "Press cancel to Quit", "Import Expressions", MessageBoxButtons.YesNoCancel);
            switch (result)
            {
              case DialogResult.No:
            break;
              case DialogResult.Yes:
            dgvExpressions.Rows.Clear();
            DBExpression.ClearAll();
            logger.Info("Expressions cleared");
            break;
              case DialogResult.Cancel:
            return;
            }

            string line = string.Empty;
            string[] parts;

            // now set watched for all in file
            while ((line = r.ReadLine()) != null)
            {
              char[] c = { ';' };
              parts = line.Split(c, 3);
              if (parts.Length != 3) continue;
              expr = new DBExpression();
              try
              {
            if (Convert.ToInt32(parts[0]) == 0 || Convert.ToInt32(parts[0]) == 1) expr.Enabled = Convert.ToBoolean(parts[0].Equals("1"));
            if (parts[1] == DBExpression.cType_Regexp || parts[1] == DBExpression.cType_Simple) expr.Type = parts[1];
            expr.Expression = parts[2];
              }
              catch (Exception ex)
              {
            logger.ErrorException("error in importing : ", ex);
            r.Close();
            LoadExpressions();
            return;
              }
              expr.Commit();
            }
            r.Close();
            logger.Info("Parsing Expressions succesfully imported!");
            LoadExpressions();
              }
        }