From 9174c7126ec21f593466d58a12277c4ac7c9cdea Mon Sep 17 00:00:00 2001 From: Hamid Reza Mohammadi Date: Sun, 14 Mar 2021 15:19:08 +0330 Subject: [PATCH] #89 removing tracker model from delete --- .../Implementation/RecitationService.cs | 43 ++----------------- 1 file changed, 4 insertions(+), 39 deletions(-) diff --git a/RMuseum/Services/Implementation/RecitationService.cs b/RMuseum/Services/Implementation/RecitationService.cs index f021876a..067f4ea6 100644 --- a/RMuseum/Services/Implementation/RecitationService.cs +++ b/RMuseum/Services/Implementation/RecitationService.cs @@ -230,33 +230,7 @@ namespace RMuseum.Services.Implementationa if (recitation.ReviewStatus == AudioReviewStatus.Approved) { - recitation.AudioSyncStatus = AudioSyncStatus.Deleted; - _context.Recitations.Update(recitation); - await _context.SaveChangesAsync(); - - _backgroundTaskQueue.QueueBackgroundWorkItem - ( - async token => - { - using (RMuseumDbContext context = new RMuseumDbContext(Configuration)) //this is long running job, so _context might be already been freed/collected by GC - { - RecitationPublishingTracker tracker = new RecitationPublishingTracker() - { - PoemNarrationId = recitation.Id, - StartDate = DateTime.Now, - XmlFileCopied = false, - Mp3FileCopied = false, - FirstDbUpdated = false, - SecondDbUpdated = false, - }; - context.RecitationPublishingTrackers.Add(tracker); - await context.SaveChangesAsync(); - - await _DeleteNarrationFromRemote(recitation, tracker, context); - } - - - }); + await _DeleteNarration(recitation, _context); } else { @@ -1241,7 +1215,7 @@ namespace RMuseum.Services.Implementationa } - private async Task _DeleteNarrationFromRemote(Recitation narration, RecitationPublishingTracker tracker, RMuseumDbContext context) + private async Task _DeleteNarration(Recitation narration, RMuseumDbContext context) { try @@ -1252,11 +1226,6 @@ namespace RMuseum.Services.Implementationa await _FinalizeDelete(context, narration); - tracker.Finished = true; - tracker.FinishDate = DateTime.Now; - context.RecitationPublishingTrackers.Update(tracker); - await context.SaveChangesAsync(); - await new RNotificationService(context).PushNotification ( userId, @@ -1269,11 +1238,6 @@ namespace RMuseum.Services.Implementationa } catch (Exception exp) { - //if an error occurs, narration.AudioSyncStatus is not updated and narration can be idetified later to do "retrypublish" attempts - tracker.LastException = exp.ToString(); - context.RecitationPublishingTrackers.Update(tracker); - await context.SaveChangesAsync(); - await new RNotificationService(context).PushNotification ( narration.OwnerId, @@ -1292,7 +1256,8 @@ namespace RMuseum.Services.Implementationa ( (Guid)moderator.Id, "خطا در حذف نهایی خوانش ارسالی", - $"لطفا صف انتظار را بررسی کنید.{ Environment.NewLine}" + $"لطفا صف انتظار را بررسی کنید.{ Environment.NewLine}" + + $"خطا: {exp.ToString()}" ); } }