This commit is contained in:
@@ -295,7 +295,7 @@ namespace AyaNova.PlugIn.V8
|
|||||||
progress.Op("Exporting Business objects");
|
progress.Op("Exporting Business objects");
|
||||||
//BIZ objects
|
//BIZ objects
|
||||||
await ExportLocales(progress);
|
await ExportLocales(progress);
|
||||||
await ExportUsers(progress);
|
await ExportStaffUsers(progress);
|
||||||
await ExportClients(progress);
|
await ExportClients(progress);
|
||||||
await ExportHeadOffices(progress);
|
await ExportHeadOffices(progress);
|
||||||
await ExportContracts(progress);
|
await ExportContracts(progress);
|
||||||
@@ -306,6 +306,7 @@ namespace AyaNova.PlugIn.V8
|
|||||||
await ExportUnits(progress);
|
await ExportUnits(progress);
|
||||||
await ExportUnitModels(progress);
|
await ExportUnitModels(progress);
|
||||||
await ExportVendors(progress);
|
await ExportVendors(progress);
|
||||||
|
await ExportExternalUsers(progress);//needs vendors, clients and headoffices already exported so needs to be here late
|
||||||
await ExportServiceWorkorders(progress);
|
await ExportServiceWorkorders(progress);
|
||||||
//todo: these are now invalid and awaiting RAVEN end implementation
|
//todo: these are now invalid and awaiting RAVEN end implementation
|
||||||
//after which can copy mostly from service workorder block
|
//after which can copy mostly from service workorder block
|
||||||
@@ -375,10 +376,11 @@ namespace AyaNova.PlugIn.V8
|
|||||||
}
|
}
|
||||||
|
|
||||||
#region users
|
#region users
|
||||||
private async System.Threading.Tasks.Task ExportUsers(ProgressForm progress)
|
|
||||||
|
private async System.Threading.Tasks.Task ExportStaffUsers(ProgressForm progress)
|
||||||
{
|
{
|
||||||
if (!progress.KeepGoing) return;
|
if (!progress.KeepGoing) return;
|
||||||
progress.Op("Start User export");
|
progress.Op("Start internal (staff) User export");
|
||||||
progress.SubOp("");
|
progress.SubOp("");
|
||||||
ResetUniqueNames();
|
ResetUniqueNames();
|
||||||
|
|
||||||
@@ -437,6 +439,8 @@ namespace AyaNova.PlugIn.V8
|
|||||||
foreach (UserPickList.UserPickListInfo i in pl)
|
foreach (UserPickList.UserPickListInfo i in pl)
|
||||||
{
|
{
|
||||||
if (!progress.KeepGoing) return;
|
if (!progress.KeepGoing) return;
|
||||||
|
|
||||||
|
|
||||||
List<string> tags = new List<string>();
|
List<string> tags = new List<string>();
|
||||||
tags.Add(ImportTag);
|
tags.Add(ImportTag);
|
||||||
|
|
||||||
@@ -446,6 +450,168 @@ namespace AyaNova.PlugIn.V8
|
|||||||
|
|
||||||
User c = User.GetItem(i.ID);
|
User c = User.GetItem(i.ID);
|
||||||
|
|
||||||
|
//skip any external users
|
||||||
|
if (i.Type == UserTypes.Client || i.Type == UserTypes.HeadOffice || c.VendorID != Guid.Empty)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var ObjectTID = new TypeAndID(RootObjectTypes.User, c.ID);
|
||||||
|
|
||||||
|
dynamic d = new JObject();
|
||||||
|
d.name = GetUniqueName(c.FirstName + " " + c.LastName);
|
||||||
|
if (IsDuplicateMapItem(c.ID, c.FirstName + " " + c.LastName, progress)) continue;
|
||||||
|
progress.Op("User " + d.name);
|
||||||
|
//throw new System.Exception("TODO: UserTypes sb done differently now to align");
|
||||||
|
//TODO: User type
|
||||||
|
//d.userType = (int)c.UserType;
|
||||||
|
|
||||||
|
//todo: this needs to be adjusted later
|
||||||
|
//after vendor, customer and headoffice objects are all exported
|
||||||
|
//then loop through all users again here and set them accordingly if required
|
||||||
|
|
||||||
|
//RAVEN user types are different numbers so even the regular ones need to be set alternatively
|
||||||
|
switch (c.UserType)
|
||||||
|
{
|
||||||
|
case UserTypes.Administrator:
|
||||||
|
d.userType = 2;
|
||||||
|
break;
|
||||||
|
case UserTypes.NonSchedulable:
|
||||||
|
d.userType = 2;
|
||||||
|
break;
|
||||||
|
case UserTypes.Schedulable:
|
||||||
|
d.userType = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
d.active = false;//all imported users are inactive to start
|
||||||
|
d.roles = 0;//todo: try to determine role from v7 member of group? or is that even possible?
|
||||||
|
d.login = util.RandomString();
|
||||||
|
d.password = util.RandomString();
|
||||||
|
|
||||||
|
d.employeeNumber = c.EmployeeNumber;
|
||||||
|
d.notes = c.Notes;
|
||||||
|
Tagit(c.RegionID, tags);
|
||||||
|
Tagit(c.DispatchZoneID, tags);
|
||||||
|
foreach (UserSkillAssigned skill in c.UserSkills)
|
||||||
|
{
|
||||||
|
Tagit(skill.UserSkillID, tags);
|
||||||
|
}
|
||||||
|
foreach (UserCertificationAssigned cert in c.UserCertifications)
|
||||||
|
{
|
||||||
|
Tagit(cert.UserCertificationID, tags);
|
||||||
|
}
|
||||||
|
SetTags(d, tags);
|
||||||
|
|
||||||
|
//Custom fields?
|
||||||
|
if (ShouldExportCustom)
|
||||||
|
d.customFields = CustomFieldData(c, DateCustomFields);
|
||||||
|
|
||||||
|
var rMainObject = await util.PostAsync("user", d.ToString());
|
||||||
|
long RavenId = util.IdFromResponse(rMainObject);
|
||||||
|
AddMap(c.ID, RavenId);
|
||||||
|
|
||||||
|
//USER OPTIONS
|
||||||
|
if (c.ScheduleBackColor != 0 || !string.IsNullOrWhiteSpace(c.EmailAddress))
|
||||||
|
{
|
||||||
|
var rOptions = await util.GetAsync("user-option/" + RavenId.ToString());
|
||||||
|
d = rOptions.ObjectResponse["data"];
|
||||||
|
d.uiColor = System.Drawing.ColorTranslator.ToHtml(System.Drawing.Color.FromArgb(c.ScheduleBackColor));
|
||||||
|
d.emailAddress = string.IsNullOrWhiteSpace(c.EmailAddress) ? null : c.EmailAddress;
|
||||||
|
if (LocaleMap.ContainsKey(c.DefaultLanguage))
|
||||||
|
d.translationId = LocaleMap[c.DefaultLanguage];
|
||||||
|
else
|
||||||
|
d.translationId = 1;
|
||||||
|
|
||||||
|
await util.PutAsync("user-option/" + RavenId.ToString(), d.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
//Attachments / FILES
|
||||||
|
await ExportAttachments(ObjectTID, progress);
|
||||||
|
|
||||||
|
//-----
|
||||||
|
bool repost = false;
|
||||||
|
d = rMainObject.ObjectResponse["data"];
|
||||||
|
// wiki
|
||||||
|
if (WikiPage.HasWiki(c.ID))
|
||||||
|
{
|
||||||
|
// await ExportAttachments(ObjectTID, progress);
|
||||||
|
d.wiki = GetWikiContent(ObjectTID);
|
||||||
|
repost = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//docs
|
||||||
|
string NonFileUrls = await ExportDocs(ObjectTID, c.Docs, progress);
|
||||||
|
if (!string.IsNullOrEmpty(NonFileUrls))
|
||||||
|
{
|
||||||
|
//need to repost the user with the notes modified
|
||||||
|
|
||||||
|
d.login = null;
|
||||||
|
d.password = null;
|
||||||
|
d.notes = NonFileUrls + "\n-----------------\n" + d.notes;
|
||||||
|
repost = true;
|
||||||
|
}
|
||||||
|
if (repost)
|
||||||
|
await util.PutAsync("user", d.ToString());
|
||||||
|
//-----
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//## NOT ALL USERS YET, SO ONLY CALL THIS WHEN THE EXTERNAL USERS LATER ARE EXPORTED
|
||||||
|
////EVENT LOG
|
||||||
|
////Because this is the User's we need to do the event log *after* they have all been posted as event log requires all user's id
|
||||||
|
//foreach (UserPickList.UserPickListInfo i in pl)
|
||||||
|
//{
|
||||||
|
// if (!progress.KeepGoing) return;
|
||||||
|
// User c = User.GetItem(i.ID);
|
||||||
|
// var newId = Map[c.ID];
|
||||||
|
// var creator = SafeGetUserMap(c.Creator);
|
||||||
|
// var modifier = SafeGetUserMap(c.Modifier);
|
||||||
|
|
||||||
|
// await util.EventLog(util.AyaType.User, newId, creator, modifier, c.Created, c.Modified);
|
||||||
|
//}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private async System.Threading.Tasks.Task ExportExternalUsers(ProgressForm progress)
|
||||||
|
{
|
||||||
|
if (!progress.KeepGoing) return;
|
||||||
|
progress.Op("Start external User export");
|
||||||
|
progress.SubOp("");
|
||||||
|
ResetUniqueNames();
|
||||||
|
|
||||||
|
//Step 1: export the CustomFields to FormCustom if applicable so that when doing individual items we can export their custom data too
|
||||||
|
var ocf = ObjectHasCustomFieldDataToExport("User");
|
||||||
|
bool ShouldExportCustom = ocf != null;
|
||||||
|
|
||||||
|
var DateCustomFields = await ExportCustomFieldSchema(ocf, "User", "User");
|
||||||
|
|
||||||
|
//Step 2: export the objects
|
||||||
|
|
||||||
|
UserPickList pl = UserPickList.GetList(false);
|
||||||
|
progress.Append("Exporting " + pl.Count.ToString() + " Users");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
foreach (UserPickList.UserPickListInfo i in pl)
|
||||||
|
{
|
||||||
|
if (!progress.KeepGoing) return;
|
||||||
|
|
||||||
|
|
||||||
|
List<string> tags = new List<string>();
|
||||||
|
tags.Add(ImportTag);
|
||||||
|
|
||||||
|
//skip administrator user fields
|
||||||
|
//but do export administrator
|
||||||
|
if (i.ID == User.AdministratorID) continue;
|
||||||
|
|
||||||
|
User c = User.GetItem(i.ID);
|
||||||
|
|
||||||
|
//skip any internal or non subcontractor Users
|
||||||
|
if (c.VendorID == Guid.Empty && (i.Type == UserTypes.Administrator || i.Type == UserTypes.NonSchedulable
|
||||||
|
|| i.Type == UserTypes.Schedulable || i.Type == UserTypes.Utility))
|
||||||
|
continue;
|
||||||
|
|
||||||
var ObjectTID = new TypeAndID(RootObjectTypes.User, c.ID);
|
var ObjectTID = new TypeAndID(RootObjectTypes.User, c.ID);
|
||||||
|
|
||||||
@@ -483,6 +649,17 @@ namespace AyaNova.PlugIn.V8
|
|||||||
if (c.VendorID != Guid.Empty)
|
if (c.VendorID != Guid.Empty)
|
||||||
{
|
{
|
||||||
d.userType = 2;
|
d.userType = 2;
|
||||||
|
d.vendorId = Map[c.VendorID];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c.ClientID != Guid.Empty)
|
||||||
|
{
|
||||||
|
d.customerId = Map[c.ClientID];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c.HeadOfficeID != Guid.Empty)
|
||||||
|
{
|
||||||
|
d.headOfficeId = Map[c.HeadOfficeID];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -574,6 +751,8 @@ namespace AyaNova.PlugIn.V8
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endregion users
|
#endregion users
|
||||||
|
|
||||||
#region Clients
|
#region Clients
|
||||||
|
|||||||
Reference in New Issue
Block a user