/// <summary> /// SyncAgent manage both server and client provider /// the tables array represents the tables you want to sync /// Don't work on the proxy provider /// </summary> public SyncAgent(string scopeName, CoreProvider clientProvider, IProvider serverProvider, string[] tables) : this(scopeName, clientProvider, serverProvider) { if (tables == null || tables.Length <= 0) { throw new ArgumentException("you need to pass at lease one table name"); } if (!(this.RemoteProvider is CoreProvider remoteCoreProvider)) { throw new ArgumentException("Since the remote provider is a web proxy, you have to configure the server side"); } if (!remoteCoreProvider.CanBeServerProvider) { throw new NotSupportedException(); } this.LocalProvider.SetConfiguration(c => { foreach (var tbl in tables) { c.Add(tbl); } }); this.RemoteProvider.SetConfiguration(c => { foreach (var tbl in tables) { c.Add(tbl); } }); }
/// <summary> /// SyncAgent manage both server and client provider /// It's the main object to launch the Sync process /// </summary> public SyncAgent(string scopeName, CoreProvider localProvider, IProvider remoteProvider) { this.LocalProvider = localProvider ?? throw new ArgumentNullException("ClientProvider"); this.RemoteProvider = remoteProvider ?? throw new ArgumentNullException("ServerProvider"); this.Configuration = new SyncConfiguration { ScopeName = scopeName ?? throw new ArgumentNullException("scopeName") }; this.LocalProvider.SyncProgress += (s, e) => this.SyncProgress?.Invoke(s, e); this.LocalProvider.BeginSession += (s, e) => this.BeginSession?.Invoke(s, e); this.LocalProvider.EndSession += (s, e) => this.EndSession?.Invoke(s, e); this.LocalProvider.TableChangesApplied += (s, e) => this.TableChangesApplied?.Invoke(s, e); this.LocalProvider.TableChangesApplying += (s, e) => this.TableChangesApplying?.Invoke(s, e); this.LocalProvider.TableChangesSelected += (s, e) => this.TableChangesSelected?.Invoke(s, e); this.LocalProvider.TableChangesSelecting += (s, e) => this.TableChangesSelecting?.Invoke(s, e); this.LocalProvider.SchemaApplied += (s, e) => this.SchemaApplied?.Invoke(s, e); this.LocalProvider.SchemaApplying += (s, e) => this.SchemaApplying?.Invoke(s, e); this.LocalProvider.DatabaseApplied += (s, e) => this.DatabaseApplied?.Invoke(s, e); this.LocalProvider.DatabaseApplying += (s, e) => this.DatabaseApplying?.Invoke(s, e); this.LocalProvider.DatabaseTableApplied += (s, e) => this.DatabaseTableApplied?.Invoke(s, e); this.LocalProvider.DatabaseTableApplying += (s, e) => this.DatabaseTableApplying?.Invoke(s, e); this.LocalProvider.ScopeLoading += (s, e) => this.ScopeLoading?.Invoke(s, e); this.LocalProvider.ScopeSaved += (s, e) => this.ScopeSaved?.Invoke(s, e); this.RemoteProvider.ApplyChangedFailed += this.RemoteProvider_ApplyChangedFailed; }
public DbMigrationTable(CoreProvider provider, SyncTable currentTable, SyncTable newTable, bool preserveTracking = true) { this.currentTable = currentTable ?? throw new ArgumentNullException(nameof(currentTable)); this.newTable = newTable ?? throw new ArgumentNullException(nameof(newTable)); this.preserveTracking = preserveTracking; this.provider = provider; }
// 9 /// <summary> /// Creates a synchronization agent that will handle a full synchronization between a client and a server. /// </summary> /// <param name="clientProvider">local provider to your client database</param> /// <param name="remoteOrchestrator">Remote Orchestrator already configured with a SyncProvider</param> /// <param name="options">Sync Options defining options used by your local provider (and remote provider if type of remoteOrchestrator is not a WebRemoteOrchestrator)</param> public SyncAgent(CoreProvider clientProvider, RemoteOrchestrator remoteOrchestrator, SyncOptions options = default) : this() { if (clientProvider is null) { throw new ArgumentNullException(nameof(clientProvider)); } if (remoteOrchestrator is null) { throw new ArgumentNullException(nameof(remoteOrchestrator)); } if (options == default) { options = new SyncOptions(); } // Override remote orchestrator options, setup and scope name remoteOrchestrator.Options = options; var localOrchestrator = new LocalOrchestrator(clientProvider, options); this.LocalOrchestrator = localOrchestrator; this.RemoteOrchestrator = remoteOrchestrator; this.EnsureOptionsAndSetupInstances(); }
/// <summary> /// Create a local orchestrator, used to orchestrates the whole sync on the client side /// </summary> public LocalOrchestrator(CoreProvider provider) : base(provider, new SyncOptions()) { if (provider == null) { throw GetSyncError(null, new MissingProviderException(nameof(LocalOrchestrator))); } }
public DbMigrationTools(CoreProvider provider, SyncOptions options, SyncSetup setup, string currentScopeInfoTableName = null) { this.provider = provider; this.newOptions = options; this.newSetup = setup; this.currentScopeInfoTableName = currentScopeInfoTableName; }
/// <summary> /// Create a remote orchestrator, used to orchestrates the whole sync on the server side /// </summary> public RemoteOrchestrator(CoreProvider provider) : base(provider, new SyncOptions()) { if (this.Provider != null && !this.Provider.CanBeServerProvider) { throw GetSyncError(null, new UnsupportedServerProviderException(this.Provider.GetProviderTypeName())); } }
/// <summary> /// Create a remote orchestrator, used to orchestrates the whole sync on the server side /// </summary> public RemoteOrchestrator(CoreProvider provider, SyncOptions options, SyncSetup setup, string scopeName = SyncOptions.DefaultScopeName) : base(provider, options, setup, scopeName) { if (!this.Provider.CanBeServerProvider) { throw new UnsupportedServerProviderException(this.Provider.GetProviderTypeName()); } }
/// <summary> /// Create a local orchestrator, used to orchestrates the whole sync on the client side /// </summary> public BaseOrchestrator(CoreProvider provider, SyncOptions options, SyncSetup setup, string scopeName = SyncOptions.DefaultScopeName) { this.ScopeName = scopeName ?? throw new ArgumentNullException(nameof(scopeName)); this.Provider = provider ?? throw new ArgumentNullException(nameof(provider)); this.Options = options ?? throw new ArgumentNullException(nameof(options)); this.Setup = setup ?? throw new ArgumentNullException(nameof(setup)); this.Provider.Orchestrator = this; this.Logger = options.Logger; }
/// <summary> /// SyncAgent manage both server and client provider /// It's the main object to launch the Sync process /// </summary> public SyncAgent(string scopeName, CoreProvider localProvider, IProvider remoteProvider) { if (string.IsNullOrEmpty(scopeName)) { throw new ArgumentNullException("scopeName"); } this.LocalProvider = localProvider ?? throw new ArgumentNullException("ClientProvider"); this.RemoteProvider = remoteProvider ?? throw new ArgumentNullException("ServerProvider"); this.LocalProvider.SetConfiguration(c => c.ScopeName = scopeName); this.RemoteProvider.SetConfiguration(c => c.ScopeName = scopeName); this.Parameters = new SyncParameterCollection(); }
// 4 /// <summary> /// Creates a synchronization agent that will handle a full synchronization between a client and a server. /// </summary> /// <param name="clientProvider">Local Provider connecting to your client database</param> /// <param name="serverProvider">Local Provider connecting to your server database</param> /// <param name="options">Sync Options defining options used by your local and remote provider</param> public SyncAgent(CoreProvider clientProvider, CoreProvider serverProvider, SyncOptions options = default) : this() { if (clientProvider is null) { throw new ArgumentNullException(nameof(clientProvider)); } if (serverProvider is null) { throw new ArgumentNullException(nameof(serverProvider)); } if (options == null) { options = new SyncOptions(); } // Affect local and remote orchestrators this.LocalOrchestrator = new LocalOrchestrator(clientProvider, options); this.RemoteOrchestrator = new RemoteOrchestrator(serverProvider, options); this.EnsureOptionsAndSetupInstances(); }
public async Task RunAsync(T args) { if (runFunc == null && runAction == null) { await Task.CompletedTask; } else { if (this.isAction) { runAction(args); } else { await runFunc(args); } if (args.Action == ChangeApplicationAction.Rollback) { CoreProvider.RaiseRollbackException(args.Context, "Rollback by user during a progress event"); } } }
/// <summary> /// Intercept the provider action when session begin is called /// </summary> public static void InterceptOutdated(this CoreProvider coreProvider, Action <OutdatedArgs> func) => coreProvider.SetInterceptor(func);
/// <summary> /// Intercept the provider when an apply change is failing /// </summary> public static void InterceptApplyChangesFailed(this CoreProvider coreProvider, Action <ApplyChangesFailedArgs> func) => coreProvider.SetInterceptor(func);
/// <summary> /// Intercept the provider when an apply change is failing /// </summary> public static void InterceptApplyChangesFailed(this CoreProvider coreProvider, Func <ApplyChangesFailedArgs, Task> func) => coreProvider.SetInterceptor(func);
/// <summary> /// Intercept the provider action when session end is called /// </summary> public static void InterceptSessionEnd(this CoreProvider coreProvider, Action <SessionEndArgs> func) => coreProvider.SetInterceptor(func);
/// <summary> /// Intercept the provider action when session end is called /// </summary> public static void InterceptSessionEnd(this CoreProvider coreProvider, Func <SessionEndArgs, Task> func) => coreProvider.SetInterceptor(func);
/// <summary> /// Local orchestrator used as a client /// </summary> public LocalOrchestrator(CoreProvider provider) => this.Provider = provider;
/// <summary> /// Create an agent where the remote orchestrator could be of type RemoteOrchestrator (TCP connection) or WebClientOrchestrator (Http connection) /// </summary> /// <param name="clientProvider">local provider to your client database</param> /// <param name="remoteOrchestrator">remote orchestrator : RemoteOrchestrator or WebClientOrchestrator) </param> /// <param name="setup">Contains list of your tables. Not used if remote orchestrator is WebClientOrchestrator</param> /// <param name="options">Options. Only used on locally if remote orchestrator is WebClientOrchestrator</param> public SyncAgent(CoreProvider clientProvider, IRemoteOrchestrator remoteOrchestrator, SyncSetup setup = null, SyncOptions options = null) : this(new LocalOrchestrator(clientProvider), remoteOrchestrator, setup, options) { }
public static void SetInterceptor <T>(this CoreProvider coreProvider, Func <T, Task> func) where T : ProgressArgs { coreProvider.SetInterceptor(new Interceptor <T>(func)); }
/// <summary> /// Create an agent based on TCP connection /// </summary> /// <param name="clientProvider">local provider to your client database</param> /// <param name="serverProvider">local provider to your server database</param> /// <param name="tables">tables list</param> public SyncAgent(CoreProvider clientProvider, CoreProvider serverProvider, string[] tables) : this(new LocalOrchestrator(clientProvider), new RemoteOrchestrator(serverProvider), new SyncSetup(tables)) { }
/// <summary> /// Intercept the provider when schema is readed /// </summary> public static void InterceptSchema(this CoreProvider coreProvider, Func <SchemaArgs, Task> func) => coreProvider.SetInterceptor(func);
/// <summary> /// SyncAgent manage both server and client provider /// the tables array represents the tables you want to sync /// Don't work on the proxy provider /// </summary> public SyncAgent(CoreProvider clientProvider, IProvider serverProvider, string[] tables) : this("DefaultScope", clientProvider, serverProvider, tables) { }
/// <summary> /// SyncAgent used in a web proxy sync session. No need to set tables, it's done from the server web api side. /// </summary> public SyncAgent(CoreProvider localProvider, IProvider remoteProvider) : this("DefaultScope", localProvider, remoteProvider) { }
/// <summary> /// Intercept the provider when schema is readed /// </summary> public static void InterceptSchema(this CoreProvider coreProvider, Action <SchemaArgs> func) => coreProvider.SetInterceptor(func);
/// <summary> /// Intercept the provider before it begins a database deprovisioning /// </summary> public static void InterceptDatabaseDeprovisioning(this CoreProvider coreProvider, Action <DatabaseDeprovisioningArgs> func) => coreProvider.SetInterceptor(func);
/// <summary> /// Intercept the provider action when changes are applied on each table defined in the configuration schema /// </summary> public static void InterceptTableChangesApplied(this CoreProvider coreProvider, Action <TableChangesAppliedArgs> func) => coreProvider.SetInterceptor(func);
/// <summary> /// Create an agent based on TCP connection /// </summary> /// <param name="clientProvider">local provider to your client database</param> /// <param name="serverProvider">local provider to your server database</param> /// <param name="setup">Contains list of your tables.</param> public SyncAgent(CoreProvider clientProvider, CoreProvider serverProvider, SyncSetup setup) : this(new LocalOrchestrator(clientProvider), new RemoteOrchestrator(serverProvider), setup) { }
/// <summary> /// Create a local orchestrator, used to orchestrates the whole sync on the client side /// </summary> public LocalOrchestrator(CoreProvider provider, SyncOptions options, SyncSetup setup, string scopeName = SyncOptions.DefaultScopeName) : base(provider, options, setup, scopeName) { }
/// <summary> /// Intercept the provider after it has deprovisioned a database /// </summary> public static void InterceptDatabaseDeprovisioned(this CoreProvider coreProvider, Func <DatabaseDeprovisionedArgs, Task> func) => coreProvider.SetInterceptor(func);