Exemple #1
0
        public async Task <IActionResult> PostAsync(List <IFormFile> files)
        {
            if (files?.Count < 1)
            {
                return(BadRequest());
            }

            var record = new MrRecord
            {
                HospitalId = HospitalId,
            };

            dbContext.Add(record);
            await dbContext.SaveChangesAsync();

            await fileStorage.SaveMRData(record.Id, files.Select(f => f.OpenReadStream()));

            return(Ok());
            //var tasks = files.Select(f => renderer.Render(f.OpenReadStream())).ToArray();
            //var folderName = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
            //var directoryInfo = Directory.CreateDirectory(folderName);
            //var memoryZipStream = new MemoryStream();
            //string zipFileName = "";
            //try
            //{
            //    await Task.WhenAll(tasks);
            //    foreach (var (picStream, FileName) in tasks.Zip(files, (task, f) => (task.Result, f.FileName)))
            //    {
            //        using (var fileStream = System.IO.File.OpenWrite(Path.Combine(folderName, $"{FileName}.png")))
            //        {
            //            await picStream.CopyToAsync(fileStream);
            //        }
            //    }
            //    zipFileName = Path.ChangeExtension(Path.GetTempFileName(), ".zip");
            //    ZipFile.CreateFromDirectory(folderName, zipFileName);
            //    using (var fileZipStream = System.IO.File.OpenRead(zipFileName))
            //    {
            //        await fileZipStream.CopyToAsync(memoryZipStream);
            //        memoryZipStream.Position = 0;
            //    }
            //}
            //finally
            //{
            //    directoryInfo.Delete(recursive: true);
            //    if (!string.IsNullOrEmpty(zipFileName))
            //        System.IO.File.Delete(zipFileName);
            //}
            //return File(memoryZipStream, "application/zip", "dataset.zip");
        }
