Ejemplo n.º 1
0
        /// <summary>
        /// Возвращает версию файла для репликации.
        /// </summary>
        /// <param name="remoteNode">Удаленный узел хранилища.</param>
        /// <param name="folderUrl">Папка файла.</param>
        /// <param name="fileUniqueID">Идентификатор файла.</param>
        /// <param name="fileVersionUniqueID">Идентификатор версии.</param>
        /// <returns></returns>
        public IRemoteFile GetReplicationFile(IStorageNode remoteNode, string folderUrl, Guid fileUniqueID, Guid fileVersionUniqueID)
        {
            if (remoteNode == null)
            {
                throw new ArgumentNullException("remoteNode");
            }

            if (string.IsNullOrEmpty(folderUrl))
            {
                throw new ArgumentNullException("folderUrl");
            }

            WcfRemoteFile remoteFile = null;

            try
            {
                ChannelFactory <IStorageReplicationService> channelFactory = this.CreateServiceChannel(remoteNode.Host);
                using (channelFactory)
                {
                    IStorageReplicationService client   = channelFactory.CreateChannel();
                    WcfRemoteFileInfo          fileInfo = WcfRemoteFileInfo.FromRemoteFileInfo(folderUrl, fileUniqueID, fileVersionUniqueID);
                    remoteFile = client.GetReplicationFile(fileInfo);
                }
            }
            catch (Exception ex)
            {
                this.Logger.WriteMessage(ex.ToString(), LogLevel.Error);
            }

            return(remoteFile);
        }
        public WcfRemoteFile GetReplicationFile(WcfRemoteFileInfo fileInfo)
        {
            var folder = this.Engine.GetFolder(fileInfo.FolderUrl);

            if (folder == null)
            {
                return(null);
            }

            var file = folder.GetFile(fileInfo.FileID, new GetFileOptions {
                LoadContent = false
            }, false);
            var version = file.GetVersion(fileInfo.VersionID, false);

            if (version == null)
            {
                return(null);
            }

            return(WcfRemoteFile.FromFileVersion(version));
        }