//FilteringSqlServerSync sqlServerSync = null; private bool InitializePhotoSyncProviders(EventTDO ev, string scopeName, string[] staticSyncTables, string[] dynamicSyncTables) { if (string.IsNullOrEmpty(AppConfig.PhotoDbServerSyncClass)) { FotoShoutUtils.Log.LogManager.Error(_logger, "The type of the database server upload sync need to be defined in app config."); return(false); } //sqlServerSync = new FilteringSqlServerSync(); //sqlServerSync.Configure(AppConfig.SyncAction, scopeName, AppConfig.ServerConnection, staticSyncTables, dynamicSyncTables); _sqlPhotoServerSync = new SqlServerSyncProviderProxy(AppConfig.SyncAction, scopeName, AppConfig.ServerConnection, staticSyncTables, dynamicSyncTables, AppConfig.PhotoDbServerSyncClass, SyncEngine.WFC_SERVICE_SQLSERVER); FotoShoutUtils.Log.LogManager.Info(_logger, "Server Upload Sync - " + _sqlPhotoServerSync.Ping()); DbSyncScopeDescription scopeDescription = _sqlPhotoServerSync.GetScopeDescription(scopeName); //DbSyncScopeDescription scopeDescription = sqlServerSync.GetScopeDescription(scopeName); _sqlPhotoClientSync = InitiateSyncScope(scopeName, scopeDescription, (SyncDirectionOrder)Enum.Parse(typeof(SyncDirectionOrder), AppConfig.PhotoSyncDirection)); if (_sqlPhotoClientSync != null) { _sqlPhotoClientSync.Synchronized += new FotoShoutUtils.Sync.Db.SynchronizedEventHandler(OnDbUploadSynchronized); } return(_sqlPhotoClientSync != null); }
public override void Execute() { try { string syncAction = AppConfig.SyncAction; if (string.IsNullOrEmpty(syncAction) || !syncAction.Equals(FotoShoutUtils.Constants.ASV_SYNCACTION_DEPROVISIONSTORE, StringComparison.InvariantCultureIgnoreCase)) { // Initialize paramerters for FotoShout API if (!InitializeApi(_fsServerService, true)) { return; } if (InitializeApi(_fsClientService, false)) { FotoShoutUtils.Log.LogManager.Info(_logger, "Synchronizing events' data from local to central server..."); UploadEventsData(); FotoShoutUtils.Log.LogManager.Info(_logger, "Done synchronized events' data."); } } // Initialize parameters for Sync database if (!InitializeEventSyncProviders()) { return; } FotoShoutUtils.Log.LogManager.Info(_logger, "Downloading database records from central server to local..."); _sqlEventClientSync.Synchronize(_sqlEventServerSync); //_sqlEventClientSync.Synchronize(sqlServerSync.Provider); FotoShoutUtils.Log.LogManager.Info(_logger, "Done downloaded database.\n"); } catch (Exception ex) { if (ex is CommunicationObjectFaultedException) { _sqlEventServerSync = null; _sqlEventClientSync = null; FotoShoutUtils.Log.LogManager.Error(_logger, ex.Message + "\n The service will be re-initiated in the next round."); } else { FotoShoutUtils.Log.LogManager.Error(_logger, ex.ToString() + "\n"); } } }