Exemple #1
0
 /// <summary>
 /// Adds sync errors to the data.
 /// </summary>
 /// <param name="errors">List of errors to add</param>
 /// <param name="context">Context used to clear conflicts</param>
 public void AddErrors(IEnumerable <SyncError> errors, WinEightContext context)
 {
     foreach (SyncError error in errors)
     {
         AddSyncError(error, context);
     }
 }
Exemple #2
0
 /// <summary>
 /// Adds sync conflicts to the data.
 /// </summary>
 /// <param name="conflicts">List of SyncConflict objects</param>
 /// <param name="context">IsolatedStorageOfflineSyncProvider</param>
 public void AddConflicts(IEnumerable <SyncConflict> conflicts, WinEightContext context)
 {
     foreach (SyncConflict conflict in conflicts)
     {
         AddSyncConflict(conflict, context);
     }
 }
Exemple #3
0
        public void AddSerializedError(SyncError error, WinEightContext context)
        {
            SyncError oldError = (SyncError)Collections[error.ErrorEntity.GetType()].MapSyncError((OfflineEntity)error.LiveEntity, error, context);

            SyncErrors.Add(error);

            if (oldError != null)
            {
                ClearSyncError(oldError, context);
            }
        }
Exemple #4
0
        /// <summary>
        /// Adds a error to the list of in-memory
        /// </summary>
        /// <param name="error"></param>
        /// <param name="context">Context for the conflict is being added</param>
        public void AddSyncError(SyncError error, WinEightContext context)
        {
            OfflineEntity entity   = Collections[error.LiveEntity.GetType()].AddOrUpdateSyncEntity((OfflineEntity)error.LiveEntity);
            SyncError     oldError = Collections[error.LiveEntity.GetType()].MapSyncError(entity, error, context);

            SyncErrors.Add(error);

            if (oldError != null)
            {
                ClearSyncError(oldError, context);
            }
        }
Exemple #5
0
        /// <summary>
        /// Adds a conflict to the list of in-memory
        /// </summary>
        /// <param name="conflict">Conflict to add</param>
        /// <param name="context">Context for which the conflict is being added</param>
        public void AddSyncConflict(SyncConflict conflict, WinEightContext context)
        {
            OfflineEntity entity      = Collections[conflict.LiveEntity.GetType()].AddOrUpdateSyncEntity((OfflineEntity)conflict.LiveEntity);
            SyncConflict  oldConflict = Collections[conflict.LiveEntity.GetType()].MapSyncConflict(entity, conflict, context);

            SyncConflicts.Add(conflict);

            if (oldConflict != null)
            {
                ClearSyncConflict(oldConflict, context);
            }
        }
Exemple #6
0
        /// <summary>
        /// Sets the sync error, providing the cache data so that the error can be removed if ClearSyncerror
        /// is called.
        /// </summary>
        ///<param name="c">IsolatedStorageOfflineContext</param>
        /// <param name="se">error to set.</param>
        internal void SetSyncError(WinEightContext c, SyncError se)
        {
            SyncError oldError = this.syncError;

            this.context   = c;
            this.syncError = se;

            OnPropertyChanged("SyncError");

            if (oldError == null)
            {
                OnPropertyChanged("HasSyncError");
            }
        }
Exemple #7
0
        /// <summary>
        /// Sets the sync conflict, providing the cache data so that the conflict can be removed if ClearSyncConflict
        /// is called.
        /// </summary>
        ///<param name="c">IsolatedStorageOfflineContext</param>
        /// <param name="sc">conflict to set.</param>
        internal void SetSyncConflict(WinEightContext c, SyncConflict sc)
        {
            SyncConflict oldConflict = this.syncConflict;

            this.context      = c;
            this.syncConflict = sc;

            OnPropertyChanged("SyncConflict");

            if (oldConflict == null)
            {
                OnPropertyChanged("HasSyncConflict");
            }
        }
Exemple #8
0
 public abstract SyncError MapSyncError(OfflineEntity entity, SyncError error,
                                        WinEightContext context);
Exemple #9
0
 public abstract SyncConflict MapSyncConflict(OfflineEntity entity, SyncConflict conflict,
                                              WinEightContext context);
Exemple #10
0
        /// <summary>
        /// Method called when an upload changes response is received.
        /// </summary>
        /// <param name="anchor">Anchor returned from upload response</param>
        /// <param name="conflicts">List of conflicts that occurred</param>
        /// <param name="updatedItems">List of items that were updated on upload</param>
        /// <param name="context">Storage context associated with the cache data</param>
        public void AddUploadChanges(byte[] anchor, IEnumerable <Conflict> conflicts, IEnumerable <OfflineEntity> updatedItems, WinEightContext context)
        {
            // For each of the uploaded entities, reset the state.  No save can happen
            // once sync is started, so this is ok.
            foreach (OfflineCollection collection in Collections.Values)
            {
                collection.ResetSavedEntitiesToUnmodified();
            }

            // Grab the sync conflicts and errors
            List <SyncConflict> syncConflicts = new List <SyncConflict>();
            List <SyncError>    syncErrors    = new List <SyncError>();

            foreach (Conflict conflict in conflicts)
            {
                if (conflict is SyncConflict)
                {
                    syncConflicts.Add((SyncConflict)conflict);
                }
                else if (conflict is SyncError)
                {
                    syncErrors.Add((SyncError)conflict);
                }
                else
                {
                    throw new ArgumentException("Unexpected conflict type returned in upload response");
                }
            }

            // Add the conflicts and errors.
            AddConflicts(syncConflicts, context);
            AddErrors(syncErrors, context);

            DownloadedChanges(anchor, updatedItems);
        }
Exemple #11
0
 private async void ClearSyncError(SyncError syncError, WinEightContext context)
 {
     RemoveSyncError(syncError);
     await context.ClearSyncError(syncError);
 }
Exemple #12
0
 private async void ClearSyncConflict(SyncConflict syncConflict, WinEightContext context)
 {
     RemoveSyncConflict(syncConflict);
     await context.ClearSyncConflict(syncConflict);
 }
Exemple #13
0
 /// <summary>
 /// Clears out the context so that conflicts cannot be resolved multiple times.
 /// </summary>
 internal void ClearContext()
 {
     context = null;
 }
Exemple #14
0
 /// <summary>
 /// Constructor which intializes the StoreConflict with the specified context.
 /// </summary>
 /// <param name="context"></param>
 internal OfflineConflict(WinEightContext context)
 {
     this.context = context;
 }