// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseHsts(); } app.UseCors(ApiAllowSpecificOrigins); app.UseHttpsRedirection(); app.UseMvc(); Api = new Api() { Url = Configuration["Api:Url"], Key = Configuration["Api:Key"], ImageUrl = Configuration["Api:ImageUrl"] }; var sync = new Sync(); _ = sync.Execute(); }
private void SynchronizeIfNecessary() { bool enableSync = Convert.ToInt16(context.Ini["offline"]["sync"]) != 0; if (enableSync) { bool enableFullCopy = Convert.ToInt16(context.Ini["offline"]["alwaysFullCopy"]) != 0; DirectoryInfo derbyDir = new DirectoryInfo("azusaOffline"); if (enableFullCopy) { RecursiveDeletion(derbyDir); } try { context.Splash.SetLabel("Bereite Synchronisation vor..."); derbyDir.Refresh(); IDatabaseDriver offlineDriver = new OfflineDriver(); Sync azusync = new Sync(context.DatabaseDriver, offlineDriver); azusync.Message += Azusync_Message; azusync.Execute(); offlineDriver.Dispose(); } catch (SyncException e) { MessageBox.Show(String.Format("Synchronisation fehlgeschlagen!\n\n{0}", e)); } } }
private static bool ParseSync(string[] args) { if (args.Contains("connect")) { _settings = new SyncSettings(); if (!args.Contains("-n")) { SyncStorage.LoadSettings(_settings); } Connect(); return(true); } if (_sync != null && _sync.IsConnected) { if (args.Contains("disconnect")) { Disconnect(); Log("Session disconnected!"); return(true); } if (args.Contains("execute") | args.Contains("exec") | args.Contains("->")) { return(ParseArguments(args, (x) => { var result = _sync.Execute(x); Log(string.Format(result.IsSuccess ? string.Format("({0}>\"{1}\")", _settings.Hostname, (result.Output != null ? result.Output : "")) : "Execution Failed: \"{0}\"", result.ErrorOutput), result.IsSuccess ? SyncLog.LogType.Info : SyncLog.LogType.Error); })); } if (args.Contains("sync")) { return(ParseArguments(args, (x) => { if (x.Length == 3) { WinSCP.SynchronizationResult result = null; if (x.Contains("--local")) { result = _sync.Synchronize(WinSCP.SynchronizationMode.Local, x[1], x[2], x.Length == 4 ? x[3] : ""); } if (x.Contains("--remote")) { } if (x.Contains("--both")) { } PrintResults(result); } else { Log("Command: \"sync -l\" has missing parameters!", SyncLog.LogType.Error); } })); } } return(false); }