Code for fort migration
This commit is contained in:
parent
aedd5f33fa
commit
4ee0eb8e87
@ -14,4 +14,13 @@ namespace Manager.Interfaces.DTO
|
|||||||
public DateTime dateCreation { get; set; }
|
public DateTime dateCreation { get; set; }
|
||||||
public string instanceId { get; set; }
|
public string instanceId { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class ResourceOLDDTO
|
||||||
|
{
|
||||||
|
public MongoId _id { get; set; }
|
||||||
|
public ResourceType Type { get; set; }
|
||||||
|
public string Label { get; set; }
|
||||||
|
public DateCustom DateCreation { get; set; }
|
||||||
|
public string InstanceId { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,10 @@
|
|||||||
using Manager.Interfaces.Models;
|
using Manager.Interfaces.Models;
|
||||||
|
using MongoDB.Bson.IO;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace Manager.Interfaces.DTO
|
namespace Manager.Interfaces.DTO
|
||||||
{
|
{
|
||||||
@ -27,4 +30,38 @@ namespace Manager.Interfaces.DTO
|
|||||||
public bool isBeacon { get; set; } // MyVisit - True if section use beacon, false otherwise
|
public bool isBeacon { get; set; } // MyVisit - True if section use beacon, false otherwise
|
||||||
public int? beaconId { get; set; } // MyVisit - Beacon' identifier
|
public int? beaconId { get; set; } // MyVisit - Beacon' identifier
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class SectionForJsonDTO
|
||||||
|
{
|
||||||
|
public MongoId _id { get; set; } // Correspond à l'objet _id dans le JSON
|
||||||
|
public string Label { get; set; } // Correspond à "Label" dans le JSON
|
||||||
|
public List<TranslationDTO> Title { get; set; } // Correspond à "Title" dans le JSON
|
||||||
|
public List<TranslationDTO> Description { get; set; } // Correspond à "Description" dans le JSON
|
||||||
|
public string ImageId { get; set; } // Correspond à "ImageId" dans le JSON
|
||||||
|
public string ImageSource { get; set; } // Correspond à "ImageSource" dans le JSON
|
||||||
|
public string ConfigurationId { get; set; } // Correspond à "ConfigurationId" dans le JSON
|
||||||
|
public bool IsSubSection { get; set; } // Correspond à "IsSubSection" dans le JSON
|
||||||
|
public string ParentId { get; set; } // Correspond à "ParentId" dans le JSON
|
||||||
|
public int Type { get; set; } // Correspond à "Type" dans le JSON
|
||||||
|
public string Data { get; set; } // Correspond à "Data" dans le JSON
|
||||||
|
|
||||||
|
public DateCustom DateCreation { get; set; }
|
||||||
|
public int? Order { get; set; } // Correspond à "Order" dans le JSON
|
||||||
|
public string InstanceId { get; set; } // Correspond à "InstanceId" dans le JSON
|
||||||
|
public bool IsBeacon { get; set; } // Correspond à "IsBeacon" dans le JSON
|
||||||
|
public string BeaconId { get; set; } // Correspond à "BeaconId" dans le JSON
|
||||||
|
public string Latitude { get; set; } // Correspond à "Latitude" dans le JSON
|
||||||
|
public string Longitude { get; set; } // Correspond à "Longitude" dans le JSON
|
||||||
|
public int? MeterZoneGPS { get; set; } // Correspond à "MeterZoneGPS" dans le JSON
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MongoId
|
||||||
|
{
|
||||||
|
public string oid { get; set; } // Correspond à "$oid" dans le JSON
|
||||||
|
}
|
||||||
|
|
||||||
|
public class DateCustom
|
||||||
|
{
|
||||||
|
public DateTime date { get; set; } // Correspond à "$oid" dans le JSON
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
25
Manager.Interfaces/DTO/SubSection/OldArticleDTO.cs
Normal file
25
Manager.Interfaces/DTO/SubSection/OldArticleDTO.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using Manager.Interfaces.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Manager.Interfaces.DTO
|
||||||
|
{
|
||||||
|
public class OldArticleDTO
|
||||||
|
{
|
||||||
|
public List<TranslationDTO> content { get; set; }
|
||||||
|
public bool isContentTop { get; set; } // MyVisit - True if content is displayed at top, false otherwise
|
||||||
|
public List<TranslationDTO> audioIds { get; set; }
|
||||||
|
public bool isReadAudioAuto { get; set; } // MyVisit - True for audio play when open the article / false otherwise
|
||||||
|
public List<OldContentDTO> images { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class OldContentDTO
|
||||||
|
{
|
||||||
|
public List<TranslationDTO> title { get; set; }
|
||||||
|
public List<TranslationDTO> description { get; set; }
|
||||||
|
public string resourceId { get; set; }
|
||||||
|
public string source { get; set; }
|
||||||
|
public int order { get; set; } // Order to show
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -18,6 +18,7 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.Server.IIS.Core;
|
using Microsoft.AspNetCore.Server.IIS.Core;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using MongoDB.Bson.Serialization.Serializers;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using NSwag.Annotations;
|
using NSwag.Annotations;
|
||||||
@ -74,8 +75,8 @@ namespace ManagerService.Controllers
|
|||||||
resources = _resourceService.GetAll(instanceId);
|
resources = _resourceService.GetAll(instanceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<ResourceDTO> resourceDTOs = new List<ResourceDTO>();
|
List<ResourceDTO> resourceDTOs = new List<ResourceDTO>();
|
||||||
foreach(var resource in resources)
|
foreach (var resource in resources)
|
||||||
{
|
{
|
||||||
ResourceDTO resourceDTO = new ResourceDTO();
|
ResourceDTO resourceDTO = new ResourceDTO();
|
||||||
resourceDTO = resource.ToDTO();
|
resourceDTO = resource.ToDTO();
|
||||||
@ -107,7 +108,7 @@ namespace ManagerService.Controllers
|
|||||||
|
|
||||||
if (resource == null)
|
if (resource == null)
|
||||||
throw new KeyNotFoundException("This resource was not found");
|
throw new KeyNotFoundException("This resource was not found");
|
||||||
|
|
||||||
ResourceDTO resourceDTO = new ResourceDTO();
|
ResourceDTO resourceDTO = new ResourceDTO();
|
||||||
resourceDTO = resource.ToDTO();
|
resourceDTO = resource.ToDTO();
|
||||||
/*if (resource.Type == ResourceType.ImageUrl)
|
/*if (resource.Type == ResourceType.ImageUrl)
|
||||||
@ -142,7 +143,7 @@ namespace ManagerService.Controllers
|
|||||||
}
|
}
|
||||||
catch (KeyNotFoundException ex)
|
catch (KeyNotFoundException ex)
|
||||||
{
|
{
|
||||||
return new NotFoundObjectResult(ex.Message) {};
|
return new NotFoundObjectResult(ex.Message) { };
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -235,23 +236,23 @@ namespace ManagerService.Controllers
|
|||||||
var resourceType = (ResourceType)Enum.Parse(typeof(ResourceType), type);
|
var resourceType = (ResourceType)Enum.Parse(typeof(ResourceType), type);
|
||||||
List<Resource> resources = new List<Resource>();
|
List<Resource> resources = new List<Resource>();
|
||||||
|
|
||||||
foreach (var file in Request.Form.Files)
|
foreach (var file in Request.Form.Files)
|
||||||
{
|
{
|
||||||
if (file.Length > 0)
|
if (file.Length > 0)
|
||||||
{
|
{
|
||||||
var stringResult = "";
|
var stringResult = "";
|
||||||
double fileSizeibMbs = (double) ((double)file.Length) / (1024*1024);
|
double fileSizeibMbs = (double)((double)file.Length) / (1024 * 1024);
|
||||||
if (fileSizeibMbs <= 1.5 || resourceType == ResourceType.Image)
|
if (fileSizeibMbs <= 1.5 || resourceType == ResourceType.Image)
|
||||||
{
|
{
|
||||||
using (var ms = new MemoryStream())
|
using (var ms = new MemoryStream())
|
||||||
{
|
{
|
||||||
file.CopyTo(ms);
|
file.CopyTo(ms);
|
||||||
var fileBytes = ms.ToArray();
|
var fileBytes = ms.ToArray();
|
||||||
if (resourceType == ResourceType.Image)
|
if (resourceType == ResourceType.Image)
|
||||||
{
|
{
|
||||||
bool isFort = instanceId == "633ee379d9405f32f166f047"; // If fort saint heribert, TODO add watermark in configuration and model
|
bool isFort = instanceId == "633ee379d9405f32f166f047"; // If fort saint heribert, TODO add watermark in configuration and model
|
||||||
|
|
||||||
if(isFort) // TODO We need to know for which purpose (mobile or tablet)
|
if (isFort) // TODO We need to know for which purpose (mobile or tablet)
|
||||||
{
|
{
|
||||||
fileBytes = ImageHelper.ResizeAndAddWatermark(fileBytes, isFort, MaxWidth, MaxHeight);
|
fileBytes = ImageHelper.ResizeAndAddWatermark(fileBytes, isFort, MaxWidth, MaxHeight);
|
||||||
}
|
}
|
||||||
@ -325,11 +326,11 @@ namespace ManagerService.Controllers
|
|||||||
}
|
}
|
||||||
catch (ArgumentNullException ex)
|
catch (ArgumentNullException ex)
|
||||||
{
|
{
|
||||||
return new BadRequestObjectResult(ex.Message) {};
|
return new BadRequestObjectResult(ex.Message) { };
|
||||||
}
|
}
|
||||||
catch (InvalidOperationException ex)
|
catch (InvalidOperationException ex)
|
||||||
{
|
{
|
||||||
return new ConflictObjectResult(ex.Message) {};
|
return new ConflictObjectResult(ex.Message) { };
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -372,11 +373,11 @@ namespace ManagerService.Controllers
|
|||||||
}
|
}
|
||||||
catch (ArgumentNullException ex)
|
catch (ArgumentNullException ex)
|
||||||
{
|
{
|
||||||
return new BadRequestObjectResult(ex.Message) {};
|
return new BadRequestObjectResult(ex.Message) { };
|
||||||
}
|
}
|
||||||
catch (KeyNotFoundException ex)
|
catch (KeyNotFoundException ex)
|
||||||
{
|
{
|
||||||
return new NotFoundObjectResult(ex.Message) {};
|
return new NotFoundObjectResult(ex.Message) { };
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -464,13 +465,13 @@ namespace ManagerService.Controllers
|
|||||||
{
|
{
|
||||||
if (question.label != null)
|
if (question.label != null)
|
||||||
{
|
{
|
||||||
foreach (var questionLabel in question.label)
|
foreach (var questionLabel in question.label)
|
||||||
{
|
{
|
||||||
questionLabel.resourceUrl = questionLabel.resourceId == id ? null : questionLabel.resourceUrl;
|
questionLabel.resourceUrl = questionLabel.resourceId == id ? null : questionLabel.resourceUrl;
|
||||||
questionLabel.resourceId = questionLabel.resourceId == id ? null : questionLabel.resourceId;
|
questionLabel.resourceId = questionLabel.resourceId == id ? null : questionLabel.resourceId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
question.imageBackgroundResourceUrl = question.imageBackgroundResourceId == id ? null : question.imageBackgroundResourceUrl;
|
question.imageBackgroundResourceUrl = question.imageBackgroundResourceId == id ? null : question.imageBackgroundResourceUrl;
|
||||||
question.imageBackgroundResourceId = question.imageBackgroundResourceId == id ? null : question.imageBackgroundResourceId;
|
question.imageBackgroundResourceId = question.imageBackgroundResourceId == id ? null : question.imageBackgroundResourceId;
|
||||||
|
|
||||||
@ -580,29 +581,61 @@ namespace ManagerService.Controllers
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
string json = System.IO.File.ReadAllText("C:/Users/ThomasFransolet/Documents/Documents/Perso/UNOV/MongoDB 10-10-24 - MyMuseum before migration/TabletDb.Resources.json");
|
||||||
|
var resourceAll = JsonConvert.DeserializeObject<List<ResourceOLDDTO>>(json); // Désérialiser en liste d'objets
|
||||||
|
|
||||||
string json = System.IO.File.ReadAllText("C:/Users/ThomasFransolet/Documents/Documents/Perso/MuseeDeLaFraise/Aout 2024/TabletDb.Resources.json");
|
using (StreamReader dataFile = new StreamReader("C:/Users/ThomasFransolet/Documents/Documents/Perso/UNOV/MongoDB 10-10-24 - MyMuseum before migration/TabletDb.ResourcesData.json"))
|
||||||
JArray resourceAll = JArray.Parse(json);
|
using (JsonTextReader dataReader = new JsonTextReader(dataFile))
|
||||||
|
|
||||||
foreach (var resource in resourceAll)
|
|
||||||
{
|
{
|
||||||
Resource newResource = new Resource();
|
while (dataReader.Read())
|
||||||
newResource.Id = (string)resource["_id"]["$oid"];
|
|
||||||
|
|
||||||
var test = _resourceService.GetById(newResource.Id);
|
|
||||||
if (test == null)
|
|
||||||
{
|
{
|
||||||
newResource.Type = ResourceType.Image;
|
if (dataReader.TokenType == JsonToken.StartObject)
|
||||||
newResource.DateCreation = (DateTime)resource["DateCreation"]["$date"];
|
{
|
||||||
newResource.Label = (string)resource["Label"];
|
JObject resourceData = JObject.Load(dataReader);
|
||||||
newResource.InstanceId = "65ccc67265373befd15be511";
|
|
||||||
|
|
||||||
var dataTest = (string)resource["Data"];
|
Resource newResource = new Resource();
|
||||||
var downloadUrl = await _firebaseStorageService.UploadBase64Async(dataTest, newResource.Id, newResource.InstanceId);
|
newResource.Id = (string)resourceData["ResourceId"];
|
||||||
newResource.Url = downloadUrl;
|
|
||||||
|
|
||||||
// TO Uncomment if needed
|
var test = _resourceService.GetById(newResource.Id);
|
||||||
//Resource createdResource = _resourceService.Create(newResource);
|
if (test == null)
|
||||||
|
{
|
||||||
|
|
||||||
|
// Rechercher la ressource correspondante dans resourceAll
|
||||||
|
var resource = resourceAll.FirstOrDefault(r => r._id.oid == newResource.Id);
|
||||||
|
|
||||||
|
if (resource != null && resource.InstanceId == "633ee379d9405f32f166f047")
|
||||||
|
{
|
||||||
|
newResource.Type = resource.Type;
|
||||||
|
newResource.DateCreation = resource.DateCreation.date;
|
||||||
|
newResource.Label = resource.Label;
|
||||||
|
newResource.InstanceId = resource.InstanceId;
|
||||||
|
|
||||||
|
var dataTest = (string)resourceData["Data"];
|
||||||
|
try {
|
||||||
|
// Uncomment if needed
|
||||||
|
/*var downloadUrl = await _firebaseStorageService.UploadBase64Async(dataTest, newResource.Id, newResource.InstanceId);
|
||||||
|
newResource.Url = downloadUrl;
|
||||||
|
Resource createdResource = _resourceService.Create(newResource);*/
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine("resource id " + newResource.Id);
|
||||||
|
Console.WriteLine(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Rechercher la ressource correspondante dans resourceAll
|
||||||
|
var resource = resourceAll.FirstOrDefault(r => r._id.oid == newResource.Id);
|
||||||
|
|
||||||
|
if (resource.Type != test.Type)
|
||||||
|
{
|
||||||
|
test.Type = resource.Type;
|
||||||
|
//_resourceService.Update(test.Id, test);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -623,4 +656,4 @@ namespace ManagerService.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -677,7 +677,7 @@ namespace ManagerService.Controllers
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
List<Section> sections = _sectionService.GetAll("65ccc67265373befd15be511"); // get by instance ID (hardcoded MDLF)
|
List<Section> sections = _sectionService.GetAll("633ee379d9405f32f166f047"); // get by instance ID (hardcoded Fort)
|
||||||
foreach (var section in sections)
|
foreach (var section in sections)
|
||||||
{
|
{
|
||||||
section.ImageSource = CheckAndUpdateURL(section.ImageSource, _resourceService);
|
section.ImageSource = CheckAndUpdateURL(section.ImageSource, _resourceService);
|
||||||
@ -752,6 +752,15 @@ namespace ManagerService.Controllers
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
case SectionType.Menu:
|
case SectionType.Menu:
|
||||||
|
break;
|
||||||
|
case SectionType.Article:
|
||||||
|
var articleData = JsonConvert.DeserializeObject<ArticleDTO>(section.Data);
|
||||||
|
foreach (var content in articleData.contents)
|
||||||
|
{
|
||||||
|
content.resourceUrl = CheckAndUpdateURL(content.resourceUrl, _resourceService);
|
||||||
|
}
|
||||||
|
section.Data = JsonConvert.SerializeObject(articleData); // Include all info from specific section as JSON
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Update DB
|
// Update DB
|
||||||
@ -776,7 +785,7 @@ namespace ManagerService.Controllers
|
|||||||
|
|
||||||
private string CheckAndUpdateURL(string sourceURL, ResourceDatabaseService resourceDatabaseService)
|
private string CheckAndUpdateURL(string sourceURL, ResourceDatabaseService resourceDatabaseService)
|
||||||
{
|
{
|
||||||
if (sourceURL != null && (sourceURL.Contains("192.168.1.19") || sourceURL.Contains("localhost")))
|
if (sourceURL != null && (sourceURL.Contains("192.168.1.19") || sourceURL.Contains("localhost") || sourceURL.Contains("https://api.mymuseum.be")))
|
||||||
{
|
{
|
||||||
if (sourceURL.Contains("localhost"))
|
if (sourceURL.Contains("localhost"))
|
||||||
{
|
{
|
||||||
@ -802,26 +811,28 @@ namespace ManagerService.Controllers
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
var i = 1;
|
||||||
|
string json = System.IO.File.ReadAllText("C:/Users/ThomasFransolet/Documents/Documents/Perso/UNOV/MongoDB 10-10-24 - MyMuseum before migration/TabletDb.Sections.json");
|
||||||
|
|
||||||
string json = System.IO.File.ReadAllText("C:/Users/ThomasFransolet/Documents/Documents/Perso/MuseeDeLaFraise/Aout 2024/TabletDb.Sections.json");
|
var sections = JsonConvert.DeserializeObject<SectionForJsonDTO[]>(json);
|
||||||
var sections = JsonConvert.DeserializeObject<SectionDTO[]>(json);
|
|
||||||
|
|
||||||
foreach (var sectionJSON in sections)
|
|
||||||
|
foreach (var sectionJSON in sections.Where(s => s.InstanceId == "633ee379d9405f32f166f047"))
|
||||||
{
|
{
|
||||||
// Todo add some verification ?
|
// Todo add some verification ?
|
||||||
Section section = new Section();
|
Section section = new Section();
|
||||||
section.Id = sectionJSON.id;
|
section.Id = sectionJSON._id.oid;
|
||||||
section.InstanceId = "65ccc67265373befd15be511"; // MDLF hardcoded
|
section.InstanceId = "633ee379d9405f32f166f047"; // Fort hardcoded
|
||||||
section.Label = sectionJSON.label;
|
section.Label = sectionJSON.Label;
|
||||||
section.ImageId = sectionJSON.imageId;
|
section.ImageId = sectionJSON.ImageId;
|
||||||
section.ImageSource = sectionJSON.imageSource;
|
section.ImageSource = sectionJSON.ImageSource;
|
||||||
section.ConfigurationId = sectionJSON.configurationId;
|
section.ConfigurationId = sectionJSON.ConfigurationId;
|
||||||
section.DateCreation = sectionJSON.dateCreation;
|
section.DateCreation = sectionJSON.DateCreation.date;
|
||||||
section.IsSubSection = sectionJSON.isSubSection;
|
section.IsSubSection = sectionJSON.IsSubSection;
|
||||||
section.ParentId = sectionJSON.parentId;
|
section.ParentId = sectionJSON.ParentId;
|
||||||
section.Type = sectionJSON.type;
|
section.Type = (SectionType)sectionJSON.Type;
|
||||||
section.Title = sectionJSON.title;
|
section.Title = sectionJSON.Title;
|
||||||
section.Description = sectionJSON.description;
|
section.Description = sectionJSON.Description;
|
||||||
section.Order = _sectionService.GetAllFromConfiguration(section.ConfigurationId).Count;
|
section.Order = _sectionService.GetAllFromConfiguration(section.ConfigurationId).Count;
|
||||||
section.IsBeacon = false;
|
section.IsBeacon = false;
|
||||||
|
|
||||||
@ -840,7 +851,7 @@ namespace ManagerService.Controllers
|
|||||||
switch (section.Type)
|
switch (section.Type)
|
||||||
{
|
{
|
||||||
case SectionType.Map:
|
case SectionType.Map:
|
||||||
var sectionDataMap = JsonConvert.DeserializeObject<MapDTO>(sectionJSON.data);
|
/*var sectionDataMap = JsonConvert.DeserializeObject<MapDTO>(sectionJSON.Data);
|
||||||
var mapDTO = new MapDTO();
|
var mapDTO = new MapDTO();
|
||||||
|
|
||||||
mapDTO.mapType = sectionDataMap.mapType;
|
mapDTO.mapType = sectionDataMap.mapType;
|
||||||
@ -853,7 +864,7 @@ namespace ManagerService.Controllers
|
|||||||
|
|
||||||
List<GeoPointDTO> geoPoints = new List<GeoPointDTO>();
|
List<GeoPointDTO> geoPoints = new List<GeoPointDTO>();
|
||||||
|
|
||||||
JObject sectionMapp = JObject.Parse(sectionJSON.data);
|
JObject sectionMapp = JObject.Parse(sectionJSON.Data);
|
||||||
foreach (var point in sectionMapp["points"])
|
foreach (var point in sectionMapp["points"])
|
||||||
{
|
{
|
||||||
GeoPointDTO pointDTO = new GeoPointDTO();
|
GeoPointDTO pointDTO = new GeoPointDTO();
|
||||||
@ -880,12 +891,12 @@ namespace ManagerService.Controllers
|
|||||||
|
|
||||||
mapDTO.points = geoPoints;
|
mapDTO.points = geoPoints;
|
||||||
mapDTO.categories = new List<CategorieDTO>();
|
mapDTO.categories = new List<CategorieDTO>();
|
||||||
section.Data = JsonConvert.SerializeObject(mapDTO); // Include all info from specific section as JSON
|
section.Data = JsonConvert.SerializeObject(mapDTO); // Include all info from specific section as JSON*/
|
||||||
break;
|
break;
|
||||||
case SectionType.Slider:
|
case SectionType.Slider:
|
||||||
//var sectionSlider = JsonConvert.DeserializeObject(sectionJSON.data);
|
//var sectionSlider = JsonConvert.DeserializeObject(sectionJSON.data);
|
||||||
var sliderDTO = new SliderDTO();
|
var sliderDTO = new SliderDTO();
|
||||||
JObject sectionSlider = JObject.Parse(sectionJSON.data);
|
JObject sectionSlider = JObject.Parse(sectionJSON.Data);
|
||||||
|
|
||||||
List<ContentDTO> newContents = new List<ContentDTO>();
|
List<ContentDTO> newContents = new List<ContentDTO>();
|
||||||
|
|
||||||
@ -913,19 +924,19 @@ namespace ManagerService.Controllers
|
|||||||
section.Data = JsonConvert.SerializeObject(sliderDTO); // Include all info from specific section as JSON
|
section.Data = JsonConvert.SerializeObject(sliderDTO); // Include all info from specific section as JSON
|
||||||
break;
|
break;
|
||||||
case SectionType.Video:
|
case SectionType.Video:
|
||||||
var sectionVideo = JsonConvert.DeserializeObject<VideoDTO>(sectionJSON.data);
|
var sectionVideo = JsonConvert.DeserializeObject<VideoDTO>(sectionJSON.Data);
|
||||||
VideoDTO videoDTO = new VideoDTO();
|
VideoDTO videoDTO = new VideoDTO();
|
||||||
videoDTO.source = sectionVideo.source;
|
videoDTO.source = sectionVideo.source;
|
||||||
section.Data = JsonConvert.SerializeObject(videoDTO); // Include all info from specific section as JSON
|
section.Data = JsonConvert.SerializeObject(videoDTO); // Include all info from specific section as JSON
|
||||||
break;
|
break;
|
||||||
case SectionType.Web:
|
case SectionType.Web:
|
||||||
var sectionWeb = JsonConvert.DeserializeObject<WebDTO>(sectionJSON.data);
|
var sectionWeb = JsonConvert.DeserializeObject<WebDTO>(sectionJSON.Data);
|
||||||
WebDTO webDTO = new WebDTO();
|
WebDTO webDTO = new WebDTO();
|
||||||
webDTO.source = sectionWeb.source;
|
webDTO.source = sectionWeb.source;
|
||||||
section.Data = JsonConvert.SerializeObject(webDTO); // Include all info from specific section as JSON
|
section.Data = JsonConvert.SerializeObject(webDTO); // Include all info from specific section as JSON
|
||||||
break;
|
break;
|
||||||
case SectionType.Menu:
|
case SectionType.Menu:
|
||||||
var sectionMenu = JsonConvert.DeserializeObject<MenuDTO>(sectionJSON.data);
|
var sectionMenu = JsonConvert.DeserializeObject<MenuDTO>(sectionJSON.Data);
|
||||||
MenuDTO menuDTO = new MenuDTO();
|
MenuDTO menuDTO = new MenuDTO();
|
||||||
menuDTO.sections = sectionMenu.sections;
|
menuDTO.sections = sectionMenu.sections;
|
||||||
foreach (var sectionMenuu in menuDTO.sections)
|
foreach (var sectionMenuu in menuDTO.sections)
|
||||||
@ -1030,7 +1041,8 @@ namespace ManagerService.Controllers
|
|||||||
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:
|
case SectionType.Quizz:
|
||||||
var sectionQuizz = JsonConvert.DeserializeObject<QuizzDTO>(sectionJSON.data);
|
// Fort don't use quizz for now piouf :)
|
||||||
|
/*var sectionQuizz = JsonConvert.DeserializeObject<QuizzDTO>(sectionJSON.Data);
|
||||||
QuizzDTO quizzDTO = new QuizzDTO();
|
QuizzDTO quizzDTO = new QuizzDTO();
|
||||||
quizzDTO.questions = sectionQuizz.questions;
|
quizzDTO.questions = sectionQuizz.questions;
|
||||||
quizzDTO.bad_level = sectionQuizz.bad_level;
|
quizzDTO.bad_level = sectionQuizz.bad_level;
|
||||||
@ -1038,21 +1050,41 @@ namespace ManagerService.Controllers
|
|||||||
quizzDTO.good_level = sectionQuizz.medium_level;
|
quizzDTO.good_level = sectionQuizz.medium_level;
|
||||||
quizzDTO.great_level = sectionQuizz.great_level;
|
quizzDTO.great_level = sectionQuizz.great_level;
|
||||||
|
|
||||||
section.Data = JsonConvert.SerializeObject(quizzDTO); // Include all info from specific section as JSON
|
section.Data = JsonConvert.SerializeObject(quizzDTO);*/ // Include all info from specific section as JSON
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// NEW CONTENTS AFTER MDLF
|
// NEW CONTENTS AFTER MDLF
|
||||||
case SectionType.Article:
|
case SectionType.Article:
|
||||||
ArticleDTO articleDTO = new ArticleDTO();
|
try {
|
||||||
articleDTO.contents = new List<ContentDTO>();
|
var sectionArticle = JsonConvert.DeserializeObject<OldArticleDTO>(sectionJSON.Data);
|
||||||
articleDTO.content = contentArticle;
|
ArticleDTO newArticle = new ArticleDTO();
|
||||||
//articleDTO.audioIds = LanguageInit.Init("Audio", languages, true);
|
newArticle.content = sectionArticle.content;
|
||||||
|
newArticle.isContentTop = sectionArticle.isContentTop;
|
||||||
|
newArticle.audioIds = sectionArticle.audioIds;
|
||||||
|
newArticle.isReadAudioAuto = sectionArticle.isReadAudioAuto;
|
||||||
|
newArticle.contents = new List<ContentDTO>();
|
||||||
|
foreach (var image in sectionArticle.images) // Migrate old images to contents
|
||||||
|
{
|
||||||
|
ContentDTO contentDTO = new ContentDTO();
|
||||||
|
|
||||||
section.Data = JsonConvert.SerializeObject(articleDTO); // Include all info from specific section as JSON
|
contentDTO.title = image.title;
|
||||||
|
contentDTO.description = image.description;
|
||||||
|
contentDTO.resourceId = image.resourceId;
|
||||||
|
contentDTO.order = image.order;
|
||||||
|
contentDTO.resourceType = ResourceType.Image;
|
||||||
|
contentDTO.resourceUrl = image.source;
|
||||||
|
newArticle.contents.Add(contentDTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
section.Data = JsonConvert.SerializeObject(newArticle); // Include all info from specific section as JSON
|
||||||
|
} catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Issue in article with id " + sectionJSON._id + e);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case SectionType.PDF:
|
/*case SectionType.PDF:
|
||||||
PdfDTO pdfDTO = new PdfDTO();
|
PdfDTO pdfDTO = new PdfDTO();
|
||||||
section.Data = JsonConvert.SerializeObject(pdfDTO); // Include all info from specific section as JSON
|
section.Data = JsonConvert.SerializeObject(pdfDTO); // Include all info from specific section as JSON
|
||||||
break;
|
break;
|
||||||
@ -1067,12 +1099,21 @@ namespace ManagerService.Controllers
|
|||||||
case SectionType.Weather:
|
case SectionType.Weather:
|
||||||
WeatherDTO weatherDTO = new WeatherDTO();
|
WeatherDTO weatherDTO = new WeatherDTO();
|
||||||
section.Data = JsonConvert.SerializeObject(weatherDTO); // Include all info from specific section as JSON
|
section.Data = JsonConvert.SerializeObject(weatherDTO); // Include all info from specific section as JSON
|
||||||
break;
|
break;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_configurationService.IsExist(section.ConfigurationId))
|
||||||
|
{
|
||||||
|
i += 1;
|
||||||
|
//Section sectionCreated = _sectionService.Create(section);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//Section sectionCreated = _sectionService.Create(section);
|
var test = i;
|
||||||
}
|
|
||||||
|
|
||||||
return new OkObjectResult(true);
|
return new OkObjectResult(true);
|
||||||
}
|
}
|
||||||
catch (ArgumentNullException ex)
|
catch (ArgumentNullException ex)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user