Beispiel #1
0
        protected virtual string AddExchangeDocumentHeader(string inputFile, bool doCompress, string docTransactionId)
        {
            string tempZipFilePath = _settingsProvider.NewTempFilePath(".zip");

            if (!_addHeader)
            {
                if (doCompress && !_compressionHelper.IsCompressed(inputFile))
                {
                    _compressionHelper.CompressFile(inputFile, tempZipFilePath);
                }
                else
                {
                    tempZipFilePath = inputFile;
                }
            }
            else
            {
                AppendAuditLogEvent("Adding an exchange header to the document ...");

                ExceptionUtils.ThrowIfFileNotFound(inputFile);

                string tempInputFilePath = _settingsProvider.NewTempFilePath(".xml");
                string tempXmlFilePath   = _settingsProvider.NewTempFilePath(".xml");

                try
                {
                    if (_compressionHelper.IsCompressed(inputFile))
                    {
                        _compressionHelper.Uncompress(inputFile, tempInputFilePath);
                        inputFile = tempInputFilePath;
                    }

                    XmlDocument doc = new XmlDocument();
                    doc.Load(inputFile);

                    _headerDocumentHelper.Configure(_author, _organization, "AQS Data", AQS_FLOW_NAME, null, null, _aqsUserId, null);
                    if (!string.IsNullOrEmpty(_senderAddress))
                    {
                        List <string> emails = StringUtils.SplitAndReallyRemoveEmptyEntries(_senderAddress, EMAIL_ADDRESS_SEPARATOR);
                        if (!CollectionUtils.IsNullOrEmpty(emails))
                        {
                            _headerDocumentHelper.AddNotifications(emails);
                        }
                    }
                    if (!string.IsNullOrEmpty(_aqsScreeningGroup))
                    {
                        _headerDocumentHelper.AddPropery("AQS.ScreeningGroup", _aqsScreeningGroup);
                    }
                    if (!string.IsNullOrEmpty(_aqsFinalProcessingStep))
                    {
                        _headerDocumentHelper.AddPropery("AQS.FinalProcessingStep", _aqsFinalProcessingStep);
                    }
                    if (!string.IsNullOrEmpty(_aqsStopOnError))
                    {
                        _headerDocumentHelper.AddPropery("AQS.StopOnError", _aqsStopOnError);
                    }
                    _headerDocumentHelper.AddPropery("AQS.SchemaVersion", "3.0");

                    _headerDocumentHelper.AddPropery("AQS.PayloadType", "XML");

                    _headerDocumentHelper.AddPayload(null, doc.DocumentElement);

                    _headerDocumentHelper.Serialize(tempXmlFilePath);

                    if (doCompress)
                    {
                        _compressionHelper.CompressFile(tempXmlFilePath, tempZipFilePath);
                    }
                    else
                    {
                        tempZipFilePath = tempXmlFilePath;
                    }
                }
                catch (Exception ex)
                {
                    AppendAuditLogEvent("Failed to add an exchange header to the document with the following exception: {0}",
                                        ExceptionUtils.GetDeepExceptionMessage(ex));
                    FileUtils.SafeDeleteFile(tempZipFilePath);
                    throw;
                }
                finally
                {
                    FileUtils.SafeDeleteFile(tempInputFilePath);
                    FileUtils.SafeDeleteFile(tempXmlFilePath);
                }
            }
            if (!string.IsNullOrEmpty(docTransactionId))
            {
                _documentManager.AddDocument(docTransactionId, CommonTransactionStatusCode.Completed, null, tempZipFilePath);
            }
            return(tempZipFilePath);
        }
Beispiel #2
0
 public override T DeserializeFromBytes <T>(byte[] bytes)
 {
     return(_serializationHelper.BinaryDeserialize <T>(_compressionHelper.Uncompress(bytes)));
 }