private IRenameOperation CreateRenameOperation(FileMessage message)
        {
            string oldPath = Path.Combine(_destinationPath, message.Harvester, message.FileName);
            string newPath = Path.Combine(_destinationPath, message.Harvester, message.NewName);

            return _renameOperationFactory.Invoke(oldPath, newPath);
        }
        public IOperation Create(FileMessage message)
        {
            IOperation result;

            switch (message.OperationType)
            {
                case OperationType.Renamed:
                {
                    result = this.CreateRenameOperation(message);
                    break;
                }
                case OperationType.Synchronize:
                {
                    result = this.CreateSynchronizationOperation(message);
                    break;
                }
                default:
                {
                    result = this.CreateCopyOperation(message);
                    break;
                }
            }

            return result;
        }
Ejemplo n.º 3
0
        public void Send(FileMessage message)
        {
            if (message == null)
            {
                throw new ArgumentNullException("message");
            }

            message.Harvester = _harvester;

            _transferManager.Send(message);
        }
Ejemplo n.º 4
0
        public async Task Perform()
        {
            using (var sourceStream = new FileStream(_path, FileMode.Open, FileAccess.Read, FileShare.Read, DefaultBufferSize, FileOptions.Asynchronous))
            {
                byte[] fileContent = new byte[sourceStream.Length];
                await sourceStream.ReadAsync(fileContent, 0, fileContent.Length);
                var message = new FileMessage
                {
                    FileContent = fileContent,
                    FileName = System.IO.Path.GetFileName(this.Path),
                    OperationType = OperationType.Changed
                };

                _fileSender.Send(message);
            }
        }
Ejemplo n.º 5
0
 public CopyOperation(string destinationPath, FileMessage fileMessage)
 {
     _fileMessage = fileMessage;
     _path = System.IO.Path.Combine(destinationPath, fileMessage.FileName);
 }
        private ISynchronizationOperation CreateSynchronizationOperation(FileMessage message)
        {
            ICopyOperation copyOperation = this.CreateCopyOperation(message);

            return _synchronizationOperationFactory.Invoke(copyOperation);
        }
        private ICopyOperation CreateCopyOperation(FileMessage message)
        {
            string pathWithHarvesterName = Path.Combine(_destinationPath, message.Harvester);

            return _copyOperationFactory.Invoke(pathWithHarvesterName, message);
        }