This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
using System.Reflection;
|
||||
@@ -183,10 +184,8 @@ namespace AyaNova.PlugIn.V8
|
||||
|
||||
/*
|
||||
TODO:
|
||||
* Current operation progress feedback
|
||||
*
|
||||
* wiki / attached docs
|
||||
*
|
||||
* locales
|
||||
*
|
||||
*
|
||||
@@ -281,32 +280,40 @@ namespace AyaNova.PlugIn.V8
|
||||
progress.Append("Exporting " + pl.Count.ToString() + " Users");
|
||||
|
||||
#region Export administrator wiki and attached files if present
|
||||
User admin = User.GetItem(User.AdministratorID);
|
||||
progress.Op("Administrator account");
|
||||
|
||||
//wiki page
|
||||
var adminWiki = GetWikiContent(new TypeAndID(RootObjectTypes.User, admin.ID));
|
||||
string adminCustomFields = null;
|
||||
//Custom fields?
|
||||
if (ShouldExportCustom)
|
||||
{
|
||||
adminCustomFields = CustomFieldData(admin, DateCustomFields);
|
||||
User admin = User.GetItem(User.AdministratorID);
|
||||
progress.Op("Administrator account");
|
||||
|
||||
//Attachments and wiki
|
||||
string AdminWikiContent = null;
|
||||
var hasWiki = WikiPage.HasWiki(User.AdministratorID);
|
||||
if (hasWiki)
|
||||
{
|
||||
await ExportAttachments(new TypeAndID(RootObjectTypes.User, User.AdministratorID), progress);
|
||||
AdminWikiContent = GetWikiContent(new TypeAndID(RootObjectTypes.User, admin.ID));
|
||||
}
|
||||
|
||||
|
||||
|
||||
string adminCustomFields = null;
|
||||
//Custom fields?
|
||||
if (ShouldExportCustom)
|
||||
{
|
||||
adminCustomFields = CustomFieldData(admin, DateCustomFields);
|
||||
}
|
||||
|
||||
//check if we need to do anything with the manager account
|
||||
if (hasWiki || adminCustomFields != null)
|
||||
{
|
||||
//yes, so fetch it and modify it and put it back again
|
||||
var a = await util.GetAsync("User/1");
|
||||
dynamic d = a.ObjectResponse["data"];
|
||||
d.wiki = AdminWikiContent;
|
||||
d.customFields = CustomFieldData(admin, DateCustomFields);
|
||||
await util.PutAsync("User/1", d.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
//check if we need to do anything with the manager account
|
||||
if (adminWiki != null || adminCustomFields != null)
|
||||
{
|
||||
//yes, so fetch it and modify it and put it back again
|
||||
var a = await util.GetAsync("User/1");
|
||||
dynamic d = a.ObjectResponse["data"];
|
||||
d.wiki = adminWiki;
|
||||
d.customFields = CustomFieldData(admin, DateCustomFields);
|
||||
await util.PutAsync("User/1", d.ToString());
|
||||
}
|
||||
|
||||
//Attachments
|
||||
if (adminWiki != null)
|
||||
await ExportAttachments(new TypeAndID(RootObjectTypes.User, User.AdministratorID), progress);
|
||||
#endregion admin export
|
||||
|
||||
|
||||
@@ -362,19 +369,17 @@ namespace AyaNova.PlugIn.V8
|
||||
}
|
||||
SetTags(d, tags);
|
||||
|
||||
//wiki page
|
||||
var w = GetWikiContent(new TypeAndID(RootObjectTypes.User, c.ID));
|
||||
if (w != null)
|
||||
//Attachments and wiki
|
||||
var hasWiki = WikiPage.HasWiki(c.ID);
|
||||
if (hasWiki)
|
||||
{
|
||||
d.wiki = w;
|
||||
await ExportAttachments(new TypeAndID(RootObjectTypes.User, c.ID), progress);
|
||||
d.wiki = GetWikiContent(new TypeAndID(RootObjectTypes.User, c.ID));
|
||||
}
|
||||
|
||||
//Custom fields?
|
||||
if (ShouldExportCustom)
|
||||
{
|
||||
d.customFields = CustomFieldData(c, DateCustomFields);
|
||||
}
|
||||
|
||||
|
||||
var a = await util.PostAsync("User", d.ToString());
|
||||
long RavenId = util.IdFromResponse(a);
|
||||
@@ -737,12 +742,20 @@ namespace AyaNova.PlugIn.V8
|
||||
private string GetWikiContent(TypeAndID tid)
|
||||
{
|
||||
//may not exist
|
||||
if (!WikiPage.HasWiki(tid.ID)) return null;
|
||||
// if (!WikiPage.HasWiki(tid.ID)) return null;
|
||||
|
||||
WikiPage w = WikiPage.GetItem(tid);
|
||||
var content = w.GetContentAsString;
|
||||
|
||||
//TODO: fixup internal urls using MAP of file attachment uploads
|
||||
|
||||
MatchCollection mc = AyaBizUtils.rxAyaImageTags.Matches(content);
|
||||
foreach (Match m in mc)
|
||||
{
|
||||
var RavenId = Map[new Guid(m.Groups["guid"].Value)];
|
||||
content = content.Replace(m.Value, "[ATTACH:" + RavenId.ToString());
|
||||
}
|
||||
|
||||
//TODO: Convert to Markdown format
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(content))
|
||||
|
||||
Reference in New Issue
Block a user