From 0b8a3a9724c4d9eb91635861dc4efbe5c9dd5262 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Sun, 26 Apr 2020 20:36:50 +0000 Subject: [PATCH] --- source/Plugins/AyaNova.Plugin.Dump/Dump.cs | 32 +++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/source/Plugins/AyaNova.Plugin.Dump/Dump.cs b/source/Plugins/AyaNova.Plugin.Dump/Dump.cs index c7a739d..111ee04 100644 --- a/source/Plugins/AyaNova.Plugin.Dump/Dump.cs +++ b/source/Plugins/AyaNova.Plugin.Dump/Dump.cs @@ -606,6 +606,7 @@ namespace AyaNova.Plugin.Dump private void DumpWikiPageAndAttachments(TypeAndID tid, string wikiOutputPath) { + //may not exist if (!WikiPage.HasWiki(tid.ID)) return; @@ -622,9 +623,38 @@ namespace AyaNova.Plugin.Dump //write out the html wiki page File.WriteAllText(wikiOutputPath + Path.DirectorySeparatorChar + "w.html", content); } + + //files + List fileNamesUsed = new List(); foreach (WikiPage.WikiFileInfo i in fileList) { - //save out each file to that path with a uniquification prepended + //save each file plus file info into their own folder by ayafile id this is because ayafiles can be dupe names and we need the wiki info to fixup the last created date etc + var filePath = wikiOutputPath + Path.DirectorySeparatorChar + i.Id.ToString(); + makeFolderIfNotExist(filePath);//output/objectype/client.f861ec01-8bde-46e1-9849-fcee9b42f05e/files/d5461ec01-8bde-46e1-9849-fcee9b42f0ff34/ + + var af=AyaFile.GetItem(new Guid(i.Id)); + if (af == null) continue; + af.WriteToDisk(filePath, af.Name); + + var fileInfo = new { name = i.Name, created=i.Created, creator=i.Creator, mimetype=af.mimeType, id=i.Id, size=i.Size,ayafiletype=af.FileType, rootobjectid=af.RootObjectID, rootobjecttype=af.RootObjectType }; + + JsonSerializer serializer = new JsonSerializer(); + serializer.NullValueHandling = NullValueHandling.Include; + +#if(DEBUG) + serializer.Formatting = Formatting.Indented; +#endif + JObject jo = JObject.FromObject(fileInfo, serializer); + + + + using (StreamWriter sw = new StreamWriter(filePath+Path.DirectorySeparatorChar+".json")) + using (JsonWriter writer = new JsonTextWriter(sw)) + { + + // serializer.Serialize(writer, o); + serializer.Serialize(writer, jo); + } } }