This commit is contained in:
@@ -156,58 +156,66 @@ namespace AyaNova.PlugIn.V8
|
||||
/// then zip it all up into a single archive file and then erase the temporary folder
|
||||
/// </summary>
|
||||
private async void DoExport()
|
||||
{
|
||||
Map.Clear();
|
||||
|
||||
/*
|
||||
TODO:
|
||||
* EMPTY DB ROUTE
|
||||
* custom fields processor for: User, Client, Contract, HeadOffice, LoanItem, part, project, purchaseorder, unit, unitmodel, vendor, workorderitem
|
||||
|
||||
|
||||
*/
|
||||
|
||||
{
|
||||
//Show progress form
|
||||
|
||||
ProgressForm progress = new ProgressForm();
|
||||
progress.Show();
|
||||
progress.StartedImport();
|
||||
progress.Append("Exporting data to AyaNova server @ " + util.ApiBaseUrl);
|
||||
try
|
||||
{
|
||||
Map.Clear();
|
||||
|
||||
/*
|
||||
TODO:
|
||||
* EMPTY DB ROUTE
|
||||
* custom fields processor for: User, Client, Contract, HeadOffice, LoanItem, part, project, purchaseorder, unit, unitmodel, vendor, workorderitem
|
||||
|
||||
|
||||
*/
|
||||
|
||||
|
||||
//Export in correct order:
|
||||
|
||||
//ERASE DB
|
||||
var a = await util.PostAsync("License/PermanentlyEraseAllData", "I understand");
|
||||
if (!a.HttpResponse.IsSuccessStatusCode) { MessageBox.Show("Error erasing database: \n" + a.HttpResponse.ReasonPhrase); return;}
|
||||
|
||||
//TAGS
|
||||
ExportUnitModelCategories(progress);
|
||||
ExportUnitServiceTypes(progress);
|
||||
ExportWorkorderItemTypes(progress);
|
||||
ExportRegions(progress);
|
||||
ExportClientGroups(progress);
|
||||
ExportWorkorderCategories(progress);
|
||||
ExportPartCategories(progress);
|
||||
ExportScheduleableUserGroups(progress);
|
||||
ExportDispatchZones(progress);
|
||||
|
||||
//BIZ objects
|
||||
ExportUsers(progress);
|
||||
|
||||
//dumpGlobalSettings(tempArchiveFolder, progress);
|
||||
//dumpLocales(tempArchiveFolder, progress);
|
||||
|
||||
//dumpSeedNumbers(tempArchiveFolder, progress);
|
||||
//dumpClients(tempArchiveFolder, progress);
|
||||
//dumpHeadOffices(tempArchiveFolder, progress);
|
||||
//
|
||||
|
||||
|
||||
//NOTE: when get to PRIORITY, or WORKORDER STATUS be sure to add color code as per already done in USER export
|
||||
//Export in correct order:
|
||||
|
||||
//ERASE DB
|
||||
var a = await util.PostAsync("License/PermanentlyEraseAllData", "\"I understand\"");
|
||||
if (!a.HttpResponse.IsSuccessStatusCode) { MessageBox.Show("Error erasing database: \n" + a.HttpResponse.ReasonPhrase); return; }
|
||||
|
||||
//TAGS
|
||||
ExportUnitModelCategories(progress);
|
||||
ExportUnitServiceTypes(progress);
|
||||
ExportWorkorderItemTypes(progress);
|
||||
ExportRegions(progress);
|
||||
ExportClientGroups(progress);
|
||||
ExportWorkorderCategories(progress);
|
||||
ExportPartCategories(progress);
|
||||
ExportScheduleableUserGroups(progress);
|
||||
ExportDispatchZones(progress);
|
||||
|
||||
//BIZ objects
|
||||
ExportUsers(progress);
|
||||
|
||||
//dumpGlobalSettings(tempArchiveFolder, progress);
|
||||
//dumpLocales(tempArchiveFolder, progress);
|
||||
|
||||
//dumpSeedNumbers(tempArchiveFolder, progress);
|
||||
//dumpClients(tempArchiveFolder, progress);
|
||||
//dumpHeadOffices(tempArchiveFolder, progress);
|
||||
//
|
||||
|
||||
|
||||
progress.Append("Export completed");
|
||||
//NOTE: when get to PRIORITY, or WORKORDER STATUS be sure to add color code as per already done in USER export
|
||||
|
||||
|
||||
progress.Append("Export completed");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
progress.Append("Export failed with error:");
|
||||
progress.Append(ex.Message);
|
||||
}
|
||||
progress.FinishedImport();
|
||||
|
||||
//-----------------------------------
|
||||
@@ -222,7 +230,7 @@ namespace AyaNova.PlugIn.V8
|
||||
#region Global settings
|
||||
private void ExportGlobalSettings(ProgressForm progress)
|
||||
{
|
||||
|
||||
|
||||
progress.Append("STUB: Dumping Global Settings");
|
||||
////DumpObjectToFolder(tempArchiveFolder, AyaBizUtils.GlobalSettings, "globalsettings", objectExcludeProperties, new TypeAndID(RootObjectTypes.Global, Address.GlobalAddressID));
|
||||
}
|
||||
@@ -231,7 +239,7 @@ namespace AyaNova.PlugIn.V8
|
||||
#region locales
|
||||
private void ExportLocales(ProgressForm progress)
|
||||
{
|
||||
// List<string> objectExcludeProperties = new List<string>(standardExcludePropertiesList);
|
||||
// List<string> objectExcludeProperties = new List<string>(standardExcludePropertiesList);
|
||||
|
||||
//Skip stock locales already handled in Raven
|
||||
List<string> SkipLocales = new List<string>();
|
||||
@@ -256,8 +264,8 @@ namespace AyaNova.PlugIn.V8
|
||||
#region REGIONS
|
||||
private void ExportRegions(ProgressForm progress)
|
||||
{
|
||||
// List<string> objectExcludeProperties = new List<string>(standardExcludePropertiesList);
|
||||
|
||||
// List<string> objectExcludeProperties = new List<string>(standardExcludePropertiesList);
|
||||
|
||||
RegionList l = RegionList.GetList(string.Empty);
|
||||
progress.Append("Dumping " + l.Count.ToString() + " Regions");
|
||||
foreach (RegionList.RegionListInfo i in l)
|
||||
@@ -281,7 +289,7 @@ namespace AyaNova.PlugIn.V8
|
||||
}
|
||||
private void ExportSeedNumbers(ProgressForm progress)
|
||||
{
|
||||
// List<string> objectExcludeProperties = new List<string>(standardExcludePropertiesList);
|
||||
// List<string> objectExcludeProperties = new List<string>(standardExcludePropertiesList);
|
||||
progress.Append("Dumping seeds");
|
||||
//create a new object with the id numbers in it and then dump it
|
||||
WorkorderPMList pml = WorkorderPMList.GetList("<?xml version=\"1.0\" encoding=\"utf-16\" standalone=\"yes\"?> \r\n" +
|
||||
@@ -323,7 +331,7 @@ namespace AyaNova.PlugIn.V8
|
||||
#region headoffices
|
||||
private void ExportHeadOffices(ProgressForm progress)
|
||||
{
|
||||
|
||||
|
||||
PickListAutoComplete pl = PickListAutoComplete.GetList("**", "headoffice");
|
||||
|
||||
progress.Append("Dumping " + pl.Count.ToString() + " Head offices");
|
||||
@@ -369,21 +377,21 @@ namespace AyaNova.PlugIn.V8
|
||||
User c = User.GetItem(i.ID);
|
||||
dynamic d = new JObject();
|
||||
d.name = c.FirstName + " " + c.LastName;
|
||||
|
||||
|
||||
d.userType = (int)c.UserType;
|
||||
if (c.VendorID != Guid.Empty)
|
||||
d.userType = 7;//7 is the RAVEN user type for subcontractor
|
||||
|
||||
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.roles = 0;//todo: try to determine role from v7 member of group? or is that even possible?
|
||||
|
||||
d.employeeNumber = c.EmployeeNumber;
|
||||
d.notes = c.Notes;
|
||||
Tagit(c.RegionID,tags);
|
||||
Tagit(c.RegionID, tags);
|
||||
Tagit(c.DispatchZoneID, tags);
|
||||
SetTags(d, tags);
|
||||
|
||||
var a=await util.PostAsync("User", d.ToString());
|
||||
var a = await util.PostAsync("User", d.ToString());
|
||||
|
||||
|
||||
//JObject xtra = new JObject();
|
||||
@@ -652,13 +660,13 @@ namespace AyaNova.PlugIn.V8
|
||||
}
|
||||
|
||||
|
||||
private void SetTags(dynamic d, List<string> tags)
|
||||
{
|
||||
dynamic dtags= new JArray();
|
||||
foreach(string s in tags)
|
||||
dtags.Add(s);
|
||||
d.tags=dtags;
|
||||
}
|
||||
private void SetTags(dynamic d, List<string> tags)
|
||||
{
|
||||
dynamic dtags = new JArray();
|
||||
foreach (string s in tags)
|
||||
dtags.Add(s);
|
||||
d.tags = dtags;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -150,6 +150,10 @@ namespace AyaNova.PlugIn.V8
|
||||
|
||||
HttpResponseMessage response = await client.SendAsync(requestMessage);
|
||||
var responseAsString = await response.Content.ReadAsStringAsync();
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
throw new Exception(responseAsString + "\n" + response.ReasonPhrase);
|
||||
}
|
||||
|
||||
return new ApiResponse() { HttpResponse = response, ObjectResponse = Parse(responseAsString) };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user