Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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}"
                });
            }
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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);
            }
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        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");
        }
Exemplo n.º 7
0
        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();
        }
Exemplo n.º 8
0
 public void ChangeDataBase(DBNames name)
 {
     _database = name.ToString();
     Init();
 }
Exemplo n.º 9
0
 public static void ChangeDataBase(DBNames name)
 {
     _database.ChangeDataBase(name);
 }
Exemplo n.º 10
0
 public void ChangeDataBase(DBNames name)
 {
     _database = name.ToString();
     Init();
 }
Exemplo n.º 11
0
 public static void ChangeDataBase(DBNames name)
 {
     _database.ChangeDataBase(name);
 }
Exemplo n.º 12
0
 private static long GetDBIdByName(string Name)
 {
     return(DBNames.ReverseMatch(Name));
 }