Beispiel #1
0
        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));
        }
Beispiel #2
0
 private bool RefreshLastActivityList(List <Uri> urls)
 {
     try
     {
         FilesData.CreateDirectoryIfNotExists(FilesData.LastFilesUrls);
         var path = FilesData.GetDirectoryPath(FilesData.LastFilesUrls, FilesData.TextFile);
         FilesData.SetFileTextWithData(path, urls);
         return(true);
     }
     catch (Exception ex)  {
         //Log Exception
         return(false);
     }
 }
        /// <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
            }
        }