Exemple #1
0
 /// <summary>
 /// Adds sync conflicts to the data.
 /// </summary>
 /// <param name="conflicts">List of SyncConflict objects</param>
 /// <param name="context">IsolatedStorageOfflineContext</param>
 public void AddConflicts(IEnumerable <SyncConflict> conflicts, IsolatedStorageOfflineContext context)
 {
     foreach (SyncConflict conflict in conflicts)
     {
         AddSyncConflict(conflict, context);
     }
 }
Exemple #2
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, IsolatedStorageOfflineContext context)
 {
     foreach (SyncError error in errors)
     {
         AddSyncError(error, context);
     }
 }
        /// <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<IsolatedStorageOfflineEntity> updatedItems, IsolatedStorageOfflineContext context)
        {
            // For each of the uploaded entities, reset the state.  No save can happen
            // once sync is started, so this is ok.
            foreach (IsolatedStorageCollection 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 #4
0
        public DAL(IsolatedStorageOfflineContext context
            , String appName
            , String language
            , String userName
            , String userPassword
            , String configName
            , String configVersion
            , IDictionary<string, string> deviceInfo
            , ProgressDelegate p
            , Func<Uri, CacheControllerBehavior, AsyncWorkerManager, CacheRequestHandler> chacheRequestFactory)
        {
            this.appName = appName;
            this.language = language;
            this.configName = configName;
            this.configVersion = configVersion;
            this.onProgress = p;

            this.context = context;
            this.context.LoadCompleted += context_LoadCompleted;
            this.context.CacheController.SetCacheRequestFactory(chacheRequestFactory);
            this.context.CacheController.RefreshCompleted += CacheController_RefreshCompleted;
            this.context.CacheController.ControllerBehavior.Credentials = new System.Net.NetworkCredential(userName, userPassword);
            this.context.CacheController.ControllerBehavior.ConfigName = this.configName;
            this.context.CacheController.ControllerBehavior.ConfigVersion = this.configVersion;
            this.context.CacheController.ControllerBehavior.CoreVersion = CoreInformation.CoreVersion;
            this.context.CacheController.ControllerBehavior.ReadProgressCallback = ReadProgressCallback;
            this.context.CacheController.ControllerBehavior.DeviceInfo = deviceInfo;

            //this.context.CacheController.ControllerBehavior.AddScopeParameters("Outlet","{A507956F-D135-4E8A-BD7F-14B54AC1E95C}");
        }
        public SQLiteCacheData(IsolatedStorageSchema schema, IsolatedStorageOfflineContext context)
        {
//            Collections = new Dictionary<EntityType, IsolatedStorageCollection>();
            SyncConflicts = new List<SyncConflict>();
            SyncErrors = new List<SyncError>();

            CreateCollections(schema, context);
        }
Exemple #6
0
        public void AddSerializedError(SyncError error, IsolatedStorageOfflineContext context)
        {
            IsolatedStorageSyncError oldError = (IsolatedStorageSyncError)Collections[error.ErrorEntity.GetType()].MapSyncError((IsolatedStorageOfflineEntity)error.LiveEntity, error, context);

            SyncErrors.Add(error);

            if (oldError != null)
            {
                ClearSyncError(oldError, context);
            }
        }
Exemple #7
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, IsolatedStorageOfflineContext context)
        {
            IsolatedStorageOfflineEntity entity = Collections[conflict.LiveEntity.GetType()].AddOrUpdateSyncEntity((IsolatedStorageOfflineEntity)conflict.LiveEntity);
            SyncConflict oldConflict            = Collections[conflict.LiveEntity.GetType()].MapSyncConflict(entity, conflict, context);

            SyncConflicts.Add(conflict);

            if (oldConflict != null)
            {
                ClearSyncConflict(oldConflict, context);
            }
        }
Exemple #8
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, IsolatedStorageOfflineContext context)
        {
            IsolatedStorageOfflineEntity entity = Collections[error.LiveEntity.GetType()].AddOrUpdateSyncEntity((IsolatedStorageOfflineEntity)error.LiveEntity);
            SyncError oldError = Collections[error.LiveEntity.GetType()].MapSyncError(entity, error, context);

            SyncErrors.Add(error);

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

            this._context   = context;
            this._syncError = syncError;

            OnPropertyChanged("SyncError");

            if (oldError == null)
            {
                OnPropertyChanged("HasSyncError");
            }
        }
        public SQLiteStorageHandler(IsolatedStorageOfflineContext ctx, IsolatedStorageSchema schema, string cachePath, SymmetricAlgorithm encryptionAlgorithm)
        {
            _context = ctx;
            _schema = schema;
            _cachePath = cachePath;
            _encryptionAlgorithm = encryptionAlgorithm;
            _anchor = null;

            _knownTypes = new List<EntityType>
            {
//                new EntityType(typeof (SyncConflict)),
//                new EntityType(typeof (SyncError))
            };

            AddKnownTypes();
        }
