This commit is contained in:
2020-05-02 23:38:49 +00:00
parent 5c567b69e2
commit 0f38277890

View File

@@ -255,7 +255,7 @@ namespace AyaNova.PlugIn.V8
await ExportUsers(progress);
await ExportClients(progress);
await ExportHeadOffices(progress);
//await ExportContracts(progress);
await ExportContracts(progress);
//await ExportLoanUnits(progress);
//await ExportParts(progress);
//await ExportProjects(progress);
@@ -481,7 +481,7 @@ namespace AyaNova.PlugIn.V8
}
#endregion users
#region clients
#region Clients
private async System.Threading.Tasks.Task ExportClients(ProgressForm progress)
{
if (!progress.KeepGoing) return;
@@ -547,7 +547,7 @@ namespace AyaNova.PlugIn.V8
}
}
#endregion clients
#endregion Clients
#region Headoffices
private async System.Threading.Tasks.Task ExportHeadOffices(ProgressForm progress)
@@ -561,9 +561,7 @@ namespace AyaNova.PlugIn.V8
//Step 2: export the objects
PickListAutoComplete pl = PickListAutoComplete.GetList("**", "headoffice");
progress.Append("Exporting " + pl.Count.ToString() + ObjectTypeName + "s");
foreach (PickListAutoComplete.PickListAutoCompleteInfo i in pl )
@@ -619,6 +617,71 @@ namespace AyaNova.PlugIn.V8
}
#endregion ho
#region Contracts
private async System.Threading.Tasks.Task ExportContracts(ProgressForm progress)
{
if (!progress.KeepGoing) return;
var ObjectTypeName = "Contract";
//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(ObjectTypeName);
bool ShouldExportCustom = ocf != null;
var DateCustomFields = await ExportCustomFieldSchema(ocf, ObjectTypeName, ObjectTypeName);
//Step 2: export the objects
PickListAutoComplete pl = PickListAutoComplete.GetList("**", "contract");
progress.Append("Exporting " + pl.Count.ToString() + ObjectTypeName + "s");
foreach (PickListAutoComplete.PickListAutoCompleteInfo i in pl)
{
if (!progress.KeepGoing) return;
List<string> tags = new List<string>();
tags.Add(ImportTag);
Contract c = Contract.GetItem(i.ID);
var ObjectTID = new TypeAndID(RootObjectTypes.Contract, c.ID);
dynamic d = new JObject();
d.name = c.Name;
progress.Op(ObjectTypeName + " " + d.name);
d.active = c.Active;
d.notes = c.Notes;
Tagit(c.RegionID, tags);
SetTags(d, tags);
var hasWiki = WikiPage.HasWiki(c.ID);
if (hasWiki)
{
d.wiki = GetWikiContent(ObjectTID);
}
//Custom fields?
if (ShouldExportCustom)
d.customFields = CustomFieldData(c, DateCustomFields);
var rMainObject = await util.PostAsync(ObjectTypeName, d.ToString());
long RavenId = util.IdFromResponse(rMainObject);
Map.Add(c.ID, RavenId);
//Attachments / FILES
await ExportAttachments(ObjectTID, progress);
//docs
string NonFileUrls = await ExportDocs(ObjectTID, c.Docs, progress);
if (!string.IsNullOrEmpty(NonFileUrls))
{
//need to repost the object with the notes modified
d = rMainObject.ObjectResponse["data"];
d.notes = NonFileUrls + "\n-----------------\n" + d.notes;
await util.PutAsync(ObjectTypeName+"/" + RavenId.ToString(), d.ToString());
}
//Event log fixup
await util.EventLog(util.AyaType.Contract, RavenId, SafeGetUserMap(c.Creator), SafeGetUserMap(c.Modifier), c.Created, c.Modified);
}
}
#endregion Contracts
#region locales
private async System.Threading.Tasks.Task ExportLocales(ProgressForm progress)