Beispiel #1
0
        /// <summary>
        /// Возвращает только кешированные хранилища метаданнх для определенной реплики
        /// </summary>
        /// <param name="replicaId">The replica id.</param>
        /// <returns></returns>
        public static SyncMetadataStore OpenStore(SyncId replicaId)
        {
            SyncMetadataStore retVal = null;

            try
            {
                lock (_lock)
                {
                    ReplicaMetadataAdaptor replica;
                    if (!_replicaCache.TryGetValue(replicaId, out replica))
                    {
                        replica = ReplicaMetadataAdaptor.CreateInstance(replicaId);
                        if (replica != null)
                        {
                            _replicaCache.Add(replicaId, replica);
                        }
                    }

                    retVal = new SyncMetadataStore(replica);
                }
            }
            catch (ArgumentException)
            {
            }
            return(retVal);
        }
Beispiel #2
0
 protected override void InitializeMetaDataStore()
 {
     if (_metaDataStore == null || _metaData == null)
     {
         // Values for adding a custom field to the metadata store
         List <FieldSchema> fields = new List <FieldSchema>();
         _metaDataStore = SyncMetadataStore.OpenStore(ReplicaId);
         _metaData      = _metaDataStore.GetReplicaMetadata(IdFormats, ReplicaId);
     }
 }
Beispiel #3
0
        protected override void BeginTransaction()
        {
            if (_metaDataStore == null)
            {
                throw new ArgumentNullException("metadata store not initialized");
            }

            SyncMetadataStore metaDataStore = _metaDataStore as SyncMetadataStore;

            metaDataStore.BeginTransaction();
        }
Beispiel #4
0
        /// <summary>
        /// Создает хранилище метаданных реплики
        /// </summary>
        /// <param name="replicaId">The replica id.</param>
        /// <param name="idFormats">The id formats.</param>
        /// <returns></returns>
        public static SyncMetadataStore CreateStore(SyncId replicaId, int principalId)
        {
            SyncMetadataStore      retVal  = null;
            ReplicaMetadataAdaptor replica = ReplicaMetadataAdaptor.CreateInstance(replicaId, StaticIdFormats);

            if (replica != null)
            {
                replica.PrincipalId = principalId;
                replica.Save();
            }
            retVal = OpenStore(replicaId);
            return(retVal);
        }
Beispiel #5
0
        /// <summary>
        /// Создает экземпляр провайдера для заданного пользователя
        /// </summary>
        /// <param name="principalId">The principal id.</param>
        /// <returns></returns>
        public static CalendarEventSyncProvider CreateInstance(int principalId)
        {
            CalendarEventSyncProvider retVal = null;

            lock (_lock)
            {
                SyncId replicaId = SyncMetadataStore.FindReplicaIdByPrincipalId(principalId);
                if (replicaId == null)
                {
                    //генерируем новый replica id
                    replicaId = new SyncId(Guid.NewGuid());
                    //Создаем новое хранилище метаданных реплики
                    SyncMetadataStore.CreateStore(replicaId, principalId);
                }

                retVal = new CalendarEventSyncProvider(replicaId);
                retVal.InitializeMetaDataStore();
            }
            return(retVal);
        }
Beispiel #6
0
        /// <summary>
        /// Возвращает только кешированные хранилища метаданнх для определенной реплики 
        /// </summary>
        /// <param name="replicaId">The replica id.</param>
        /// <returns></returns>
        public static SyncMetadataStore OpenStore(SyncId replicaId)
        {
            SyncMetadataStore retVal = null;
            try
            {
                lock (_lock)
                {
                    ReplicaMetadataAdaptor replica;
                    if (!_replicaCache.TryGetValue(replicaId, out replica))
                    {
                        replica = ReplicaMetadataAdaptor.CreateInstance(replicaId);
                        if (replica != null)
                        {
                            _replicaCache.Add(replicaId, replica);
                        }
                    }

                    retVal = new SyncMetadataStore(replica);
                }
            }
            catch (ArgumentException)
            {
            }
            return retVal;
        }