예제 #1
0
 public override bool Load(UtlFileAccess fileAccess)
 {
     if (DatabaseUrl.IsFileBasedDatabaseType(this._database.GetDatabaseType()))
     {
         bool flag2;
         try
         {
             flag2 = base.Load(fileAccess);
         }
         catch (Exception exception)
         {
             object[] add = new object[] { exception.Message, base.FileName };
             throw Error.GetError(exception, 0x1c4, 0x1b, add);
         }
         if (!flag2)
         {
             return(false);
         }
         this.FilterLoadedProperties();
         if (this.GetProperty("version").CompareTo(ThisVersion) > 0)
         {
             throw Error.GetError(0x1c5);
         }
         if (this.GetIntegerProperty("LibCore.script_format") != 0)
         {
             throw Error.GetError(0x1c5);
         }
     }
     return(true);
 }
예제 #2
0
 public SimpleHttpServer(int port, string host, DatabaseName databaseName, DatabaseUrl databaseUrl, params SpecialHandler[] handlers)
 {
     UserContext.InitDb(databaseUrl, databaseName);
     Handlers = handlers;
     Port     = port;
     Host     = host;
     Console.WriteLine($"Running server on port: {port}");
     foreach (var handler in handlers)
     {
         Console.WriteLine($"Using handler: {handler.GetType().Name} on /{handler.Path}");
     }
     _serverThread = new Thread(Listen);
     _serverThread.Start();
 }
예제 #3
0
        public void Open()
        {
            LibCoreProperties props = this.CreateDbProperties();

            if (this.ConnectionOptions.ContextConnection)
            {
                this.SessionProxy       = UtlContext.session;
                this._isClrSpConnection = true;
            }
            else
            {
                if (this.ConnectionOptions.SlOob)
                {
                    props.SetProperty("url_sl_oob", this.ConnectionOptions.SlOob);
                }
                props.SetProperty("shutdown", this.ConnectionOptions.AutoShutdown);
                if (!string.IsNullOrEmpty(this.ConnectionOptions.CryptoType))
                {
                    props.SetProperty("crypt_type", this.ConnectionOptions.CryptoType);
                    props.SetProperty("crypt_key", this.ConnectionOptions.CryptoKey);
                    props.SetProperty("crypt_iv", this.ConnectionOptions.CryptoIv);
                }
                try
                {
                    if (!DatabaseUrl.IsInProcessDatabaseType(this.ConnectionOptions.ConnectionType))
                    {
                        throw UtlException.GetException(0x1a7, this.ConnectionOptions.ConnectionType);
                    }
                    this.SessionProxy = DatabaseManager.NewSession(this.ConnectionOptions.ConnectionType, this.ConnectionOptions.Database, this.ConnectionOptions.User, this.ConnectionOptions.Password, props, "", 0);
                    if (!this.ConnectionOptions.AutoCommit)
                    {
                        this.SessionProxy.SetAutoCommit(this.ConnectionOptions.AutoCommit);
                    }
                    if (this.ConnectionOptions.Readonly)
                    {
                        this.SessionProxy.SetReadOnlyDefault(this.ConnectionOptions.Readonly);
                    }
                    if (this.ConnectionOptions.IsolationLevel != System.Data.IsolationLevel.ReadCommitted)
                    {
                        this.SessionProxy.SetIsolationDefault((int)this.ConnectionOptions.IsolationLevel);
                    }
                }
                catch (CoreException exception1)
                {
                    throw UtlException.GetException(exception1);
                }
            }
        }
