Inheritance: AObjects
Exemplo n.º 1
0
        void Load()
        {
            try
            {
                Servers = _db.Query<Servers>(typeof(Servers))[0];
            }
            catch (InvalidOperationException) {}
            catch (Db4oRecoverableException) {}
            if (Servers == null)
            {
                Servers = new Servers();
                _db.Store(Servers);
            }

            try
            {
                Files = _db.Query<Files>(typeof(Files))[0];
            }
            catch (InvalidOperationException) {}
            catch (Db4oRecoverableException) {}
            if (Files == null)
            {
                Files = new Files();
                _db.Store(Files);
            }

            try
            {
                Searches = _db.Query<Searches>(typeof(Searches))[0];
            }
            catch (InvalidOperationException) {}
            catch (Db4oRecoverableException) {}
            if (Searches == null)
            {
                Searches = new Searches();
                _db.Store(Searches);
            }

            try
            {
                ApiKeys = _db.Query<ApiKeys>(typeof(ApiKeys))[0];
            }
            catch (InvalidOperationException) {}
            catch (Db4oRecoverableException) {}
            if (ApiKeys == null)
            {
                ApiKeys = new ApiKeys();
                _db.Store(ApiKeys);
            }

            TryCommit();
        }
Exemplo n.º 2
0
        void LoadObjects()
        {
            var _servers = new Servers();
            var _files = new Files();
            var _searches = new Searches();
            var _apiKeys = new ApiKeys();

            using (ISession session = _sessions.OpenSession(new TrackingNumberInterceptor()))
            {
                var servers = session.CreateQuery("FROM Server").List<Server>();
                foreach (var server in servers)
                {
                    _servers.Add(server);
                }

                var files = session.CreateQuery("FROM File").List<File>();
                foreach (var file in files)
                {
                    _files.Add(file);
                }

                var searches = session.CreateQuery("FROM Search").List<Search>();
                foreach (var search in searches)
                {
                    _searches.Add(search);
                }

                var apiKeys = session.CreateQuery("FROM ApiKey").List<ApiKey>();
                foreach (var apiKey in apiKeys)
                {
                    _apiKeys.Add(apiKey);
                }
            }

            Servers = _servers;
            Files = _files;
            Searches = _searches;
            ApiKeys = _apiKeys;

            _lastSave = DateTime.Now;
        }
Exemplo n.º 3
0
        void Load()
        {
            try
            {
                Servers = _db.Query<Servers>(typeof(Servers)).First();
            }
            catch (InvalidOperationException)
            {
                Servers = new Servers();
                _db.Store(Servers);
            }

            try
            {
                Files = _db.Query<Files>(typeof(Files)).First();
            }
            catch (InvalidOperationException)
            {
                Files = new Files();
                _db.Store(Files);
            }

            try
            {
                Searches = _db.Query<Searches>(typeof(Searches)).First();
            }
            catch (InvalidOperationException)
            {
                Searches = new Searches();
                _db.Store(Searches);
            }

            try
            {
                ApiKeys = _db.Query<ApiKeys>(typeof(ApiKeys)).First();
            }
            catch (InvalidOperationException)
            {
                ApiKeys = new ApiKeys();
                _db.Store(ApiKeys);
            }

            _db.Commit();
        }