12345678910111213141516171819202122232425262728293031323334353637383940 |
- using System;
- using System.Linq;
- using InABox.Core;
- namespace PRS.Mobile
- {
- public class DigitalFormEmbeddedMediaValue
- {
- public Guid ID { get; set; }
- public byte[] Data { get; set; }
- public DigitalFormEmbeddedMediaValue(String json = "")
- {
- if (String.IsNullOrWhiteSpace(json))
- return;
- if (Guid.TryParse(json, out Guid id) && (id != Guid.Empty))
- {
- DigitalFormDocumentHandler.LoadDocument(id,
- data =>
- {
- ID = id;
- Data = data;
- }
- );
- }
- else if (json.IsBase64String())
- {
- ID = Guid.Empty;
- Data = Convert.FromBase64String(json);
- }
- }
- public override string ToString()
- {
- if ((ID == Guid.Empty) && (Data.Any() == true))
- ID = DigitalFormDocumentHandler.SaveDocument(Data);
- return ID.ToString();
- }
- }
- }
|