private void ParseNestedObject(StreamReader reader, string line, MetaObject dbo) { string[] lines = line.Split(','); string fileName = lines[2].Replace("}", string.Empty); string objectName = lines[3].Replace("\"", string.Empty); MetaObject nested = new MetaObject() { Owner = dbo, Name = objectName, Parent = dbo.Parent }; dbo.MetaObjects.Add(nested); if (DBNames.TryGetValue(fileName, out DBNameEntry entry)) { DBName dbname = entry.DBNames.Where(i => i.Token == DBToken.VT).FirstOrDefault(); if (dbname != null) { nested.Token = dbname.Token; nested.TypeCode = dbname.TypeCode; nested.TableName = CreateTableName(nested, dbname); } } ParseNestedMetaProperties(reader, nested); }
private void ParseAccumulationRegister(string fileName) { if (!DBNames.TryGetValue(fileName, out DBNameEntry entry)) { return; } foreach (DBName dbname in entry.DBNames) { string name = GetChildMetaObjectName(dbname.Token); if (string.IsNullOrEmpty(name)) { continue; } entry.MetaObject.MetaObjects.Add( new MetaObject() { Name = name, Token = dbname.Token, Owner = entry.MetaObject, TypeCode = dbname.TypeCode, TableName = $"_{dbname.Token}{dbname.TypeCode}" }); } }
private void ParseMetaProperty(StreamReader reader, string line, MetaObject dbo, MetaPropertyPurpose purpose) { string[] lines = line.Split(','); string fileName = lines[2].Replace("}", string.Empty); string objectName = lines[3].Replace("\"", string.Empty); MetaProperty property = new MetaProperty { Parent = dbo, Name = objectName, Purpose = purpose }; dbo.Properties.Add(property); if (DBNames.TryGetValue(fileName, out DBNameEntry entry)) { if (entry.DBNames.Count == 1) { property.DbName = CreateMetaFieldName(entry.DBNames[0]); } else if (entry.DBNames.Count > 1) { foreach (var dbn in entry.DBNames.Where(dbn => dbn.Token == DBToken.Fld)) { property.DbName = CreateMetaFieldName(dbn); } } } ParseMetaPropertyTypes(reader, property); }
private void ParseReferenceOwner(StreamReader reader, MetaObject dbo) { int count = 0; string[] lines; string line = reader.ReadLine(); // 8. line if (line != null) { lines = line.Split(','); count = int.Parse(lines[1].Replace("}", string.Empty)); } if (count == 0) { return; } Match match; List <TypeInfo> types = new List <TypeInfo>(); for (int i = 0; i < count; i++) { _ = reader.ReadLine(); line = reader.ReadLine(); if (line == null) { return; } match = rxUUID.Match(line); if (match.Success) { if (DBNames.TryGetValue(match.Value, out DBNameEntry entry)) { types.Add(new TypeInfo() { TypeCode = entry.MetaObject.TypeCode, Name = entry.MetaObject.TableName, MetaObject = entry.MetaObject }); } } _ = reader.ReadLine(); } if (types.Count > 0) { MetaProperty property = new MetaProperty { Parent = dbo, Types = types, Name = "Владелец", DbName = "OwnerID" // [_OwnerIDRRef] | [_OwnerID_TYPE] + [_OwnerID_RTRef] + [_OwnerID_RRRef] // TODO: add DbField at once ? }; dbo.Properties.Add(property); } }
internal static string PostReload(string Reloaded) { Reloaded = UpdateOverlay(Reloaded); const string SwitchDatabasePrefix = "::SETDB-"; if (Reloaded.StartsWith(SwitchDatabasePrefix)) { string DB = Reloaded.Substring(SwitchDatabasePrefix.Length); DB = DB.Substring(0, DB.IndexOf("::")); bool IsDBName = false; if (int.TryParse(DB, out int DBID)) { if (DBNames.ContainsKey(DBID)) { SetDBID(DBID); } else { IsDBName = true; } } else { IsDBName = true; } if (IsDBName) { if (DBNames.ContainsValue(DB)) { SetDBID((int)DBNames.ReverseMatch(DB)); } else { Error("Database \"{0}\" not found", DB); } } Reloaded = Reloaded.Substring(Reloaded.IndexOf("::", 2) + 2); } return(Reloaded); }
internal void SaveDbObjectToFile(MetaObject dbo) { var kv = DBNames .Where(i => i.Value.MetaObject == dbo) .FirstOrDefault(); string fileName = kv.Key; if (new Guid(fileName) == Guid.Empty) { return; } SqlBytes binaryData = ReadConfigFromDatabase(fileName); if (binaryData == null) { return; } DeflateStream stream = new DeflateStream(binaryData.Stream, CompressionMode.Decompress); WriteBinaryDataToFile(stream, $"{fileName}.txt"); }
public static void To(DBNames targetDb) { Func <IDatabase> db; switch (targetDb) { case DBNames.Firebase: db = () => ServiceLocator.GetInstance <IFirebase>(); break; case DBNames.Python: db = () => ServiceLocator.GetInstance <IPython>(); break; default: db = () => ServiceLocator.GetInstance <IAzure>(); break; } var ddb = ServiceLocator.GetInstance <IDynamicDB>(); ddb.SetCurrentDB(db); ddb.Connect(); }
public void ChangeDataBase(DBNames name) { _database = name.ToString(); Init(); }
public static void ChangeDataBase(DBNames name) { _database.ChangeDataBase(name); }
private static long GetDBIdByName(string Name) { return(DBNames.ReverseMatch(Name)); }