Compare commits

...

7 Commits

162 changed files with 13704 additions and 22 deletions

View File

@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Manager.Interfaces.DTO
{
public class QuizzDTO
{
public List<QuestionDTO> questions { get; set; }
public LevelDTO bad_level { get; set; }
public LevelDTO medium_level { get; set; }
public LevelDTO good_level { get; set; }
public LevelDTO great_level { get; set; }
}
public class QuestionDTO
{
public List<TranslationDTO> label { get; set; }
public List<ResponseDTO> responses { get; set; }
public string resourceId { get; set; } // question image
public string source { get; set; }
public int order { get; set; } // Order to show
}
public class ResponseDTO
{
public List<TranslationDTO> label { get; set; }
public bool isGood { get; set; }
public int order { get; set; } // Order to show
}
public class LevelDTO
{
public List<TranslationDTO> label { get; set; }
public string resourceId { get; set; } // level result image
public string source { get; set; }
}
}

View File

@ -88,6 +88,7 @@ namespace Manager.Interfaces.Models
Slider, Slider,
Video, Video,
Web, Web,
Menu Menu,
Quizz
} }
} }

View File

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Manager.Interfaces.DTO; using Manager.Interfaces.DTO;
using Manager.Interfaces.Models; using Manager.Interfaces.Models;
@ -233,12 +234,13 @@ namespace ManagerService.Controllers
/// Export a configuration /// Export a configuration
/// </summary> /// </summary>
/// <param name="id">Id of configuration to export</param> /// <param name="id">Id of configuration to export</param>
[ProducesResponseType(typeof(ExportConfigurationDTO), 200)] [AllowAnonymous]
[ProducesResponseType(typeof(FileContentResult), 200)]
[ProducesResponseType(typeof(string), 400)] [ProducesResponseType(typeof(string), 400)]
[ProducesResponseType(typeof(string), 404)] [ProducesResponseType(typeof(string), 404)]
[ProducesResponseType(typeof(string), 500)] [ProducesResponseType(typeof(string), 500)]
[HttpGet("{id}/export")] [HttpGet("{id}/export")]
public ObjectResult Export(string id) public FileContentResult Export(string id)
{ {
try try
{ {
@ -286,6 +288,44 @@ namespace ManagerService.Controllers
} }
} }
break; break;
case SectionType.Quizz:
QuizzDTO quizzDTO = JsonConvert.DeserializeObject<QuizzDTO>(section.data);
foreach (var question in quizzDTO.questions)
{
if (question.resourceId != null)
{
addResourceToList(resourceDTOs, question.resourceId);
}
}
if (quizzDTO.bad_level != null)
{
if (quizzDTO.bad_level.resourceId != null)
{
addResourceToList(resourceDTOs, quizzDTO.bad_level.resourceId);
}
}
if (quizzDTO.medium_level != null)
{
if (quizzDTO.medium_level.resourceId != null)
{
addResourceToList(resourceDTOs, quizzDTO.medium_level.resourceId);
}
}
if (quizzDTO.good_level != null)
{
if (quizzDTO.good_level.resourceId != null)
{
addResourceToList(resourceDTOs, quizzDTO.good_level.resourceId);
}
}
if (quizzDTO.great_level != null)
{
if (quizzDTO.great_level.resourceId != null)
{
addResourceToList(resourceDTOs, quizzDTO.great_level.resourceId);
}
}
break;
case SectionType.Menu: case SectionType.Menu:
case SectionType.Web: case SectionType.Web:
case SectionType.Video: case SectionType.Video:
@ -293,21 +333,30 @@ namespace ManagerService.Controllers
break; break;
} }
} }
ExportConfigurationDTO toDownload = configuration.ToExportDTO(sectionDTOs, resourceDTOs);
return new OkObjectResult(configuration.ToExportDTO(sectionDTOs, resourceDTOs)); string jsonString = JsonConvert.SerializeObject(toDownload);
var fileName = $"{configuration.Label}.json";
var mimeType = "application/json";
var fileBytes = Encoding.ASCII.GetBytes(jsonString);
return new FileContentResult(fileBytes, mimeType)
{
FileDownloadName = fileName
};
} }
catch (ArgumentNullException ex) catch (ArgumentNullException ex)
{ {
return new BadRequestObjectResult(ex.Message) { }; return null;
//return new BadRequestObjectResult(ex.Message) { };
} }
catch (KeyNotFoundException ex) catch (KeyNotFoundException ex)
{ {
return new NotFoundObjectResult(ex.Message) { }; return null;
//return new NotFoundObjectResult(ex.Message) { };
} }
catch (Exception ex) catch (Exception ex)
{ {
return new ObjectResult(ex.Message) { StatusCode = 500 }; return null;
//return new ObjectResult(ex.Message) { StatusCode = 500 };
} }
} }
@ -397,6 +446,44 @@ namespace ManagerService.Controllers
} }
} }
break; break;
case SectionType.Quizz:
QuizzDTO quizzDTO = JsonConvert.DeserializeObject<QuizzDTO>(section.data);
foreach (var question in quizzDTO.questions)
{
if (question.resourceId != null)
{
createResource(exportConfiguration.resources.Where(r => r.id == question.resourceId).FirstOrDefault());
}
}
if (quizzDTO.bad_level != null)
{
if(quizzDTO.bad_level.resourceId != null)
{
createResource(exportConfiguration.resources.Where(r => r.id == quizzDTO.bad_level.resourceId).FirstOrDefault());
}
}
if (quizzDTO.medium_level != null)
{
if (quizzDTO.medium_level.resourceId != null)
{
createResource(exportConfiguration.resources.Where(r => r.id == quizzDTO.medium_level.resourceId).FirstOrDefault());
}
}
if (quizzDTO.good_level != null)
{
if (quizzDTO.good_level.resourceId != null)
{
createResource(exportConfiguration.resources.Where(r => r.id == quizzDTO.good_level.resourceId).FirstOrDefault());
}
}
if (quizzDTO.great_level != null)
{
if (quizzDTO.great_level.resourceId != null)
{
createResource(exportConfiguration.resources.Where(r => r.id == quizzDTO.great_level.resourceId).FirstOrDefault());
}
}
break;
case SectionType.Menu: case SectionType.Menu:
case SectionType.Web: case SectionType.Web:
case SectionType.Video: case SectionType.Video:

