internal void ProvisionTriggerAndProcedureUpdates(SyncDatabase db, SqlConnection connection, DbSyncScopeDescription scopeDesc) { var provision = new SqlSyncScopeProvisioning(connection, scopeDesc); if (provision.ScopeExists(scopeDesc.ScopeName)) { try { Log.Info("[DistributedDb] Provision Scope Trigger And Procedure Updates [" + scopeDesc.ScopeName + "] Start", this); provision.SetCreateTableDefault(DbSyncCreationOption.Skip); provision.CommandTimeout = 3600; provision.ApplyTriggerAndProcedureUpdates(connection); Log.Info("[DistributedDb] Provision Scope Trigger And Procedure Updates [" + scopeDesc.ScopeName + "] End", this); } catch (Exception ex) { Log.Error("[DistributedDb] Provision Scope Trigger And Procedure Updates [" + scopeDesc.ScopeName + "] Error", ex, this); } } else { Log.Info("[DistributedDb] Provision Scope Trigger And Procedure Updates [" + scopeDesc.ScopeName + "] Skipped", this); } }
public DbSyncProvider(IDbConnection Connection, string Name) { log.Debug("ctor"); this._Db = new SyncDatabase(Connection); this._Name = Name; Configuration.ConflictResolutionPolicy = ConflictResolutionPolicy.SourceWins; // установка значений форматов идентификаторов idFormats = new SyncIdFormatGroup(); // для идентификаторов изменений используется BIGINT (2^64) IdFormats.ChangeUnitIdFormat.Length = 64; // filter-id какие то, пока не знаю что это IdFormats.FilterIdFormat.Length = 64; // идентификатор элементов IdFormats.ItemIdFormat.Length = 256; IdFormats.ItemIdFormat.IsVariableLength = true; IdFormats.ReplicaIdFormat.Length = 300; IdFormats.ReplicaIdFormat.IsVariableLength = true; // создание таблицы, которая будет использована для сбора информации о синхронизации tableSyncLog = new DataTable(); log.Debug("ctor finished"); }
public void UpdateRootMatchesInput() { var expected = JToken.Parse(_weather); var client = A.Fake <IFirebaseNetworkConnection>(); A.CallTo(() => client.Send(A <FirebaseMessage> ._)).Invokes((FirebaseMessage message) => { Assert.AreEqual(WriteBehavior.Merge, message.Behavior); Assert.AreEqual(new FirebasePath(), message.Path); Assert.IsTrue(JToken.DeepEquals(expected, JToken.Parse(message.Value)), "The contents being written did not match the provided contents"); message.Callback(null); }); var jc = new SyncDatabase(null, client); using (var mre = new ManualResetEvent(false)) { jc.Update(new FirebasePath(), _weather, (error) => { mre.Set(); }); Assert.IsTrue(mre.WaitOne(TimeSpan.FromSeconds(5)), "Time out waiting for cache callback"); } Assert.IsTrue(JToken.DeepEquals(expected, JToken.Parse(jc.Dump())), "The cache contents did not match the expected structure"); }
internal void Deprovision(SyncDatabase db, SqlConnection connection, DbSyncScopeDescription scopeDesc) { this.GetDescriptionForTables(db.Tables, connection, ref scopeDesc); var provision = new SqlSyncScopeProvisioning(connection, scopeDesc); if (provision.ScopeExists(scopeDesc.ScopeName)) { try { var deprovision = new SqlSyncScopeDeprovisioning(connection); Log.Info("[DistributedDb] Deprovision Scope [" + scopeDesc.ScopeName + "] Start", this); deprovision.DeprovisionScope(scopeDesc.ScopeName); Log.Info("[DistributedDb] Deprovision Scope [" + scopeDesc.ScopeName + "] End", this); } catch (Exception ex) { Log.Error("[DistributedDb] Deprovision Scope [" + scopeDesc.ScopeName + "] Error", ex, this); } } else { Log.Info("[DistributedDb] Deprovision Scope [" + scopeDesc.ScopeName + "] Skipped", this); } }
public override IDbCommand CreateSpecialCommand(SyncDatabase db, SyncDatabaseVendorCommandMode mode, params object[] args) { if (mode == SyncDatabaseVendorCommandMode.UpdateOrInsertTable) { return(GetInsertOrUpdateCommand2(db, args[0] as SyncTable, args[1] as DataTable, args[2] as List <string>)); } return(null); }
private static void ExecSql(SyncDatabase db, string sql) { using (IDbCommand cmd = db.CreateCommand()) { cmd.CommandText = sql; object o = cmd.ExecuteScalar(); } }
public SyncDatabase GetDatabase() { SyncDatabase db = new SyncDatabase(this.Configuration.RelationshipId); db.Configuration.ProxyCreationEnabled = false; return(db); }
// - - - - - - - - - - - - - - - - - - - - private FbCommand GetInsertOrUpdateCommand(SyncDatabase db, SyncTable syncTable, DataTable dataTable, List <string> excludeFields) { FbCommand cmd = db.CreateCommand() as FbCommand; CreateInsertOrUpdateStoredProc(db, syncTable, dataTable, excludeFields); StringBuilder sb = new StringBuilder(string.Format("select rows_affected from {0}(", get_sp_name())); int cc = 0; foreach (DataColumn col in syncTable.Columns) { if (col.ColumnName != Const.Field_LOG_ID) { if (cc++ > 0) { sb.Append(","); } sb.Append("@"); sb.Append(col.ColumnName); } } foreach (string key_col in syncTable.KeyColumns) { if (cc++ > 0) { sb.Append(","); } sb.Append("@"); sb.Append(key_col); } sb.Append(");"); cmd.CommandText = sb.ToString(); foreach (DataColumn col in syncTable.Columns) { if (col.ColumnName != Const.Field_LOG_ID) { CreateParameter(cmd, col, col.ColumnName); } } foreach (string key_col in syncTable.KeyColumns) { DataColumn col = dataTable.Columns[key_col]; if (col.ColumnName != Const.Field_LOG_ID) { CreateParameter(cmd, col, "PK_" + col.ColumnName); } } return(cmd); }
private string GetColumnsInfoForExecuteBlock(SyncDatabase db, string table_name, SyncTable table) { string sql = @"select rtrim(rf.rdb$field_name), CASE rtrim(t.rdb$type_name) WHEN 'LONG' THEN 'INTEGER' WHEN 'VARYING' THEN 'VARCHAR' WHEN 'DOUBLE' THEN 'DOUBLE PRECISION' WHEN 'SHORT' THEN 'SMALLINT' WHEN 'TEXT' THEN 'CHAR' WHEN 'INT64' THEN iif(f.rdb$field_scale = 0, 'BIgINt', 'NUMERIC(' || cast(f.rdb$field_precision as varchar(10)) || ',' || cast(-f.rdb$field_scale as varchar(10)) || ')') ELSE rtrim(t.rdb$type_name) END || iif(rtrim(t.rdb$type_name) = 'VARYING', '(' || f.rdb$field_length || ')', '') || iif(rtrim(t.rdb$type_name) = 'TEXT', '(' || f.rdb$field_length || ')', '') || iif(rtrim(t.rdb$type_name) = 'BLOB', iif(f.rdb$field_sub_type is not null, ' SUB_TYPE ' || f.rdb$field_sub_type, '') || iif(f.rdb$segment_length is not null,' SEGMENT SIZE ' || f.rdb$segment_length, ''), '') type_name from rdb$relation_fields rf left join rdb$fields f on f.rdb$field_name = rf.rdb$field_source left join rdb$types t on t.rdb$type = f.rdb$field_type and t.rdb$field_name = 'RDB$FIELD_TYPE' where rf.rdb$relation_name = upper(@table_name) and f.rdb$computed_blr is null order by rdb$field_position"; StringBuilder sb = new StringBuilder(1024); StringBuilder sb_key = new StringBuilder(100); FbCommand cmd = db.CreateCommand() as FbCommand; cmd.CommandText = sql; cmd.Parameters.Add("@table_name", FbDbType.VarChar).Value = table_name; using (FbDataReader reader = cmd.ExecuteReader()) while (reader.Read()) { if (sb.Length > 0) { sb.Append(", "); } string col_name = reader[0].ToString(); string col_type = reader[1].ToString(); if (table.KeyColumns.Contains(col_name)) { if (sb_key.Length > 0) { sb_key.Append(", "); } sb_key.AppendFormat("PK_{0} {1} = @PK_{0}", col_name, col_type); } sb.AppendFormat("{0} {1} = @{0}", col_name, col_type); } sb.Append(","); sb.Append(sb_key.ToString()); return(sb.ToString()); }
private bool IsTableExists(string proc_name, SyncDatabase db) { using (FbCommand cmd = db.CreateCommand() as FbCommand) { cmd.CommandText = "select count(*) from rdb$relations where rdb$relation_name = @name"; cmd.Parameters.Add("@name", FbDbType.VarChar).Value = proc_name.ToUpper(); return(Convert.ToInt32(cmd.ExecuteScalar()) > 0); } }
private void deleteAccountButton_Click(object sender, RoutedEventArgs e) { SecureStorage secure = new SecureStorage(_group, _email); secure.Delete(); SyncDatabase.Delete(_email); (Parent as Panel).Children.Remove(this); }
internal static SyncLink GetById(int value, SyncDatabase db) { SyncLink result = new SyncLink(); result.Id = value; if (result.Fill(db)) { return(result); } return(null); }
public override Stream GetReadStreamForEntry(SyncEntry entry) { long size = entry.GetSize(this.Relationship, SyncEntryPropertyLocation.Destination); using (SyncDatabase db = this.Relationship.GetDatabase()) { return(new AzureStorageDownloadStream( this.storageClient, this.TypedConfiguration.ContainerName, entry.GetRelativePath(db, "/"), size)); } }
private void PrepareReplica_ExecuteCode(object sender, EventArgs e) { SyncDatabase db = new SyncDatabase( new FbConnection("Database=fdb:/var/db/ch_bl_s.fdb;User=SYSDBA;Password=3Ky1u6nd;Charset=WIN1251")); db.StartSession(SessionMode.Read); SyncLogReplicaInfo replicaInfo = db.SourcePrepare(db.GetSyncLink(0)); //SyncLogReplica replica = db.SourceGetNextReplica(replicaInfo, false) as SyncLogReplica; //replica.Serialize("c:\\test.replica", true); db.EndSession(true); }
private void TryFixRdbProcGen(SyncDatabase db) { string sql = @"select gen_id(rdb$procedures, (select max(rdb$procedure_id) + 1000 from rdb$procedures) - (gen_id(rdb$procedures, 0))) from rdb$database"; using (IDbCommand cmd = db.CreateCommand()) { cmd.CommandText = sql; cmd.ExecuteNonQuery(); } }
public override void FillTableColumnsList(SyncDatabase db, string TableName, SyncTable table) { using (IDbCommand cmd = db.CreateCommand()) { table.Columns.Clear(); table.KeyColumns.Clear(); cmd.CommandText = string.Format("select first 0 * from {0}", TableName); using (IDataReader reader = cmd.ExecuteReader()) { DataTable schemaTable = reader.GetSchemaTable(); foreach (DataRow row in schemaTable.Rows) { DataColumn col = new DataColumn(); col.AllowDBNull = Convert.ToBoolean(row["AllowDBNull"]); col.ColumnName = Convert.ToString(row["ColumnName"]); col.DataType = (row["DataType"] as Type); col.ReadOnly = Convert.ToBoolean(row["IsReadOnly"]); table.Columns.Add(col); if (Convert.ToBoolean(row["IsKey"])) { table.KeyColumns.Add(col.ColumnName); } } } if (table.KeyColumns.Count > 1) { using (FbCommand cmd_key = db.CreateCommand() as FbCommand) { // если несколько полей в ключе, то перезапрашиваем, чтобы уточнить порядок следования полей cmd_key.CommandText = @"select rdb$field_name from rdb$relation_constraints c left join rdb$index_segments i on i.rdb$index_name = c.rdb$index_name where rdb$constraint_type = 'PRIMARY KEY' and rdb$relation_name = @tablename order by rdb$field_position"; cmd_key.Parameters.Add("@tablename", FbDbType.VarChar).Value = TableName.ToUpper(); table.KeyColumns.Clear(); using (IDataReader reader_key = cmd_key.ExecuteReader()) while (reader_key.Read()) { table.KeyColumns.Add(reader_key[0].ToString().Trim()); } } } } }
public override void StartSession(SyncDatabase db, SessionMode Mode) { ExecSql(db, "select rdb$set_context('USER_TRANSACTION', 'SYNC_RECV', '1') from rdb$database"); if (Mode == SessionMode.Write) { using (IDbCommand cmd = db.CreateCommand()) { cmd.CommandText = "select rdb$set_context('USER_TRANSACTION', 'SYNC_LOG_DISABLED', '1') from rdb$database"; cmd.ExecuteNonQuery(); } ExecSql(db, "select rdb$set_context('USER_TRANSACTION', 'TRG_DISABLE', '1') from rdb$database"); } }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); Args = e.Args; CreateJumpList(); // Make the main process appear connected to the update process // in the taskbar. try { SetCurrentProcessExplicitAppUserModelID(GlobalAssemblyInfo.AssemblyName); } catch { } AppointmentDatabase.Load(); AppointmentDatabase.OnSaveCompletedEvent += AppointmentDatabase_OnSaveCompletedEvent; ContactDatabase.Load(); ContactDatabase.OnSaveCompletedEvent += ContactDatabase_OnSaveCompletedEvent; TaskDatabase.Load(); TaskDatabase.OnSaveCompletedEvent += TaskDatabase_OnSaveCompletedEvent; NoteDatabase.Load(); NoteDatabase.OnSaveCompletedEvent += NoteDatabase_OnSaveCompletedEvent; SyncDatabase.Load(); SyncDatabase.OnSaveCompletedEvent += SyncDatabase_OnSaveCompletedEvent; QuoteDatabase.Load(); QuoteDatabase.OnSaveCompletedEvent += QuoteDatabase_OnSaveCompletedEvent; ThemeHelpers.UpdateTheme(true); MainWindow mainWindow = new MainWindow(); mainWindow.ContentRendered += mainWindow_ContentRendered; mainWindow.Show(); SystemEvents.UserPreferenceChanged += SystemEvents_UserPreferenceChanged; SystemEvents.TimeChanged += SystemEvents_TimeChanged; if (BackstageEvents.StaticUpdater == null) { BackstageEvents.StaticUpdater = new BackstageEvents(); } BackstageEvents.StaticUpdater.OnForceUpdateEvent += StaticUpdater_OnForceUpdateEvent; BackstageEvents.StaticUpdater.OnThemeChangedEvent += StaticUpdater_OnThemeChangedEvent; BackstageEvents.StaticUpdater.OnExportEvent += StaticUpdater_OnExportEvent; BackstageEvents.StaticUpdater.OnHelpEvent += StaticUpdater_OnHelpEvent; BackstageEvents.StaticUpdater.OnDocumentRequestEvent += StaticUpdater_OnDocumentRequestEvent; BackstageEvents.StaticUpdater.OnPrintStartedEvent += StaticUpdater_OnPrintStartedEvent; BackstageEvents.StaticUpdater.OnImportEvent += StaticUpdater_OnImportEvent; BackstageEvents.StaticUpdater.OnQuotesChangedEvent += StaticUpdater_OnQuotesChangedEvent; }
private static string GenerateReplicaIdString(SyncDatabase Connection) { try { IDbCommand cmd_gen_replica = Connection.CreateCommand(); cmd_gen_replica.CommandText = "SP_SYNC_GEN_REPLICA_ID"; cmd_gen_replica.CommandType = CommandType.StoredProcedure; return(Convert.ToString(cmd_gen_replica.ExecuteScalar())); } catch (Exception ex) { throw new InvalidOperationException( string.Format("Невозможно сгенерировать код новой реплики. {0}.", ex.Message), ex); } }
private void AddGoogleService() { GoogleSignIn gSignIn = new GoogleSignIn(); gSignIn.Owner = Window.GetWindow(this); if (gSignIn.ShowDialog() == true) { AccountDisplay display = new AccountDisplay(new BitmapImage(new Uri("pack://application:,,,/Daytimer.Images;component/Images/google.png", UriKind.Absolute)), "Google", gSignIn.Email); servicesPanel.Children.Add(display); if (SyncDatabase.GetSyncObject(gSignIn.Email) == null) { SyncDatabase.Add(new SyncObject(gSignIn.Email, DateTime.Now, SyncType.EntireAccount)); } } }
private List <SyncDatabase> ParseSettings(XmlNodeList config, Dictionary <string, string> connectionStrings) { Assert.IsNotNull(config, "[DistributedDb] config is null"); Assert.IsNotNull(connectionStrings, "[DistributedDb] connection is null"); var dbs = new List <SyncDatabase>(); foreach (XmlNode dbNode in config) { var db = new SyncDatabase(); db.Scope = XmlUtil.GetAttribute("scope", dbNode); Assert.IsNotNullOrEmpty(db.Scope, "[DistributedDb] scope is missing"); db.Client = XmlUtil.GetAttribute("client", dbNode); Assert.IsNotNullOrEmpty(db.Client, "[DistributedDb] client is missing"); db.ClientConnectionString = connectionStrings[db.Client]; Assert.IsNotNullOrEmpty(db.ClientConnectionString, "client connectionstring is missing"); db.Server = XmlUtil.GetAttribute("server", dbNode); Assert.IsNotNullOrEmpty(db.Server, "[DistributedDb] server is missing"); db.ServerConnectionString = connectionStrings[db.Server]; Assert.IsNotNullOrEmpty(db.ServerConnectionString, "server connectionstring is missing"); foreach (XmlNode tableNode in dbNode.ChildNodes) { var table = new SyncTable(); table.Name = XmlUtil.GetAttribute("name", tableNode); table.Database = db; Assert.IsNotNullOrEmpty(table.Name, "[DistributedDb] table name is missing"); if (db.Tables == null) { db.Tables = new List <SyncTable>(); } db.Tables.Add(table); } Assert.IsTrue(db.Tables.Count > 0, "[DistributedDb] no tables found"); dbs.Add(db); } Assert.IsTrue(dbs.Count > 0, "[DistributedDb] no database found"); return(dbs); }
public override void CleanSpecialCommand(SyncDatabase db, SyncDatabaseVendorCommandMode mode) { /*if (mode == SyncDatabaseVendorCommandMode.UpdateOrInsertTable) * { * try * { * using (IDbCommand cmd_sp = db.CreateCommand()) * { * cmd_sp.CommandText = string.Format("drop procedure {0}", get_sp_name()); * cmd_sp.ExecuteNonQuery(); * } * } * catch (FbException ex) * { * if (!ex.Message.Contains("not found")) * throw; * } * * }*/ }
public override List <string> GetKeyColumns(SyncDatabase syncDatabase, string tableName) { using (FbCommand cmd = syncDatabase.CreateCommand() as FbCommand) { cmd.CommandText = @"select rtrim(rdb$field_name) from rdb$relation_constraints rc left join rdb$index_segments i on i.rdb$index_name = rc.rdb$index_name where rdb$constraint_type = 'PRIMARY KEY' and rc.rdb$relation_name = upper(@table_name) order by i.rdb$field_position"; cmd.Parameters.Add("@table_name", FbDbType.VarChar).Value = tableName; List <string> result = new List <string>(); using (FbDataReader reader = cmd.ExecuteReader()) while (reader.Read()) { result.Add(reader[0].ToString()); } return(result); } }
/// <summary> /// получение участника синхронизации по идентификатору /// </summary> /// <param name="id">идентификатор участника синхронизации</param> /// <returns></returns> public static SyncParticipant GetById(int id, SyncDatabase db) { using (IDbCommand cmd = db.CreateCommand()) { cmd.CommandText = Const.Sql_SyncParticipantGet; cmd.Parameters.Add(cmd.CreateParameter()); IDbDataParameter p = (cmd.Parameters[0] as IDbDataParameter); p.Direction = ParameterDirection.Input; p.ParameterName = "@id"; p.Value = id; using (IDataReader reader = cmd.ExecuteReader()) if (reader.Read()) { return(new SyncParticipant(reader)); } else { return(null); } } }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - #region логгер //[NonSerialized] //private ILog log = LogManager.GetLogger(MethodInfo.GetCurrentMethod().DeclaringType); #endregion // - - - - - - - - - - - - - - - - - - - - - - - - - - - - #region ISyncDataObject Members public void Fill(SyncDatabase db, IDataReader reader) { _Id = Convert.ToInt32(reader["ID"]); _Name = Convert.ToString(reader["NAME"]); _ParticipantFrom = SyncParticipant.GetById(Convert.ToInt32(reader["PARTICIPANT_FROM"]), db); _ParticipantTo = SyncParticipant.GetById(Convert.ToInt32(reader["PARTICIPANT_TO"]), db); _LogPosition = Convert.ToInt64(reader["LOG_POSITION"]); _PositionUpdateCount = Convert.ToInt32(reader["POSITION_UPD_COUNT"]); if (!reader.IsDBNull(reader.GetOrdinal("LAST_UPDATE_TM"))) { _LastUpdateTime = Convert.ToDateTime(reader["LAST_UPDATE_TM"]); } if (!reader.IsDBNull(reader.GetOrdinal("LAST_UPDATE_USER_ID"))) { _LastUpdateUser = Convert.ToString(reader["LAST_UPDATE_USER_ID"]); } if (!reader.IsDBNull(reader.GetOrdinal("LAST_UPDATE_CLIENT_ADDR"))) { _LastUpdateClientAddr = Convert.ToString(reader["LAST_UPDATE_CLIENT_ADDR"]); } }
public override void WriteSyncJournal(SyncDatabase db, SyncJournalInfo JournalInfo) { if (IsTableExists("SYNC_JNL", db) && (JournalInfo.LocalReplicaCount > 1 || JournalInfo.RemoteReplicaCount > 1)) { string sql = @"INSERT INTO SYNC_JNL (DAT, LOCAL_LINK_ID, REMOTE_LINK_ID, TIME_START, TIME_END, LOGTEXT, SUCCESS, LOCAL_REPLICA_COUNT, REMOTE_REPLICA_COUNT) VALUES (@DAT, @LOCAL_LINK_ID, @REMOTE_LINK_ID, @TIME_START, @TIME_END, @LOGTEXT, @SUCCESS, @LOCAL_REPLICA_COUNT, @REMOTE_REPLICA_COUNT)"; FbCommand cmd = db.CreateCommand() as FbCommand; cmd.CommandText = sql; cmd.Parameters.Add("@DAT", FbDbType.Date).Value = JournalInfo.Date; cmd.Parameters.Add("@LOCAL_LINK_ID", FbDbType.Date).Value = JournalInfo.LocalLinkId; cmd.Parameters.Add("@REMOTE_LINK_ID", FbDbType.Date).Value = JournalInfo.RemoteLinkId; cmd.Parameters.Add("@TIME_START", FbDbType.Date).Value = JournalInfo.TimeStart; cmd.Parameters.Add("@TIME_END", FbDbType.Date).Value = JournalInfo.TimeEnd; cmd.Parameters.Add("@LOGTEXT", FbDbType.Date).Value = JournalInfo.LogMessages; cmd.Parameters.Add("@SUCCESS", FbDbType.SmallInt).Value = JournalInfo.Success ? 1 : 0; cmd.Parameters.Add("@LOCAL_REPLICA_COUNT", FbDbType.Integer).Value = JournalInfo.LocalReplicaCount; cmd.Parameters.Add("@REMOTE_REPLICA_COUNT", FbDbType.Integer).Value = JournalInfo.RemoteReplicaCount; cmd.ExecuteNonQuery(); } }
private void test_ExecuteCode(object sender, EventArgs e) { SyncLogReplica replica1; BinaryFormatter bf = new BinaryFormatter(); using (FileStream fs = new FileStream(@"C:\test.replica", FileMode.Open, FileAccess.Read)) { replica1 = SyncLogReplica.Deserialize(fs); } SyncDatabase db2 = new SyncDatabase( new FbConnection("Database=fdb:/var/db/ch_bl_s2.fdb;User=SYSDBA;Password=3Ky1u6nd;Charset=WIN1251")); db2.StartSession(SessionMode.Write); //db2.TargetProcessReplica(replica1, false); db2.EndSession(true); // - - - }
public static void LogDatabase(SyncDatabase db) { foreach (SyncEntry entry in db.Entries.Include(e => e.AdapterEntries).ToList()) { Logger.Info("Entry {0}:", entry.Id); Logger.Info(" Name: {0}", entry.Name); Logger.Info(" Full Path: \\{0}", entry.GetRelativePath(db, "\\")); Logger.Info(" State: {0}", JoinFlags <AdapterFlags>(entry.State)); Logger.Info(" Parent ID: {0}", entry.ParentId == null ? "(null)" : entry.ParentId.ToString()); Logger.Info(" Type: {0}", entry.Type); Logger.Info(" Creation: {0}", entry.CreationDateTimeUtc); Logger.Info(" Modified: {0}", entry.ModifiedDateTimeUtc); Logger.Info(" Last Updated: {0}", entry.EntryLastUpdatedDateTimeUtc); Logger.Info(" Source Size: {0}", entry.OriginalSize); Logger.Info(" Dest Size: {0}", entry.EncryptedSize); Logger.Info(" Source SHA1 Hash: {0}", HashToHex(entry.OriginalSha1Hash)); Logger.Info(" Dest SHA1 Hash: {0}", HashToHex(entry.EncryptedSha1Hash)); Logger.Info(" Source MD5 Hash: {0}", HashToHex(entry.OriginalMd5Hash)); Logger.Info(" Dest MD5 Hash: {0}", HashToHex(entry.EncryptedMd5Hash)); Logger.Info(" Adapter IDs:"); foreach (SyncEntryAdapterData adapterEntry in entry.AdapterEntries) { Logger.Info(" AdapterEntry {0}: Adapter {1} => {2}:", adapterEntry.Id, adapterEntry.AdapterId, adapterEntry.AdapterEntryId); } } foreach (SyncHistoryData history in db.History.ToList()) { Logger.Info("History {0}:", history.Id); Logger.Info(" Start: {0}", history.Start); Logger.Info(" End: {0}", history.End); Logger.Info(" Result: {0}", history.Result); Logger.Info(" Total Files: {0}", history.TotalFiles); Logger.Info(" Total Bytes: {0}", history.TotalBytes); } Logger.Info("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"); }
private void AddSyncEntriesRecursive( SyncDatabase db, List <EntryUpdateInfo> updatesToRestore, SyncEntry syncEntry, RestoreOnlyWindowsFileSystemAdapter destAdapter) { EntryUpdateInfo updateInfo = new EntryUpdateInfo( syncEntry, destAdapter, SyncEntryChangedFlags.Restored, syncEntry.GetRelativePath(db, "/")); updatesToRestore.Add(updateInfo); if (syncEntry.Type == SyncEntryType.Directory) { List <SyncEntry> childEntries = db.Entries.Where(e => e.ParentId == syncEntry.Id).ToList(); foreach (SyncEntry childEntry in childEntries) { this.AddSyncEntriesRecursive(db, updatesToRestore, childEntry, destAdapter); } } }
protected override void OnExit(ExitEventArgs e) { base.OnExit(e); // // Save databases // AppointmentDatabase.OnSaveCompletedEvent -= AppointmentDatabase_OnSaveCompletedEvent; AppointmentDatabase.Save(); ContactDatabase.OnSaveCompletedEvent -= AppointmentDatabase_OnSaveCompletedEvent; ContactDatabase.Save(); TaskDatabase.OnSaveCompletedEvent -= TaskDatabase_OnSaveCompletedEvent; TaskDatabase.Save(); NoteDatabase.OnSaveCompletedEvent -= NoteDatabase_OnSaveCompletedEvent; NoteDatabase.Save(); SyncDatabase.OnSaveCompletedEvent -= SyncDatabase_OnSaveCompletedEvent; SyncDatabase.Save(); // // Unregister system hooks // SystemEvents.UserPreferenceChanged -= SystemEvents_UserPreferenceChanged; SystemEvents.TimeChanged -= SystemEvents_TimeChanged; // // Delete autorecover information // new RecoveryDatabase(RecoveryVersion.Current).Delete(); new RecoveryDatabase(RecoveryVersion.LastRun).Delete(); // // Install any updates which may have been downloaded. // string localPath = (new FileInfo(Process.GetCurrentProcess().MainModule.FileName)).DirectoryName; Process.Start(localPath + "\\UpdateManager.exe", "/update " + Process.GetCurrentProcess().Id.ToString()); }