This commit is contained in:
@@ -147,6 +147,14 @@ namespace AyaNova.PlugIn.V8
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Opt dOpt = new Opt();
|
||||
var ro = dOpt.ShowDialog();
|
||||
if (ro == DialogResult.Cancel)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ExportAssignedDocs = dOpt.ExportAssignedDocs;
|
||||
//here because we logged in fine and can proceed
|
||||
|
||||
//MessageBox.Show("Login successful! JWT is " + util.JWT);
|
||||
@@ -161,14 +169,14 @@ namespace AyaNova.PlugIn.V8
|
||||
private Dictionary<string, long> LocaleMap = new Dictionary<string, long>();
|
||||
|
||||
private string ImportTag = "v7-import";
|
||||
|
||||
private bool ExportAssignedDocs = false;
|
||||
/// <summary>
|
||||
/// Dump the objects into a temporary directory as a series of JSON files
|
||||
/// then zip it all up into a single archive file and then erase the temporary folder
|
||||
/// </summary>
|
||||
private async void DoExport()
|
||||
{
|
||||
Cursor.Current = Cursors.WaitCursor;
|
||||
|
||||
//Show progress form
|
||||
ProgressForm progress = new ProgressForm();
|
||||
progress.Show();
|
||||
@@ -293,7 +301,7 @@ namespace AyaNova.PlugIn.V8
|
||||
finally
|
||||
{
|
||||
progress.FinishedImport();
|
||||
Cursor.Current = Cursors.Default;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1026,6 +1034,72 @@ namespace AyaNova.PlugIn.V8
|
||||
}
|
||||
#endregion attachments
|
||||
|
||||
|
||||
#region Assigned docs exporter
|
||||
private async System.Threading.Tasks.Task ExportAttachments(TypeAndID tid, AssignedDocs docs, ProgressForm progress)
|
||||
{
|
||||
if (!ExportAssignedDocs) return;
|
||||
|
||||
if (docs.Count == 0) return;
|
||||
|
||||
|
||||
//iterate the files
|
||||
foreach (AssignedDoc doc in docs)
|
||||
{
|
||||
if (!progress.KeepGoing) return;
|
||||
var af = AyaFile.GetItem(i.LT_O_AyaFile.Value);
|
||||
if (af == null) continue;
|
||||
|
||||
progress.SubOp("Wikifile: \"" + af.Name + "\" " + AyaBizUtils.FileSizeDisplay((decimal)af.FileSize));
|
||||
|
||||
//Compile the FileData property
|
||||
var sDate = i.LT_Common_Label_Created.ToString();
|
||||
DateTimeOffset dtLastModified = DateTime.UtcNow;
|
||||
if (sDate != null)
|
||||
{
|
||||
//parse out to UTC date
|
||||
DateTime dt = new DateTime();
|
||||
if (DateTime.TryParse(sDate, out dt))
|
||||
{
|
||||
dtLastModified = dt.ToUniversalTime();
|
||||
}
|
||||
}
|
||||
dynamic dFileData = new JArray();
|
||||
dynamic dFile = new JObject();
|
||||
dFile.name = af.Name;
|
||||
dFile.lastModified = dtLastModified.ToUnixTimeMilliseconds();
|
||||
dFileData.Add(dFile);
|
||||
|
||||
//Upload
|
||||
|
||||
MultipartFormDataContent formDataContent = new MultipartFormDataContent();
|
||||
|
||||
//Form data like the bizobject type and id
|
||||
formDataContent.Add(new StringContent(util.RootObjectToAyaType(tid.RootObjectType).ToString()), name: "AttachToObjectType");
|
||||
formDataContent.Add(new StringContent(Map[tid.ID].ToString()), name: "AttachToObjectId");
|
||||
formDataContent.Add(new StringContent(ImportTag), name: "Notes");
|
||||
formDataContent.Add(new StringContent(dFileData.ToString()), name: "FileData");
|
||||
|
||||
StreamContent AttachmentFile = new StreamContent(af.GetContent());
|
||||
AttachmentFile.Headers.ContentType = new MediaTypeHeaderValue(af.mimeType);
|
||||
AttachmentFile.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data");
|
||||
AttachmentFile.Headers.ContentDisposition.FileName = af.Name;
|
||||
|
||||
AttachmentFile.Headers.ContentDisposition.ModificationDate = dtLastModified;
|
||||
formDataContent.Add(AttachmentFile);
|
||||
|
||||
//Upload
|
||||
var a = await util.PostFormDataAsync("Attachment", formDataContent);
|
||||
//Map it for later processing of wiki
|
||||
var ravenId = a.ObjectResponse["data"][0]["id"].Value<long>();
|
||||
Map.Add(af.ID, ravenId);
|
||||
}
|
||||
|
||||
progress.SubOp("");
|
||||
|
||||
}
|
||||
#endregion assigned docs
|
||||
|
||||
#region WIKI page exporter
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user