diff --git a/devdocs/todo.txt b/devdocs/todo.txt
index 31e3d546..df32a513 100644
--- a/devdocs/todo.txt
+++ b/devdocs/todo.txt
@@ -13,6 +13,12 @@ TODO CLIENT STUFF
- Validate time zone offset is accurate: it should validate the time zone offset when the client software starts and if it's found to be off what was set offer to change it automatically
- This way it works client to client and will handle DST changes almost automatically
+ - TODO: Will need currency symbol, date format, numeric format from user settings at server
+ - rather than try to use local browser settings which is fraught with peril will need to be specified at server itself
+ - Wherever I am currently storing time zone that's where these other settings need to be
+ - Need to find out in client world what format should be stored and how to document it
+
+ - Error messages: ensure error messages that come back from API that start with LT: will be localized correctly before display / logging (may need string interpolation too for some in future, consider that)
- LIST
- Overall list menu toolbar at top with following icons:
@@ -73,18 +79,12 @@ TODO CLIENT STUFF
----------------
TODO SERVER STUFF
+
+
- - Trial license ROCKFISH up it to 1000 techs to cover huge seeding.
-
- - AyaNova 7 import is NOT erasing the db before it does the import but it should be so what's up with that??
- - Also isn't it supposed to respect if there is existing data and force user to erase db first??
-
- - TODO: Will need currency symbol, date format, numeric format from user settings at server
- - rather than try to use local browser settings which is fraught with peril will need to be specified at server itself
- - Wherever I am currently storing time zone that's where these other settings need to be
-
- TODO: Make sure private data filters get deleted with users who created them
+ - non issue due to delete not allowed for any user after any data created under it so
- TAGS: REally need to have a think about how tags are used in the UI, probably need a autofill route that has a source of used or common tags to drive it
- so user can type first fiew characters adn select
- So consistency is maintained and not sloppy multiple spellings
diff --git a/server/AyaNova/Controllers/ImportAyaNova7Controller.cs b/server/AyaNova/Controllers/ImportAyaNova7Controller.cs
index bb54b262..590acedd 100644
--- a/server/AyaNova/Controllers/ImportAyaNova7Controller.cs
+++ b/server/AyaNova/Controllers/ImportAyaNova7Controller.cs
@@ -56,10 +56,8 @@ namespace AyaNova.Api.Controllers
///
- /// Upload AyaNova 7 import file
- ///
+ /// Upload AyaNova 7 import file
/// Required roles: OpsAdminFull
- ///
///
/// NameValue list of filenames and id's
[HttpPost]
@@ -182,10 +180,7 @@ namespace AyaNova.Api.Controllers
///
/// Get AyaNova 7 data dump uploaded files list
///
- /// Required roles: OpsAdminFull
- ///
- /// This list cannot be filtered or queried
- ///
+ /// Required roles: OpsAdminFull
///
/// List of uploaded data dump files
[HttpGet]
@@ -214,7 +209,8 @@ namespace AyaNova.Api.Controllers
///
- /// Start import of previously uploaded import file
+ /// *ERASE DATABASE and start import of previously uploaded import file
+ /// **This will permanently erase all current data in database without further warning as the first step in the import process**
///
/// Required roles: OpsAdminFull
///
diff --git a/server/AyaNova/biz/ImportAyaNova7Biz.cs b/server/AyaNova/biz/ImportAyaNova7Biz.cs
index 8912fa9e..5ae6e5a9 100644
--- a/server/AyaNova/biz/ImportAyaNova7Biz.cs
+++ b/server/AyaNova/biz/ImportAyaNova7Biz.cs
@@ -78,6 +78,13 @@ namespace AyaNova.Biz
throw new System.ArgumentNullException("ImportAyaNova7 job failed due to import file specified not existing");
}
+
+ //Erase all the data except for the license, schema and the manager user
+ Microsoft.Extensions.Logging.ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger("ImportAyaNova7");
+ JobsBiz.LogJob(job.GId, "ImportAyaNova7 - Erasing data from database", ct);
+ DbUtil.EmptyBizDataFromDatabaseForSeedingOrImporting(log);
+
+
//get the contents of the archive
List zipEntries = FileUtil.ZipGetUtilityFileEntries(importFileName);
@@ -94,45 +101,45 @@ namespace AyaNova.Biz
//
//FIRST: import items that will become tags first into temporary cache lists
- Dictionary> TagLists=new Dictionary>();
+ Dictionary> TagLists = new Dictionary>();
//IMPORT UNIT MODEL CATEGORIES AS TAGS
- TagLists.Add("UnitModelCategory",new Dictionary());
+ TagLists.Add("UnitModelCategory", new Dictionary());
ImportTagList("GZTW.AyaNova.BLL.UnitModelCategory", job.GId, TagLists["UnitModelCategory"], importFileName, zipEntries);
//IMPORT Unit service type AS TAGS
- TagLists.Add("UnitServiceType",new Dictionary());
+ TagLists.Add("UnitServiceType", new Dictionary());
ImportTagList("GZTW.AyaNova.BLL.UnitServiceType", job.GId, TagLists["UnitServiceType"], importFileName, zipEntries);
//IMPORT Workorder Item Type AS TAGS
- TagLists.Add("WorkorderItemType",new Dictionary());
+ TagLists.Add("WorkorderItemType", new Dictionary());
ImportTagList("GZTW.AyaNova.BLL.WorkorderItemType", job.GId, TagLists["WorkorderItemType"], importFileName, zipEntries);
//IMPORT Client group AS TAGS
- TagLists.Add("ClientGroup",new Dictionary());
+ TagLists.Add("ClientGroup", new Dictionary());
ImportTagList("GZTW.AyaNova.BLL.ClientGroup", job.GId, TagLists["ClientGroup"], importFileName, zipEntries);
//IMPORT Workorder category AS TAGS
- TagLists.Add("WorkorderCategory",new Dictionary());
+ TagLists.Add("WorkorderCategory", new Dictionary());
ImportTagList("GZTW.AyaNova.BLL.WorkorderCategory", job.GId, TagLists["WorkorderCategory"], importFileName, zipEntries);
//IMPORT Part Category AS TAGS
- TagLists.Add("PartCategory",new Dictionary());
+ TagLists.Add("PartCategory", new Dictionary());
ImportTagList("GZTW.AyaNova.BLL.PartCategory", job.GId, TagLists["PartCategory"], importFileName, zipEntries);
//IMPORT Dispatch zones AS TAGS
- TagLists.Add("DispatchZone",new Dictionary());
+ TagLists.Add("DispatchZone", new Dictionary());
ImportTagList("GZTW.AyaNova.BLL.DispatchZone", job.GId, TagLists["DispatchZone"], importFileName, zipEntries);
//IMPORT Scheduleable User Groups AS TAGS
- TagLists.Add("ScheduleableUserGroup",new Dictionary());
+ TagLists.Add("ScheduleableUserGroup", new Dictionary());
ImportTagList("GZTW.AyaNova.BLL.ScheduleableUserGroup", job.GId, TagLists["ScheduleableUserGroup"], importFileName, zipEntries);
//Now can set users to correct tag for scheduleable user group
// await ImportTagList("GZTW.AyaNova.BLL.ScheduleableUserGroup", "scheduleableusergrouptags", AyaType.Tag, job.GId, importMap, importFileName, zipEntries);
//IMPORT REGIONS AS TAGS
- TagLists.Add("Region",new Dictionary());
+ TagLists.Add("Region", new Dictionary());
ImportTagList("GZTW.AyaNova.BLL.Region", job.GId, TagLists["Region"], importFileName, zipEntries);
@@ -187,7 +194,7 @@ namespace AyaNova.Biz
///
///
///
- private async Task DoImport(string entryStartsWith, string importTask, AyaType importerType, Guid jobId,
+ private async Task DoImport(string entryStartsWith, string importTask, AyaType importerType, Guid jobId,
List importMap, string importFileName, List zipEntries, Dictionary> tagLists)
{
var zipObjectList = zipEntries.Where(m => m.StartsWith(entryStartsWith)).ToList();
diff --git a/server/AyaNova/util/AySchema.cs b/server/AyaNova/util/AySchema.cs
index fc6d7134..1fd612d8 100644
--- a/server/AyaNova/util/AySchema.cs
+++ b/server/AyaNova/util/AySchema.cs
@@ -307,6 +307,8 @@ namespace AyaNova.Util
}
+ //#########################################
+ //!!!!WARNING: BE SURE TO UPDATE THE DbUtil::EmptyBizDataFromDatabaseForSeedingOrImporting WHEN NEW TABLES ADDED!!!!
//////////////////////////////////////////////////
// FUTURE
@@ -318,7 +320,7 @@ namespace AyaNova.Util
// }
- //!!!!WARNING: BE SURE TO UPDATE THE DbUtil::PrepareDatabaseForSeeding WHEN NEW TABLES ADDED!!!!
+
diff --git a/server/AyaNova/util/DbUtil.cs b/server/AyaNova/util/DbUtil.cs
index c67313f0..a745a313 100644
--- a/server/AyaNova/util/DbUtil.cs
+++ b/server/AyaNova/util/DbUtil.cs
@@ -251,8 +251,10 @@ namespace AyaNova.Util
// Erase all user entered data from the db
// This is called by seeder for trial seeding purposes
//
- internal static void PrepareDatabaseForSeeding(ILogger _log)
+ internal static void EmptyBizDataFromDatabaseForSeedingOrImporting(ILogger _log)
{
+
+
_log.LogInformation("Erasing Database \"{0}\"", _dbName);
AyaNova.Api.ControllerHelpers.ApiServerState apiServerState = (AyaNova.Api.ControllerHelpers.ApiServerState)ServiceProviderProvider.Provider.GetService(typeof(AyaNova.Api.ControllerHelpers.ApiServerState));
@@ -265,6 +267,15 @@ namespace AyaNova.Util
{
conn.Open();
+ //Delete from user options table first
+ using (var cmd = new Npgsql.NpgsqlCommand())
+ {
+ cmd.Connection = conn;
+ cmd.CommandText = "delete from \"auseroptions\" where UserId <> 1;";
+ cmd.ExecuteNonQuery();
+ }
+
+ //Delete from users table
using (var cmd = new Npgsql.NpgsqlCommand())
{
cmd.Connection = conn;
@@ -272,14 +283,14 @@ namespace AyaNova.Util
cmd.ExecuteNonQuery();
}
- //THIS METHOD IS ONLY CALLED BY SEEDER
- //SO ONLY REMOVE DATA THAT IS SEEDED
- //I.E. Normal user business data, not infrastructure data like license or localized text etc
-
+ //REMOVE ALL DATA with few exceptions of manager user, license, schema tables
+ //and job logs because this is called by job code
EraseTable("afileattachment", conn);
EraseTable("awidget", conn);
EraseTable("aevent", conn);
EraseTable("adatafilter", conn);
+ EraseTable("asearchkey", conn);
+ EraseTable("asearchdictionary", conn);
conn.Close();
}
@@ -309,7 +320,7 @@ namespace AyaNova.Util
///////////////////////////////////////////
// Check if DB is empty
// CALLED BY LICENSE CONTROLLER AND LICENSE.CS FOR TRIAL Request check
- //
+ // Also called by Import
internal static bool DBIsEmpty(AyContext ctx, ILogger _log)
{
//TODO: This needs to be way more thorough, only the main tables though, no need to get crazy with it
diff --git a/server/AyaNova/util/Seeder.cs b/server/AyaNova/util/Seeder.cs
index 7cdfc856..100fcda6 100644
--- a/server/AyaNova/util/Seeder.cs
+++ b/server/AyaNova/util/Seeder.cs
@@ -66,7 +66,7 @@ namespace AyaNova.Util
apiServerState.SetOpsOnly("Seeding database");
//Erase all the data except for the license, schema and the manager user
- DbUtil.PrepareDatabaseForSeeding(log);
+ DbUtil.EmptyBizDataFromDatabaseForSeedingOrImporting(log);
//Set the time zone of the manager account
{