Пример #1
0
        private static bool DownloadFile(FileToDownload file, string destinationfolder)
        {
            List <FileToDownload> files = new List <FileToDownload>();

            files.Add(file);
            return(DownloadFile(files, destinationfolder));
        }
Пример #2
0
        private void AddToDownloadQueue(FileToDownload file, string targetFolder)
        {
            var downloadItem = new DownloadItem(file.PrettyName, file, targetFolder + file.OutName);

            downloadItem.SetStatus("pending");
            downloadQueue.Add(downloadItem);
        }
Пример #3
0
 public DownloadItem(string title, FileToDownload fileToDownload, string destination)
 {
     originalTitle  = title;
     Title          = title;
     FileToDownload = fileToDownload;
     Destination    = destination;
     Percentage     = 0;
 }
Пример #4
0
        public async Task <IActionResult> Index(IFormFile uploadedFile)
        {
            IText text;

            string[] file = uploadedFile.FileName.Split('.');
            if (uploadedFile != null)
            {
                string path     = "wwwroot/Files/" + file[0] + DateTime.Now.ToString("yyyyMMdd_HHmmssff") + "." + file[1];
                string xslsPath = path.Replace($".{file[1]}", ".xlsx");
                using (var fileStream = new FileStream(path, FileMode.Create))
                {
                    await uploadedFile.CopyToAsync(fileStream);
                }
                var uploaded = new UploadedFile()
                {
                    Filename = path.Replace("wwwroot/Files/", ""), Extension = uploadedFile.ContentType
                };
                _app.UploadedFiles.Add(uploaded);
                ICollection <string> strings = _fileService.GetData(path, uploadedFile.ContentType);
                text = _parser.ParseText(strings);
                IEnumerable <ConcordanceItem> x = _textService.Concordance(text);
                var morph = _textService.ConcordanceMorphy(x);
                var items = _mapper.Map <IEnumerable <ConcordanceItemsDTO>, IEnumerable <ConcordanceItemViewModel> >(morph);
                _fileService.WriteData(morph, xslsPath);
                var toDownload = new FileToDownload()
                {
                    Filename = xslsPath.Replace("wwwroot/Files/", "")
                };
                _app.FileToDownloads.Add(toDownload);
                _app.FileLinks.Add(new FileLinks()
                {
                    UploadedFile = uploaded, FileToDownload = toDownload
                });
                await _app.SaveChangesAsync();

                var fileViewModel = new FileViewModel()
                {
                    FileInfo = xslsPath, Items = items
                };
                return(View("List", fileViewModel));
            }
            return(RedirectToAction("Index"));
        }
Пример #5
0
        private static List <FileToDownload> GetFilesToDownload(List <ProgramVersion> versions)
        {
            isError    = false;
            StatusText = "Sprawdzanie plików do pobrania";

            List <FileToDownload> filesToDownload = new List <FileToDownload>();

            try
            {
                for (int i = 0; versions[i].CompareTo(Program.Version) > 0; i++)
                {
                    WebClient webClient;
                    webClient = new WebClient();

                    string url = "http://www.IdleClicker.hexcore.pl/FilesInfo/VersionsFiles/" + versions[i] + ".php";
                    //string url = "http://localhost/IdleClicker/Files/FilesInfo/" + versions[i] + ".php";
                    string getStringTask = webClient.DownloadString(url);

                    string[] files = getStringTask.Split('|');
                    foreach (string item in files)
                    {
                        FileToDownload fileToDownload = new FileToDownload()
                        {
                            File = "http://www.IdleClicker.hexcore.pl/Files/" + versions[i] + "/" + item
                        };
                        if (!filesToDownload.Contains(fileToDownload))
                        {
                            filesToDownload.Add(fileToDownload);
                        }
                    }
                }
                return(filesToDownload);
            }
            catch// (Exception e)
            {
                throw new Exception("Błąd pobierania plików zmian");
            }
        }
Пример #6
0
        public static void DownloadInstallFile(string destination)
        {
            try
            {
                isError    = false;
                StatusText = "Pobieranie pliku instalacyjnego...";

                FileToDownload ftd = new FileToDownload()
                {
                    File = Program.WebSite + @"/Download/IdleClicker Install.exe"
                };

                DownloadFile(ftd, destination);

                isError    = false;
                StatusText = "Pomyślnie zaktualizowano. Możesz teraz zainstalować...";
            }
            catch (Exception e)
            {
                isError    = true;
                StatusText = e.Message;
            }
        }