예제 #1
0
        public FilesStore()
        {
            Credentials = CredentialCache.DefaultNetworkCredentials;

            SharedOperationsHeaders = new NameValueCollection();
            Conventions = new FilesConvention();
        }
예제 #2
0
파일: FilesStore.cs 프로젝트: lahma/ravendb
        public FilesStore()
        {
            Credentials = CredentialCache.DefaultNetworkCredentials;

            SharedOperationsHeaders = new NameValueCollection();
            Conventions             = new FilesConvention();
        }
예제 #3
0
        public AbstractFilesQuery(InMemoryFilesSessionOperations theSession, IAsyncFilesCommands commands)
        {
            this.conventions      = theSession == null ? new FilesConvention() : theSession.Conventions;
            this.linqPathProvider = new LinqPathProvider(conventions);

            this.Session  = theSession;
            this.Commands = commands;
        }
예제 #4
0
        private const int DefaultNumberOfCachedRequests = 2048;         //put this in asyncserverclient

        public SynchronizationServerClient(string serverUrl, string fileSystem, string apiKey, ICredentials credentials, FilesConvention convention = null,
                                           OperationCredentials operationCredentials = null, HttpJsonRequestFactory requestFactory = null, NameValueCollection operationsHeaders = null)
        {
            serverUrl                 = serverUrl.TrimEnd('/');
            baseUrl                   = serverUrl + "/fs/" + Uri.EscapeDataString(fileSystem);
            credentials               = credentials ?? CredentialCache.DefaultNetworkCredentials;
            this.filesConvention      = convention ?? new FilesConvention();
            this.operationCredentials = operationCredentials ?? new OperationCredentials(apiKey, credentials);
            this.requestFactory       = requestFactory ?? new HttpJsonRequestFactory(DefaultNumberOfCachedRequests);
            this.OperationsHeaders    = operationsHeaders ?? new NameValueCollection();

            SecurityExtensions.InitializeSecurity(Conventions, RequestFactory, serverUrl, credentials);
        }
예제 #5
0
		private const int DefaultNumberOfCachedRequests = 2048; //put this in asyncserverclient

		public SynchronizationServerClient(string serverUrl, string fileSystem, string apiKey, ICredentials credentials, FilesConvention convention = null, 
			OperationCredentials operationCredentials = null, HttpJsonRequestFactory requestFactory = null, NameValueCollection operationsHeaders = null)
		{
			serverUrl = serverUrl.TrimEnd('/');
			baseUrl = serverUrl + "/fs/" + Uri.EscapeDataString(fileSystem);
			credentials = credentials ?? CredentialCache.DefaultNetworkCredentials;
			this.filesConvention = convention ?? new FilesConvention();
			this.operationCredentials = operationCredentials ?? new OperationCredentials(apiKey, credentials);
			this.requestFactory = requestFactory ?? new HttpJsonRequestFactory(DefaultNumberOfCachedRequests);
			this.OperationsHeaders = operationsHeaders ?? new NameValueCollection();

			SecurityExtensions.InitializeSecurity(Conventions, RequestFactory, serverUrl, credentials);
		}
예제 #6
0
        public async Task<SynchronizationReport> SynchronizeFileToAsync(string fileName, SynchronizationDestination destination)
        {
            ICredentials credentials = null;
            if (string.IsNullOrEmpty(destination.Username) == false)
            {
                credentials = string.IsNullOrEmpty(destination.Domain)
                                  ? new NetworkCredential(destination.Username, destination.Password)
                                  : new NetworkCredential(destination.Username, destination.Password, destination.Domain);
            }

            var conventions = new FilesConvention();
            if (string.IsNullOrEmpty(destination.AuthenticationScheme) == false)
                conventions.AuthenticationScheme = destination.AuthenticationScheme;

            var destinationClient = new SynchronizationServerClient(destination.ServerUrl, destination.FileSystem, convention: conventions, apiKey: destination.ApiKey, credentials: credentials);

            RavenJObject destinationMetadata;

            try
            {
                destinationMetadata = await destinationClient.GetMetadataForAsync(fileName).ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                var exceptionMessage = "Could not get metadata details for " + fileName + " from " + destination.Url;
                Log.WarnException(exceptionMessage, ex);

                return new SynchronizationReport(fileName, Guid.Empty, SynchronizationType.Unknown)
                {
                    Exception = new SynchronizationException(exceptionMessage, ex)
                };
            }

            RavenJObject localMetadata = GetLocalMetadata(fileName);

            NoSyncReason reason;
            SynchronizationWorkItem work = synchronizationStrategy.DetermineWork(fileName, localMetadata, destinationMetadata, FileSystemUrl, out reason);

            if (work == null)
            {
                Log.Debug("File '{0}' was not synchronized to {1}. {2}", fileName, destination.Url, reason.GetDescription());

                return new SynchronizationReport(fileName, Guid.Empty, SynchronizationType.Unknown)
                {
                    Exception = new SynchronizationException(reason.GetDescription())
                };
            }

            return await PerformSynchronizationAsync(destinationClient, work).ConfigureAwait(false);
        }
 public RegionMetadataBasedResolutionStrategy(IList<string> shardIds, ShardStrategy.ModifyFileNameFunc modifyFileName, FilesConvention conventions)
 {
     this.shardIds = shardIds;
     this.modifyFileName = modifyFileName;
     this.conventions = conventions;
 }
예제 #8
0
 public CountryResolutionStrategy(IList<string> shardIds, ShardStrategy.ModifyFileNameFunc modifyFileName, FilesConvention conventions)
 {
     this.shardIds = shardIds;
     this.modifyFileName = modifyFileName;
     this.conventions = conventions;
 }
예제 #9
0
 public FilesStore()
 {
     SharedOperationsHeaders = new NameValueCollection();
     Conventions             = new FilesConvention();
 }
예제 #10
0
 public FilesStore()
 {
     SharedOperationsHeaders = new NameValueCollection();
     Conventions = new FilesConvention();
 }