public override void RunCommand() { if (!LicenseTool.FeatureAllowedMsg(JobsFeature.Test)) { Logging.Error("Proffesional edition required"); return; } if (m_jobname.ToLower().EndsWith(".djb")) { m_jobname = m_jobname.Substring(0, m_jobname.Length - 4); } Job job = Job.LoadFromFile(Path.Combine(Core.JobsDirectory, m_jobname + ".djb")); Logging.Info("Running job: " + job.ToString()); if (!String.IsNullOrEmpty(Filtercommands)) { var job2 = new Job(); var ids = new HashSetEx <string>(Filtercommands.Split('|')); foreach (var cmd in job.Root.Commands) { if (ids.Contains(cmd.GroupId)) { job2.AddCommand(cmd.Clone(false)); } } job2 = job; } job.Run(ExtParams); Logging.Info("Job finished"); }
public void FillColumns(ColumnDisplay disp, string[] filterColumns, bool exactMatch) { m_disp = disp; m_initColumns = filterColumns; m_exactMatch = exactMatch; var set = new HashSetEx <string>(); if (filterColumns != null) { set.AddRange(filterColumns); } foreach (var col in disp) { var cs = (IColumnStructure)col.ValueTag; if (cs == null) { continue; } if (cs.DataType is DbTypeXml || cs.DataType is DbTypeBlob) { continue; } string colname = col.ValueRef.ToString(); checkedListBox1.Items.Add(colname, set.Contains(colname)); } chbExactMatch.Checked = exactMatch; }
public IEnumerable <string> GetFiles() { var files = new HashSetEx <string>(); string libdir = GetLibDirectory(); if (Directory.Exists(libdir)) { foreach (string fn in Directory.GetFiles(libdir, "*" + FileExtension)) { string ofn = Path.Combine(GetDirectory(), Path.GetFileName(fn)); if (File.Exists(ofn)) { files.Add(IOTool.NormalizePath(ofn)); yield return(ofn); } else { yield return(fn); } } } foreach (string fn in Directory.GetFiles(GetDirectory(), "*" + FileExtension)) { if (files.Contains(IOTool.NormalizePath(fn))) { continue; } yield return(fn); } }
//public override bool AllowDragDrop(ITreeNode draggingNode) //{ // //if (!RealNode.TreeBehaviour.AllowDragDrop) return false; // if (draggingNode is IDatabaseTreeNode) return true; // return false; //} protected override void DoGetChildren() { List <ITreeNode> res = new List <ITreeNode>(); var dbs = new HashSetEx <string>(); foreach (string name in m_conn.Databases) { res.Add(new Database_SourceTreeNode(m_conn.GetDatabase(name), this, name, true)); if (name == null) { continue; } dbs.Add(name.ToLower()); } string dbsdir = Parent.GetPrivateSubFolder("databases"); if (Directory.Exists(dbsdir)) { foreach (string subdir in Directory.GetDirectories(dbsdir)) { string dbname = System.IO.Path.GetFileName(subdir); if (dbs.Contains(dbname.ToLower())) { continue; } var db = new PhantomDatabaseSource(m_conn, subdir); res.Add(new Database_SourceTreeNode(db, this, dbname, true)); } } res.SortByKey(n => n.Title); m_children = res.ToArray(); }
public static bool EqualsDictionary <Key, Value>(this IDictionary <Key, Value> a, IDictionary <Key, Value> b, IList <Key> ignoreKeys) { var allkeys = new HashSetEx <Key>(a.Keys); allkeys.AddRange(b.Keys); foreach (Key key in allkeys) { if (ignoreKeys.Contains(key)) { continue; } if (!a.ContainsKey(key)) { return(false); } if (!b.ContainsKey(key)) { return(false); } if (!a[key].Equals(b[key])) { return(false); } } return(true); }
protected virtual HashSetEx <string> LoadPossibleKeywords() { var res = new HashSetEx <string>(); res.AddRange(from k in CoreRes.keywords.Split('\n') where k != "" select k.ToUpper().Trim()); return(res); }
private static void _AddFile(string path, HashSetEx <string> deleted, string indexFile) { var files = new HashSetEx <string>(IOTool.LoadLines(indexFile)); files.Add(path); IOTool.SaveLines(indexFile, files); deleted.Add(path.ToLower()); }
public TokenizerBase(TextReader reader, IStringSliceProvider sliceProvider) { m_reader = reader; Current = TokenType.None; SliceProvider = sliceProvider; m_currentChar = m_reader.Read(); m_position++; m_nextChar = m_reader.Read(); m_position++; m_symbols = GetSymbols(); }
public static void SaveLines(string path, HashSetEx <string> lines) { using (var sw = new StreamWriter(path)) { foreach (string line in lines) { sw.WriteLine(line); } } }
protected virtual HashSetEx <string> LoadNoContextReservedWords() { var res = new HashSetEx <string>(); res.Add("SELECT"); res.Add("CREATE"); res.Add("UPDATE"); res.Add("DELETE"); res.Add("DROP"); res.Add("ALTER"); res.Add("TABLE"); res.Add("VIEW"); res.Add("FROM"); res.Add("WHERE"); res.Add("GROUP"); res.Add("ORDER"); res.Add("BY"); res.Add("ASC"); res.Add("DESC"); res.Add("HAVING"); res.Add("INTO"); res.Add("ASC"); res.Add("LEFT"); res.Add("RIGHT"); res.Add("INNER"); res.Add("OUTER"); res.Add("CROSS"); res.Add("NATURAL"); res.Add("JOIN"); res.Add("ON"); res.Add("DISTINCT"); res.Add("ALL"); res.Add("ANY"); return(res); }
public static string[] Difference(IEnumerable <string> a, IEnumerable <string> b) { var sb = new HashSetEx <string>(b); var res = new List <string>(); foreach (string s in a) { if (!sb.Contains(s)) { res.Add(s); } } return(res.ToArray()); }
private void SetChecked(string[] cols) { if (cols == null) { return; } var set = new HashSetEx <string>(cols); for (int i = 0; i < checkedListBox1.Items.Count; i++) { checkedListBox1.SetItemChecked(i, set.Contains(checkedListBox1.Items[i].ToString())); } OnSettingsChanged(); }
public static bool AllowLoadPlugin(string name) { if (m_pluginFilter.StartsWith("#")) { return(true); } if (m_pluginFilter.IsEmpty()) { return(true); } if (m_pluginFilterSet == null) { m_pluginFilterSet = new HashSetEx <string>(m_pluginFilter.ToLower().Split(';')); } return(m_pluginFilterSet.Contains(name.ToLower())); }
public static void DeleteRowsWithSelectedCells(this DataGridView grid) { var rows = new HashSetEx <int>(); foreach (DataGridViewCell cell in grid.SelectedCells) { rows.Add(cell.RowIndex); } var irows = new List <int>(rows); irows.Sort(); irows.Reverse(); foreach (int rowindex in irows) { grid.Rows.RemoveAt(rowindex); } }
private static void _Initialize(string indexFile, HashSetEx <string> files) { foreach (string line in IOTool.LoadLines(indexFile)) { try { if (File.Exists(line)) { File.Delete(line); } if (Directory.Exists(line)) { Directory.Delete(line, true); } } catch { files.Add(line.ToLower()); } } IOTool.SaveLines(indexFile, files); }
internal static bool _FeatureAllowed(string features, HashSetEx <string> testedFeatures) { if (testedFeatures.Contains("all")) { return(true); } if (String.IsNullOrEmpty(features)) { return(true); } foreach (string item in features.Split('|')) { if (testedFeatures.Contains(item)) { return(true); } var ifeat = GetFeature(item); if (ifeat != null && ifeat.AllwaysAllowed) { return(true); } } return(false); }
private void InitOperatorTable() { m_operatorTable = GetOperatorTable(); for (int i = 1; i < m_operatorTable.Length; i++) { m_operatorTable[i - 1].HigherPriority = m_operatorTable[i]; } HashSetEx <string> ops = new HashSetEx <string>(); foreach (var g in m_operatorTable) { foreach (var op in g.EnumOperators()) { if (op.IsSymbol) { foreach (var sym in op.Tokens) { ops.Add(sym); } } } } m_tokenizer.SetMultiSymbolOperators(ops); }
/// <summary> /// adds primary key information to query definition, or marks columns as read only, of no PK is available /// </summary> /// <param name="handler">used for obtain table structures with PKs</param> public void CompleteUpdatingInfo(IDmlfHandler handler) { var pks = new Dictionary <DmlfSource, IPrimaryKey>(); var required_pks = new Dictionary <DmlfSource, IPrimaryKey>(); // list of columns var usedcols = new HashSetEx <DmlfColumnRef>(); foreach (var col in Columns) { var di = col.DisplayInfo; if (di == null) { continue; } var tbl = col.Source; if (tbl == null) { tbl = handler.BaseTable; } if (tbl == null) { continue; } var cr = col.Expr as DmlfColumnRefExpression; if (cr == null) { di.IsReadOnly = true; continue; } if (!pks.ContainsKey(tbl)) { pks[tbl] = null; if (handler != null) { var ts = handler.GetStructure(tbl.TableOrView); if (ts != null) { pks[tbl] = ts.FindConstraint <IPrimaryKey>(); } } } var pk = pks[tbl]; if (pk == null) { // no primary key, is readonly di.IsReadOnly = true; continue; } var pkcols = new List <string>(pk.Columns.GetNames()); if (pkcols.Contains(cr.Column.ColumnName)) { di.IsPrimaryKey = true; } usedcols.Add(new DmlfColumnRef { Source = tbl, ColumnName = cr.Column.ColumnName }); if (di.Style == ColumnDisplayInfo.UsageStyle.Value) { required_pks[tbl] = pk; } if (di.Style == ColumnDisplayInfo.UsageStyle.Lookup) { di.IsReadOnly = true; } } // add missing primary key columns as hidden columns foreach (var pkt in required_pks) { foreach (string col in pkt.Value.Columns.GetNames()) { var key = new DmlfColumnRef { Source = pkt.Key, ColumnName = col }; if (usedcols.Contains(key)) { continue; } usedcols.Add(key); var nc = new DmlfResultField { DisplayInfo = new ColumnDisplayInfo { IsPrimaryKey = true, Style = ColumnDisplayInfo.UsageStyle.Hidden, }, Expr = new DmlfColumnRefExpression { Column = new DmlfColumnRef { Source = pkt.Key, ColumnName = col, } } }; Columns.Add(nc); } } }
public void SetSqlReservedWords(IEnumerable <string> words) { m_reservedWords = new HashSetEx <string>(words); }