private async Task MarkDownloadFileAsComplete(DownloadStatusModel downloadFile) { //Check file if exist into the Database if (_movieContextUpdate.Movies .Where(Q => Q.DownloadId == downloadFile.GID) .Include(In => In.TranscoddedFiles).Count() == 0) { return; } //Get the movie instant from the database var movie = await _movieContextUpdate.Movies .Where(Q => Q.DownloadId == downloadFile.GID) .Include(In => In.TranscoddedFiles) .FirstAsync(); movie.DownloadStatus = CinemaMaxFeeder.Database.Model.MovieDownloadStatus.Complete; movie.FinishDownloadAt = DateTime.Now; var getMovieLink = movie.TranscoddedFiles .Where(q => q.Resolution == HelperFunctions.FindMovieRes(movie.TranscoddedFiles)) .First(); getMovieLink.DownloadStatus = CinemaMaxFeeder.Database.Model.MovieDownloadStatus.Complete; getMovieLink.FinishDownloadAt = DateTime.Now; getMovieLink.DownloadLocalPath = downloadFile.Files[0].Path; getMovieLink.FileSize = downloadFile.TotalLength; _movieContextUpdate.SaveChanges(); }
public static DownloadTask Convert(this DownloadStatusModel model) { DownloadStatus status; Enum.TryParse(model.Status, true, out status); var filename = "新任务"; if (model.Files != null && model.Files.Count == 1) { var file = model.Files.First(); if (File.Exists(file.Path)) { filename = new FileInfo(file.Path).Name; } } else if (model.BitTorrent != null && model.BitTorrent.Info != null) { filename = model.BitTorrent.Info.Name; } return(new DownloadTask { GID = model.GID, Status = status, TaskName = filename, CompletedLength = model.CompletedLength, DownloadSpeed = model.DownloadSpeed, TotalLength = model.TotalLength, UploadSpeed = model.UploadSpeed }); }
private async Task MarkDownloadFileAsErrored(DownloadStatusModel downloadFile) { //Check file if exist into the Database if (_movieContextUpdate.Movies .Where(Q => Q.DownloadId == downloadFile.GID) .Include(In => In.TranscoddedFiles).Count() == 0) { Console.WriteLine("----------------------FILE NOT FOUND IN THE DATABASE............................."); await _aria2Client.Remove(downloadFile.GID); await _aria2Client.ForceRemove(downloadFile.GID); return; } //Get the movie instant from the database Console.WriteLine("----------------------FILE FOUND IN THE DATABASE............................."); var movie = await _movieContextUpdate.Movies .Where(Q => Q.DownloadId == downloadFile.GID) .Include(In => In.TranscoddedFiles) .FirstAsync(); movie.DownloadStatus = CinemaMaxFeeder.Database.Model.MovieDownloadStatus.Error; var getMovieLink = movie.TranscoddedFiles .Where(q => q.Resolution == HelperFunctions.FindMovieRes(movie.TranscoddedFiles)) .First(); getMovieLink.DownloadStatus = CinemaMaxFeeder.Database.Model.MovieDownloadStatus.Error; getMovieLink.FinishDownloadAt = DateTime.Now; _movieContextUpdate.SaveChanges(); await _aria2Client.Remove(downloadFile.GID); await _aria2Client.ForceRemove(downloadFile.GID); }
private void LoopThrowAria2Files(List <DownloadProgressModel> downloadsModel, DownloadStatusModel downloadFile) { }