Exemple #1
0
        public AzureSynchronizer(RemoteInfo ri, string container, SynchronizeDirection syncDirection)
        {
            disposed = false;
            string _containerName = container;

            //
            // Setup Store and Provider
            //
            CloudStorageAccount storageAccount = new CloudStorageAccount(new StorageCredentialsAccountAndKey(ri.accountName, ri.accountKey), true);
            AzureBlobStore      blobStore      = new AzureBlobStore(_containerName, storageAccount);

            Console.WriteLine("Successfully created/attached to container {0}.", _containerName);
            AzureBlobSyncProvider azureProvider = new AzureBlobSyncProvider(_containerName, blobStore);

            azureProvider.ApplyingChange += new EventHandler <ApplyingBlobEventArgs>(UploadingFile);

            orchestrator = new SyncOrchestrator();
            orchestrator.RemoteProvider = azureProvider;

            if (syncDirection == SynchronizeDirection.Upload)
            {
                orchestrator.Direction = SyncDirectionOrder.Upload;
            }
            else if (syncDirection == SynchronizeDirection.Download)
            {
                orchestrator.Direction = SyncDirectionOrder.Download;
            }
        }
        // Construct a data store by providing a name for the endpoint (replica) and
        // a file to which we'll persist the sync metadata (file)
        public AzureBlobSyncProvider(
            string name,
            AzureBlobStore store
            )
        {
            _name  = name;
            _store = store;

            _replicaMetadataFile = MetadataDirectory + _name + ".Metadata";
            _replicaIdFile       = MetadataDirectory + _name + ".Replicaid";

            // Set ItemIdFormat and ReplicaIdFormat for using Guid ids.
            _idFormats = new SyncIdFormatGroup();
            _idFormats.ChangeUnitIdFormat.IsVariableLength = false;
            _idFormats.ChangeUnitIdFormat.Length           = 4;
            _idFormats.ItemIdFormat.IsVariableLength       = false;
            _idFormats.ItemIdFormat.Length = 24;
            _idFormats.ReplicaIdFormat.IsVariableLength = false;
            _idFormats.ReplicaIdFormat.Length           = 16;
        }
        public AzureSynchronizer(RemoteInfo ri, string container, SynchronizeDirection syncDirection)
        {
            disposed = false;
            string _containerName = container;

            //
            // Setup Store and Provider
            //
            CloudStorageAccount storageAccount = new CloudStorageAccount(new StorageCredentialsAccountAndKey(ri.accountName, ri.accountKey), true);
            AzureBlobStore blobStore = new AzureBlobStore(_containerName, storageAccount);
            Console.WriteLine("Successfully created/attached to container {0}.", _containerName);
            AzureBlobSyncProvider azureProvider = new AzureBlobSyncProvider(_containerName, blobStore);
            azureProvider.ApplyingChange += new EventHandler<ApplyingBlobEventArgs>(UploadingFile);

            orchestrator = new SyncOrchestrator();
            orchestrator.RemoteProvider = azureProvider;

            if (syncDirection == SynchronizeDirection.Upload)
                orchestrator.Direction = SyncDirectionOrder.Upload;
            else if (syncDirection == SynchronizeDirection.Download)
                orchestrator.Direction = SyncDirectionOrder.Download;
        }
        // Construct a data store by providing a name for the endpoint (replica) and
        // a file to which we'll persist the sync metadata (file)
        public AzureBlobSyncProvider(
            string name, 
            AzureBlobStore store
            )
        {
            _name = name;
            _store = store;

            _replicaMetadataFile = MetadataDirectory + _name + ".Metadata";
            _replicaIdFile = MetadataDirectory + _name + ".Replicaid";

            // Set ItemIdFormat and ReplicaIdFormat for using Guid ids.
            _idFormats = new SyncIdFormatGroup();
            _idFormats.ChangeUnitIdFormat.IsVariableLength = false;
            _idFormats.ChangeUnitIdFormat.Length = 4;
            _idFormats.ItemIdFormat.IsVariableLength = false;
            _idFormats.ItemIdFormat.Length = 24;
            _idFormats.ReplicaIdFormat.IsVariableLength = false;
            _idFormats.ReplicaIdFormat.Length = 16;
        }