コード例 #1
0
        public string ReceiveOnlineBatchExternalAttachment(string username, string passwd, string receiversReference, long sequenceNumber, string batch, [XmlElement(DataType = "base64Binary")] byte[] attachments)
        {
            _logger.Info("ReceiveOnlineBatchExternalAttachment Recieved from: " + username);
            _logger.Debug("ReceiveOnlineBatchExternalAttachment Recieved from: " + username + " Batch: " + batch);

            // Authenticate username + passw
            if (!Authenticate(username, passwd))
            {
                _logger.Debug("ReceiveOnlineBatchExternalAttachment Invalid request");
                return(Response(resultCodeType.FAILED_DO_NOT_RETRY));
            }
            _logger.Debug("ReceiveOnlineBatchExternalAttachment, User Aithenticated");
            // Verify batch vs. XSD (Schema verification)
            if (!XmlUtils.ValidateBatchXml(batch, _filepath, new List <string> {
                "/xsd/genericbatch.2013.06.xsd"
            }))
            {
                _logger.Debug("ReceiveOnlineBatchExternalAttachment Validation Failed");
                return(Response(resultCodeType.FAILED_DO_NOT_RETRY));
            }

            try
            {
                var serializer = XmlUtils.GetXmlSerializerOfType <DataBatch>();
                // result is a DataBack object, which can be sent async to a recipient in the reciever application portfolio
                var result = XmlUtils.DeserializeXmlString <DataBatch>(serializer, batch);

                if (FileUtil.AlreadyExists(_filepath, _foldername, username, receiversReference, sequenceNumber))
                {
                    _logger.Debug("ReceiveOnlineBatchExternalAttachment Duplicate Request");
                    return(Response(resultCodeType.FAILED_DO_NOT_RETRY));
                }
                // Saving payload to disk
                var filename = Guid.NewGuid() + "_" + username + "_" + receiversReference + "_" + sequenceNumber;
                FileUtil.SaveXmlFileToDisk(_filepath, _foldername, filename, serializer, result);
                FileUtil.SaveAttatchmentsAsZip(_filepath, _foldername, filename, attachments);
            }
            catch (Exception ex)
            {
                _logger.Error(ex);
                return(ex.Message);
            }

            _logger.Debug("ReceiveOnlineBatchExternalAttachment Validated OK ");
            return(Response(resultCodeType.OK));
        }