/// <summary> /// Backups the data. /// </summary> /// <param name="option">The option.</param> /// <param name="callBack">The call back.</param> /// <returns></returns> public DataBackupedFromPhone BackupData(BackupDataOption option, Action<DataSynchronizationInfo> callBack) { var data = string.Empty; //todo:Test: DataBackupedFromPhone result = new DataBackupedFromPhone(); if (ToBackupDataBase) { result.SdfFileContent = ExtractDataFromSdb(); result.CategoryListXmlSource = "accountBook_database_v{0}.0.sdf".FormatWith(DatabaseVersion.LatestVersion); result.AppSettingXmlSource = "This is sdf file content. only for database version : " + DatabaseVersion.LatestVersion; } else { data = dataContextDataHandler.BackupData(); result.AccountItemXmlSource = data; } if (callBack != null) callBack(dataContextDataHandler.DataSynchronizationDataArg); return result; }
private void client_GetDataCompleted(object sender, GetDataCompletedEventArgs e) { if (e.Error != null) { this.ProcessError(this.connectingServerStep, e.Error); } else { this.connectingServerStep.Success(); this.datatransferingStep.Start(); if (this.SyncActionPicker.SelectedIndex == 0) { try { DataSynchronizationInfo data = null; BackupDataOption option = new BackupDataOption { TotalEffects = 0, DbFileNameTobackup = DataSynchronizationHandler.DatabaseFileToBackup, }; DataBackupedFromPhone phone = this.dataSynchronizationHandler.BackupData(option, delegate(DataSynchronizationInfo callBack) { data = callBack; }); DataSynchronizationArgs arg = new DataSynchronizationArgs { AccountItemListXmlSource = phone.AccountItemXmlSource, AppSettingsXmlSource = data.GetMessage(), CategoryListXmlSource = phone.CategoryListXmlSource, SdfFileContent = phone.SdfFileContent }; this.serverProxy.BackupAsync(arg, data); } catch (System.Exception exception) { this.ProcessError(this.datatransferingStep, exception); } } else { int selectedIndex = this.CoverOrAppendPicker.SelectedIndex; this.dataSynchronizationHandler.RestoreOption = (selectedIndex == 0) ? ActionOption.Cover : ActionOption.Append; this.serverProxy.RestoreAsync((selectedIndex == 0) ? DataSynchronizationActionOption.Cover : DataSynchronizationActionOption.Append); } } }