private void Puller_Changed(object sender, ReplicationChangeEventArgs e) { Toast.MakeText(this, "puller count" + pullercount, ToastLength.Short).Show(); messagesList.Clear(); GetItems(); mListView.SetSelection(mListView.Adapter.Count - 1); }
public void Changed(object sender, ReplicationChangeEventArgs args) { if (args.Status == ReplicationStatus.Stopped && doneSignal.CurrentCount > 0) { doneSignal.Signal(); } }
protected bool IsProcessing(object sender, ReplicationChangeEventArgs e) { if (pull.Status == ReplicationStatus.Active) { Console.WriteLine("Sync in progress"); return(true); } else if (e.LastError != null) { Exception error = e.LastError; if (error is HttpResponseException) { HttpResponseException exception = (HttpResponseException)error; if ((int)exception.StatusCode == 401) { Console.WriteLine("Authentication error"); } } return(true); } else { return(false); } }
internal static XDocument ReplicationChangeEventArgsToXml(ReplicationChangeEventArgs changeEvent) { var json = ReplicationChangeEventArgsToJson(changeEvent); string toto = json.ToString(); var xml = C8oFullSyncTranslator.FullSyncJsonToXml(json); return(xml); }
public void Changed(ReplicationChangeEventArgs args) { var replicator = args.Source; if (replicator.LastError != null) { doneSignal.CountDown(); } }
public void Changed(ReplicationChangeEventArgs args) { var replicator = args.Source; if (replicator.Status == ReplicationStatus.Stopped) { doneSignal.CountDown(); } }
//configs protected override void PullChanged(object sender, ReplicationChangeEventArgs e) { if (!IsProcessing(sender, e)) { //Start Syncing Couchbase Document to Objects Staff staff = RemoteStaffSystem.GetInstance().LoginModule.LoggedInStaff; syncContract(staff); Console.WriteLine("Done Syncing!"); } }
private void ReplicationChanged(object sender, ReplicationChangeEventArgs args) { if (args.Source.CompletedChangesCount < args.Source.ChangesCount) { return; } Changed -= ReplicationChanged; FinishStopping(); }
// This method is called when an observed replication changes private void ReplicationChanged(object sender, ReplicationChangeEventArgs e) { var replication = (Replication)sender; if(replication.LocalDatabase.Manager == DbManager) { if(!Response.SendContinuousLine(replication.ActiveTaskInfo, ChangesFeedMode)) { replication.Changed -= ReplicationChanged; CouchbaseLiteRouter.ResponseFinished(this); } } }
public void Changed(object sender, ReplicationChangeEventArgs args) { if (replicationFinished) { return; } var replicator = args; LiteTestCase.WriteDebug(replicator + " changed: " + replicator.CompletedChangesCount + " / " + replicator.ChangesCount); if (replicator.CompletedChangesCount < 0) { var msg = replicator + ": replicator.CompletedChangesCount < 0"; Console.WriteLine(msg); throw new Exception(msg); } if (replicator.ChangesCount < 0) { var msg = replicator + ": replicator.ChangesCount < 0"; Console.WriteLine(msg); throw new Exception(msg); } if (replicator.CompletedChangesCount > replicator.ChangesCount) { var msgStr = "replicator.CompletedChangesCount : " + replicator.CompletedChangesCount + " > replicator.ChangesCount : " + replicator.ChangesCount; Console.WriteLine(msgStr); throw new Exception(msgStr); } if (args.Status == ReplicationStatus.Idle || args.Status == ReplicationStatus.Stopped) { this.replicationFinished = true; string msg = "ReplicationFinishedObserver.changed called, set replicationFinished to true"; LiteTestCase.WriteDebug(msg); if (doneSignal.CurrentCount > 0) { doneSignal.Signal(); } args.Source.Changed -= Changed; } else { string msg = string.Format("ReplicationFinishedObserver.changed called, but replicator still running, so ignore it"); LiteTestCase.WriteDebug(msg); } }
void NotifyChangeListeners() { var evt = Changed; if (evt == null) { return; } var args = new ReplicationChangeEventArgs(this); evt(this, args); }
// This method is called when an observed replication changes private void ReplicationChanged(object sender, ReplicationChangeEventArgs e) { var replication = (Replication)sender; if (replication.LocalDatabase.Manager == DbManager) { if (!Response.SendContinuousLine(replication.ActiveTaskInfo, ChangesFeedMode)) { replication.Changed -= ReplicationChanged; CouchbaseLiteRouter.ResponseFinished(this); } } }
// Called when the observed replication changes private void ReplicationChanged (object sender, ReplicationChangeEventArgs e) { var replication = (Replication)sender; replication.Changed -= ReplicationChanged; if (replication.Status == ReplicationStatus.Stopped) { Response.InternalStatus = replication.LastError == null ? StatusCode.Ok : StatusCode.InternalServerError; Response.WriteHeaders(); Response.JsonBody = new Body(new NonNullDictionary<string, object> { { "ok", replication.LastError != null ? (bool?)true : null }, { "session_id", replication.sessionID } }); Response.WriteToContext(); } }
private static void HandleReplicationChanged(object sender, ReplicationChangeEventArgs args) { var error = Interlocked.Exchange(ref _syncError, args.LastError); if (error != args.LastError) { var errorCode = (args.LastError as CouchbaseLiteException)?.CBLStatus?.Code ?? (StatusCode?)(args.LastError as HttpResponseException)?.StatusCode; if (errorCode == StatusCode.Unauthorized) { Mvx.Resolve <IUserDialogs>().AlertAsync("Your username or password is not correct.", "Authorization failed"); } } }
private void OnChanged(object sender, ReplicationChangeEventArgs args) { Console.WriteLine($"Replication change status {args.Status} [{args.Source}]"); _changedHandler?.Invoke(args.Source); var error = _pull?.LastError; if (error != null && error != _syncError) { _syncError = error; DisplayAlert("Error", _syncError.ToString(), "OK"); _pull?.ClearAuthenticationStores(); } }
public void ReplicationChanged(object sender, ReplicationChangeEventArgs args) { Couchbase.Lite.Util.Log.D(Tag, "Replication Changed: {0}", args); var replicator = args.Source; var totalCount = replicator.ChangesCount; var completedCount = replicator.CompletedChangesCount; if (totalCount > 0 && completedCount < totalCount) { SetProgressBarIndeterminateVisibility(true); } else { SetProgressBarIndeterminateVisibility(false); } }
public void Changed(object sender, ReplicationChangeEventArgs args) { if (replicationFinished) { return; } var replicator = args.Source; Log.D(Tag, replicator + " changed: " + replicator.CompletedChangesCount + " / " + replicator.ChangesCount); if (replicator.CompletedChangesCount < 0) { var msg = replicator + ": replicator.CompletedChangesCount < 0"; Log.E(Tag, msg); throw new Exception(msg); } if (replicator.ChangesCount < 0) { var msg = replicator + ": replicator.ChangesCount < 0"; Log.E(Tag, msg); throw new Exception(msg); } if (replicator.CompletedChangesCount > replicator.ChangesCount) { var msgStr = "replicator.CompletedChangesCount : " + replicator.CompletedChangesCount + " > replicator.ChangesCount : " + replicator.ChangesCount; Log.E(Tag, msgStr); throw new Exception(msgStr); } if (!replicator.IsRunning) { this.replicationFinished = true; string msg = "ReplicationFinishedObserver.changed called, set replicationFinished to true"; Log.D(Tag, msg); doneSignal.Signal(); replicator.Changed -= Changed; } else { string msg = string.Format("ReplicationFinishedObserver.changed called, but replicator still running, so ignore it"); Log.D(Tag, msg); } }
// Called when the observed replication changes private void ReplicationChanged(object sender, ReplicationChangeEventArgs e) { var replication = (Replication)sender; if (replication.Status == ReplicationStatus.Stopped) { replication.Changed -= ReplicationChanged; Response.InternalStatus = replication.LastError == null ? StatusCode.Ok : StatusCode.InternalServerError; Response.WriteHeaders(); Response.JsonBody = new Body(new NonNullDictionary <string, object> { { "ok", replication.LastError != null ? (bool?)true : null }, { "session_id", replication.sessionID } }); Response.WriteToContext(); } }
private void OnPushChanged(object sender, ReplicationChangeEventArgs replicationChangeEventArgs) { switch (replicationChangeEventArgs.ReplicationStateTransition.Destination) { case ReplicationState.Idle: var id = AddDoc(); AddAttachment(id); break; } RunOnUiThread( () => InsertInfo(replicationChangeEventArgs.ReplicationStateTransition.Destination.ToString(), DateTime.Now.ToString(CultureInfo.CurrentCulture))); RunOnUiThread(() => _numberGenerated.Text = $"Documents generated: {_count}"); }
public void ReplicationChanged(object sender, ReplicationChangeEventArgs args) { Couchbase.Lite.Util.Log.D(Tag, "Replication Changed: {0}", args); var replicator = args.Source; var totalCount = replicator.ChangesCount; var completedCount = replicator.CompletedChangesCount; if (totalCount > 0 && completedCount < totalCount) { // update progress } else { // hide progress } }
//*** ChangeEvent ***// //*** Sync, ReplicatePull, ReplicatePush ***// internal static JObject ReplicationChangeEventArgsToJson(ReplicationChangeEventArgs changeEvent) { var json = new JObject(); // Change count (total) json[C8oFullSyncTranslator.FULL_SYNC_RESPONSE_KEY_TOTAL] = changeEvent.Source.ChangesCount; // Completed change count (current) json[C8oFullSyncTranslator.FULL_SYNC_RESPONSE_KEY_CURRENT] = changeEvent.Source.CompletedChangesCount; // Progress // ??? // Direction if (changeEvent.Source.IsPull) { json[C8oFullSyncTranslator.FULL_SYNC_RESPONSE_KEY_DIRECTION] = C8oFullSyncTranslator.FULL_SYNC_RESPONSE_VALUE_DIRECTION_PULL; } else { json[C8oFullSyncTranslator.FULL_SYNC_RESPONSE_KEY_DIRECTION] = C8oFullSyncTranslator.FULL_SYNC_RESPONSE_VALUE_DIRECTION_PUSH; } // Status (ok) if (changeEvent.Source.LastError == null) { json[C8oFullSyncTranslator.FULL_SYNC_RESPONSE_KEY_OK] = true; } else { json[C8oFullSyncTranslator.FULL_SYNC_RESPONSE_KEY_OK] = false; } if (changeEvent.Source.DocIds != null) { json["docids"] = changeEvent.Source.DocIds.ToString(); } json["taskInfo"] = C8oFullSyncTranslator.DictionaryToString(changeEvent.Source.ActiveTaskInfo); json["status"] = "" + changeEvent.Source.Status; return(json); }
protected override void PullChanged(object sender, ReplicationChangeEventArgs e) { if (!IsProcessing(sender, e)) { } }
public void ReplicationChanged(ReplicationDriverContext context, ReplicationChangeEventArgs eventArgs) { }
public void ReplicationChanged(ReplicationDriverContext context, ReplicationChangeEventArgs eventArgs) { //if(eventArgs.LastError != null) // context.Abort(eventArgs.LastError.Message, eventArgs.LastError.ToString()); }
void ReplicationProgress(object replication, ReplicationChangeEventArgs args) { var active = args.Source; Debug.WriteLine(String.Format("Push: {0}, Pull: {1}", push.Status, pull.Status)); int lastTotal = 0; if (_leader == null) { if (active.IsPull && (pull.Status == ReplicationStatus.Active && push.Status != ReplicationStatus.Active)) { _leader = pull; } else if (!active.IsPull && (push.Status == ReplicationStatus.Active && pull.Status != ReplicationStatus.Active)) { _leader = push; } else { _leader = null; } } if (active == pull) { lastTotal = _lastPullCompleted; } else { lastTotal = _lastPushCompleted; } Debug.WriteLine(String.Format("Sync: {2} Progress: {0}/{1};", active.CompletedChangesCount - lastTotal, active.ChangesCount - lastTotal, active == push ? "Push" : "Pull")); var progress = (float)(active.CompletedChangesCount - lastTotal) / (float)(Math.Max(active.ChangesCount - lastTotal, 1)); ShowSyncStatus(); Debug.WriteLine(String.Format("({0:F})", progress)); if (active == pull) { Progress.TintColor = UIColor.White; } else { Progress.TintColor = UIColor.LightGray; } Progress.Hidden = false; if (progress < Progress.Progress) { Progress.SetProgress(progress, false); } else { Progress.SetProgress(progress, false); } if (!(pull.Status != ReplicationStatus.Active && push.Status != ReplicationStatus.Active)) { if (progress < 1f) { return; } } if (active == null) { return; } var initiatorName = active.IsPull ? "Pull" : "Push"; _lastPushCompleted = push.ChangesCount; _lastPullCompleted = pull.ChangesCount; if (Progress == null) { return; } Progress.Hidden = false; Progress.SetProgress(1f, false); var t = new System.Timers.Timer(300); t.Elapsed += (sender, e) => { InvokeOnMainThread(() => { t.Dispose(); Progress.Hidden = true; Progress.SetProgress(0f, false); Debug.WriteLine(String.Format("{0} Sync Session Finished.", initiatorName)); ShowSyncButton(); }); }; t.Start(); }
private void Pull_Changed(object sender, ReplicationChangeEventArgs e) { Console.WriteLine("Pull: " + e.Status, " " + e.ChangesCount); }
protected abstract void PullChanged(object sender, ReplicationChangeEventArgs e);
private void ReplicationProgress(object replication, ReplicationChangeEventArgs args) { if (args.Source.LastError != null) { var httpError = args.Source.LastError as HttpResponseException; if (httpError != null && httpError.StatusCode == System.Net.HttpStatusCode.Unauthorized) { LoginValid = false; // TODO : Notify user about login failed return; } } else { LoginValid = true; } var active = args.Source; Debug.WriteLine(String.Format("Push: {0}, Pull: {1}", push.Status, pull.Status)); int lastTotal = 0; if (_leader == null) { if (active.IsPull && (pull.Status == ReplicationStatus.Active && push.Status != ReplicationStatus.Active)) { _leader = pull; } else if (!active.IsPull && (push.Status == ReplicationStatus.Active && pull.Status != ReplicationStatus.Active)) { _leader = push; } else { _leader = null; } } if (active == pull) { lastTotal = lastPullCompleted; } else { lastTotal = lastPushCompleted; } Debug.WriteLine( String.Format( "Sync: {2} Progress: {0}/{1};", active.CompletedChangesCount - lastTotal, active.ChangesCount - lastTotal, active == push ? "Push" : "Pull")); var progress = (float)(active.CompletedChangesCount - lastTotal) / (float)(Math.Max(active.ChangesCount - lastTotal, 1)); Debug.WriteLine(String.Format("({0:F})", progress)); if (!(pull.Status != ReplicationStatus.Active && push.Status != ReplicationStatus.Active)) { if (progress < 1f) { return; } } if (active == null) { return; } lastPushCompleted = push.ChangesCount; lastPullCompleted = pull.ChangesCount; }