Ejemplo n.º 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);
     }
 }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 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}");
        }
Ejemplo n.º 5
0
        public SQLiteCacheData(IsolatedStorageSchema schema, IsolatedStorageOfflineContext context)
        {
//            Collections = new Dictionary<EntityType, IsolatedStorageCollection>();
            SyncConflicts = new List<SyncConflict>();
            SyncErrors = new List<SyncError>();

            CreateCollections(schema, context);
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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");
            }
        }
Ejemplo n.º 10
0
        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();
        }
Ejemplo n.º 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");
            }
        }
Ejemplo n.º 12
0
 public void AddErrors(IEnumerable<SyncError> errors, IsolatedStorageOfflineContext context)
 {
 }
Ejemplo n.º 13
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");
            }
        }
Ejemplo n.º 14
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");
            }
        }
Ejemplo n.º 15
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);
     }
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Constructor which intializes the StoreConflict with the specified context.
 /// </summary>
 /// <param name="context"></param>
 internal StoreConflict(IsolatedStorageOfflineContext context)
 {
     this._context = context;
 }
Ejemplo n.º 17
0
 private void ClearSyncConflict(SyncConflict syncConflict, IsolatedStorageOfflineContext context)
 {
     RemoveSyncConflict(syncConflict);
     context.StorageHandler.ClearSyncConflict((IsolatedStorageSyncConflict)syncConflict);
 }
Ejemplo n.º 18
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);
            }
        }
Ejemplo n.º 19
0
 public void AddSerializedConflict(SyncConflict conflict, IsolatedStorageOfflineContext context)
 {
 }
Ejemplo n.º 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;
//            }
        }
Ejemplo n.º 21
0
 public void AddUploadChanges(byte[] anchor, IEnumerable<Conflict> conflicts, IEnumerable<IsolatedStorageOfflineEntity> updatedItems, IsolatedStorageOfflineContext context)
 {
 }
Ejemplo n.º 22
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);                
            }
        }
 public abstract SyncConflict MapSyncConflict(IsolatedStorageOfflineEntity entity, SyncConflict conflict, IsolatedStorageOfflineContext context);
Ejemplo n.º 24
0
 public void AddSerializedError(SyncError error, IsolatedStorageOfflineContext context)
 {
 }
Ejemplo n.º 25
0
        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);
            }
        }
Ejemplo n.º 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);
Ejemplo n.º 29
0
 private void ClearSyncError(SyncError syncError, IsolatedStorageOfflineContext context)
 {
     RemoveSyncError(syncError);
     context.StorageHandler.ClearSyncError((IsolatedStorageSyncError)syncError);
 }
Ejemplo n.º 30
0
 public void AddConflicts(IEnumerable<SyncConflict> conflicts, IsolatedStorageOfflineContext context)
 {
 }
Ejemplo n.º 31
0
 private void ClearSyncConflict(SyncConflict syncConflict, IsolatedStorageOfflineContext context)
 {
     RemoveSyncConflict(syncConflict);
     context.StorageHandler.ClearSyncConflict((IsolatedStorageSyncConflict)syncConflict);
 }
Ejemplo n.º 32
0
 /// <summary>
 /// Constructor which intializes the StoreConflict with the specified context.
 /// </summary>
 /// <param name="context"></param>
 internal StoreConflict(IsolatedStorageOfflineContext context)
 {
     this._context = context;
 }
Ejemplo n.º 33
0
 private void ClearSyncError(SyncError syncError, IsolatedStorageOfflineContext context)
 {
     RemoveSyncError(syncError);
     context.StorageHandler.ClearSyncError((IsolatedStorageSyncError)syncError);
 }
Ejemplo n.º 34
0
 public SQLiteCacheData Load(IsolatedStorageOfflineContext context)
 {
     return new SQLiteCacheData(_schema, context);
 }
Ejemplo n.º 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);
Ejemplo n.º 37
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);
     }
 }