Beispiel #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);
 }
Beispiel #2
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);
         }
     }
 }
Beispiel #3
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());
                }
            }
        }
Beispiel #4
0
 public bool IsLogged()
 {
     return(DatabaseUrl.IsFileBasedDatabaseType(this._database.GetDatabaseType()) && !this._database.IsFilesReadOnly());
 }