I am working on an app that is using Synchronization Framework v2. I am basically done with it, but would like to offer some better fedback about the progress of the synchronization. I was looking at one of the Synchframework examples that Microsoft offers, SharingAppDemo-CEProviderEndToEnd, and see that the have a method in the ProgressForm that takes a SyncStagedProgressEventArgs and converts it to DbSyncSessionProgressEventArgs which makes sense because DbSyncSessionProgressEventArgs inherits from SyncStagedProgressEventArgs, but when I try this I always get an error saying that implicit conversion failed.
Am I missing something or is this conversion really not possible?
Thanks!
Method in ProgressForm
public void ProgressChanged(SyncStagedProgressEventArgs args)
{
string message = "";
listSyncProgress.Items.Add(message);
try
{
DbSyncSessionProgressEventArgs sessionProgress = (DbSyncSessionProgressEventArgs)args;
DbSyncScopeProgress progress = sessionProgress.GroupProgress;
switch (sessionProgress.DbSyncStage)
{
case DbSyncStage.SelectingChanges:
message += "Sync Stage: Selecting Changes";
listSyncProgress.Items.Add(message);
foreach (DbSyncTableProgress tableProgress in progress.TablesProgress)
{
message = "Enumerated changes for table: " + tableProgress.TableName;
message += "[Inserts:" + tableProgress.Inserts.ToString() + "/Updates :" + tableProgress.Updates.ToString() + "/Deletes :" + tableProgress.Deletes.ToString() + "]";
listSyncProgress.Items.Add(message);
}
break;
case DbSyncStage.ApplyingChanges:
message += "Sync Stage: Applying Changes";
listSyncProgress.Items.Add(message);
foreach (DbSyncTableProgress tableProgress in progress.TablesProgress)
{
message = "Applied changes for table: " + tableProgress.TableName;
message += "[Inserts:" + tableProgress.Inserts.ToString() + "/Updates :" + tableProgress.Updates.ToString() + "/Deletes :" + tableProgress.Deletes.ToString() + "]";
listSyncProgress.Items.Add(message);
}
break;
default:
break;
}
message = "Total Changes : " + progress.TotalChanges.ToString() + " Inserts :" + progress.TotalInserts.ToString();
message += " Updates :" + progress.TotalUpdates.ToString() + " Deletes :" + progress.TotalDeletes.ToString();
listSyncProgress.Items.Add(message);
}
catch (Exception e)
{
throw e;
}
message = "Completed : " + args.CompletedWork + "%";
listSyncProgress.Items.Add(message);
Application.DoEvents();
}