DFLayoutSignaturePadProperties.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System;
  2. using System.Collections.Generic;
  3. namespace InABox.Core
  4. {
  5. // need to add a property to signaturefield (manager signature or something) that prevents a form being saved for later if the
  6. // manager signature is present - ensures that form is completed and submitted / cannot be changed
  7. public class DFLayoutSignaturePadProperties : DFLayoutFieldProperties<byte[]>
  8. {
  9. public override string FormatValue(object value)
  10. {
  11. return value != null ? "Yes" : "";
  12. }
  13. public override object? ParseValue(object value)
  14. {
  15. if (value is byte[])
  16. return value;
  17. if (value is string str)
  18. {
  19. if (Guid.TryParse(str, out var id))
  20. {
  21. return Array.Empty<byte>();
  22. }
  23. try
  24. {
  25. return Convert.FromBase64String(str);
  26. }
  27. catch (Exception e)
  28. {
  29. return null;
  30. }
  31. }
  32. return null;
  33. }
  34. }
  35. }