View File

@ -329,6 +329,34 @@ namespace ManagerService.Controllers
sliderDTO.images = imagesToKeep; sliderDTO.images = imagesToKeep;
section.Data = JsonConvert.SerializeObject(sliderDTO); section.Data = JsonConvert.SerializeObject(sliderDTO);
break; break;
case SectionType.Quizz:
QuizzDTO quizzDTO = JsonConvert.DeserializeObject<QuizzDTO>(section.Data);
foreach (var question in quizzDTO.questions)
{
question.source = question.resourceId == id ? null : question.source;
question.resourceId = question.resourceId == id ? null : question.resourceId;
}
if (quizzDTO.bad_level != null) {
quizzDTO.bad_level.source = quizzDTO.bad_level.resourceId == id ? null : quizzDTO.bad_level.source;
quizzDTO.bad_level.resourceId = quizzDTO.bad_level.resourceId == id ? null : quizzDTO.bad_level.resourceId;
}
if (quizzDTO.medium_level != null)
{
quizzDTO.medium_level.source = quizzDTO.medium_level.resourceId == id ? null : quizzDTO.medium_level.source;
quizzDTO.medium_level.resourceId = quizzDTO.medium_level.resourceId == id ? null : quizzDTO.medium_level.resourceId;
}
if (quizzDTO.good_level != null)
{
quizzDTO.good_level.source = quizzDTO.good_level.resourceId == id ? null : quizzDTO.good_level.source;
quizzDTO.good_level.resourceId = quizzDTO.good_level.resourceId == id ? null : quizzDTO.good_level.resourceId;
}
if (quizzDTO.great_level != null)
{
quizzDTO.great_level.source = quizzDTO.great_level.resourceId == id ? null : quizzDTO.great_level.source;
quizzDTO.great_level.resourceId = quizzDTO.great_level.resourceId == id ? null : quizzDTO.great_level.resourceId;
}
section.Data = JsonConvert.SerializeObject(quizzDTO);
break;
} }
_sectionService.Update(section.Id, section); _sectionService.Update(section.Id, section);

