From 42804d4fcdcc1c8ae9520ea0d4b22b89db11e081 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Wed, 29 Apr 2020 00:24:42 +0000 Subject: [PATCH] --- source/Plugins/AyaNova.Plugin.V8/V8.cs | 57 +++++++++++++++++++++--- source/Plugins/AyaNova.Plugin.V8/util.cs | 1 + 2 files changed, 51 insertions(+), 7 deletions(-) diff --git a/source/Plugins/AyaNova.Plugin.V8/V8.cs b/source/Plugins/AyaNova.Plugin.V8/V8.cs index 923d6f7..37d1ee9 100644 --- a/source/Plugins/AyaNova.Plugin.V8/V8.cs +++ b/source/Plugins/AyaNova.Plugin.V8/V8.cs @@ -79,6 +79,8 @@ namespace AyaNova.PlugIn.V8 return false; } + util.LocaleText = localizedText; + ObjectsWeCanDealWith = new List(); ObjectsWeCanDealWith.Add(RootObjectTypes.Nothing); return true; @@ -151,6 +153,7 @@ namespace AyaNova.PlugIn.V8 private Dictionary Map = new Dictionary(); private Dictionary TagMap = new Dictionary(); + private Dictionary CustomFieldLocaleKeys = new Dictionary();//holds custom field Raven as key and v7 custom text for that field for later export private string ImportTag = "v7-import"; /// /// 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> ExportCustomFieldSchema(string objectName, string RavenCustomTranslationKeyObjectName=null) + { + var ret = new List(); + 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) //{ diff --git a/source/Plugins/AyaNova.Plugin.V8/util.cs b/source/Plugins/AyaNova.Plugin.V8/util.cs index 007f6bf..efd97f1 100644 --- a/source/Plugins/AyaNova.Plugin.V8/util.cs +++ b/source/Plugins/AyaNova.Plugin.V8/util.cs @@ -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();