C# Class CmisSync.Lib.Cmis.Database

Database to cache remote information from the CMIS server. Implemented with SQLite.
Inheritance: IDisposable
Exibir arquivo Open project: keithwharrison/Oris4Sync Class Usage Examples

Public Methods

Method Description
AddFile ( string path, System.DateTime serverSideModificationDate, string[]>.Dictionary metadata, byte filehash ) : void

Add a file to the database. If checksum is not null, it will be used for the database entry

AddFolder ( string path, System.DateTime serverSideModificationDate ) : void

Add a folder to the database.

ContainsFile ( string path ) : bool

Checks whether the database contains a given file.

ContainsFolder ( string path ) : bool

Checks whether the database contains a given folder.

Database ( string dataPath ) : System

Constructor.

Dispose ( ) : void

Implement IDisposable interface.

GetChangeLogToken ( ) : string

Get the ChangeLog token that was stored at the end of the last successful CmisSync synchronization.

GetSQLiteConnection ( ) : SQLiteConnection

Connection to the database. The sqliteConnection must not be used directly, used this method instead.

GetServerSideModificationDate ( string path ) : DateTime?

Get the time at which the file was last modified. This is the time on the CMIS server side, in UTC. Client-side time does not matter.

LocalFileHasChanged ( string path ) : bool

Check whether a file's content has changed locally since it was last synchronized. This happens when the user edits a file on the local computer. This method does not communicate with the CMIS server, it just checks whether the checksum has changed.

MoveFile ( string oldPath, string newPath ) : void

Move a file.

MoveFolder ( string oldPath, string newPath ) : void

Move a folder.

RecalculateChecksum ( string path ) : void

Recalculate the checksum of a file and save it to database.

RemoveFile ( string path ) : void

Remove a file from the database.

RemoveFolder ( string path ) : void

Remove a folder from the database.

SetChangeLogToken ( string token ) : void

Set the stored ChangeLog token. This should be called after each successful CmisSync synchronization.

SetFileServerSideModificationDate ( string path, DateTime serverSideModificationDate ) : void

Set the last modification date of a file. This is the time on the CMIS server side, in UTC. Client-side time does not matter. TODO Combine this method and the next in a new method ModifyFile, and find out if GetServerSideModificationDate is really needed.

Protected Methods

Method Description
Dispose ( bool disposing ) : void

Dispose pattern implementation.

Private Methods

Method Description
AddFile ( string path, System.DateTime serverSideModificationDate, string[]>.Dictionary metadata ) : void
Checksum ( string filePath ) : string

Calculate the SHA1 checksum of a file. Code from http://stackoverflow.com/a/1993919/226958

ChecksumToString ( byte hash ) : string

Transforms a given hash into a string

ComposeSQLCommand ( SQLiteCommand command, string text, object>.Dictionary parameters ) : void

Helper method to fill the parameters inside an SQL command.

ExecuteSQLAction ( string text, object>.Dictionary parameters ) : void

Helper method to execute an SQL command that does not return anything.

ExecuteSQLFunction ( string text, object>.Dictionary parameters ) : object

Helper method to execute an SQL command that returns something.

Json ( string[]>.Dictionary dictionary ) : string

Put all the values of a dictionary into a JSON string.

Normalize ( string path ) : string

Normalize a path. All paths stored in database must be normalized. Goals: - Make data smaller in database - Reduce OS-specific differences

Method Details

AddFile() public method

Add a file to the database. If checksum is not null, it will be used for the database entry
public AddFile ( string path, System.DateTime serverSideModificationDate, string[]>.Dictionary metadata, byte filehash ) : void
path string
serverSideModificationDate System.DateTime
metadata string[]>.Dictionary
filehash byte
return void

AddFolder() public method

Add a folder to the database.
public AddFolder ( string path, System.DateTime serverSideModificationDate ) : void
path string
serverSideModificationDate System.DateTime
return void

ContainsFile() public method

Checks whether the database contains a given file.
public ContainsFile ( string path ) : bool
path string
return bool

ContainsFolder() public method

Checks whether the database contains a given folder.
public ContainsFolder ( string path ) : bool
path string
return bool

Database() public method

Constructor.
public Database ( string dataPath ) : System
dataPath string
return System

Dispose() public method

Implement IDisposable interface.
public Dispose ( ) : void
return void

Dispose() protected method

Dispose pattern implementation.
protected Dispose ( bool disposing ) : void
disposing bool
return void

GetChangeLogToken() public method

Get the ChangeLog token that was stored at the end of the last successful CmisSync synchronization.
public GetChangeLogToken ( ) : string
return string

GetSQLiteConnection() public method

Connection to the database. The sqliteConnection must not be used directly, used this method instead.
public GetSQLiteConnection ( ) : SQLiteConnection
return SQLiteConnection

GetServerSideModificationDate() public method

Get the time at which the file was last modified. This is the time on the CMIS server side, in UTC. Client-side time does not matter.
public GetServerSideModificationDate ( string path ) : DateTime?
path string
return DateTime?

LocalFileHasChanged() public method

Check whether a file's content has changed locally since it was last synchronized. This happens when the user edits a file on the local computer. This method does not communicate with the CMIS server, it just checks whether the checksum has changed.
public LocalFileHasChanged ( string path ) : bool
path string
return bool

MoveFile() public method

Move a file.
public MoveFile ( string oldPath, string newPath ) : void
oldPath string
newPath string
return void

MoveFolder() public method

Move a folder.
public MoveFolder ( string oldPath, string newPath ) : void
oldPath string
newPath string
return void

RecalculateChecksum() public method

Recalculate the checksum of a file and save it to database.
public RecalculateChecksum ( string path ) : void
path string
return void

RemoveFile() public method

Remove a file from the database.
public RemoveFile ( string path ) : void
path string
return void

RemoveFolder() public method

Remove a folder from the database.
public RemoveFolder ( string path ) : void
path string
return void

SetChangeLogToken() public method

Set the stored ChangeLog token. This should be called after each successful CmisSync synchronization.
public SetChangeLogToken ( string token ) : void
token string
return void

SetFileServerSideModificationDate() public method

Set the last modification date of a file. This is the time on the CMIS server side, in UTC. Client-side time does not matter. TODO Combine this method and the next in a new method ModifyFile, and find out if GetServerSideModificationDate is really needed.
public SetFileServerSideModificationDate ( string path, DateTime serverSideModificationDate ) : void
path string
serverSideModificationDate DateTime
return void