private void SyncCompletedCallback(IAsyncResult ar) { try { SqlCeReplication repl = (SqlCeReplication)ar.AsyncState; repl.EndSynchronize(ar); repl.SaveProperties(); string result = "Successfully completed sync" + Environment.NewLine; result += string.Format("Number of changes downloaded: {0}{1}", repl.PublisherChanges.ToString(), Environment.NewLine); result += string.Format("Number of changes uploaded: {0}{1}", repl.SubscriberChanges.ToString(), Environment.NewLine); result += string.Format("Number of conflicts at Publisher: {0}{1}", repl.PublisherConflicts.ToString(), Environment.NewLine); #if V40 SyncArgs4 args = new SyncArgs4(result, null); #else SyncArgs args = new SyncArgs(result, null); #endif Completed(this, args); } catch (SqlCeException e) { #if V40 SyncArgs4 args = new SyncArgs4("Errors occured during sync", e); #else SyncArgs args = new SyncArgs("Errors occured during sync", e); #endif Completed(this, args); } }
private void OnStartTableDownloadCallback(IAsyncResult ar, string tableName) { this.tableName = tableName; var args = new SyncArgs("Began downloading table : " + tableName, null); Progress(this, args); }
private void OnSynchronizationCallback(IAsyncResult ar, int percentComplete) { this.percentage = percentComplete; var args = new SyncArgs("Sync with SQL Server is " + percentage.ToString() + "% complete.", null); Progress(this, args); }
private void SyncCompletedEvent(object sender, SyncArgs e) { _sync.Completed -= SyncCompletedEvent; _sync.Progress -= SyncProgressEvent; _syncArgs = e; Invoke(_myStatusEvent); }
private void OnStartTableUploadCallback(IAsyncResult ar, string tableName) { this.tableName = tableName; #if V40 var args = new SyncArgs4("Began uploading table : " + tableName, null); #else var args = new SyncArgs("Began uploading table : " + tableName, null); #endif Progress(this, args); }
private void OnStartTableDownloadCallback(IAsyncResult ar, string tableName) { this.tableName = tableName; #if V40 var args = new SyncArgs4("Began downloading table : " + tableName, null); #else var args = new SyncArgs("Began downloading table : " + tableName, null); #endif Progress(this, args); }
private void OnSynchronizationCallback(IAsyncResult ar, int percentComplete) { this.percentage = percentComplete; #if V40 var args = new SyncArgs4("Sync with SQL Server is " + percentage.ToString() + "% complete.", null); #else var args = new SyncArgs("Sync with SQL Server is " + percentage.ToString() + "% complete.", null); #endif Progress(this, args); }
public string Sync(SyncArgs args) { Dictionary<string, object> results = new Dictionary<string, object>(); try { PTLocalPatient p = PTDatabase.GetPatient(args.authentication.email, args.authentication.password); if (p == null) { results["error"] = "Invalid username or password."; } else { List<PTProtocol> protocols = PTDatabase.GetProtocolsForPatient(p.ID); results["patient"] = p; results["protocols"] = protocols; if (protocols.Count() > 0) { results["messages"] = PTDatabase.GetMessages(protocols.First().ID, args.lastTime); Dictionary<string, string> images = new Dictionary<string, string>(); foreach (PTMessage message in (List<PTMessage>)results["messages"]) { if (!string.IsNullOrEmpty(message.imageName)) { try { byte[] data = System.IO.File.ReadAllBytes(PTDatabase.PathForImageNamed(message.imageName, false)); images.Add(message.imageName, Convert.ToBase64String(data)); } catch { } } } results["images"] = images; } } } catch (Exception e) { results["error"] = e.Message; } return s.Serialize(results); }
public string Login(PTLocalPatient patient) { try { SyncArgs args = new SyncArgs(); args.authentication = new Auth(); args.authentication.email = patient.email; args.authentication.password = patient.password; args.lastTime = 0; return Sync(args); } catch (Exception e) { return e.Message; } }
private void OnStartTableUploadCallback(IAsyncResult ar, string tableName) { this.tableName = tableName; var args = new SyncArgs("Began uploading table : " + tableName, null); Progress(this, args); }
private void SyncProgressEvent(object sender, SyncArgs e) { _syncArgs = e; Invoke(_myStatusEvent); }