public DBTable(string[][] @base, int increment, string name, VS source) { Name = name; cols.Clear(); rows.Clear(); src = source; if (increment < 1) { throw new VDataBaseException("Значение инкремента неверно. Ошибка парсинга", "vdbobjs", 0x2); } if (@base.Length < 1 || @base[0].Length < 2) { throw new VDataBaseException("Неверный формат таблицы. Ошибка парсинга", "vdbobjs", 0x1); } try { Increment = increment; for (int i = 0; i < @base[0].Length; i++) { cols.Add(new DBColumn(@base[0][i]) { ID = i }); } for (int r = 1; r < @base.Length; r++) { DBRow dbr; (string, DBColumn)[] cells = new (string, DBColumn)[@base[r].Length];
public static VDataBase Create(ushort auth_code, string db_name, string author = "nocopy", string description = "") { if (VS.SystemExists(out string d_path)) { var source = VS.SetLayout(auth_code, db_name, Path.Combine(d_path, "data"), author, description); return(new VDataBase(source)); } else { throw new VDataBaseException("DBVN не установлен на данной системе.", "vndbw.vdatabase", 0xff1); } }
public static VDataBase Open(ushort auth_code, string db_name) { if (VS.SystemExists(out string d_path)) { var source = VS.GetLayout(auth_code, db_name, Path.Combine(d_path, "data")); return(new VDataBase(source)); } else { throw new VDataBaseException("DBVN не установлен на данной системе.", "vndbw.vdatabase", 0xff1); } }
private VDataBase(VS source) { src = source; db_dir = new DirectoryInfo(src.FullName); resMan = new VResourceManager(Path.Combine(db_dir.FullName, "resources")); cfgMan = new VConfigManager(Path.Combine(db_dir.FullName, "configs")); dbtMan = new DBTableManager( Path.Combine(db_dir.FullName, "tables"), src, DBTableParser ); dbtMan.MTableDeleted += TableDeleted; dbtMan.MTableSaved += TableSaved; }
public static DBTable CreateTable(string name, VS source, params DBColumn[] columns) { if (columns.Length == 0) { throw new VDataBaseException("Таблица должна иметь хотя бы один пользовательский столбец", "DBTable24", 0xa); } List <DBColumn> cc = new List <DBColumn>(); cc.Add(new DBColumn("id", false, ColumnDateType.None)); foreach (var column in columns) { if (cc.Select(t => t.Name).Contains(column.Name)) { throw new VDataBaseException("Не допускается хранение стобцов с одинаковым именем. Ошибка парсинга", "vdbobjs", 0xa); } cc.Add(column); } return(new DBTable(new string[][] { cc.Select(t => t.ToString()).ToArray() }, 1, name, source)); }
public static bool DataBaseExists(ushort auth_code, string db_name) { if (VS.SystemExists(out string d_path)) { try { VS.GetLayout(auth_code, db_name, Path.Combine(d_path, "data")); return(true); } catch (InvalidOperationException) { return(false); } } else { throw new VDataBaseException("DBVN не установлен на данной системе.", "vndbw.vdatabase", 0xff1); } }