This commit is contained in:
2020-04-29 00:24:42 +00:00
parent 75f9524058
commit 42804d4fcd
2 changed files with 51 additions and 7 deletions

View File

@@ -79,6 +79,8 @@ namespace AyaNova.PlugIn.V8
return false;
}
util.LocaleText = localizedText;
ObjectsWeCanDealWith = new List<RootObjectTypes>();
ObjectsWeCanDealWith.Add(RootObjectTypes.Nothing);
return true;
@@ -151,6 +153,7 @@ namespace AyaNova.PlugIn.V8
private Dictionary<Guid, long> Map = new Dictionary<Guid, long>();
private Dictionary<Guid, string> TagMap = new Dictionary<Guid, string>();
private Dictionary<string, string> CustomFieldLocaleKeys = new Dictionary<string, string>();//holds custom field Raven as key and v7 custom text for that field for later export
private string ImportTag = "v7-import";
/// <summary>
/// Dump the objects into a temporary directory as a series of JSON files
@@ -167,6 +170,7 @@ namespace AyaNova.PlugIn.V8
{
Map.Clear();
TagMap.Clear();
CustomFieldLocaleKeys.Clear();
//admin user (not exported but is there already)
Map.Add(User.AdministratorID, 1);
@@ -204,14 +208,14 @@ namespace AyaNova.PlugIn.V8
//BIZ objects
await ExportUsers(progress);
//dumpLocales(tempArchiveFolder, progress);
//dumpLocales(tempArchiveFolder, progress);
//dumpGlobalSettings(tempArchiveFolder, progress);
//dumpSeedNumbers(tempArchiveFolder, progress);
//dumpClients(tempArchiveFolder, progress);
//dumpHeadOffices(tempArchiveFolder, progress);
@@ -344,7 +348,7 @@ namespace AyaNova.PlugIn.V8
private async System.Threading.Tasks.Task ExportUsers(ProgressForm progress)
{
//Step 1: export the CustomFields to FormCustom if applicable so that when doing individual items we can export their custom data too
var CustomFieldsToExport = await ExportCustomFieldSchema("User");
//Step 2: export the users
@@ -391,7 +395,8 @@ namespace AyaNova.PlugIn.V8
d.notes = c.Notes;
Tagit(c.RegionID, tags);
Tagit(c.DispatchZoneID, tags);
foreach (UserSkillAssigned skill in c.UserSkills) {
foreach (UserSkillAssigned skill in c.UserSkills)
{
Tagit(skill.UserSkillID, tags);
}
foreach (UserCertificationAssigned cert in c.UserCertifications)
@@ -410,9 +415,9 @@ namespace AyaNova.PlugIn.V8
a = await util.GetAsync("UserOptions/" + RavenId.ToString());
d = a.ObjectResponse["data"];
d.uiColor = System.Drawing.ColorTranslator.ToHtml(System.Drawing.Color.FromArgb(c.ScheduleBackColor));
d.emailAddress = string.IsNullOrWhiteSpace(c.EmailAddress)?null:c.EmailAddress;
d.emailAddress = string.IsNullOrWhiteSpace(c.EmailAddress) ? null : c.EmailAddress;
await util.PutAsync("UserOptions/" + RavenId.ToString(), d.ToString());
await util.PutAsync("UserOptions/" + RavenId.ToString(), d.ToString());
}
}
@@ -538,7 +543,7 @@ namespace AyaNova.PlugIn.V8
foreach (UserCertification i in l)
TagMap.Add(i.ID, util.NormalizeTag(i.Name + "." + "user-certification"));
}
#endregion TAG ITEMS
//--------------------------------------------
#endregion object dump methods
@@ -728,6 +733,44 @@ namespace AyaNova.PlugIn.V8
private async System.Threading.Tasks.Task<List<string>> ExportCustomFieldSchema(string objectName, string RavenCustomTranslationKeyObjectName=null)
{
var ret = new List<string>();
if (RavenCustomTranslationKeyObjectName == null) RavenCustomTranslationKeyObjectName = objectName;//i.e. WidgetCustom1, WidgetCustom2 etc
//NOTE: this code stolen from winforApp::Util.cs PrepareCustomFieldsGrid method
//is there customizations designated for this object?
ObjectCustomFields ocf = ObjectCustomFields.GetItems(objectName);
if (ocf.Count == 0)
return ret;
bool bAtLeastOneFieldIsVisible = false;
foreach (ObjectCustomField f in ocf)
{
if (f.Visible)
{
bAtLeastOneFieldIsVisible = true;
ret.Add(f.FieldName);
int n=Convert.ToInt32(f.FieldName.Replace("Custom", ""))+1;//raven custom fields are 1 based, v7 are zero based
CustomFieldLocaleKeys.Add(RavenCustomTranslationKeyObjectName + n.ToString(), util.LocaleText.GetLocalizedText(objectName + ".Label." + f.FieldName));
}
}
if (!bAtLeastOneFieldIsVisible)
return ret;
//ok, were here because there *are* custom fields available
return ret;
}
//private static string EnsureValidFileName(string fileName)
//{

View File

@@ -14,6 +14,7 @@ namespace AyaNova.PlugIn.V8
{
class util
{
public static LocalizedTextTable LocaleText = null;
const string TEST_ROUTE = "ServerInfo";
const string API_BASE_ROUTE = "api/v8/";
static HttpClient client = new HttpClient();