// Constructor public FileSyncAgent(SyncJob job) { this._job = job; // Instantiates providers actProvider = SyncClient.GetSyncActionsProvider(this._job.IntermediaryStorage.Path); mdProvider = SyncClient.GetMetaDataProvider(_job.IntermediaryStorage.Path, _job.SyncSource.ID); }
public static void CreateDataStore(string pathToJobFolder, SyncSource syncSource, IntermediaryStorage metaDataSource) { if (!Directory.Exists(pathToJobFolder)) { Directory.CreateDirectory(pathToJobFolder); } if (!Directory.Exists(metaDataSource.Path)) { Directory.CreateDirectory(metaDataSource.Path); } SqliteConnection con1 = null; SqliteConnection con2 = null; SqliteTransaction transaction1 = null; SqliteTransaction transaction2 = null; try { SQLiteAccess dbAccess1 = new SQLiteAccess(Path.Combine(pathToJobFolder, Configuration.DATABASE_NAME), true); SQLiteAccess dbAccess2 = new SQLiteAccess(Path.Combine(metaDataSource.Path, Configuration.DATABASE_NAME), true); con1 = dbAccess1.NewSQLiteConnection(); con2 = dbAccess2.NewSQLiteConnection(); if (con1 == null) { throw new DatabaseException(String.Format(m_ResourceManager.GetString("err_somethingNotFound"), Path.Combine(pathToJobFolder, Configuration.DATABASE_NAME))); } if (con2 == null) { throw new DatabaseException(String.Format(m_ResourceManager.GetString("err_somethingNotFound"), Path.Combine(metaDataSource.Path, Configuration.DATABASE_NAME))); } transaction2 = (SqliteTransaction)con2.BeginTransaction(); transaction1 = (SqliteTransaction)con1.BeginTransaction(); //Create schema for source info table in job folder SQLiteSyncSourceProvider.CreateSchema(con1); //Create schema for profile table in job folder SQLiteSyncJobManager.CreateSchema(con1); //create schema for source info table in intermediate storage folder SQLiteSyncSourceProvider.CreateSchema(con2); //create schema for metadata table in intermediate storage folder SQLiteMetaDataProvider mdProvider = (SQLiteMetaDataProvider)SyncClient.GetMetaDataProvider(metaDataSource.Path, Configuration.DATABASE_NAME); mdProvider.CreateSchema(con2); //create schema for action table in intermediate storage folder SQLiteSyncActionsProvider actionProvider = (SQLiteSyncActionsProvider)SyncClient.GetSyncActionsProvider(metaDataSource.Path); actionProvider.CreateSchema(con2); transaction2.Commit(); transaction1.Commit(); } catch (Exception ex) { Console.WriteLine(ex.Message); if (transaction2 != null) { transaction2.Rollback(); } if (transaction1 != null) { transaction1.Rollback(); } throw new DatabaseException(m_ResourceManager.GetString("err_databaseException")); } finally { if (con1 != null) { con1.Dispose(); } if (con2 != null) { con2.Dispose(); } } }