This commit is contained in:
2020-05-02 14:28:36 +00:00
parent a27790308a
commit 3ff4d3d11c
5 changed files with 2418 additions and 3 deletions

View File

@@ -67,6 +67,12 @@
<Compile Include="Auth.Designer.cs">
<DependentUpon>Auth.cs</DependentUpon>
</Compile>
<Compile Include="Opt.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Opt.Designer.cs">
<DependentUpon>Opt.cs</DependentUpon>
</Compile>
<Compile Include="Resource1.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
@@ -128,6 +134,9 @@
<EmbeddedResource Include="Auth.resx">
<DependentUpon>Auth.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Opt.resx">
<DependentUpon>Opt.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="ProgressForm.resx">
<DependentUpon>ProgressForm.cs</DependentUpon>
</EmbeddedResource>

View File

@@ -0,0 +1,97 @@
namespace AyaNova.PlugIn.V8
{
partial class Opt
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Opt));
this.btnCancel = new System.Windows.Forms.Button();
this.btnOk = new System.Windows.Forms.Button();
this.ckExportAssignedDocs = new System.Windows.Forms.CheckBox();
this.SuspendLayout();
//
// btnCancel
//
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnCancel.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.btnCancel.Image = global::AyaNova.PlugIn.V8.Resource1.Cancel24;
this.btnCancel.Location = new System.Drawing.Point(26, 283);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(68, 41);
this.btnCancel.TabIndex = 26;
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
// btnOk
//
this.btnOk.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.btnOk.Image = global::AyaNova.PlugIn.V8.Resource1.OK24;
this.btnOk.Location = new System.Drawing.Point(534, 283);
this.btnOk.Name = "btnOk";
this.btnOk.Size = new System.Drawing.Size(68, 41);
this.btnOk.TabIndex = 3;
this.btnOk.UseVisualStyleBackColor = true;
this.btnOk.Click += new System.EventHandler(this.btnOk_Click);
//
// ckExportAssignedDocs
//
this.ckExportAssignedDocs.AutoSize = true;
this.ckExportAssignedDocs.Checked = true;
this.ckExportAssignedDocs.CheckState = System.Windows.Forms.CheckState.Checked;
this.ckExportAssignedDocs.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.ckExportAssignedDocs.Location = new System.Drawing.Point(26, 61);
this.ckExportAssignedDocs.Name = "ckExportAssignedDocs";
this.ckExportAssignedDocs.Size = new System.Drawing.Size(401, 21);
this.ckExportAssignedDocs.TabIndex = 27;
this.ckExportAssignedDocs.Text = "Export Assigned documents as Attachments where possible";
this.ckExportAssignedDocs.UseVisualStyleBackColor = true;
//
// Opt
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.AutoSize = true;
this.ClientSize = new System.Drawing.Size(614, 353);
this.ControlBox = false;
this.Controls.Add(this.ckExportAssignedDocs);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnOk);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "Opt";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Export options";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button btnOk;
private System.Windows.Forms.Button btnCancel;
private System.Windows.Forms.CheckBox ckExportAssignedDocs;
}
}

View File

@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace AyaNova.PlugIn.V8
{
public partial class Opt : Form
{
public bool ExportAssignedDocs { get { return ckExportAssignedDocs.Checked; } }
public Opt()
{
InitializeComponent();
}
private void btnOk_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.OK;
this.Close();
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.Close();
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -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