Exemple #11
0
        /// <summary>
        /// Sets the sync conflict, providing the cache data so that the conflict can be removed if ClearSyncConflict
        /// is called.
        /// </summary>
        ///<param name="context">IsolatedStorageOfflineContext</param>
        /// <param name="syncConflict">conflict to set.</param>
        internal void SetSyncConflict(
            IsolatedStorageOfflineContext context,
            SyncConflict syncConflict)
        {
            SyncConflict oldConflict = this._syncConflict;

            this._context      = context;
            this._syncConflict = syncConflict;

            OnPropertyChanged("SyncConflict");

            if (oldConflict == null)
            {
                OnPropertyChanged("HasSyncConflict");
            }
        }
Exemple #12
0
 public void AddErrors(IEnumerable<SyncError> errors, IsolatedStorageOfflineContext context)
 {
 }
        /// <summary>
        /// Sets the sync error, providing the cache data so that the error can be removed if ClearSyncerror
        /// is called.
        /// </summary>
        ///<param name="context">IsolatedStorageOfflineContext</param>
        /// <param name="syncError">error to set.</param>
        internal void SetSyncError(IsolatedStorageOfflineContext context, SyncError syncError)
        {
            SyncError oldError = this._syncError;

            this._context = context;
            this._syncError = syncError;

            OnPropertyChanged("SyncError");

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

            this._context = context;
            this._syncConflict = syncConflict;

            OnPropertyChanged("SyncConflict");

            if (oldConflict == null)
            {
                OnPropertyChanged("HasSyncConflict");
            }
        }
 /// <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, IsolatedStorageOfflineContext context)
 {
     foreach (SyncError error in errors)
     {
         AddSyncError(error, context);
     }
 }
 /// <summary>
 /// Constructor which intializes the StoreConflict with the specified context.
 /// </summary>
 /// <param name="context"></param>
 internal StoreConflict(IsolatedStorageOfflineContext context)
 {
     this._context = context;
 }
 private void ClearSyncConflict(SyncConflict syncConflict, IsolatedStorageOfflineContext context)
 {
     RemoveSyncConflict(syncConflict);
     context.StorageHandler.ClearSyncConflict((IsolatedStorageSyncConflict)syncConflict);
 }
        public void AddSerializedError(SyncError error, IsolatedStorageOfflineContext context)
        {
            IsolatedStorageSyncError oldError = (IsolatedStorageSyncError)Collections[error.ErrorEntity.GetType()].MapSyncError((IsolatedStorageOfflineEntity)error.LiveEntity, error, context);

            SyncErrors.Add(error);

            if (oldError != null)
            {                
                ClearSyncError(oldError,context);
            }
        }
Exemple #19
0
 public void AddSerializedConflict(SyncConflict conflict, IsolatedStorageOfflineContext context)
 {
 }
Exemple #20
0
        private void CreateCollections(IsolatedStorageSchema schema, IsolatedStorageOfflineContext context)
        {
//            Type collectionType = typeof(IsolatedStorageCollection<>);
//            foreach (EntityType t in schema.Collections)
//            {
//                // CreateInstance the generic type for the type in the collection.
//                Type generic = collectionType.MakeGenericType(t);
//                IsolatedStorageCollection collection = (IsolatedStorageCollection)Activator.CreateInstance(generic, context);
//                Collections[t] = collection;
//            }
        }
