Пример #1
0
        public IEnumerable <FileSystemItem> GetDrives(FileSystemRequest request)
        {
            requestPool.CancellAllFromSourceInGroup(request.SourceToken, EploreFilesOperationsGroup);

            if (request.Cached)
            {
                var cached = fileSystemItemsCacheRepository.TryGet("DrivesListCache");
                if (cached != null)
                {
                    return(cached);
                }
            }

            return(DoGetDrives(request));
        }
        public IStep Step(FileSystemRequest request)
        {
            if (IsCommited(request))
            {
                Response            = new FileSystemResponse(request);
                Response.FileStatus = request.FileStatus;
                Response.IsSuccess  = false;
            }
            else
            {
                Response = Commit(request);
            }

            return(this);
        }
Пример #3
0
        private void CreatePipeLine(FileSystemRequest request)
        {
            switch (request.Command.Split()[0])
            {
            case "Commit":
                nextStep = new ChangeFIleStatusStep(worker);
                break;

            case "Reset":
                nextStep = new ResetFileSystemStep(worker);
                break;

            case "Status":
                nextStep = new CheckFileSystemStep(worker);
                break;
            }
        }
Пример #4
0
        private CountFilesResponse DoCount(FileSystemRequest request)
        {
            var cancellableOperation = new CancellableOperation <string, CountFilesResult>(
                fileExplorerService.CountFilesInDirectory, request.Path, request.SourceToken, CountOperationsGroup);

            requestPool.Add(cancellableOperation);

            cancellableOperation.CancelAfter(requestConfiguration.ExecutionTimeout);
            cancellableOperation.Operation.Wait();

            var result   = cancellableOperation.Operation.Result;
            var response = CreateCountFilesResponse(result, cancellableOperation.Cancelled);

            countFilesCacheRepository.Add(request.Path, response);

            return(response);
        }
Пример #5
0
        private IEnumerable <FileSystemItem> DoGetDrives(FileSystemRequest request)
        {
            var cancellableOperation = new CancellableOperation <string, IEnumerable <FileSystemItem> >(
                fileExplorerService.GetDrives, request.SourceToken, EploreFilesOperationsGroup);

            cancellableOperation.CancelAfter(requestConfiguration.ExecutionTimeout);
            cancellableOperation.Operation.Wait();

            var result = cancellableOperation.Operation.Result;

            if (result.Any())
            {
                fileSystemItemsCacheRepository.Add("DrivesListCache", result.ToArray());
            }

            return(result);
        }
Пример #6
0
        public CountFilesResponse CountFiles(FileSystemRequest request)
        {
            if (String.IsNullOrWhiteSpace(request.Path))
            {
                return(null);
            }

            requestPool.CancellAllFromSourceInGroup(request.SourceToken, CountOperationsGroup);

            if (request.Cached)
            {
                var cached = countFilesCacheRepository.TryGet(request.Path);
                if (cached != null)
                {
                    return(cached);
                }
            }

            return(DoCount(request));
        }
        public FileManager(ListView listBox, ArchiveService archiver, FileService fileService, FileManager fileManager)
        {
            Init(listBox, archiver, fileService);
            OnArchiveRequested             = new FileSystemRequest(fileManager.Archive);
            fileManager.OnArchiveRequested = new FileSystemRequest(Archive);

            OnDecompressRequested             = new FileSystemRequest(fileManager.Decompress);
            fileManager.OnDecompressRequested = new FileSystemRequest(Decompress);

            OnCopyRequested             = new FileSystemRequest(fileManager.Copy);
            fileManager.OnCopyRequested = new FileSystemRequest(Copy);

            OnMoveRequested             = new FileSystemRequest(fileManager.Move);
            fileManager.OnMoveRequested = new FileSystemRequest(Move);

            OnRefreshRequested             = new RefreshRequest(fileManager.Refresh);
            fileManager.OnRefreshRequested = new RefreshRequest(Refresh);

            OnRootChangeRequested             = new RootChangeRequest(fileManager.ChangeRoot);
            fileManager.OnRootChangeRequested = new RootChangeRequest(ChangeRoot);
        }
Пример #8
0
        public FileSystemResponse Read(FileSystemRequest request)
        {
            string[] fileNames = null;
            var      folder    = request.FileStatus[0].FolderName;

            fileNames = GetFilesFromDirectory(folder);
            fileNames = GetFileNames(request, fileNames);

            // string content = null;
            List <FileStatus> files = new List <FileStatus>();

            foreach (var fileName in fileNames)
            {
                var fileStatus = new FileStatus()
                {
                    FileName   = fileName,
                    FolderName = folder,
                };

                fileStatus.Content = ReadContent(fileName);

                var splitFileName = fileName.Split('_')[0].Split('\\').Last();

                if (request.FileStatus[0].FileName.Contains(splitFileName))
                {
                    files.Add(fileStatus);
                }
            }

            var response = new FileSystemResponse(request)
            {
                FileStatus = files,
            };

            return(response);
        }
Пример #9
0
        public IStep Step(FileSystemRequest request)
        {
            try
            {
                var firstRequest = (FileSystemRequest)request.Clone();
                var command      = firstRequest.Command.Split();
                var fileName     = command[1].Split('.');
                firstRequest.FileStatus[0].FileName   = fileName[0] + "_" + (DateTime.Parse($"{command[2]} {command[3].Replace(".", ":")}")).ToString().Replace(":", ".") + ".txt";
                firstRequest.FileStatus[0].FolderName = request.FileStatus[0].FolderName + "\\Backup";

                var backupFile = worker.Read(firstRequest);
                request.FileStatus[0].Content = backupFile.FileStatus[0].Content;
                var response = worker.Write(request);

                Response           = response;
                Response.IsSuccess = true;
            }
            catch (Exception)
            {
                Response.IsSuccess = false;
            }

            return(this);
        }
        public IStep Step(FileSystemRequest request)
        {
            var files  = worker.Read(request.FileStatus[0].FolderName);
            var status = new List <FileStatus>();

            foreach (var item in files.FileStatus)
            {
                if (IsCommited(item, request))
                {
                    item.FileStatusSetings = FileStatusSetings.Commit;
                }
                else
                {
                    item.FileStatusSetings = FileStatusSetings.Change;
                }

                status.Add(item);
            }

            files.FileStatus = status;
            Response         = files;

            return(this);
        }
Пример #11
0
 public IStep Step(FileSystemRequest request)
 {
     CreatePipeLine(request);
     return(nextStep.Step(request));
 }