Compare commits

..

1 Commits

Author SHA1 Message Date
Thomas Fransolet
bc79528591 README.json created online with Bitbucket 2022-10-28 08:37:43 +00:00
163 changed files with 26 additions and 13704 deletions

View File

@ -1,38 +0,0 @@
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,7 +88,6 @@ namespace Manager.Interfaces.Models
Slider,
Video,
Web,
Menu,
Quizz
Menu
}
}

View File

@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Manager.Interfaces.DTO;
using Manager.Interfaces.Models;
@ -229,18 +228,17 @@ namespace ManagerService.Controllers
}
}
/// <summary>
/// Export a configuration
/// </summary>
/// <param name="id">Id of configuration to export</param>
[AllowAnonymous]
[ProducesResponseType(typeof(FileContentResult), 200)]
[ProducesResponseType(typeof(ExportConfigurationDTO), 200)]
[ProducesResponseType(typeof(string), 400)]
[ProducesResponseType(typeof(string), 404)]
[ProducesResponseType(typeof(string), 500)]
[HttpGet("{id}/export")]
public FileContentResult Export(string id)
public ObjectResult Export(string id)
{
try
{
@ -288,44 +286,6 @@ namespace ManagerService.Controllers
}
}
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.Web:
case SectionType.Video:
@ -333,30 +293,21 @@ namespace ManagerService.Controllers
break;
}
}
ExportConfigurationDTO toDownload = 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
};
return new OkObjectResult(configuration.ToExportDTO(sectionDTOs, resourceDTOs));
}
catch (ArgumentNullException ex)
{
return null;
//return new BadRequestObjectResult(ex.Message) { };
return new BadRequestObjectResult(ex.Message) { };
}
catch (KeyNotFoundException ex)
{
return null;
//return new NotFoundObjectResult(ex.Message) { };
return new NotFoundObjectResult(ex.Message) { };
}
catch (Exception ex)
{
return null;
//return new ObjectResult(ex.Message) { StatusCode = 500 };
return new ObjectResult(ex.Message) { StatusCode = 500 };
}
}
@ -446,44 +397,6 @@ namespace ManagerService.Controllers
}
}
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.Web:
case SectionType.Video:

View File

@ -329,34 +329,6 @@ namespace ManagerService.Controllers
sliderDTO.images = imagesToKeep;
section.Data = JsonConvert.SerializeObject(sliderDTO);
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);

View File

@ -333,11 +333,6 @@ namespace ManagerService.Controllers
menuDTO.Sections.Add(section1DTO);*/
section.Data = JsonConvert.SerializeObject(menuDTO); // Include all info from specific section as JSON
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);
@ -611,15 +606,5 @@ namespace ManagerService.Controllers
{
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)
{
var client = new MongoClient(config.GetConnectionString("TabletDbOld"));
var database = client.GetDatabase("TabletDbOld");
var client = new MongoClient(config.GetConnectionString("TabletDb"));
var database = client.GetDatabase("TabletDb");
_Configurations = database.GetCollection<Configuration>("Configurations");
}
public List<Configuration> GetAll()

View File

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

View File

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

View File

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

View File

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

View File

@ -1,10 +1,8 @@
{
"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
"TabletDbOld": "mongodb://admin:MioTech4ever!@192.168.31.140:27017" //PROD - Thomas
//"TabletDb": "mongodb://admin:mdlf2021!@localhost:27017" //PROD
//"TabletDb": "mongodb://admin:MioTech4ever!@localhost:27017" //PROD - Thomas
"TabletDb": "mongodb://admin:mdlf2021!@localhost:27017" //PROD
},
"Logging": {
"LogLevel": {

4
README.json Normal file
View File

@ -0,0 +1,4 @@
# Publier sur docker
Publish via Visual studio, le docker file est à jour.
(registry.unov.be)

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -1,14 +0,0 @@
{
"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
}
}
}

View File

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

View File

@ -1,38 +0,0 @@
{
"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"
}

View File

@ -1,14 +0,0 @@
{
"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