This commit is contained in:
2020-05-03 14:10:16 +00:00
parent 350d98f982
commit fb1f8d32b4

View File

@@ -816,6 +816,73 @@ namespace AyaNova.PlugIn.V8
#endregion Parts
#region Projects
private async System.Threading.Tasks.Task ExportProjects(ProgressForm progress)
{
if (!progress.KeepGoing) return;
var ObjectTypeName = "Project";
//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("**", "project");
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);
Project c = Project.GetItem(i.ID);
var ObjectTID = new TypeAndID(RootObjectTypes.Project, 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.Project, RavenId, SafeGetUserMap(c.Creator), SafeGetUserMap(c.Modifier), c.Created, c.Modified);
}
}
#endregion Projects
#region locales
private async System.Threading.Tasks.Task ExportLocales(ProgressForm progress)
{