diff --git a/RMuseum/Controllers/AudioNarrationController.cs b/RMuseum/Controllers/AudioNarrationController.cs
index b0012285..c7e0b35c 100644
--- a/RMuseum/Controllers/AudioNarrationController.cs
+++ b/RMuseum/Controllers/AudioNarrationController.cs
@@ -1,9 +1,11 @@
using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using RMuseum.Models.Auth.Memory;
using RMuseum.Models.GanjoorAudio;
using RMuseum.Models.GanjoorAudio.ViewModels;
+using RMuseum.Models.UploadSession;
using RMuseum.Services;
using RSecurityBackend.Models.Generic;
using RSecurityBackend.Services;
@@ -66,6 +68,36 @@ namespace RMuseum.Controllers
return Ok(res.Result.Items);
}
+ ///
+ /// Narration Upload
+ ///
+ ///
+ [HttpPost]
+ [Authorize]
+ [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(UploadSession))]
+ [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
+ [ProducesResponseType((int)HttpStatusCode.Unauthorized)]
+ [ProducesResponseType((int)HttpStatusCode.Forbidden, Type = typeof(string))]
+ public async Task UploadNarrations()
+ {
+ try
+ {
+ Guid loggedOnUserId = new Guid(User.Claims.FirstOrDefault(c => c.Type == "UserId").Value);
+ RServiceResult resSession = await _audioService.InitiateNewUploadSession(loggedOnUserId);
+ if (!string.IsNullOrEmpty(resSession.ExceptionString))
+ return BadRequest(resSession.ExceptionString);
+ foreach(IFormFile file in Request.Form.Files)
+ {
+
+ }
+ return Ok(await _audioService.GetUploadSession(resSession.Result.Id));
+ }
+ catch (Exception exp)
+ {
+ return BadRequest(exp.ToString());
+ }
+ }
+
///
/// imports data from ganjoor MySql database
diff --git a/RMuseum/DbContext/RMuseumDbContext.cs b/RMuseum/DbContext/RMuseumDbContext.cs
index a6d0ef0e..a92167d3 100644
--- a/RMuseum/DbContext/RMuseumDbContext.cs
+++ b/RMuseum/DbContext/RMuseumDbContext.cs
@@ -3,6 +3,7 @@ using Microsoft.Extensions.Configuration;
using RMuseum.Models.Artifact;
using RMuseum.Models.Bookmark;
using RMuseum.Models.GanjoorAudio;
+using RMuseum.Models.UploadSession;
using RMuseum.Models.GanjoorIntegration;
using RMuseum.Models.ImportJob;
using RMuseum.Models.Note;
@@ -132,5 +133,10 @@ namespace RMuseum.DbContext
///
public DbSet AudioFiles { get; set; }
+ ///
+ /// Upload Sessions
+ ///
+ public DbSet UploadSessions { get; set; }
+
}
}
diff --git a/RMuseum/Models/UploadSession/UploadSession.cs b/RMuseum/Models/UploadSession/UploadSession.cs
new file mode 100644
index 00000000..b70f1058
--- /dev/null
+++ b/RMuseum/Models/UploadSession/UploadSession.cs
@@ -0,0 +1,69 @@
+using RSecurityBackend.Models.Auth.Db;
+using System;
+using System.Collections.Generic;
+
+namespace RMuseum.Models.UploadSession
+{
+ ///
+ /// Upload Session
+ ///
+ public class UploadSession
+ {
+ ///
+ /// Id
+ ///
+ public Guid Id { get; set; }
+
+ ///
+ /// Session Type
+ ///
+ public UploadSessionType SessionType { get; set; }
+
+ ///
+ /// User
+ ///
+ public RAppUser User { get; set; }
+
+ ///
+ /// User Id
+ ///
+ public Guid UseId { get; set; }
+
+ ///
+ /// Upload Start Time
+ ///
+ public DateTime UploadStartTime { get; set; }
+
+ ///
+ /// Upload End Time
+ ///
+ public DateTime UploadEndTime { get; set; }
+
+ ///
+ /// Process Start Time
+ ///
+ public DateTime ProcessStartTime { get; set; }
+
+ ///
+ /// Process End Time
+ ///
+ public DateTime ProcessEndTime { get; set; }
+
+ ///
+ /// Process Progress
+ ///
+ public int ProcessProgress { get; set; }
+
+ ///
+ /// Status
+ ///
+ public UploadSessionProcessStatus Status { get; set; }
+
+ ///
+ /// Uploaded Files
+ ///
+ public ICollection UploadedFiles { get; set; }
+
+
+ }
+}
diff --git a/RMuseum/Models/UploadSession/UploadSessionFile.cs b/RMuseum/Models/UploadSession/UploadSessionFile.cs
new file mode 100644
index 00000000..18dfd1a4
--- /dev/null
+++ b/RMuseum/Models/UploadSession/UploadSessionFile.cs
@@ -0,0 +1,48 @@
+using System;
+
+
+namespace RMuseum.Models.UploadSession
+{
+ ///
+ /// Upload Session File
+ ///
+ public class UploadSessionFile
+ {
+ ///
+ /// Id
+ ///
+ public Guid Id { get; set; }
+
+ ///
+ /// ContentDisposition
+ ///
+ public string ContentDisposition { get; set; }
+
+ ///
+ /// ContentType
+ ///
+ public string ContentType { get; set; }
+
+ ///
+ /// FileName
+ ///
+ public string FileName { get; set; }
+
+ ///
+ /// Length
+ ///
+ public long Length { get; set; }
+
+ ///
+ /// Name
+ ///
+ public string Name { get; set; }
+
+ ///
+ /// File Path
+ ///
+ public string FilePath { get; set; }
+
+
+ }
+}
diff --git a/RMuseum/Models/UploadSession/UploadSessionProcessStatus.cs b/RMuseum/Models/UploadSession/UploadSessionProcessStatus.cs
new file mode 100644
index 00000000..bdca0c33
--- /dev/null
+++ b/RMuseum/Models/UploadSession/UploadSessionProcessStatus.cs
@@ -0,0 +1,21 @@
+namespace RMuseum.Models.UploadSession
+{
+ ///
+ /// Upload Session Process Status
+ ///
+ public enum UploadSessionProcessStatus
+ {
+ ///
+ /// Not Started
+ ///
+ NotStarted = 0,
+ ///
+ /// Started
+ ///
+ Started = 1,
+ ///
+ /// Finished
+ ///
+ Finished = 2
+ }
+}
diff --git a/RMuseum/Models/UploadSession/UploadSessionType.cs b/RMuseum/Models/UploadSession/UploadSessionType.cs
new file mode 100644
index 00000000..3372f18d
--- /dev/null
+++ b/RMuseum/Models/UploadSession/UploadSessionType.cs
@@ -0,0 +1,20 @@
+
+namespace RMuseum.Models.UploadSession
+{
+ ///
+ /// Upload Session Types
+ ///
+ public enum UploadSessionType
+ {
+ ///
+ /// Generic
+ ///
+ Generic = 0,
+
+ ///
+ /// Audio
+ ///
+ Audio = 1
+
+ }
+}
diff --git a/RMuseum/RMuseum.xml b/RMuseum/RMuseum.xml
index d9821015..b4268be1 100644
--- a/RMuseum/RMuseum.xml
+++ b/RMuseum/RMuseum.xml
@@ -629,6 +629,12 @@
default: -1, unfiltered
+
+
+ Narration Upload
+
+
+
imports data from ganjoor MySql database
@@ -814,6 +820,11 @@
Ganjoor Audio Files
+
+
+ Upload Sessions
+
+
Items or pictures status
@@ -2698,6 +2709,141 @@
Text
+
+
+ Upload Session
+
+
+
+
+ Id
+
+
+
+
+ Session Type
+
+
+
+
+ User
+
+
+
+
+ User Id
+
+
+
+
+ Upload Start Time
+
+
+
+
+ Upload End Time
+
+
+
+
+ Process Start Time
+
+
+
+
+ Process End Time
+
+
+
+
+ Process Progress
+
+
+
+
+ Status
+
+
+
+
+ Uploaded Files
+
+
+
+
+ Upload Session File
+
+
+
+
+ Id
+
+
+
+
+ ContentDisposition
+
+
+
+
+ ContentType
+
+
+
+
+ FileName
+
+
+
+
+ Length
+
+
+
+
+ Name
+
+
+
+
+ File Path
+
+
+
+
+ Upload Session Process Status
+
+
+
+
+ Not Started
+
+
+
+
+ Started
+
+
+
+
+ Finished
+
+
+
+
+ Upload Session Types
+
+
+
+
+ Generic
+
+
+
+
+ Audio
+
+
Artifact Item Service
@@ -3234,6 +3380,20 @@
User Id which becomes owner of imported data
+
+
+ Initiate New Upload Session for audio
+
+
+
+
+
+
+ Get Upload Session (including files)
+
+
+
+
IArtifactService implementation
@@ -3962,6 +4122,20 @@
User Id which becomes owner of imported data
+
+
+ Initiate New Upload Session for audio
+
+
+
+
+
+
+ Get Upload Session (including files)
+
+
+
+
Configuration
diff --git a/RMuseum/Services/IAudioNarrationService.cs b/RMuseum/Services/IAudioNarrationService.cs
index 98687b32..954ef2ac 100644
--- a/RMuseum/Services/IAudioNarrationService.cs
+++ b/RMuseum/Services/IAudioNarrationService.cs
@@ -1,5 +1,6 @@
using RMuseum.Models.GanjoorAudio;
using RMuseum.Models.GanjoorAudio.ViewModels;
+using RMuseum.Models.UploadSession;
using RSecurityBackend.Models.Generic;
using System;
using System.Threading.Tasks;
@@ -26,5 +27,19 @@ namespace RMuseum.Services
/// User Id which becomes owner of imported data
///
Task> OneTimeImport(Guid OwnrRAppUserId);
+
+ ///
+ /// Initiate New Upload Session for audio
+ ///
+ ///
+ ///
+ Task> InitiateNewUploadSession(Guid userId);
+
+ ///
+ /// Get Upload Session (including files)
+ ///
+ ///
+ ///
+ Task> GetUploadSession(Guid id);
}
}
diff --git a/RMuseum/Services/Implementation/AudioNarrationService.cs b/RMuseum/Services/Implementation/AudioNarrationService.cs
index b7e7843c..e62ac1d1 100644
--- a/RMuseum/Services/Implementation/AudioNarrationService.cs
+++ b/RMuseum/Services/Implementation/AudioNarrationService.cs
@@ -4,6 +4,7 @@ using MySql.Data.MySqlClient;
using RMuseum.DbContext;
using RMuseum.Models.GanjoorAudio;
using RMuseum.Models.GanjoorAudio.ViewModels;
+using RMuseum.Models.UploadSession;
using RSecurityBackend.Models.Generic;
using RSecurityBackend.Services.Implementation;
using System;
@@ -136,6 +137,56 @@ namespace RMuseum.Services.Implementation
}
+ ///
+ /// Initiate New Upload Session for audio
+ ///
+ ///
+ ///
+ public async Task> InitiateNewUploadSession(Guid userId)
+ {
+ try
+ {
+ UploadSession session = new UploadSession()
+ {
+ SessionType = UploadSessionType.Audio,
+ UseId = userId,
+ UploadStartTime = DateTime.Now,
+ Status = UploadSessionProcessStatus.NotStarted,
+ ProcessProgress = 0
+ };
+ await _context.UploadSessions.AddAsync(session);
+ await _context.SaveChangesAsync();
+
+ return new RServiceResult(session);
+
+ }
+ catch(Exception exp)
+ {
+ return new RServiceResult(null, exp.ToString());
+ }
+ }
+
+ ///
+ /// Get Upload Session (including files)
+ ///
+ ///
+ ///
+ public async Task> GetUploadSession(Guid id)
+ {
+ try
+ {
+ return new RServiceResult
+ (
+ await _context.UploadSessions.Include(s => s.UploadedFiles).FirstOrDefaultAsync(s => s.Id == id)
+ );
+
+ }
+ catch (Exception exp)
+ {
+ return new RServiceResult(null, exp.ToString());
+ }
+ }
+
///
/// Configuration
diff --git a/RMuseum/Startup.cs b/RMuseum/Startup.cs
index ea96692b..acb6134c 100644
--- a/RMuseum/Startup.cs
+++ b/RMuseum/Startup.cs
@@ -251,6 +251,12 @@ namespace RMuseum
//audio service
services.AddTransient();
+ //upload limit for IIS
+ services.Configure(options =>
+ {
+ options.MaxRequestBodySize = 52428800; //50MB
+ });
+
services.AddHostedService();
services.AddSingleton();