コード例 #1
0
ファイル: syncing.cs プロジェクト: s-chand/qmap
    /// <summary>
    /// Handles errors that happen during syncing down to the client.
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    static void slaveProvider_ApplyChangeFailed(object sender, Microsoft.Synchronization.Data.DbApplyChangeFailedEventArgs e)
    {
        switch (e.Conflict.Type)
        {
        case Microsoft.Synchronization.Data.DbConflictType.ErrorsOccurred:
            break;

        case Microsoft.Synchronization.Data.DbConflictType.LocalCleanedupDeleteRemoteUpdate:
            break;

        case Microsoft.Synchronization.Data.DbConflictType.LocalDeleteRemoteDelete:
            break;

        case Microsoft.Synchronization.Data.DbConflictType.LocalDeleteRemoteUpdate:
            break;

        case Microsoft.Synchronization.Data.DbConflictType.LocalInsertRemoteInsert:
            break;

        case Microsoft.Synchronization.Data.DbConflictType.LocalUpdateRemoteDelete:
            break;

        case Microsoft.Synchronization.Data.DbConflictType.LocalUpdateRemoteUpdate:
            // If there are server edits and local edits then the server always wins.
            e.Action = ApplyAction.RetryWithForceWrite;
            break;

        default:
            break;
        }
    }
コード例 #2
0
 private void OnDbApplyChangeFailed(object sender, Microsoft.Synchronization.Data.DbApplyChangeFailedEventArgs ev)
 {
     if ((ev.Conflict.Type == DbConflictType.LocalInsertRemoteInsert) || (ev.Conflict.Type == DbConflictType.LocalUpdateRemoteUpdate))
     {
         DataTable     conflictingLocalChange = ev.Conflict.LocalChange;
         StringBuilder sb = new StringBuilder();
         DataTable     conflictingRemoteChange = ev.Conflict.RemoteChange;
         for (int idx = 0; idx < conflictingRemoteChange.Columns.Count; idx++)
         {
             if (sb.Length > 0)
             {
                 sb.Append("|");
             }
             sb.Append(conflictingRemoteChange.Rows[0][idx]);
         }
         if (conflictingLocalChange.TableName.Equals(FotoShoutUtils.Constants.TABLE_ACCOUNTS, StringComparison.InvariantCultureIgnoreCase) ||
             conflictingLocalChange.TableName.Equals(FotoShoutUtils.Constants.TABLE_USERROLES, StringComparison.InvariantCultureIgnoreCase) ||
             conflictingLocalChange.TableName.Equals(FotoShoutUtils.Constants.TABLE_USERAUTHORIZATIONS, StringComparison.InvariantCultureIgnoreCase) ||
             conflictingLocalChange.TableName.Equals(FotoShoutUtils.Constants.TABLE_USERS, StringComparison.InvariantCultureIgnoreCase) ||
             conflictingLocalChange.TableName.Equals(FotoShoutUtils.Constants.TABLE_EVENTOPTIONS, StringComparison.InvariantCultureIgnoreCase) ||
             conflictingLocalChange.TableName.Equals(FotoShoutUtils.Constants.TABLE_EVENTS, StringComparison.InvariantCultureIgnoreCase))
         {
             ev.Action = ApplyAction.RetryWithForceWrite;
             FotoShoutUtils.Log.LogManager.Error(_logger, string.Format("Row from the {0} table was conflicted and will be forced to write to the client: {1}", conflictingRemoteChange.TableName, sb.ToString()));
         }
         else
         {
             ev.Action = ApplyAction.Continue;
             FotoShoutUtils.Log.LogManager.Error(_logger, string.Format("Row from the {0} table was conflicted and will be bypass: {1}", conflictingRemoteChange.TableName, sb.ToString()));
         }
     }
     else
     {
         FotoShoutUtils.Log.LogManager.Error(_logger, string.Format("Conflict of type {0} was detected.", ev.Conflict.Type));
     }
 }