private void ReplicationStatusUpdate(object sender, ReplicatorStatusChangedEventArgs args) { //The replication is finished or hit a fatal error. if (args.Status.Activity == ReplicatorActivityLevel.Stopped) { ConnectionStatus = "DISCONNECTED"; ConnectionStatusColor = Color.Black; }//The replicator is offline as the remote host is unreachable. else if (args.Status.Activity == ReplicatorActivityLevel.Offline) { ConnectionStatus = "OFFLINE"; ConnectionStatusColor = Color.Red; } //The replicator is connecting to the remote host. else if (args.Status.Activity == ReplicatorActivityLevel.Connecting) { ConnectionStatus = "CONNECTING"; ConnectionStatusColor = Color.Red; } //The replication caught up with all the changes available from the server. //The IDLE state is only used in continuous replications. else if (args.Status.Activity == ReplicatorActivityLevel.Idle) { ConnectionStatus = "CONNECTED"; ConnectionStatusColor = Color.Green; } //The replication is actively transferring data. else if (args.Status.Activity == ReplicatorActivityLevel.Busy) { ConnectionStatus = "BUSY"; ConnectionStatusColor = Color.Green; } }
private void _replicator_StatusChanged(object sender, ReplicatorStatusChangedEventArgs e) { MessagingCenter.Send(new ReplicatorStatusMessage(e.Status, _replicator.Status.Error?.Message), "REPLICATOR_STATUS"); if (_replicator.Status.Error != null) { #if DEBUG #endif MessagingCenter.Send(new ReplicatorStatusMessage(e.Status, _replicator.Status.Error?.Message), "REPLICATOR_RESTART"); } }
private void VerifyChange(ReplicatorStatusChangedEventArgs change, int errorCode, C4ErrorDomain domain) { var s = change.Status; WriteLine($"---Status: {s.Activity} ({s.Progress.Completed} / {s.Progress.Total}), lastError = {s.Error}"); if (s.Activity == ReplicatorActivityLevel.Stopped) { if (errorCode != 0) { s.Error.Should().BeAssignableTo <LiteCoreException>(); var error = s.Error.As <LiteCoreException>().Error; error.code.Should().Be(errorCode); if ((int)domain != 0) { error.domain.As <C4ErrorDomain>().Should().Be(domain); } } else { s.Error.Should().BeNull("because otherwise an unexpected error occurred"); } } }
void OnReplicatorUpdate(object sender, ReplicatorStatusChangedEventArgs e) { var status = e.Status; switch (status.Activity) { case ReplicatorActivityLevel.Busy: Console.WriteLine("Busy transferring data."); break; case ReplicatorActivityLevel.Connecting: Console.WriteLine("Connecting to Sync Gateway."); break; case ReplicatorActivityLevel.Idle: Console.WriteLine("Replicator in idle state."); break; case ReplicatorActivityLevel.Offline: Console.WriteLine("Replicator in offline state."); break; case ReplicatorActivityLevel.Stopped: Console.WriteLine("Completed syncing documents."); break; } if (status.Progress.Completed == status.Progress.Total) { Console.WriteLine("All documents synced."); } else { Console.WriteLine($"Documents {status.Progress.Total - status.Progress.Completed} still pending sync"); } }