Exemple #21
0
 public void AddUploadChanges(byte[] anchor, IEnumerable<Conflict> conflicts, IEnumerable<IsolatedStorageOfflineEntity> updatedItems, IsolatedStorageOfflineContext context)
 {
 }
        /// <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, IsolatedStorageOfflineContext context)
        {
            IsolatedStorageOfflineEntity entity = Collections[error.LiveEntity.GetType()].AddOrUpdateSyncEntity((IsolatedStorageOfflineEntity)error.LiveEntity);
            SyncError oldError = Collections[error.LiveEntity.GetType()].MapSyncError(entity, error, context);

            SyncErrors.Add(error);

            if (oldError != null)
            {
                ClearSyncError(oldError, context);                
            }
        }
 public abstract SyncConflict MapSyncConflict(IsolatedStorageOfflineEntity entity, SyncConflict conflict, IsolatedStorageOfflineContext context);
Exemple #24
0
 public void AddSerializedError(SyncError error, IsolatedStorageOfflineContext context)
 {
 }
        public void AddSerializedConflict(SyncConflict conflict, IsolatedStorageOfflineContext context)
        {
            Type entityType = conflict.LiveEntity.GetType();
            IsolatedStorageOfflineEntity entity = Collections[entityType].AddOrUpdateSyncEntity((IsolatedStorageOfflineEntity)conflict.LiveEntity);
            IsolatedStorageSyncConflict oldConflict = (IsolatedStorageSyncConflict)Collections[entityType].MapSyncConflict(entity, conflict, context);

            SyncConflicts.Add(conflict);

            if (oldConflict != null)
            {
                ClearSyncConflict(oldConflict,context);
            }
        }
Exemple #26
0
 private void ClearSyncConflict(SyncConflict syncConflict, IsolatedStorageOfflineContext context)
 {
 }
 public abstract SyncError MapSyncError(IsolatedStorageOfflineEntity entity, SyncError error, IsolatedStorageOfflineContext context);
 public abstract SyncConflict MapSyncConflict(IsolatedStorageOfflineEntity entity, SyncConflict conflict, IsolatedStorageOfflineContext context);
 private void ClearSyncError(SyncError syncError, IsolatedStorageOfflineContext context)
 {
     RemoveSyncError(syncError);
     context.StorageHandler.ClearSyncError((IsolatedStorageSyncError)syncError);
 }
Exemple #30
0
 public void AddConflicts(IEnumerable<SyncConflict> conflicts, IsolatedStorageOfflineContext context)
 {
 }
Exemple #31
0
 private void ClearSyncConflict(SyncConflict syncConflict, IsolatedStorageOfflineContext context)
 {
     RemoveSyncConflict(syncConflict);
     context.StorageHandler.ClearSyncConflict((IsolatedStorageSyncConflict)syncConflict);
 }
Exemple #32
0
 /// <summary>
 /// Constructor which intializes the StoreConflict with the specified context.
 /// </summary>
 /// <param name="context"></param>
 internal StoreConflict(IsolatedStorageOfflineContext context)
 {
     this._context = context;
 }
Exemple #33
0
 private void ClearSyncError(SyncError syncError, IsolatedStorageOfflineContext context)
 {
     RemoveSyncError(syncError);
     context.StorageHandler.ClearSyncError((IsolatedStorageSyncError)syncError);
 }
 public SQLiteCacheData Load(IsolatedStorageOfflineContext context)
 {
     return new SQLiteCacheData(_schema, context);
 }
Exemple #35
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 <IsolatedStorageOfflineEntity> updatedItems, IsolatedStorageOfflineContext context)
        {
            // For each of the uploaded entities, reset the state.  No save can happen
            // once sync is started, so this is ok.
            foreach (IsolatedStorageCollection 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);
        }
 public abstract SyncError MapSyncError(IsolatedStorageOfflineEntity entity, SyncError error, IsolatedStorageOfflineContext context);
 /// <summary>
 /// Adds sync conflicts to the data.
 /// </summary>
 /// <param name="conflicts">List of SyncConflict objects</param>
 /// <param name="context">IsolatedStorageOfflineContext</param>
 public void AddConflicts(IEnumerable<SyncConflict> conflicts, IsolatedStorageOfflineContext context)
 {
     foreach (SyncConflict conflict in conflicts)
     {
         AddSyncConflict(conflict, context);
     }
 }