Example #1
0
 public void Init(IFileShare view)
 {
     if (_userSession.LoggedIn)
     {
         _view = view;
         LoadFile();
     }
 }
        private async IAsyncEnumerable <GetTransactionsResponseV1File> HandleShare(
            IFileShare share,
            FileStoreFilterV1 filter,
            [EnumeratorCancellation] CancellationToken cancellationToken)
        {
            await foreach (var fileDirectory in share.ListAsync(new DatePathFilter(filter), cancellationToken))
            {
                if (filter.AllFileIdsFound)
                {
                    yield break;
                }

                var eventFile = await DownloadFile(share, fileDirectory, cancellationToken);

                if (!eventFile.TryParseEventDateWithFilter(filter, out var timestamp))
                {
                    continue;
                }
                if (!eventFile.TryParseFileIdWithFilter(filter, out var fileId))
                {
                    continue;
                }
                if (!eventFile.TryParseFileTypeWithFilter(filter, out var fileType))
                {
                    continue;
                }
                if (!eventFile.TryParseRiskWithFilter(filter, out var risk))
                {
                    continue;
                }
                if (!eventFile.TryParsePolicyIdWithFilter(filter, out var policyId))
                {
                    continue;
                }

                yield return(new GetTransactionsResponseV1File
                {
                    ActivePolicyId = policyId,
                    DetectionFileType = fileType,
                    FileId = fileId,
                    Risk = risk,
                    Timestamp = timestamp,
                    Directory = fileDirectory
                });
            }
        }
        private async Task <TransactionAdapationEventMetadataFile> DownloadFile(IFileShare share, string fileDirectory, CancellationToken cancellationToken)
        {
            using var ms = await share.DownloadAsync($"{fileDirectory}/metadata.json", cancellationToken);

            return(await _jsonSerialiser.Deserialize <TransactionAdapationEventMetadataFile>(ms, Encoding.UTF8));
        }