View File

@ -333,6 +333,11 @@ namespace ManagerService.Controllers
menuDTO.Sections.Add(section1DTO);*/ menuDTO.Sections.Add(section1DTO);*/
section.Data = JsonConvert.SerializeObject(menuDTO); // Include all info from specific section as JSON section.Data = JsonConvert.SerializeObject(menuDTO); // Include all info from specific section as JSON
break; break;
case SectionType.Quizz:
QuizzDTO quizzDTO = new QuizzDTO();
quizzDTO.questions = new List<QuestionDTO>();
section.Data = JsonConvert.SerializeObject(quizzDTO); // Include all info from specific section as JSON
break;
} }
Section sectionCreated = _sectionService.Create(section); Section sectionCreated = _sectionService.Create(section);
@ -606,5 +611,15 @@ namespace ManagerService.Controllers
{ {
return new ObjectResult("PlayerMessageDTO") { StatusCode = 200 }; return new ObjectResult("PlayerMessageDTO") { StatusCode = 200 };
} }
/// <summary>
/// Useless, just to generate dto code
/// </summary>
[ProducesResponseType(typeof(QuizzDTO), 200)]
[HttpGet("QuizzDTO")]
public ObjectResult GetQuizzDTO()
{
return new ObjectResult("QuizzDTO") { StatusCode = 200 };
}
} }
} }

View File

@ -14,8 +14,8 @@ namespace Manager.Services
public ConfigurationDatabaseService(IConfiguration config) public ConfigurationDatabaseService(IConfiguration config)
{ {
var client = new MongoClient(config.GetConnectionString("TabletDb")); var client = new MongoClient(config.GetConnectionString("TabletDbOld"));
var database = client.GetDatabase("TabletDb"); var database = client.GetDatabase("TabletDbOld");
_Configurations = database.GetCollection<Configuration>("Configurations"); _Configurations = database.GetCollection<Configuration>("Configurations");
} }
public List<Configuration> GetAll() public List<Configuration> GetAll()

View File

@ -14,8 +14,8 @@ namespace Manager.Services
public DeviceDatabaseService(IConfiguration config) public DeviceDatabaseService(IConfiguration config)
{ {
var client = new MongoClient(config.GetConnectionString("TabletDb")); var client = new MongoClient(config.GetConnectionString("TabletDbOld"));
var database = client.GetDatabase("TabletDb"); var database = client.GetDatabase("TabletDbOld");
_Devices = database.GetCollection<Device>("Devices"); _Devices = database.GetCollection<Device>("Devices");
} }

View File

@ -14,8 +14,8 @@ namespace Manager.Services
public ResourceDatabaseService(IConfiguration config) public ResourceDatabaseService(IConfiguration config)
{ {
var client = new MongoClient(config.GetConnectionString("TabletDb")); var client = new MongoClient(config.GetConnectionString("TabletDbOld"));
var database = client.GetDatabase("TabletDb"); var database = client.GetDatabase("TabletDbOld");
_Resources = database.GetCollection<Resource>("Resources"); _Resources = database.GetCollection<Resource>("Resources");
} }
public List<Resource> GetAll() public List<Resource> GetAll()

View File

@ -14,8 +14,8 @@ namespace Manager.Services
public SectionDatabaseService(IConfiguration config) public SectionDatabaseService(IConfiguration config)
{ {
var client = new MongoClient(config.GetConnectionString("TabletDb")); var client = new MongoClient(config.GetConnectionString("TabletDbOld"));
var database = client.GetDatabase("TabletDb"); var database = client.GetDatabase("TabletDbOld");
_Sections = database.GetCollection<Section>("Sections"); _Sections = database.GetCollection<Section>("Sections");
} }

