3using System.Threading.Tasks;
19 private XmlWriter output;
20 private bool exportCollection =
false;
21 private bool inCollection =
false;
22 private bool inMetaData =
false;
34 bool OnlySelectedCollections, Array SelectedCollections)
35 : base(
FileName,
Created, File, OnlySelectedCollections, SelectedCollections)
43 if (!(this.output is
null))
47 this.output.Dispose();
58 public override async Task<bool>
Start()
60 await this.output.WriteStartDocumentAsync();
70 public override async Task<bool>
End()
72 await this.output.WriteEndElementAsync();
73 await this.output.WriteEndDocumentAsync();
94 await this.output.WriteEndElementAsync();
115 await this.output.WriteEndElementAsync();
126 this.inCollection =
true;
130 await this.output.WriteAttributeStringAsync(
string.Empty,
"name",
string.Empty, CollectionName);
142 this.inCollection =
false;
143 if (this.exportCollection)
144 await this.output.WriteEndElementAsync();
155 if (this.exportCollection)
167 if (this.exportCollection)
168 await this.output.WriteEndElementAsync();
181 if (this.exportCollection)
184 await this.output.WriteAttributeStringAsync(
string.Empty,
"name",
string.Empty, FieldName);
185 await this.output.WriteAttributeStringAsync(
string.Empty,
"ascending",
string.Empty,
CommonTypes.
Encode(Ascending));
186 await this.output.WriteEndElementAsync();
199 if (this.exportCollection)
202 await this.output.WriteAttributeStringAsync(
string.Empty,
"id",
string.Empty, BlockID);
214 if (this.exportCollection)
218 await this.output.WriteEndElementAsync();
219 this.inMetaData =
false;
222 await this.output.WriteEndElementAsync();
236 if (this.exportCollection)
238 if (!this.inMetaData)
241 this.inMetaData =
true;
255 public override async Task<string>
StartObject(
string ObjectId,
string TypeName)
257 if (this.exportCollection)
260 await this.output.WriteAttributeStringAsync(
string.Empty,
"id",
string.Empty, ObjectId);
261 await this.output.WriteAttributeStringAsync(
string.Empty,
"type",
string.Empty, TypeName);
273 if (this.exportCollection)
275 await this.output.WriteEndElementAsync();
292 if (this.exportCollection)
296 await this.output.WriteEndElementAsync();
297 this.inMetaData =
false;
301 await this.output.WriteAttributeStringAsync(
string.Empty,
"id",
string.Empty, ObjectId);
302 await this.output.WriteAttributeStringAsync(
string.Empty,
"type",
string.Empty, TypeName);
303 await this.output.WriteAttributeStringAsync(
string.Empty,
"ts",
string.Empty,
XML.
Encode(EntryTimestamp));
315 if (this.exportCollection)
317 await this.output.WriteEndElementAsync();
331 if (this.exportCollection)
335 await this.output.WriteEndElementAsync();
336 this.inMetaData =
false;
340 await this.output.WriteAttributeStringAsync(
string.Empty,
"ts",
string.Empty,
XML.
Encode(EntryTimestamp));
352 public override async Task<bool>
ReportProperty(
string PropertyName,
object PropertyValue)
354 if (this.exportCollection)
367 if (!this.inCollection || this.exportCollection)
380 if (!this.inCollection || this.exportCollection)
383 await this.output.WriteAttributeStringAsync(
string.Empty,
"message",
string.Empty, Exception.Message);
384 this.output.WriteElementString(
"StackTrace",
Log.
CleanStackTrace(Exception.StackTrace));
386 if (Exception is AggregateException AggregateException)
388 foreach (Exception ex
in AggregateException.InnerExceptions)
391 else if (!(Exception.InnerException is
null))
394 await this.output.WriteEndElementAsync();
414 await this.output.WriteEndElementAsync();
428 await this.output.WriteAttributeStringAsync(
string.Empty,
"fileName",
string.Empty,
FileName);
431 long c = File.Length;
447 await File.ReadAllAsync(Buf, 0, j);
449 this.output.WriteElementString(
"Chunk", Convert.ToBase64String(Buf, 0, j, Base64FormattingOptions.None));
453 await this.output.WriteEndElementAsync();
Helps with parsing of commong data types.
static string Encode(bool x)
Encodes a Boolean for use in XML and other formats.
Helps with common XML-related tasks.
static string Encode(string s)
Encodes a string for use in XML.
Static class managing the application event log. Applications and services log events on this static ...
static string CleanStackTrace(string StackTrace)
Cleans a Stack Trace string, removing entries from the asynchronous execution model,...
Simple ledger that records anything that happens in the database to XML files in the program data fol...
const string Namespace
http://waher.se/Schema/Export.xsd
static async Task ReportProperty(XmlWriter Output, string PropertyName, object PropertyValue, string Namespace)
Serializes a property to XML.
EntryType
Ledger entry type.