Exemple #2
0
        public DnsResourceRecord GetRecord(ResourceRecordInfo info)
        {
            if (info == null)
            {
                throw new ArgumentNullException(nameof(info));
            }

            var oldIndex = _reader.Index;
            DnsResourceRecord result;

            switch (info.RecordType)
            {
            case ResourceRecordType.A:
                result = new ARecord(info, _reader.ReadIPAddress());
                break;

            case ResourceRecordType.NS:
                result = new NsRecord(info, _reader.ReadDnsName());
                break;

            case ResourceRecordType.CNAME:
                result = new CNameRecord(info, _reader.ReadDnsName());
                break;

            case ResourceRecordType.SOA:
                result = ResolveSoaRecord(info);
                break;

            case ResourceRecordType.MB:
                result = new MbRecord(info, _reader.ReadDnsName());
                break;

            case ResourceRecordType.MG:
                result = new MgRecord(info, _reader.ReadDnsName());
                break;

            case ResourceRecordType.MR:
                result = new MrRecord(info, _reader.ReadDnsName());
                break;

            case ResourceRecordType.NULL:
                result = new NullRecord(info, _reader.ReadBytes(info.RawDataLength).ToArray());
                break;

            case ResourceRecordType.WKS:
                result = ResolveWksRecord(info);
                break;

            case ResourceRecordType.PTR:
                result = new PtrRecord(info, _reader.ReadDnsName());
                break;

            case ResourceRecordType.HINFO:
                result = new HInfoRecord(info, _reader.ReadString(), _reader.ReadString());
                break;

            case ResourceRecordType.MINFO:
                result = new MInfoRecord(info, _reader.ReadDnsName(), _reader.ReadDnsName());
                break;

            case ResourceRecordType.MX:
                result = ResolveMXRecord(info);
                break;

            case ResourceRecordType.TXT:
                result = ResolveTXTRecord(info);
                break;

            case ResourceRecordType.RP:
                result = new RpRecord(info, _reader.ReadDnsName(), _reader.ReadDnsName());
                break;

            case ResourceRecordType.AFSDB:
                result = new AfsDbRecord(info, (AfsType)_reader.ReadUInt16NetworkOrder(), _reader.ReadDnsName());
                break;

            case ResourceRecordType.AAAA:
                result = new AaaaRecord(info, _reader.ReadIPv6Address());
                break;

            case ResourceRecordType.SRV:
                result = ResolveSrvRecord(info);
                break;

            case ResourceRecordType.OPT:
                result = ResolveOptRecord(info);
                break;

            case ResourceRecordType.URI:
                result = ResolveUriRecord(info);
                break;

            case ResourceRecordType.CAA:
                result = ResolveCaaRecord(info);
                break;

            default:
                // update reader index because we don't read full data for the empty record
                _reader.Index += info.RawDataLength;
                result         = new EmptyRecord(info);
                break;
            }

            // sanity check
            if (_reader.Index != oldIndex + info.RawDataLength)
            {
                throw new InvalidOperationException("Record reader index out of sync.");
            }

            return(result);
        }
        public DnsResourceRecord GetRecord(ResourceRecordInfo info)
        {
            if (info == null)
            {
                throw new ArgumentNullException(nameof(info));
            }

            var oldIndex = _reader.Index;
            DnsResourceRecord result;

            switch (info.RecordType)
            {
            case ResourceRecordType.A:
                result = new ARecord(info, _reader.ReadIPAddress());
                break;

            case ResourceRecordType.NS:
                result = new NsRecord(info, _reader.ReadDnsName());
                break;

            case ResourceRecordType.CNAME:
                result = new CNameRecord(info, _reader.ReadDnsName());
                break;

            case ResourceRecordType.SOA:
                result = ResolveSoaRecord(info);
                break;

            case ResourceRecordType.MB:
                result = new MbRecord(info, _reader.ReadDnsName());
                break;

            case ResourceRecordType.MG:
                result = new MgRecord(info, _reader.ReadDnsName());
                break;

            case ResourceRecordType.MR:
                result = new MrRecord(info, _reader.ReadDnsName());
                break;

            case ResourceRecordType.NULL:
                result = new NullRecord(info, _reader.ReadBytes(info.RawDataLength).ToArray());
                break;

            case ResourceRecordType.WKS:
                result = ResolveWksRecord(info);
                break;

            case ResourceRecordType.PTR:
                result = new PtrRecord(info, _reader.ReadDnsName());
                break;

            case ResourceRecordType.HINFO:
                result = new HInfoRecord(info, _reader.ReadStringWithLengthPrefix(), _reader.ReadStringWithLengthPrefix());
                break;

            case ResourceRecordType.MINFO:
                result = new MInfoRecord(info, _reader.ReadDnsName(), _reader.ReadDnsName());
                break;

            case ResourceRecordType.MX:
                result = ResolveMXRecord(info);
                break;

            case ResourceRecordType.TXT:
                result = ResolveTXTRecord(info);
                break;

            case ResourceRecordType.RP:
                result = new RpRecord(info, _reader.ReadDnsName(), _reader.ReadDnsName());
                break;

            case ResourceRecordType.AFSDB:
                result = new AfsDbRecord(info, (AfsType)_reader.ReadUInt16NetworkOrder(), _reader.ReadDnsName());
                break;

            case ResourceRecordType.AAAA:
                result = new AaaaRecord(info, _reader.ReadIPv6Address());
                break;

            case ResourceRecordType.SRV:
                result = ResolveSrvRecord(info);
                break;

            case ResourceRecordType.OPT:
                result = ResolveOptRecord(info);
                break;

            case ResourceRecordType.URI:
                result = ResolveUriRecord(info);
                break;

            case ResourceRecordType.CAA:
                result = ResolveCaaRecord(info);
                break;

            case ResourceRecordType.SSHFP:
                result = ResolveSshfpRecord(info);
                break;

            default:
                result = new UnknownRecord(info, _reader.ReadBytes(info.RawDataLength).ToArray());
                break;
            }

            // sanity check
            _reader.SanitizeResult(oldIndex + info.RawDataLength, info.RawDataLength);

            return(result);
        }
Exemple #4
0
 public CdrRtdRecord(MrRecord mrRecord)
 {
     mrRecord.RefCell.CloneProperties(this);
     Rtd = mrRecord.RefCell.Ta*78.12;
 }
 public CdrRtdRecord(MrRecord mrRecord)
 {
     mrRecord.RefCell.CloneProperties(this);
     Rtd = mrRecord.RefCell.Ta * 78.12;
 }