public IOperation Create(FileSystemWatcherEventArgs eventArgs, IFileSender fileSender)
        {
            IOperation result;

            switch (eventArgs.ChangeType)
            {
                case FileSystemWatcherChangeType.Renamed:
                {
                    result = this.CreateRenameOperation(eventArgs, fileSender);
                    break;
                }
                case FileSystemWatcherChangeType.Synchronize:
                {
                    result = this.CreateSynchronizeOperation(eventArgs, fileSender);
                    break;
                }
                default:
                {
                    result = this.CreateCopyOperation(eventArgs, fileSender);
                    break;
                }
            }

            return result;
        }
 public LocalFileReader(IFileSender sendAdapter, IHandleUpdateResponsed responsedHandler = null,
                        IHandleFileSendProgress progressHandler = null) : this()
 {
     this._sendAdapter      = sendAdapter;
     this._responsedHandler = responsedHandler;
     this._progressHandler  = progressHandler;
 }
        private IOperation CreateRenameOperation(FileSystemWatcherEventArgs eventArgs, IFileSender fileSender)
        {
            var renameArgs = eventArgs as FileSystemWatcherRenameEventArgs;
            if (renameArgs == null)
            {
                throw new ArgumentException("The operation is specified as 'Rename' but the actual arguments is different.");
            }

            return _renameOperationFactory.Invoke(renameArgs.OldName, renameArgs.Name, fileSender);
        }
Example #4
0
        /// <summary>
        /// 생성자
        /// </summary>
        protected FileServiceBase(IFileRepository repository)
        {
            if(IsDebugEnabled)
                log.Debug("FileSerivce 인스턴스를 생성합니다... repository=[{0}]", repository);

            var parameters = new Dictionary<object, object> {{"repository", repository}};

            Receiver = IoC.Resolve<IFileReceiver>(parameters);
            Sender = IoC.Resolve<IFileSender>(parameters);
        }
Example #5
0
        public FileHandler(string mailToSendFP, string invalidMailFP, IFileWatcher watcher, IFileManipulator manipulator, IFileSender sender, ILog logger)
        {
            this.MailToSendFP  = mailToSendFP;
            this.InvalidMailFP = invalidMailFP;

            this._fileWatcher = watcher;
            this._manipulator = manipulator;
            this._fileSender  = sender;
            this._logger      = logger;

            this._manipulator.CreateFolder(this.MailToSendFP);
            this._manipulator.CreateFolder(this.InvalidMailFP);
        }
Example #6
0
        /// <summary>
        /// 생성자
        /// </summary>
        protected FileServiceBase(IFileRepository repository)
        {
            if (IsDebugEnabled)
            {
                log.Debug("FileSerivce 인스턴스를 생성합니다... repository=[{0}]", repository);
            }

            var parameters = new Dictionary <object, object> {
                { "repository", repository }
            };

            Receiver = IoC.Resolve <IFileReceiver>(parameters);
            Sender   = IoC.Resolve <IFileSender>(parameters);
        }
Example #7
0
        public FolderWatcher(IConfiguration configuration, IFileSender fileSender)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            if (fileSender == null)
            {
                throw new ArgumentNullException("fileSender");
            }

            _configuration = configuration;
            _fileSender    = fileSender;

            InitilaizeFileSystemWatcher();
        }
        private void LanFileListTransfer(ClientToken targetToken, string[] filePathList)
        {
            IFileSender adapter      = FileUpdateClientProxy.CreateTcpProxy(targetToken.GenServiceAddress());
            var         easyTransfer = new LocalFileReader(adapter, this, this);

            List <Task> taskList = new List <Task>();

            foreach (var path in filePathList)
            {
                Task t = new Task(() =>
                {
                    //bug : appeared throw
                    easyTransfer.RunFileTransfer(path);//这个接口目前只支持局域网
                });
                taskList.Add(t);
                t.Start();
            }
            Task.WaitAll(taskList.ToArray());//使用多线程上传文件
        }
Example #9
0
        public MainForm(IAboutBox aboutBox,
                        ILogger logger,
                        IEchoer echoer,
                        IFileSender fileSender,
                        CurrentDataDevice dataDevice,
                        WinformsMainMenuExtender mainMenuExtender,
                        IEnumerable<IStatusbarExtension> statusbarExtensions)
        {
            _aboutBox = aboutBox;
            _logger = logger;
            _echoer = echoer;
            _fileSender = fileSender;
            _mainMenuExtender = mainMenuExtender;
            _statusbarExtensions = statusbarExtensions;

            _currentDataDevice = dataDevice;
            _currentDataDevice.PropertyChanged += (sender, args) =>
                                                    {
                                                        var oldDataDevice = _dataDevice;
                                                        _dataDevice = _currentDataDevice.CurrentDevice;
                                                        if (_dataDevice != null)
                                                        {
                                                            _dataDevice.PropertyChanged += DataDeviceOnPropertyChanged;
                                                            _dataDevice.DataReceived += DataDeviceOnDataReceived;
                                                        }
                                                        if (oldDataDevice != null)
                                                        {
                                                            oldDataDevice.PropertyChanged -= DataDeviceOnPropertyChanged;
                                                            oldDataDevice.DataReceived -= DataDeviceOnDataReceived;
                                                        }
                                                    };

            _dataDevice = _currentDataDevice.CurrentDevice;

            Log.Debug("Mainform object created");
        }
 private IOperation CreateSynchronizeOperation(FileSystemWatcherEventArgs eventArgs, IFileSender fileSender)
 {
     return _synchronizationOperationFactory.Invoke(eventArgs.FullPath, fileSender);
 }
 private IOperation CreateCopyOperation(FileSystemWatcherEventArgs eventArgs, IFileSender fileSender)
 {
     return _copyOperationFactory.Invoke(eventArgs.FullPath, fileSender);
 }
 public FtpProxyController(ILogger <FtpProxyController> logger, IFileSender sender)
 {
     this.Logger = logger;
     this.Sender = sender;
 }
Example #13
0
 public FileTransferTest(IFileSender fileSender)
 {
     reader = new LocalFileReader(fileSender);
 }
 public CopyOperation(string path, IFileSender fileSender)
 {
     _path = path;
     _fileSender = fileSender;
 }
 public SynchronizationOperation(string path, IFileSender fileSender)
 {
     _path = path;
     _fileSender = fileSender;
 }
Example #16
0
 public Worker(IDirectoryWatcher directoryWatcher, IFileSender fileSender, ILogger <Worker> logger)
 {
     _logger           = logger;
     _fileSender       = fileSender;
     _directoryWatcher = directoryWatcher;
 }