/// <summary> /// Initializes the meta data store. /// </summary> protected override void InitializeMetaDataStore() { // Values for adding a custom field to the metadata store List <FieldSchema> fields = new List <FieldSchema>(); SyncId id = ReplicaId; string replicaMetadataFile = _activeSyncSetting.replicaStoreFileName; // Create or open the metadata store, initializing it with the id formats we'll use to reference our items and endpoints if (!File.Exists(replicaMetadataFile)) { fields.Add(new FieldSchema(TIMESTAMP_COLUMNNAME, typeof(System.UInt64))); fields.Add(new FieldSchema(URI_COLUMNNAME, typeof(string), 1024)); _metaDataStore = SqlMetadataStore.CreateStore(replicaMetadataFile); _metaDataStore.InitializeReplicaMetadata(IdFormats, ReplicaId, fields, new IndexSchema[] { new IndexSchema(URI_COLUMNNAME, true) }); } else { _metaDataStore = SqlMetadataStore.OpenStore(replicaMetadataFile); } _metaData = _metaDataStore.GetReplicaMetadata(IdFormats, ReplicaId); //Если ReplicaId изменилась то необходимо пересоздать хранилище if (_metaData.ReplicaId != ReplicaId) { CloseMetaDataStore(); File.Delete(replicaMetadataFile); InitializeMetaDataStore(); } }
private void InitializeMetadataStore() { SyncId id = ReplicaId; if (!File.Exists(_replicaMetadataFile)) { _metadataStore = SqlMetadataStore.CreateStore(_replicaMetadataFile); } else { _metadataStore = SqlMetadataStore.OpenStore(_replicaMetadataFile); } }
private void InitializeMetadataStore() { SyncId id = ReplicaId; // Create or open the metadata store, initializing it with the id formats we'll use to reference our items and endpoints if (!File.Exists(_replicaMetadataFile)) { _metadataStore = SqlMetadataStore.CreateStore(_replicaMetadataFile); } else { _metadataStore = SqlMetadataStore.OpenStore(_replicaMetadataFile); } }
private void InitializeMetadataStore() { // Values for adding a custom field to the metadata store List <FieldSchema> fields = new List <FieldSchema>(); SyncId id = ReplicaId; // Create or open the metadata store, initializing it with the id formats we'll use to reference our items and endpoints if (!File.Exists(_replicaMetadataFile)) { fields.Add(new FieldSchema(TIMESTAMP_COLUMNNAME, typeof(System.UInt64))); _metadataStore = SqlMetadataStore.CreateStore(_replicaMetadataFile); _metadata = _metadataStore.InitializeReplicaMetadata(_idFormats, _replicaId, fields, null /*No indexes to create*/); } else { _metadataStore = SqlMetadataStore.OpenStore(_replicaMetadataFile); _metadata = _metadataStore.GetReplicaMetadata(_idFormats, _replicaId); } }
public void InitializeMetadataStore() { List <FieldSchema> fields = new List <FieldSchema>(); if (!File.Exists(_replicaMetadataFile)) { fields.Add(new FieldSchema(ID_COLUMNNAME, typeof(string), idLength)); fields.Add(new FieldSchema(PATH_COLUMNNAME, typeof(string), pathLength)); _metadataStore = SqlMetadataStore.CreateStore(_replicaMetadataFile); var indexes = new List <IndexSchema> { new IndexSchema(ID_COLUMNNAME, false) }; _metadata = _metadataStore.InitializeReplicaMetadata(_idFormats, new SyncId(Guid.NewGuid()), fields, indexes); } else { _metadataStore = SqlMetadataStore.OpenStore(_replicaMetadataFile); _metadata = _metadataStore.GetSingleReplicaMetadata(); } ReplicaId = _metadata.ReplicaId; }
private void CreateMetadataStore( string metadataFilePath ) { if (metadataFilePath == null) { throw new ArgumentNullException("metadataFilePath"); } SqlMetadataStore result; // Create or open the metadata store, initializing it with the ID formats // that are used to reference items and replicas. if (!File.Exists(metadataFilePath)) { result = SqlMetadataStore.CreateStore(metadataFilePath); } else { result = SqlMetadataStore.OpenStore(metadataFilePath); } _metadataStore = result; }