C# 클래스 CmisSync.Lib.Database.Database

Database to cache remote information from the CMIS server. Implemented with SQLite.
상속: IDisposable
파일 보기 프로젝트 열기: aegif/CmisSync 1 사용 예제들

공개 메소드들

메소드 설명
AddFile ( SyncItem item, string objectId, 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 ( SyncItem item, string objectId, System.DateTime serverSideModificationDate ) : void

Add a folder to the database.

BeginTransaction ( ) : DbTransaction

Begins a Database transaction

Checksum ( SyncItem item ) : string

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

Checksum ( string filePath ) : string

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

ContainsFolder ( SyncItem item ) : bool

Checks whether the database contains a given folder item.

ContainsFolder ( string path ) : bool

Checks whether the database contains a given folder.

ContainsLocalFile ( string localPath ) : bool

Checks whether the database contains a given item. Local filename is often different from remote document name.

ContainsLocalPath ( string localPath ) : bool

Checks whether the database contains a given folders's id.

ContainsRemoteFile ( string remoteRelativePath ) : bool

Checks whether the database contains a given item.

Database ( string databaseFileName, string localPathPrefix, string remotePathPrefix ) : System

Constructor. dataPath: Local path to the database file localPathPrefix: Path to the synchronized files, ex: C:\Users\win7pro32bit\CmisSync\agency remotePathPrefix: Path on the remote server, ex: /Sites/swsdp/documentLibrary/Agency Files

DeleteAllFailedOperations ( ) : void

Deletes all failed upload counter.

DeleteAllFailedOperations ( SyncItem item ) : void

Deletes the upload retry counter.

Dispose ( ) : void

Implement IDisposable interface.

GetAllFoldersWithCmisId ( string id ) : List
GetChangeLogToken ( ) : string

Get the ChangeLog token that was stored at the end of the last successful CmisSync synchronization. If no ChangeLog has ever been stored, return null.

GetChecksum ( string path ) : string

Get checksum from database. Public for debugging purposes only.

GetChecksummedFiles ( ) : List
GetDownloadServerSideModificationDate ( SyncItem item ) : DateTime?

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

GetFilePath ( string id ) : string

path field in files table for id

GetFolderRemotePath ( string id ) : string

path field in folders table for id

GetFolderSyncItemFromLocalPath ( string localPath ) : SyncItem

Gets the syncitem from local path.

GetFolderSyncItemFromRemotePath ( string remotePath ) : SyncItem

Gets the syncitem from remote path.

GetLocalFolders ( ) : List
GetOperationRetryCounter ( SyncItem item, OperationType type ) : long

Gets the upload retry counter.

GetOperationRetryCounter ( string path, OperationType type ) : long

Gets the upload retry counter.

GetRemoteFilePath ( string id ) : string

GetSQLiteConnection ( ) : SQLiteConnection

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

GetServerSideModificationDate ( SyncItem item ) : 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.

GetSyncItem ( string id ) : SyncItem

Gets the syncitem from id.

GetSyncItemFromLocalPath ( string localPath ) : SyncItem

Gets the syncitem from local path.

GetSyncItemFromRemotePath ( string remotePath ) : SyncItem

Gets the syncitem from remote path.

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.

LocalToRemote ( string localPath, bool isFolder ) : string

Return the local path of an item identified by its remote path. If no such item exist yet in database (ex: new remote file), returns the local path it should be written to.

MoveFile ( SyncItem oldItem, SyncItem newItem ) : void

Move a file.

MoveFolder ( SyncItem oldItem, SyncItem newItem ) : void

Move a folder.

RecalculateChecksum ( SyncItem syncItem ) : void

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

RemoteToLocal ( string remotePath, bool isFolder ) : string

Return the remote path of an item identified by its local path. If no such item exist yet in database (ex: new local file), returns the remote path it should be written to.

RemoveFile ( SyncItem item ) : void

Remove a file from the database.

RemoveFolder ( SyncItem item ) : 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.

SetDownloadServerSideModificationDate ( SyncItem item, System.DateTime serverSideModificationDate ) : void

Set the last download date of a file. This is the time on the CMIS server side, in UTC. Client-side time does not matter.

SetFileServerSideModificationDate ( SyncItem item, System.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.

SetOperationRetryCounter ( SyncItem item, long counter, OperationType type ) : void

Sets the upload retry counter.

보호된 메소드들

메소드 설명
Dispose ( bool disposing ) : void

Dispose pattern implementation.

비공개 메소드들

메소드 설명
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.

Denormalize ( string path ) : string

Denormalize a path from the normalized one to a local path.

DenormalizeRemotePath ( string path ) : string

Denormalizes a remote path from the normalized one to a remote path.

ExecuteMultiRecordSQL ( string text, object>.Dictionary parameters ) : object>>.List

Executes the SQL and Return multiple results.

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

Executes the SQL and Return one record results.

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.

GetGeneralTableValue ( string key ) : object
GetRemotePathPrefix ( ) : string

Gets the remote path prefix.

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

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

RemoveLocalPrefix ( string path ) : string

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

RemoveRemotePrefix ( string path ) : string

Normalizes a remote path. All remote paths in database must be normalized.

SetGeneralTableValue ( string key, string value ) : void
SetRemotePathPrefix ( string pathprefix ) : void

Sets the reomte path prefix.

operationTypeToString ( OperationType type ) : string

메소드 상세

AddFile() 공개 메소드

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

AddFolder() 공개 메소드

Add a folder to the database.
public AddFolder ( SyncItem item, string objectId, System.DateTime serverSideModificationDate ) : void
item SyncItem
objectId string
serverSideModificationDate System.DateTime
리턴 void

BeginTransaction() 공개 메소드

Begins a Database transaction
public BeginTransaction ( ) : DbTransaction
리턴 System.Data.Common.DbTransaction

Checksum() 공개 정적인 메소드

Calculate the SHA1 checksum of a syncitem. Code from http://stackoverflow.com/a/1993919/226958
public static Checksum ( SyncItem item ) : string
item SyncItem sync item
리턴 string

Checksum() 공개 정적인 메소드

Calculate the SHA1 checksum of a file. Code from http://stackoverflow.com/a/1993919/226958
public static Checksum ( string filePath ) : string
filePath string
리턴 string

ContainsFolder() 공개 메소드

Checks whether the database contains a given folder item.
public ContainsFolder ( SyncItem item ) : bool
item SyncItem
리턴 bool

ContainsFolder() 공개 메소드

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

ContainsLocalFile() 공개 메소드

Checks whether the database contains a given item. Local filename is often different from remote document name.
public ContainsLocalFile ( string localPath ) : bool
localPath string
리턴 bool

ContainsLocalPath() 공개 메소드

Checks whether the database contains a given folders's id.
public ContainsLocalPath ( string localPath ) : bool
localPath string
리턴 bool

ContainsRemoteFile() 공개 메소드

Checks whether the database contains a given item.
public ContainsRemoteFile ( string remoteRelativePath ) : bool
remoteRelativePath string
리턴 bool

Database() 공개 메소드

Constructor. dataPath: Local path to the database file localPathPrefix: Path to the synchronized files, ex: C:\Users\win7pro32bit\CmisSync\agency remotePathPrefix: Path on the remote server, ex: /Sites/swsdp/documentLibrary/Agency Files
public Database ( string databaseFileName, string localPathPrefix, string remotePathPrefix ) : System
databaseFileName string
localPathPrefix string
remotePathPrefix string
리턴 System

DeleteAllFailedOperations() 공개 메소드

Deletes all failed upload counter.
public DeleteAllFailedOperations ( ) : void
리턴 void

DeleteAllFailedOperations() 공개 메소드

Deletes the upload retry counter.
public DeleteAllFailedOperations ( SyncItem item ) : void
item SyncItem Path of the local file.
리턴 void

Dispose() 공개 메소드

Implement IDisposable interface.
public Dispose ( ) : void
리턴 void

Dispose() 보호된 메소드

Dispose pattern implementation.
protected Dispose ( bool disposing ) : void
disposing bool
리턴 void

GetAllFoldersWithCmisId() 공개 메소드

public GetAllFoldersWithCmisId ( string id ) : List
id string
리턴 List

GetChangeLogToken() 공개 메소드

Get the ChangeLog token that was stored at the end of the last successful CmisSync synchronization. If no ChangeLog has ever been stored, return null.
public GetChangeLogToken ( ) : string
리턴 string

GetChecksum() 공개 메소드

Get checksum from database. Public for debugging purposes only.
public GetChecksum ( string path ) : string
path string
리턴 string

GetChecksummedFiles() 공개 메소드

public GetChecksummedFiles ( ) : List
리턴 List

GetDownloadServerSideModificationDate() 공개 메소드

Get the date at which the file was last download. This is the time on the CMIS server side, in UTC. Client-side time does not matter.
public GetDownloadServerSideModificationDate ( SyncItem item ) : DateTime?
item SyncItem
리턴 DateTime?

GetFilePath() 공개 메소드

path field in files table for id
public GetFilePath ( string id ) : string
id string
리턴 string

GetFolderRemotePath() 공개 메소드

path field in folders table for id
public GetFolderRemotePath ( string id ) : string
id string
리턴 string

GetFolderSyncItemFromLocalPath() 공개 메소드

Gets the syncitem from local path.
public GetFolderSyncItemFromLocalPath ( string localPath ) : SyncItem
localPath string Local path.
리턴 SyncItem

GetFolderSyncItemFromRemotePath() 공개 메소드

Gets the syncitem from remote path.
public GetFolderSyncItemFromRemotePath ( string remotePath ) : SyncItem
remotePath string Remote path.
리턴 SyncItem

GetLocalFolders() 공개 메소드

public GetLocalFolders ( ) : List
리턴 List

GetOperationRetryCounter() 공개 메소드

Gets the upload retry counter.
public GetOperationRetryCounter ( SyncItem item, OperationType type ) : long
item SyncItem Path of the local file.
type OperationType
리턴 long

GetOperationRetryCounter() 공개 메소드

Gets the upload retry counter.
public GetOperationRetryCounter ( string path, OperationType type ) : long
path string Path of the local file.
type OperationType
리턴 long

GetRemoteFilePath() 공개 메소드

public GetRemoteFilePath ( string id ) : string
id string
리턴 string

GetSQLiteConnection() 공개 메소드

Connection to the database. The sqliteConnection must not be used directly, used this method instead.
public GetSQLiteConnection ( ) : SQLiteConnection
리턴 System.Data.SQLite.SQLiteConnection

GetServerSideModificationDate() 공개 메소드

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 ( SyncItem item ) : DateTime?
item SyncItem
리턴 DateTime?

GetSyncItem() 공개 메소드

Gets the syncitem from id.
public GetSyncItem ( string id ) : SyncItem
id string Identifier.
리턴 SyncItem

GetSyncItemFromLocalPath() 공개 메소드

Gets the syncitem from local path.
public GetSyncItemFromLocalPath ( string localPath ) : SyncItem
localPath string Local path.
리턴 SyncItem

GetSyncItemFromRemotePath() 공개 메소드

Gets the syncitem from remote path.
public GetSyncItemFromRemotePath ( string remotePath ) : SyncItem
remotePath string Remote path.
리턴 SyncItem

LocalFileHasChanged() 공개 메소드

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
리턴 bool

LocalToRemote() 공개 메소드

Return the local path of an item identified by its remote path. If no such item exist yet in database (ex: new remote file), returns the local path it should be written to.
public LocalToRemote ( string localPath, bool isFolder ) : string
localPath string
isFolder bool
리턴 string

MoveFile() 공개 메소드

Move a file.
public MoveFile ( SyncItem oldItem, SyncItem newItem ) : void
oldItem SyncItem
newItem SyncItem
리턴 void

MoveFolder() 공개 메소드

Move a folder.
public MoveFolder ( SyncItem oldItem, SyncItem newItem ) : void
oldItem SyncItem
newItem SyncItem
리턴 void

RecalculateChecksum() 공개 메소드

Recalculate the checksum of a file and save it to database.
public RecalculateChecksum ( SyncItem syncItem ) : void
syncItem SyncItem
리턴 void

RemoteToLocal() 공개 메소드

Return the remote path of an item identified by its local path. If no such item exist yet in database (ex: new local file), returns the remote path it should be written to.
public RemoteToLocal ( string remotePath, bool isFolder ) : string
remotePath string
isFolder bool
리턴 string

RemoveFile() 공개 메소드

Remove a file from the database.
public RemoveFile ( SyncItem item ) : void
item SyncItem
리턴 void

RemoveFolder() 공개 메소드

Remove a folder from the database.
public RemoveFolder ( SyncItem item ) : void
item SyncItem
리턴 void

SetChangeLogToken() 공개 메소드

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

SetDownloadServerSideModificationDate() 공개 메소드

Set the last download date of a file. This is the time on the CMIS server side, in UTC. Client-side time does not matter.
public SetDownloadServerSideModificationDate ( SyncItem item, System.DateTime serverSideModificationDate ) : void
item SyncItem
serverSideModificationDate System.DateTime
리턴 void

SetFileServerSideModificationDate() 공개 메소드

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 ( SyncItem item, System.DateTime serverSideModificationDate ) : void
item SyncItem
serverSideModificationDate System.DateTime
리턴 void

SetOperationRetryCounter() 공개 메소드

Sets the upload retry counter.
public SetOperationRetryCounter ( SyncItem item, long counter, OperationType type ) : void
item SyncItem Path of the local file.
counter long Counter.
type OperationType
리턴 void