Beispiel #1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="dbPath">dbFilePath must point to the DIT file on the local computer.</param>
 /// <param name="logPath">The path should point to a writeable folder on the local computer, where ESE log files will be created. If not specified, then temp folder will be used.</param>
 public DirectoryContext(string dbFilePath, bool readOnly, string logDirectoryPath = null)
 {
     if (!File.Exists(dbFilePath))
     {
         // TODO: Extract as resource
         throw new FileNotFoundException("The specified database file does not exist.", dbFilePath);
     }
     int pageSize = DirectoryContext.GetDBPageSize(dbFilePath);
     string dbDirectoryPath = Path.GetDirectoryName(dbFilePath);
     string checkpointDirectoryPath = dbDirectoryPath;
     string tempDirectoryPath = dbDirectoryPath;
     if (logDirectoryPath != null)
     {
         if (!Directory.Exists(logDirectoryPath))
         {
             // TODO: Extract as resource
             throw new FileNotFoundException("The specified log directory does not exist.", logDirectoryPath);
         }
     }
     else
     {
         logDirectoryPath = dbDirectoryPath;
     }
     // TODO: Exception handling?
     // HACK: IsamInstance constructor throws AccessDenied Exception when the path does not end with a backslash.
     // TODO: Const isam instance name
     string instanceName = "DSInternals";
     this.instance = new IsamInstance(AddPathSeparator(checkpointDirectoryPath), AddPathSeparator(logDirectoryPath), AddPathSeparator(tempDirectoryPath), ADConstants.EseBaseName, instanceName, readOnly, pageSize);
     try
     {
         var isamParameters = this.instance.IsamSystemParameters;
         // TODO: Add param explanations
         isamParameters.LogFileSize = ADConstants.EseLogFileSize;
         isamParameters.DeleteOutOfRangeLogs = true;
         isamParameters.EnableIndexChecking = 1;
         isamParameters.EnableIndexCleanup = true;
         isamParameters.CircularLog = true;
         // TODO: Configure additional ISAM parameters
         // this.instance.IsamSystemParameters.EnableOnlineDefrag = false;
         // JET_paramDeleteOldLogs =  1
         this.session = this.instance.CreateSession();
         this.session.AttachDatabase(dbFilePath);
         this.attachedDatabasePath = dbFilePath;
         this.database = this.session.OpenDatabase(dbFilePath);
         this.Schema = new DirectorySchema(this.database);
         this.SecurityDescriptorRersolver = new SecurityDescriptorRersolver(this.database);
         this.DistinguishedNameResolver = new DistinguishedNameResolver(this.database, this.Schema);
         this.LinkResolver = new LinkResolver(this.database, this.Schema);
         this.DomainController = new DomainController(this);
     }
     catch
     {
         // Free resources if anything failed
         this.Dispose();
         throw;
     }
 }
Beispiel #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="IsamSession"/> class.
 /// </summary>
 /// <param name="isamInstance">The instance.</param>
 internal IsamSession(IsamInstance isamInstance)
 {
     lock (isamInstance)
     {
         this.isamInstance = isamInstance;
         Api.JetBeginSession(isamInstance.Inst, out this.sesid, null, null);
         this.cleanup = true;
         this.transactionLevelID = new long[7]; // JET only supports 7 levels
     }
 }
Beispiel #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="IsamSession"/> class.
 /// </summary>
 /// <param name="isamInstance">The instance.</param>
 internal IsamSession(IsamInstance isamInstance)
 {
     lock (isamInstance)
     {
         this.isamInstance = isamInstance;
         Api.JetBeginSession(isamInstance.Inst, out this.sesid, null, null);
         this.cleanup            = true;
         this.transactionLevelID = new long[7]; // JET only supports 7 levels
     }
 }
Beispiel #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="IsamSystemParameters"/> class.
 /// </summary>
 /// <param name="instance">The instance.</param>
 internal IsamSystemParameters(IsamInstance instance)
 {
     this.instance = instance;
 }
 protected virtual void Dispose(bool disposing)
 {
     if (!disposing)
     {
         // Do nothing
         return;
     }
     if(this.LinkResolver != null)
     {
         this.LinkResolver.Dispose();
         this.LinkResolver = null;
     }
     if (this.SecurityDescriptorRersolver != null)
     {
         this.SecurityDescriptorRersolver.Dispose();
         this.SecurityDescriptorRersolver = null;
     }
     if (this.DistinguishedNameResolver != null)
     {
         this.DistinguishedNameResolver.Dispose();
         this.DistinguishedNameResolver = null;
     }
     if (this.DomainController != null)
     {
         this.DomainController.Dispose();
         this.DomainController = null;
     }
     if (this.database != null)
     {
         this.database.Dispose();
         this.database = null;
     }
     if (this.session != null)
     {
         if (this.attachedDatabasePath != null)
         {
             this.session.DetachDatabase(this.attachedDatabasePath);
             this.attachedDatabasePath = null;
         }
         this.session.Dispose();
         this.session = null;
     }
     if (this.instance != null)
     {
         this.instance.Dispose();
         this.instance = null;
     }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="IsamSystemParameters"/> class.
 /// </summary>
 /// <param name="instance">The instance.</param>
 internal IsamSystemParameters(IsamInstance instance)
 {
     this.instance = instance;
 }