View File

@ -14,8 +14,8 @@ namespace Manager.Services
public UserDatabaseService(IConfiguration config) public UserDatabaseService(IConfiguration config)
{ {
var client = new MongoClient(config.GetConnectionString("TabletDb")); var client = new MongoClient(config.GetConnectionString("TabletDbOld"));
var database = client.GetDatabase("TabletDb"); var database = client.GetDatabase("TabletDbOld");
_Users = database.GetCollection<User>("Users"); _Users = database.GetCollection<User>("Users");
} }
public List<User> GetAll() public List<User> GetAll()

View File

@ -1,8 +1,10 @@
{ {
"ConnectionStrings": { "ConnectionStrings": {
//"TabletDb": "mongodb://admin:MioTech4ever!@localhost:27017" //DEV //"TabletDb": "mongodb://admin:MioTech4ever!@localhost:27017" //DEV
//"TabletDb": "mongodb://admin:MioTech4ever!@localhost:27017" //PROD - Thomas //"TabletDb": "mongodb://admin:MioTech4ever!@localhost:27017", //PROD - Thomas
"TabletDb": "mongodb://admin:mdlf2021!@localhost:27017" //PROD //"TabletDb": "mongodb://admin:MioTech4ever!@192.168.31.140:27017", //PROD - Thomas
"TabletDbOld": "mongodb://admin:MioTech4ever!@192.168.31.140:27017" //PROD - Thomas
//"TabletDb": "mongodb://admin:mdlf2021!@localhost:27017" //PROD
}, },
"Logging": { "Logging": {
"LogLevel": { "LogLevel": {

View File

@ -0,0 +1 @@
Ajout du quizz

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,8 @@
{
"runtimeOptions": {
"additionalProbingPaths": [
"C:\\Users\\thoma\\.dotnet\\store\\|arch|\\|tfm|",
"C:\\Users\\thoma\\.nuget\\packages"
]
}
}

View File

@ -0,0 +1,14 @@
{
"runtimeOptions": {
"tfm": "netcoreapp3.1",
"framework": {
"name": "Microsoft.AspNetCore.App",
"version": "3.1.0"
},
"configProperties": {
"System.GC.Server": true,
"System.Reflection.Metadata.MetadataUpdater.IsSupported": false,
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
}
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}

View File

@ -0,0 +1,38 @@
{
"ConnectionStrings": {
//"TabletDb": "mongodb://admin:MioTech4ever!@localhost:27017" //DEV
//"TabletDb": "mongodb://admin:MioTech4ever!@localhost:27017", //PROD - Thomas
//"TabletDb": "mongodb://admin:MioTech4ever!@192.168.31.140:27017" //PROD - Thomas
"TabletDb": "mongodb://admin:mdlf2021!@localhost:27017" //PROD
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"Tokens": {
"Secret": "WVD[&vAwis9=#883bM$FRc0Mw8h",
"AccessTokenExpiration": 86400,
"RefreshTokenExpiration": 518400
},
"SecuritySettings": {
"Secret": "kfexxgohdxeelabz",
"Issuer": "Manager",
"Audience": "the client of your app",
"IdType": "Name",
"TokenExpiryInHours": 2
},
"BrokerHostSettings": {
"Host": "localhost",
"Port": 1883
},
"ClientSettings": {
"Id": "ManagerService",
"UserName": "admin",
"Password": "mdlf2021!"
},
"Urls": "http://localhost:5002"
}

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,14 @@
{
"runtimeOptions": {
"tfm": "netcoreapp3.1",
"framework": {
"name": "Microsoft.AspNetCore.App",
"version": "3.1.0"
},
"configProperties": {
"System.GC.Server": true,
"System.Reflection.Metadata.MetadataUpdater.IsSupported": false,
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
}
}
}

Some files were not shown because too many files have changed in this diff Show More