//Запуск нового процесса public void StartProcess(string process, //Имя процесса params Tuple <string, int>[] bounds) //Ограничения на количества процессов, которые должны быть соблюдены { while (true) { lock (_providersLock) { bool b = false; foreach (var bound in bounds) { b |= _providers.Get(bound.Item1, 0) >= bound.Item2; } if (!b) { break; } } Thread.Sleep(100); } lock (_providersLock) { if (!_providers.ContainsKey(process)) { _providers.Add(process, 1); } else { _providers[process]++; } } }
private void Open(Database db, string stSql, object type = null, object options = null, object lockEdit = null) { if (db == null || stSql.IsEmpty()) { throw new NullReferenceException("База данных и строка запроса не могут быть равными null"); } if (type == null) { Recordset = db.OpenRecordset(stSql, RecordsetTypeEnum.dbOpenDynaset); } else if (options == null) { Recordset = db.OpenRecordset(stSql, type); } else if (lockEdit == null) { Recordset = db.OpenRecordset(stSql, type, options); } else { Recordset = db.OpenRecordset(stSql, type, options, lockEdit); } for (int i = 0; i < Recordset.Fields.Count; i++) { _fields.Add(Recordset.Fields[i].Name, Recordset.Fields[i]); _fieldsNum.Add(i, Recordset.Fields[i]); } if (Recordset.RecordCount != 0) { Recordset.MoveFirst(); } _isEdit = false; _isMove = false; }
//Переводит строку со свойствами в словарь DicS public static DicS <string> ToPropertyDicS(this string str, string separator = ";") { var res = new DicS <string>(); try { if (!str.IsEmpty()) { string[] st = str.Split(new[] { separator }, StringSplitOptions.RemoveEmptyEntries); foreach (var s in st) { int p = s.IndexOf("="); //res.Add(s.Substring(0, p), s.Substring(p + 1)); string key = ""; for (int i = 0; i < p; i++) { key += s[i]; } string val = ""; for (int i = p + 1; i < s.Length; i++) { val += s[i]; } res.Add(key, val); } } } catch { } return(res); }
//Переводит строку со свойствами в словарь DicS public static DicS <string> ToPropertyDicS(this string str, string separator = ";") { var res = new DicS <string>(); try { if (!str.IsEmpty()) { string[] st = str.Split(new[] { separator }, StringSplitOptions.RemoveEmptyEntries); foreach (var s in st) { int p = s.IndexOf("=", StringComparison.Ordinal); res.Add(s.Substring(0, p), s.Substring(p + 1)); } } } catch { } return(res); }
public void Put(string field, string val, bool cut = false) { _values.Add(field, "'" + val + "'"); }