public async Task <IActionResult> PutRun(int id, Run run) { if (id != run.RunId) { return(BadRequest()); } _context.Entry(run).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RunExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutCommentLine(int id, CommentLine commentLine) { if (id != commentLine.CommentLineId) { return(BadRequest()); } _context.Entry(commentLine).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CommentLineExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task GetDataFromBucketList() { ReadFile(); Console.WriteLine($"get data from bucket started"); AmazonS3Config config = new AmazonS3Config(); AmazonS3Client s3Client = new AmazonS3Client( _accessKey, _secretKey, config ); var oneFile = Stopwatch.StartNew(); var tasks = new List <Task>(); foreach (string fileName in SummaryFiles) { var request = new GetObjectRequest { BucketName = "lovelywater", Key = $"{fileName}" }; string responseBody = ""; var s3Stopwatch = Stopwatch.StartNew(); try { Console.WriteLine("test"); var result = await s3Client.GetObjectAsync(request); using (var stream = result.ResponseStream) using (var reader = new StreamReader(stream)) { Console.WriteLine($"file read"); var readerStopwatch = Stopwatch.StartNew(); responseBody = await reader.ReadToEndAsync(); //Console.WriteLine($"{readerStopwatch.ElapsedMilliseconds}"); var task = Task.Run(async() => { using (var context = new SerratusSummaryContext()) { var parserStopwatch = Stopwatch.StartNew(); var lines = responseBody.Split('\n'); var unparsedFile = ReadFile(lines); var finishedFile = ParseFile(fileName, unparsedFile); Console.WriteLine($"file parsed"); //Console.WriteLine($"{parserStopwatch.ElapsedMilliseconds}"); var dbStopwatch = Stopwatch.StartNew(); context.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking; context.Runs.Add(finishedFile.Run); await context.SaveChangesAsync(); Console.WriteLine($"file saved in db"); //Console.WriteLine($"{dbStopwatch.ElapsedMilliseconds}"); } }); tasks.Add(task); } } catch { continue; } if (tasks.Count == 100) { await Task.WhenAll(tasks); Console.WriteLine("tasks done!"); } //Console.WriteLine($"{s3Stopwatch.ElapsedMilliseconds}"); } Console.WriteLine("PARSER COMPLETE"); //if (moreKeys == true) //{ // Console.WriteLine("getting more buckets"); // GetBucketsFromS3(); //} //else //{ // return; //} }