This commit is contained in:
2018-08-30 22:59:41 +00:00
parent 1d2ba080c9
commit 1222fe9c2c
2 changed files with 37 additions and 34 deletions

View File

@@ -446,6 +446,7 @@ namespace AyaNova.Biz
{
await ct.SaveChangesAsync();
var mapItem = new ImportAyaNova7MapItem(V7Id, AyaType.User, o.Id);
importMap.Add(mapItem);
}
}
@@ -462,77 +463,78 @@ namespace AyaNova.Biz
break;
case "GZTW.AyaNova.BLL.User-locale":
{
//get the userId
var V7Id = new Guid(j["ID"].Value<string>());
var MapItem = importMap.Where(m => m.V7ObjectId == V7Id).FirstOrDefault();
if (MapItem == null)
{
throw new System.Exception("UserBiz::ImportV7Async-locale - FATAL ERROR, IMPORT FROM V7 CANNOT CONTINUE USER NOT FOUND IN IMPORTMAP");
}
var NewId = MapItem.NewObjectAyaTypeId.ObjectId;
User u = ct.User.Where(m => m.Id == NewId).FirstOrDefault();
if (u == null)
{
throw new System.Exception("UserBiz::ImportV7Async-locale - FATAL ERROR, IMPORT FROM V7 CANNOT CONTINUE USER NOT FOUND IN DATABASE");
}
//handle locale entries for users now that we have the locales created
var V7Locale = j["DefaultLanguage"].Value<string>();
//Get the RAVEN locale name and id instead
//Get new locale name
var NewLocaleName = string.Empty;
switch (V7Locale)
{
case "Français":
NewLocaleName = "fr";
break;
case "Español":
NewLocaleName = "es";
break;
case "Deutsch":
NewLocaleName = "de";
break;
case "English":
NewLocaleName = "en";
break;
default:
{
//It's a custom locale, translate it from v7 original format to imported name format
//make lower and replace spaces with dashes
V7Locale = V7Locale.ToLowerInvariant().Replace(" ", "-");
NewLocaleName = V7Locale.ToLowerInvariant().Replace(" ", "-");
//ensure each character is a valid path character
foreach (char c in System.IO.Path.GetInvalidFileNameChars())
foreach (char c in System.IO.Path.GetInvalidFileNameChars())//is this kosher on linux? Original code was windows
{
V7Locale = V7Locale.Replace(c, '_');
NewLocaleName = NewLocaleName.Replace(c, '_');
}
}
break;
}
// if (!LocaleExists("en"))
// {
// throw new System.Exception($"E1015: stock locale English (en) not found in database!");
// }
// if (!LocaleExists("es"))
// {
// throw new System.Exception($"E1015: stock locale Spanish (es) not found in database!");
// }
// if (!LocaleExists("de"))
// {
// throw new System.Exception($"E1015: stock locale German (de) not found in database!");
// }
// if (!LocaleExists("fr"))
u.LocaleId = LocaleBiz.LocaleNameToIdStatic(NewLocaleName, ct);
//"Español",??
//Find the matching ID number for this locale
// LocaleBiz.LocaleExistsStatic
ct.SaveChanges();
}
break;
case "GZTW.AyaNova.BLL.User-scheduleableusergrouptags":
{
//handle tag entries for users now that we have the SUG tags created
throw new System.NotImplementedException();
// throw new System.NotImplementedException();
}
//break;
break;
case "GZTW.AyaNova.BLL.User-client":
{
//handle setting client id for user client login
throw new System.NotImplementedException();
//throw new System.NotImplementedException();
}
//break;
break;
case "GZTW.AyaNova.BLL.User-headoffice":
{
//handle setting ho id for user headoffice login
throw new System.NotImplementedException();
//throw new System.NotImplementedException();
}
//break;
break;
}
//just to hide compiler warning for now

View File

@@ -8,12 +8,13 @@ namespace AyaNova.Models
/// </summary>
public partial class ImportAyaNova7MapItem
{
public AyaTypeId NewObject { get; set; }
public AyaTypeId NewObjectAyaTypeId { get; set; }
public Guid V7ObjectId { get; set; }
public ImportAyaNova7MapItem(Guid v7Guid, AyaType ayaType, long newId){
NewObject=new AyaTypeId(ayaType,newId);
V7ObjectId=v7Guid;
public ImportAyaNova7MapItem(Guid v7Guid, AyaType ayaType, long newId)
{
NewObjectAyaTypeId = new AyaTypeId(ayaType, newId);
V7ObjectId = v7Guid;
}
}