5using System.Threading.Tasks;
39 cache.Add(AttachmentId, Item);
80 Created = DateTime.UtcNow,
86 Salt = Attachment.Salt
105 DateTime Expires,
byte[] Data,
string ContentType,
LegalComponent Legal)
117 cache.Add(AttachmentId, Item);
123 byte[] Key =
new byte[32];
124 byte[] IV =
new byte[16];
128 AttachmentId = AttachmentId,
129 Created = DateTime.UtcNow,
130 Expires = Expires.ToUniversalTime(),
131 ContentType = ContentType,
132 LocalAttachmentId =
null,
133 FileName = Path.Combine(Folder, AttachmentId +
".bin"),
140 using FileStream AttachmentFile = File.Create(Item.FileName);
141 Aes Aes = Aes.Create();
145 Aes.Mode = CipherMode.CBC;
146 Aes.Padding = PaddingMode.Zeros;
148 using ICryptoTransform Encryptor = Aes.CreateEncryptor(Key, IV);
149 using CryptoStream EncryptedAttachmentFile =
new CryptoStream(AttachmentFile, Encryptor, CryptoStreamMode.Write);
151 await EncryptedAttachmentFile.WriteAsync(Data, 0, Data.Length);
152 EncryptedAttachmentFile.FlushFinalBlock();
163 DateTime Limit = DateTime.UtcNow;
164 const int MaxCount = 10;
167 IEnumerable<AttachmentCacheItem> Items;
194 while (c == MaxCount);
Static class managing the application event log. Applications and services log events on this static ...
static void Exception(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, params KeyValuePair< string, object >[] Tags)
Logs an exception. Event type will be determined by the severity of the exception.
Static class managing the runtime environment of the IoT Gateway.
static byte[] NextBytes(int NrBytes)
Generates an array of random bytes.
Represents a case-insensitive string.
string LowerCase
Lower-case representation of the case-insensitive string.
Static interface for database persistence. In order to work, a database provider has to be assigned t...
static Task< IEnumerable< object > > FindDelete(string Collection, params string[] SortOrder)
Finds objects in a given collection and deletes them in the same atomic operation.
static async Task Insert(object Object)
Inserts an object into the default collection of the database.
This filter selects objects that have a named field equal to a given value.
This filter selects objects that have a named field lesser or equal to a given value.
Implements an in-memory cache.
Represents a named semaphore, i.e. an object, identified by a name, that allows single concurrent wri...
Static class of application-wide semaphores that can be used to order access to editable objects.
static async Task< Semaphore > BeginRead(string Key)
Waits until the semaphore identified by Key is ready for reading. Each call to BeginRead must be fol...
static async Task< Semaphore > BeginWrite(string Key)
Waits until the semaphore identified by Key is ready for writing. Each call to BeginWrite must be fo...
static async Task< bool > AddRemoteAttachment(CaseInsensitiveString AttachmentId, DateTime Expires, byte[] Data, string ContentType, LegalComponent Legal)
Attempts to add an attachment to the cache.
static async Task< int > DeleteOldAttachments()
Deletes old attachments from the cache and database.
static async Task< AttachmentCacheItem > TryGetAttachment(CaseInsensitiveString AttachmentId)
Tries to get an attachment from the cache.
static async Task< bool > ContainsAttachment(CaseInsensitiveString AttachmentId)
Checks if the cache contains an attachment with the given ID.
static async Task< bool > AddLocalAttachment(Attachment Attachment, DateTime Expires)
Attempts to add a local attachment to the cache.
string LocalAttachmentId
If the attachment represents a local attachment, this property contains the Object ID of the attachme...
string FileName
Local File name to encrypted file.
string AttachmentId
Attachment ID
Represents an attachment to a document.
long Size
Size of attachment, in bytes.
CaseInsensitiveString Id
Attachment ID
string ObjectId
Object ID of attachment.
string LocalFileName
Local Filename of attachment.
string ContentType
Internet Content Type of binary attachment.
Legal (digital identities, smart contracts) service component.
string AttachmentsFolder
Attachments folder.