예제 #4
0
 public override void Save()
 {
     if ((DatabaseUrl.IsFileBasedDatabaseType(this._database.GetDatabaseType()) && !this._database.IsFilesReadOnly()) && !this._database.IsFilesInAssembly())
     {
         try
         {
             LibCoreProperties properties1 = new LibCoreProperties(this._database.GetPath(), this._database.logger.GetFileAccess());
             properties1.SetProperty("version", ThisVersion);
             properties1.SetProperty("modified", this.GetProperty("modified"));
             properties1.Save(base.FileName + ".properties.new");
             base.Fa.RenameElement(base.FileName + ".properties.new", base.FileName + ".properties");
         }
         catch (Exception exception)
         {
             this._database.logger.LogSevereEvent(FwNs.Core.LC.cResources.SR.LibCoreDatabaseProperties_Save_save_failed, exception);
             object[] add = new object[] { exception.Message, base.FileName };
             throw Error.GetError(exception, 0x1c4, 0x1b, add);
         }
     }
 }
예제 #5
0
        protected UserContext(string body, DatabaseUrl databaseUrl, DatabaseName databaseName)
        {
            if (!DbContext.Initalized)
            {
                DbContext.Initialize(databaseUrl.Url, databaseName.Name);
            }

            if (string.IsNullOrEmpty(body))
            {
                return;
            }

            try
            {
                var query = JObject.Parse(body).GetValue("query").ToString();
                Document = GetDocument(query);
            }
            catch (Exception)
            {
                Document = GetDocument(body);
            }
        }
예제 #6
0
        public void OpenPersistence()
        {
            if (this._database.IsFilesInAssembly())
            {
                this.fileAccess = FileUtil.GetFileAccessResource();
            }
            else
            {
                this.fileAccess = FileUtil.GetDefaultInstance();
            }
            this.isStoredFileAccess = true;
            bool flag = DatabaseUrl.IsFileBasedDatabaseType(this._database.GetDatabaseType());

            this._database.DatabaseProperties = new LibCoreDatabaseProperties(this._database);
            this.IsNewDatabase = !flag || !this.fileAccess.IsStreamElement(this._database.GetPath() + ".script");
            if (this.IsNewDatabase)
            {
                string name = NewUniqueName();
                this._database.SetUniqueName(name);
                if (this._database.UrlProperties.IsPropertyTrue("ifexists"))
                {
                    throw Error.GetError(0x1d1, this._database.GetPath());
                }
                this._database.DatabaseProperties.SetUrlProperties(this._database.UrlProperties);
            }
            else
            {
                this._database.DatabaseProperties.Load(this.fileAccess);
                if (this._database.UrlProperties.IsPropertyTrue("LibCore.files_readonly"))
                {
                    this._database.DatabaseProperties.SetProperty("LibCore.files_readonly", true);
                }
                if (this._database.UrlProperties.IsPropertyTrue("readonly"))
                {
                    this._database.DatabaseProperties.SetProperty("readonly", true);
                }
            }
            this.SetVariables();
            string path = null;

            if (DatabaseUrl.IsFileBasedDatabaseType(this._database.GetDatabaseType()) && !this._database.IsFilesReadOnly())
            {
                path = this._database.GetPath() + ".app.log";
            }
            this.AppLog = new SimpleLog(path, this._propEventLogLevel, this.fileAccess);
            this._database.SetReferentialIntegrity(this._propRefIntegrity);
            if (flag)
            {
                this.CheckpointRequired = false;
                this._logsStatements    = false;
                if (this._database.GetProperties().IsPropertyTrue("LibCore.lock_file") && !this._database.IsFilesReadOnly())
                {
                    this.AcquireLock(this._database.GetPath());
                }
                this.log = new Log(this._database);
                this.log.Open();
                this._logsStatements = true;
                this._loggingEnabled = this.PropLogData && !this._database.IsFilesReadOnly();
                if (this._database.GetUniqueName() == null)
                {
                    this._database.SetUniqueName(NewUniqueName());
                }
            }
        }
예제 #7
0
 public bool IsLogged()
 {
     return(DatabaseUrl.IsFileBasedDatabaseType(this._database.GetDatabaseType()) && !this._database.IsFilesReadOnly());
 }
예제 #8
0
 public static void InitDb(DatabaseUrl databaseUrl, DatabaseName databaseName)
 {
     new UserContext(null, databaseUrl, databaseName);
 }