This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
@@ -183,10 +184,8 @@ namespace AyaNova.PlugIn.V8
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
TODO:
|
TODO:
|
||||||
* Current operation progress feedback
|
|
||||||
*
|
*
|
||||||
* wiki / attached docs
|
* wiki / attached docs
|
||||||
*
|
|
||||||
* locales
|
* locales
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
@@ -281,32 +280,40 @@ namespace AyaNova.PlugIn.V8
|
|||||||
progress.Append("Exporting " + pl.Count.ToString() + " Users");
|
progress.Append("Exporting " + pl.Count.ToString() + " Users");
|
||||||
|
|
||||||
#region Export administrator wiki and attached files if present
|
#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
|
#endregion admin export
|
||||||
|
|
||||||
|
|
||||||
@@ -362,20 +369,18 @@ namespace AyaNova.PlugIn.V8
|
|||||||
}
|
}
|
||||||
SetTags(d, tags);
|
SetTags(d, tags);
|
||||||
|
|
||||||
//wiki page
|
//Attachments and wiki
|
||||||
var w = GetWikiContent(new TypeAndID(RootObjectTypes.User, c.ID));
|
var hasWiki = WikiPage.HasWiki(c.ID);
|
||||||
if (w != null)
|
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?
|
//Custom fields?
|
||||||
if (ShouldExportCustom)
|
if (ShouldExportCustom)
|
||||||
{
|
|
||||||
d.customFields = CustomFieldData(c, DateCustomFields);
|
d.customFields = CustomFieldData(c, DateCustomFields);
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
var a = await util.PostAsync("User", d.ToString());
|
var a = await util.PostAsync("User", d.ToString());
|
||||||
long RavenId = util.IdFromResponse(a);
|
long RavenId = util.IdFromResponse(a);
|
||||||
Map.Add(c.ID, RavenId);
|
Map.Add(c.ID, RavenId);
|
||||||
@@ -737,12 +742,20 @@ namespace AyaNova.PlugIn.V8
|
|||||||
private string GetWikiContent(TypeAndID tid)
|
private string GetWikiContent(TypeAndID tid)
|
||||||
{
|
{
|
||||||
//may not exist
|
//may not exist
|
||||||
if (!WikiPage.HasWiki(tid.ID)) return null;
|
// if (!WikiPage.HasWiki(tid.ID)) return null;
|
||||||
|
|
||||||
WikiPage w = WikiPage.GetItem(tid);
|
WikiPage w = WikiPage.GetItem(tid);
|
||||||
var content = w.GetContentAsString;
|
var content = w.GetContentAsString;
|
||||||
|
|
||||||
//TODO: fixup internal urls using MAP of file attachment uploads
|
//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
|
//TODO: Convert to Markdown format
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(content))
|
if (!string.IsNullOrWhiteSpace(content))
|
||||||
|
|||||||
Reference in New Issue
Block a user