public async Task <ActionResult> DownloadFiles(string downloadData, int degreeOfParallelism) { ResponseMessage response = new ResponseMessage { Success = true, Message = "Download Cancelled!" }; if (!string.IsNullOrEmpty(downloadData)) { var fileData = new DownloadModel { DataUrl = JsonConvert.DeserializeObject <List <DataUrl> >(downloadData), PathToDownload = FilesData.MapPathFolder(FilesData.DownloadFiles), degreeOfParallelism = degreeOfParallelism, }; FilesData.CreateDirectoryIfNotExists(FilesData.DownloadFiles); if (fileData.DataUrl.Any()) { response = (ResponseMessage)await _fileServices.DownloadFiles(fileData); } } return(Json(new { data = JsonConvertExtensions.GetJsonConvert(response) }, JsonRequestBehavior.AllowGet)); }
private FileViewModel GetFileViewModel(bool isRefresh) { var model = new FileViewModel(); var dataFiles = _fileServices.GetListOfFiles().ToList(); if (!isRefresh) { var path = FilesData.MapPathFolder(FilesData.LastFiles); var lastActivity = _memoryCache.Get(string.Format(Constants.GetLastActivityListOfFilesCacheKey), () => _fileServices.GetLastActivityListOfFiles(path).ToList()); _fileModelFactory.PrepareLastFileViewModel(lastActivity, model); } _fileModelFactory.PrepareFileViewModel(dataFiles, model); RefreshLastActivityList(dataFiles); return(model); }
/// <inheritdoc /> public IResponseMessage CleanCurrentDirecoryData() { ResponseMessage response = new ResponseMessage { Success = true, Message = "Direcory deleted sucessfully" }; try { FilesData.DeleteDirectoryOrContent(FilesData.MapPathFolder(FilesData.DownloadFiles), true); FilesData.DeleteDirectoryOrContent(FilesData.MapPathFolder(FilesData.LastFiles), true); return(response); }catch (Exception ex) { response.Success = false; response.Message = ex.GetFullMessage(); return(response); } }
/// <summary> /// Load Last Activity /// </summary> public async Task GetLatesActivity() { try { var fileServices = DependencyResolver.Current.GetService <IFileServices>(); var memoryCache = DependencyResolver.Current.GetService <IMemoryCache>(); var textFilePath = FilesData.MapPathFolder(FilesData.LastFilesUrls) + FilesData.TextFile; FilesData.CreateDirectoryIfNotExists(FilesData.LastFiles); var pathLastFiles = FilesData.MapPathFolder(FilesData.LastFiles); var downloadModel = new DownloadModel { PathToDownload = pathLastFiles, }; FilesData.GetFileTextWithData(textFilePath).ForEach(x => downloadModel.DataUrl.Add(new DataUrl { AbsoluteUri = x })); await fileServices.DownloadFiles(downloadModel); memoryCache.Set(string.Format(Constants.GetLastActivityListOfFilesCacheKey), fileServices.GetLastActivityListOfFiles(pathLastFiles)); } catch (Exception ex) { //Log Exception } }