|
@@ -11,6 +11,7 @@ namespace InABox.Core
|
|
|
public interface IDigitalFormDocumentHandler
|
|
|
{
|
|
|
void LoadDocument(Guid id, Action<byte[]> callback);
|
|
|
+ byte[] LoadDocument(Guid id);
|
|
|
Guid SaveDocument(byte[] data);
|
|
|
void Run();
|
|
|
void Stop();
|
|
@@ -26,6 +27,20 @@ namespace InABox.Core
|
|
|
protected abstract bool IsConnected { get; }
|
|
|
|
|
|
private static Action<bool>? _status;
|
|
|
+
|
|
|
+ public byte[] LoadDocument(Guid id)
|
|
|
+ {
|
|
|
+ var fullpath = Path.Combine(CachePath, FileName(id));
|
|
|
+ if (File.Exists(fullpath))
|
|
|
+ return File.ReadAllBytes(fullpath);
|
|
|
+
|
|
|
+ var result = new Client<Document>().Query(
|
|
|
+ new Filter<Document>(x => x.FileName).IsEqualTo(FileName(id)),
|
|
|
+ null,
|
|
|
+ null
|
|
|
+ ).Rows.FirstOrDefault()?.Get<Document,byte[]>(c=>c.Data);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
|
|
|
public void LoadDocument(Guid id, Action<byte[]> callback)
|
|
|
{
|
|
@@ -131,7 +146,7 @@ namespace InABox.Core
|
|
|
public static void Stop() => _handler?.Stop();
|
|
|
|
|
|
public static void LoadDocument(Guid id, Action<byte[]> callback) => _handler?.LoadDocument(id, callback);
|
|
|
-
|
|
|
+ public static byte[]? LoadDocument(Guid id) => _handler?.LoadDocument(id);
|
|
|
public static Guid SaveDocument(byte[] data) => _handler?.SaveDocument(data) ?? Guid.Empty;
|
|
|
|
|
|
}
|