This commit is contained in:
@@ -271,6 +271,12 @@ namespace AyaNova.Biz
|
|||||||
return v.First();
|
return v.First();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static long LocaleNameToIdStatic(string localeName, AyContext ct)
|
||||||
|
{
|
||||||
|
var v = ct.Locale.Where(c => c.Name == localeName).Select(x => x.Id);
|
||||||
|
if (v.Count() < 1) return ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID;
|
||||||
|
return v.First();
|
||||||
|
}
|
||||||
|
|
||||||
public bool LocaleExists(string localeName)
|
public bool LocaleExists(string localeName)
|
||||||
{
|
{
|
||||||
@@ -360,7 +366,7 @@ namespace AyaNova.Biz
|
|||||||
default:
|
default:
|
||||||
if (!LocaleExists(ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE))
|
if (!LocaleExists(ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE))
|
||||||
{
|
{
|
||||||
throw new System.Exception($"E1015: stock locale French (fr) not found in database!");
|
throw new System.Exception($"E1015: stock locale {ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE} not found in database!");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -376,11 +382,6 @@ namespace AyaNova.Biz
|
|||||||
/// IMPORT v7 implementation
|
/// IMPORT v7 implementation
|
||||||
public async Task<bool> ImportV7Async(JObject j, List<ImportAyaNova7MapItem> importMap, Guid jobId)
|
public async Task<bool> ImportV7Async(JObject j, List<ImportAyaNova7MapItem> importMap, Guid jobId)
|
||||||
{
|
{
|
||||||
//TODO: when locales are imported that's when it should take a pass over users collection and then set the correct locale accordingly
|
|
||||||
//or default if it's missing
|
|
||||||
//v7 users locale json element:
|
|
||||||
//var V7Locale=j["DefaultLanguage"].Value<string>();
|
|
||||||
|
|
||||||
//some types need to import from more than one source hence the seemingly redundant switch statement for futureproofing
|
//some types need to import from more than one source hence the seemingly redundant switch statement for futureproofing
|
||||||
switch (j["V7_TYPE"].Value<string>())
|
switch (j["V7_TYPE"].Value<string>())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -387,7 +387,7 @@ namespace AyaNova.Biz
|
|||||||
"VendorID": "06e502c2-69ba-4e88-8efb-5b53c1687740",
|
"VendorID": "06e502c2-69ba-4e88-8efb-5b53c1687740",
|
||||||
"RegionID": "f856423a-d468-4344-b7b8-121e466738c6",
|
"RegionID": "f856423a-d468-4344-b7b8-121e466738c6",
|
||||||
"DispatchZoneID": "00000000-0000-0000-0000-000000000000",
|
"DispatchZoneID": "00000000-0000-0000-0000-000000000000",
|
||||||
"SubContractor": false,
|
"SubContractor": false,//This is not actually a feature in v7, you can just pick a vendorId for subcontractor but still be of type technician
|
||||||
"DefaultWarehouseID": "d45eab37-b6e6-4ad2-9163-66d7ba83a98c",
|
"DefaultWarehouseID": "d45eab37-b6e6-4ad2-9163-66d7ba83a98c",
|
||||||
"Custom1": "",
|
"Custom1": "",
|
||||||
"Custom2": "",
|
"Custom2": "",
|
||||||
@@ -419,11 +419,17 @@ namespace AyaNova.Biz
|
|||||||
User i = new User();
|
User i = new User();
|
||||||
i.Name = j["FirstName"].Value<string>() + " " + j["LastName"].Value<string>();
|
i.Name = j["FirstName"].Value<string>() + " " + j["LastName"].Value<string>();
|
||||||
i.UserType = j["UserType"].Value<UserType>();
|
i.UserType = j["UserType"].Value<UserType>();
|
||||||
i.Active = j["Active"].Value<bool>();
|
|
||||||
|
|
||||||
//TODO: i.LocaleId
|
//If there is a vendorId set then this user is actually a subcontractor in v7 so set accordingly
|
||||||
//when locales are imported that's when it should take a pass over users and set them as per here
|
var VendorId = new Guid(j["VendorID"].Value<string>());
|
||||||
//var V7Locale=j["DefaultLanguage"].Value<string>();
|
if (VendorId != Guid.Empty)
|
||||||
|
{
|
||||||
|
i.UserType = UserType.Subcontractor;
|
||||||
|
}
|
||||||
|
|
||||||
|
i.Active = j["Active"].Value<bool>();
|
||||||
|
i.EmployeeNumber = j["EmployeeNumber"].Value<string>();
|
||||||
|
i.Notes = j["Notes"].Value<string>();
|
||||||
|
|
||||||
User o = await CreateAsync(i);
|
User o = await CreateAsync(i);
|
||||||
if (HasErrors)
|
if (HasErrors)
|
||||||
@@ -451,15 +457,64 @@ namespace AyaNova.Biz
|
|||||||
//EventLogProcessor.AddEntry(new Event(userId, o.Id, AyaType.User, AyaEvent.Created), ct);
|
//EventLogProcessor.AddEntry(new Event(userId, o.Id, AyaType.User, AyaEvent.Created), ct);
|
||||||
//MODIFIED HERE
|
//MODIFIED HERE
|
||||||
// await ct.SaveChangesAsync();
|
// await ct.SaveChangesAsync();
|
||||||
throw new System.NotImplementedException();
|
|
||||||
}
|
}
|
||||||
//break;
|
break;
|
||||||
case "GZTW.AyaNova.BLL.User-locale":
|
case "GZTW.AyaNova.BLL.User-locale":
|
||||||
{
|
{
|
||||||
//handle locale entries for users now that we have the locales created
|
//handle locale entries for users now that we have the locales created
|
||||||
throw new System.NotImplementedException();
|
var V7Locale = j["DefaultLanguage"].Value<string>();
|
||||||
|
|
||||||
|
//Get the RAVEN locale name and id instead
|
||||||
|
switch (V7Locale)
|
||||||
|
{
|
||||||
|
case "Français":
|
||||||
|
break;
|
||||||
|
case "Español":
|
||||||
|
break;
|
||||||
|
case "Deutsch":
|
||||||
|
break;
|
||||||
|
case "English":
|
||||||
|
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(" ", "-");
|
||||||
|
|
||||||
|
//ensure each character is a valid path character
|
||||||
|
foreach (char c in System.IO.Path.GetInvalidFileNameChars())
|
||||||
|
{
|
||||||
|
V7Locale = V7Locale.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"))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//"Español",??
|
||||||
|
//Find the matching ID number for this locale
|
||||||
|
// LocaleBiz.LocaleExistsStatic
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
// break;
|
break;
|
||||||
case "GZTW.AyaNova.BLL.User-scheduleableusergrouptags":
|
case "GZTW.AyaNova.BLL.User-scheduleableusergrouptags":
|
||||||
{
|
{
|
||||||
//handle tag entries for users now that we have the SUG tags created
|
//handle tag entries for users now that we have the SUG tags created
|
||||||
|
|||||||
Reference in New Issue
Block a user