Example #1
0
        public PaginatedContentResult ProcessQuery(string requestId)
        {
            GetServiceImplementation(out _requestManager);
            GetServiceImplementation(out _serializationHelper);
            GetServiceImplementation(out _documentManager);
            GetServiceImplementation(out _accountManager);
            GetServiceImplementation(out _flowManager);

            AppendAuditLogEvent("Validating requestId ...");
            DataRequest dataRequest = _requestManager.GetDataRequest(requestId);

            GetAuthorizedUsersResponse response = GetAuthorizedUsersResponseData();

            byte[] content = _serializationHelper.Serialize(response);

            if (response.AuthorizedUserList.Length == 0)
            {
                AppendAuditLogEvent("Did not find authorization information for any users");
            }
            else
            {
                AppendAuditLogEvent("Returning authorization information for {0} users ...", response.AuthorizedUserList.Length);
            }

            string docId =
                _documentManager.AddDocument(dataRequest.TransactionId, CommonTransactionStatusCode.Completed,
                                             null, new Document(null, CommonContentType.XML, content));

            PaginatedContentResult result = new PaginatedContentResult(0, response.AuthorizedUserList.Length, true,
                                                                       CommonContentType.XML, content);

            return(result);
        }
        protected virtual string GenerateSubmissionFileAndAddToTransaction(T data)
        {
            string submitFile = GenerateSubmissionFile(data);
            string zippedFile = _settingsProvider.NewTempFilePath(".zip");

            try
            {
                _compressionHelper.CompressFile(submitFile, zippedFile);

                AppendAuditLogEvent("Attaching submission document to transaction \"{0}\"",
                                    _dataRequest.TransactionId);
                _documentManager.AddDocument(_dataRequest.TransactionId,
                                             CommonTransactionStatusCode.Completed,
                                             null, zippedFile);
            }
            catch (Exception e)
            {
                AppendAuditLogEvent("Failed to attach submission document \"{0}\" to transaction \"{1}\" with exception: {2}",
                                    submitFile, _dataRequest.TransactionId, ExceptionUtils.ToShortString(e));
                FileUtils.SafeDeleteFile(zippedFile);
                throw;
            }
            finally
            {
                FileUtils.SafeDeleteFile(submitFile);
            }
            return(zippedFile);
        }
Example #3
0
        protected string GenerateSubmissionFileAndAddToTransaction(CERSDataType data, string transactionId,
                                                                   string authorName, string organizationName,
                                                                   string senderContactInfo, bool isProductionSubmission,
                                                                   string attachmentFolderPath, SpringBaseDao baseDao)
        {
            string submitFile = GenerateSubmissionFile(data, authorName, organizationName, senderContactInfo,
                                                       isProductionSubmission, attachmentFolderPath, baseDao);

            try
            {
                AppendAuditLogEvent("Attaching submission document to transaction \"{0}\"",
                                    transactionId);
                _documentManager.AddDocument(transactionId,
                                             CommonTransactionStatusCode.Completed,
                                             null, submitFile);
            }
            catch (Exception e)
            {
                AppendAuditLogEvent("Failed to attach submission document \"{0}\" to transaction \"{1}\" with exception: {2}",
                                    submitFile, transactionId, ExceptionUtils.ToShortString(e));
                FileUtils.SafeDeleteFile(submitFile);
                throw;
            }
            return(submitFile);
        }
Example #4
0
        protected virtual void AttachSubmissionResponseToTransaction(string transactionId)
        {
            string tempXmlFilePath = _settingsProvider.NewTempFilePath();
            string tempZipFilePath = _settingsProvider.NewTempFilePath();

            try
            {
                Windsor.Node2008.WNOSPlugin.ICISAIR_54.SubmissionResponseDataType response =
                    new Windsor.Node2008.WNOSPlugin.ICISAIR_54.SubmissionResponseDataType();
                response.CreationDate          = response.SubmissionDate = DateTime.Now;
                response.TransactionIdentifier = transactionId;

                _serializationHelper.Serialize(response, tempXmlFilePath);

                string zipDocumentName         = string.Format("{0}_Response.xml", transactionId);
                string transactionDocumentName = Path.ChangeExtension(zipDocumentName, ".zip");

                _compressionHelper.CompressFile(tempXmlFilePath, zipDocumentName, tempZipFilePath);

                var document =
                    new Windsor.Node2008.WNOSDomain.Document(transactionDocumentName, CommonContentType.ZIP,
                                                             File.ReadAllBytes(tempZipFilePath));
                _documentManager.AddDocument(transactionId, CommonTransactionStatusCode.Completed, null, document);
            }
            catch (Exception e)
            {
                AppendAuditLogEvent("Failed to add response file to transaction \"{0}\" with error: {1}",
                                    transactionId, ExceptionUtils.GetDeepExceptionMessage(e));
                throw;
            }
            finally
            {
                FileUtils.SafeDeleteFile(tempXmlFilePath);
            }
        }
Example #5
0
        public void ProcessSolicit(string requestId)
        {
            AppendAuditLogEvent("NCT ProcessSolicit() enter");

            LazyInit();

            DataRequest            dataRequest = _requestManager.GetDataRequest(requestId);
            PaginatedContentResult result      = OnProcessQueryRequest(dataRequest);

            _documentManager.AddDocument(dataRequest.TransactionId, CommonTransactionStatusCode.Processed,
                                         string.Empty, new Document(string.Empty, string.Empty,
                                                                    result.Content.Type,
                                                                    result.Content.Content));
            AddReportDocumentToTransaction(dataRequest.TransactionId, true);
            AppendAuditLogEvent("NCT ProcessSolicit() exit");
        }
 public void AddDocument(Document document)
 {
     lock (this)
     {
         _documentManager.AddDocument(document);
     }
 }
        protected string GenerateSubmissionFileAndAddToTransaction(Organization data)
        {
            // Serialize data to xml

            string submitFile = CreateSubmissionFile(data);

            try
            {
                // Attach the xml file to the task transaction

                AppendAuditLogEvent("Attaching submission document to transaction \"{0}\"",
                                    _dataRequest.TransactionId);
                _documentManager.AddDocument(_dataRequest.TransactionId,
                                             CommonTransactionStatusCode.Completed,
                                             null, submitFile);
            }
            catch (Exception e)
            {
                AppendAuditLogEvent("Failed to attach submission document \"{0}\" to transaction \"{1}\" with exception: {2}",
                                    submitFile, _dataRequest.TransactionId, ExceptionUtils.ToShortString(e));
                FileUtils.SafeDeleteFile(submitFile);
                throw;
            }
            return(submitFile);
        }
Example #8
0
        public void ProcessSolicit(string requestId)
        {
            AppendAuditLogEvent("Initializing {0} plugin ...", this.GetType().Name);

            GetServiceImplementation(out _serializationHelper);
            GetServiceImplementation(out _compressionHelper);
            GetServiceImplementation(out _requestManager);
            GetServiceImplementation(out _documentManager);
            GetServiceImplementation(out _settingsProvider);

            _baseDao = ValidateDBProvider(SOURCE_PROVIDER_KEY, typeof(NamedNullMappingDataReader));

            TryGetConfigParameter(CONFIG_COMPRESS_RESULTS, ref _compressResults);

            AppendAuditLogEvent("Loading request with id \"{0}\"", requestId);
            _dataRequest = _requestManager.GetDataRequest(requestId);
            AppendAuditLogEvent("Request loaded: {0}", _dataRequest);

            //get params
            GetParameters();

            //call the build here
            string results = GetAssessmentData(_cycle, _huc, _county, _waterbody, _waterType, _IRCategory);

            string tempXmlPath = _settingsProvider.NewTempFilePath(".xml");

            using (StreamWriter outfile = new StreamWriter(tempXmlPath))
            {
                outfile.Write(results);
            }

            AppendAuditLogEvent("Attaching submission document to transaction \"{0}\"", _dataRequest.TransactionId);

            if (_compressResults)
            {
                //.zip the results before returning
                string tempZipPath = _settingsProvider.NewTempFilePath(".zip");
                _compressionHelper.CompressFile(tempXmlPath, tempZipPath);
                _documentManager.AddDocument(_dataRequest.TransactionId,
                                             CommonTransactionStatusCode.Completed, null, tempZipPath);
            }
            else
            {
                _documentManager.AddDocument(_dataRequest.TransactionId,
                                             CommonTransactionStatusCode.Completed, null, tempXmlPath);
            }
        }
        protected string DoRequest(string requestId)
        {
            LazyInit();

            ValidateRequest(requestId);

            string filePath = RunMapForceQueryInstance();

            _documentManager.AddDocument(_dataRequest.TransactionId, CommonTransactionStatusCode.Completed,
                                         null, filePath);

            return(filePath);
        }
Example #10
0
        public void ProcessSolicit(string requestId)
        {
            try
            {
                AppendAuditLogEvent("Getting request...");
                LOG.DebugEnter(MethodBase.GetCurrentMethod(), requestId);

                LazyInit();

                DataRequest request = _requestManager.GetDataRequest(requestId);

                AppendAuditLogEvent("Getting data from request...");
                object returnData = GetObjectFromRequest(request);

                AppendAuditLogEvent("Serializing data to file...");
                LOG.Debug("Serializing results to file...");
                string serializedFilePath = _serializationHelper.SerializeToTempFile(returnData);
                LOG.Debug("Serialized file path: " + serializedFilePath);

                AppendAuditLogEvent("Compressing serialized data...");
                LOG.Debug("Compressing serialized file...");
                string compressedFilePath = _compressionHelper.CompressFile(serializedFilePath);
                LOG.Debug("Compressed file path: " + compressedFilePath);

                AppendAuditLogEvent("Saving compressed data...");
                LOG.Debug("Saving data");
                _documentManager.AddDocument(request.TransactionId,
                                             CommonTransactionStatusCode.Processed,
                                             "Request Processed: " + request.ToString(),
                                             compressedFilePath);

                AppendAuditLogEvent("Plugin done");
                LOG.Debug("OK");
            }
            catch (Exception ex)
            {
                LOG.Error(ex);
                AppendAuditLogEvent("Error: " + ex.StackTrace);
                throw new ApplicationException("Error while executing plugin", ex);
            }
        }
        public PaginatedContentResult ProcessQuery(string requestId)
        {
            LazyInit();

            ValidateRequest(requestId);

            int rowCount;

            byte[] content = GetSubmittedDocumentList(out rowCount);

            PaginatedContentResult result = new PaginatedContentResult();

            result.Paging  = new PaginationIndicator(0, rowCount, true);
            result.Content = new SimpleContent(CommonContentType.XML, content);

            string docId =
                _documentManager.AddDocument(_dataRequest.TransactionId, CommonTransactionStatusCode.Completed,
                                             null, new Document(null, CommonContentType.XML, content));

            return(result);
        }
        protected virtual void SaveCheckStatusInfo(CheckStatusInfo info)
        {
            byte[]   content = _serializationHelper.SerializeWithLineBreaks(info);
            Document doc     = new Document(SUBMISSION_CHECK_STATUS_INFO_FILE_NAME, CommonContentType.XML, content);

            doc.DontAutoCompress = true;
            Document existingDoc = null;

            try
            {
                existingDoc = _documentManager.GetDocumentByName(_transaction.Id, SUBMISSION_CHECK_STATUS_INFO_FILE_NAME, false);
            }
            catch (FileNotFoundException)
            {
            }
            if (existingDoc != null)
            {
                _documentManager.DeleteDocument(_transaction.Id, existingDoc.Id);
            }
            _documentManager.AddDocument(_transaction.Id, CommonTransactionStatusCode.Completed, string.Empty, doc);
        }
Example #13
0
        protected virtual string GenerateQuerySolicitFileAndAddToTransaction(BeachDataSubmissionDataType data)
        {
            string querySolicitFile = GenerateQuerySolicitFile(data);

            try
            {
                AppendAuditLogEvent("Attaching submission document to transaction \"{0}\"",
                                    _dataRequest.TransactionId);
                _documentManager.AddDocument(_dataRequest.TransactionId,
                                             CommonTransactionStatusCode.Completed,
                                             null, querySolicitFile);
            }
            catch (Exception e)
            {
                AppendAuditLogEvent("Failed to attach submission document \"{0}\" to transaction \"{1}\" with exception: {2}",
                                    querySolicitFile, _dataRequest.TransactionId, ExceptionUtils.ToShortString(e));
                FileUtils.SafeDeleteFile(querySolicitFile);
                throw;
            }
            return(querySolicitFile);
        }
        public void DoRequestUpdate(AccountAuthorizationRequest request, string adminName, bool doAccept)
        {
            request.Response.AuthorizationGeneratedOn = DateTime.Now;
            AuthorizationResponse response = GetAuthorizationResponse(request, doAccept);

            byte[]   authorizationResponsContent = _serializationHelper.Serialize(response);
            Document document = new Document(response.GetType().Name + ".xml", CommonContentType.XML, authorizationResponsContent);

            string statusDetail = string.Format("{0} {1} authorization request from user \"{2} ({3})\"",
                                                adminName, doAccept ? "accepted" : "rejected",
                                                request.FullName, request.NaasAccount);

            TransactionTemplate.Execute(delegate
            {
                Save(request);
                _documentManager.AddDocument(request.TransactionId, CommonTransactionStatusCode.Completed,
                                             statusDetail, document);
                _transactionDao.SetTransactionStatus(request.TransactionId, CommonTransactionStatusCode.Completed,
                                                     statusDetail, true);
                return(null);
            });
        }
Example #15
0
        protected byte[] GetServices(ServiceType returnServiceTypes, out int rowCount, out CommonContentType contentType)
        {
            NetworkNodeType networkNodeType = GetServices(returnServiceTypes);

            rowCount = networkNodeType.NodeServiceList.Length;

            NetworkNodeListType networkNodeListType = new NetworkNodeListType();

            networkNodeListType.NetworkNodeDetails = new NetworkNodeType[1] {
                networkNodeType
            };

            byte[] content = _serializationHelper.Serialize(networkNodeListType);

            contentType = CommonContentType.XML;
            content     = CheckToXsltTransformContent(content, "xml_schema.XsltTransforms.zip",
                                                      _xsltTransformName, ref contentType);

            string docId =
                _documentManager.AddDocument(_dataRequest.TransactionId, CommonTransactionStatusCode.Completed,
                                             null, new Document(null, contentType, content));

            return(content);
        }
Example #16
0
        protected string GenerateSubmissionFile()
        {
            string authorName, organizationName;
            bool   isProductionSubmission;

            CERSDataType data = GetCERSData.GetData(this, _databasePath, _dataCategory, out authorName, out organizationName, out isProductionSubmission);

            string tempZipFilePath      = _settingsProvider.NewTempFilePath(".zip");
            string tempXmlFilePath      = _settingsProvider.NewTempFilePath(".xml");
            string tempXmlCleanFilePath = _settingsProvider.NewTempFilePath(".xml");
            string validationResultsFilePath;

            // Required for the EIS backend parser:
            //XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
            //ns.Add("cer", "http://www.exchangenetwork.net/schema/cer/1");
            try
            {
                //_serializationHelper.SerializerNamespaces = ns;
                _serializationHelper.Serialize(data, tempXmlFilePath);

                XmlDocument xsl = new XmlDocument();
                xsl.LoadXml(XSL_REMOVE_EMPTY_TAGS); // constant contains the XSL above

                System.Xml.Xsl.XslCompiledTransform transform = new System.Xml.Xsl.XslCompiledTransform();
                transform.Load(xsl);
                transform.Transform(tempXmlFilePath, tempXmlCleanFilePath);

                validationResultsFilePath = ValidateXmlFile(tempXmlCleanFilePath, "xml_schema.CER_Schema_v1.2.zip", null);

                if (validationResultsFilePath == null)
                {
                    _passedSchemaValidation = true;
                }
                else
                {
                    _passedSchemaValidation = false;
                    _documentManager.AddDocument(_dataRequest.TransactionId,
                                                 CommonTransactionStatusCode.Failed,
                                                 null, validationResultsFilePath);
                }
                AppendAuditLogEvent("Generating submission file (with an exchange header) from results");

                IHeaderDocument2Helper headerDocumentHelper;
                GetServiceImplementation(out headerDocumentHelper);

                //headerDocumentHelper.SerializerNamespaces = ns;
                // Configure the submission header helper
                headerDocumentHelper.Configure(authorName, organizationName, "EIS", "EIS_v1_0", string.Empty,
                                               string.Empty, null);

                DataCategory submissionDataCategory = data.DataCategory;

                headerDocumentHelper.AddPropery(SUBMISSION_TYPE_HEADER_KEY,
                                                isProductionSubmission ? PRODUCTION_SUBMISSION_TYPE_NAME : QA_SUBMISSION_TYPE_NAME);
                headerDocumentHelper.AddPropery(DATA_CATEGORY_HEADER_KEY,
                                                EnumUtils.ToDescription(submissionDataCategory));

                string tempXmlFilePath2 = _settingsProvider.NewTempFilePath(".xml");

                try
                {
                    XmlDocument doc = new XmlDocument();
                    doc.Load(tempXmlCleanFilePath);

                    headerDocumentHelper.AddPayload(string.Empty, doc.DocumentElement);

                    headerDocumentHelper.Serialize(tempXmlFilePath2);

                    _compressionHelper.CompressFile(tempXmlFilePath2, tempZipFilePath);
                }
                finally
                {
                    FileUtils.SafeDeleteFile(tempXmlFilePath2);
                }
            }
            catch (Exception)
            {
                FileUtils.SafeDeleteFile(tempZipFilePath);
                throw;
            }
            finally
            {
                FileUtils.SafeDeleteFile(tempXmlFilePath);
            }

            return(tempZipFilePath);
        }
Example #17
0
        protected virtual bool DoXmlLoad(out string submitFilePath)
        {
            submitFilePath = null;
            Type mappingAttributesType = typeof(Windsor.Node2008.WNOSPlugin.ICISNPDES_56.MappingAttributes);
            IDictionary <string, DbAppendSelectWhereClause>             selectClauses = Windsor.Node2008.WNOSPlugin.ICISNPDES_56.PayloadData.GetDefaultSelectClauses(_stagingDao);
            List <Windsor.Node2008.WNOSPlugin.ICISNPDES_56.PayloadData> payloads      =
                _objectsFromDatabase.LoadFromDatabase <Windsor.Node2008.WNOSPlugin.ICISNPDES_56.PayloadData>(_stagingDao, selectClauses, mappingAttributesType);

            // Remove payloads that don't contain any data
            if (payloads != null)
            {
                for (int i = payloads.Count - 1; i >= 0; i--)
                {
                    if (CollectionUtils.IsNullOrEmpty(payloads[i].Items))
                    {
                        // TSM: Is this log really necessary?
                        //AppendAuditLogEvent(string.Format("The payload with operation \"{0}\" will not be included in the submission because it does not contain any data", payloads[i].Operation.ToString()));
                        payloads.RemoveAt(i);
                    }
                }
            }

            if (CollectionUtils.IsNullOrEmpty(payloads))
            {
                _submissionTrackingDataType.WorkflowStatus        = TransactionStatusCode.Completed;
                _submissionTrackingDataType.WorkflowStatusMessage = "The staging database does not contain any payloads to submit";
                AppendAuditLogEvent(_submissionTrackingDataType.WorkflowStatusMessage + ", exiting plugin ...");
                SubmissionTrackingTableHelper.Update(_stagingDao, _submissionTrackingDataTypePK, _submissionTrackingDataType);
                return(false);
            }

            AppendAuditLogEvent("The following ICIS payload(s) were loaded from the database: {0}", GetPayloadsDescription(payloads));

            Windsor.Node2008.WNOSPlugin.ICISNPDES_56.Document document = new Document();

            document.Payload = payloads.ToArray();
            document.Header  = CreateHeader();

            string tempFolder  = _settingsProvider.CreateNewTempFolderPath();
            string tempXmlPath = Path.Combine(tempFolder, ICIS_SUBMISSION_XML_FILENAME);
            string tempZipPath = Path.Combine(tempFolder, ICIS_SUBMISSION_ZIP_FILENAME);

            try
            {
                AppendAuditLogEvent("Serializing ICIS payload(s) to xml ...");

                _serializationHelper.Serialize(document, tempXmlPath);

                if (_validateXml)
                {
                    ValidateXmlFileAndAttachErrorsAndFileToTransaction(tempXmlPath, "xml_schema.xml_schema.zip",
                                                                       null, _dataRequest.TransactionId);
                }

                _compressionHelper.CompressFile(tempXmlPath, tempZipPath);

                _documentManager.AddDocument(_dataRequest.TransactionId, CommonTransactionStatusCode.Completed, null, tempZipPath);
            }
            catch (Exception)
            {
                FileUtils.SafeDeleteFile(tempZipPath);
                throw;
            }
            finally
            {
                FileUtils.SafeDeleteFile(tempXmlPath);
            }

            submitFilePath = tempZipPath;

            return(true);
        }
Example #18
0
        public void ProcessSolicit(string requestId)
        {
            LOG.DebugEnter(MethodBase.GetCurrentMethod(), requestId);

            LazyInit();

            _dataRequest = _requestManager.GetDataRequest(requestId);

            if (TryGetParameter(_dataRequest, PARAM_NAAS_SUBMIT_USERNAME, 0, ref _submitUsername))
            {
                if (_naasUsernameToPasswordMap == null)
                {
                    throw new ArgumentException(string.Format("A request parameter \"{0}\" = \"{1}\" was specified, but the service does not specify a \"{2}\" config parameter",
                                                              PARAM_NAAS_SUBMIT_USERNAME, _submitUsername, CONFIG_NAAS_USER_MAPPING_FILE_PATH));
                }
                if (!_naasUsernameToPasswordMap.ContainsKey(_submitUsername.ToUpper()))
                {
                    throw new ArgumentException(string.Format("A request parameter \"{0}\" = \"{1}\" was specified, but the username was not found in the mapping file specified by the \"{2}\" config parameter",
                                                              PARAM_NAAS_SUBMIT_USERNAME, _submitUsername, CONFIG_NAAS_USER_MAPPING_FILE_PATH));
                }
                UserSubmitInfo userSubmitInfo = _naasUsernameToPasswordMap[_submitUsername.ToUpper()];
                _rcraInfoUserId = userSubmitInfo.RCRAInfoUserID;
            }

            object returnData = GetObjectFromRequest(_dataRequest);

            string serializedFilePath = null;

            if (_addHeader)
            {
                LOG.Debug("Serializing results and making header...");
                AppendAuditLogEvent("Serializing results and making header...");
                serializedFilePath = MakeHeaderFile(returnData);
            }
            else
            {
                LOG.Debug("Serializing results to file...");
                AppendAuditLogEvent("Serializing results to file...");
                serializedFilePath = _serializationHelper.SerializeToTempFile(returnData);
                if (_validateXml)
                {
                    ValidateXmlFileAndAttachErrorsAndFileToTransaction(serializedFilePath, "xml_schema.xml_schema.zip",
                                                                       null, _dataRequest.TransactionId);
                }
            }

            LOG.Debug("Serialized file path: " + serializedFilePath);
            AppendAuditLogEvent("Serialized file path: " + serializedFilePath);

            LOG.Debug("Compressing serialized file...");
            AppendAuditLogEvent("Compressing serialized file...");
            string compressedFilePath = _compressionHelper.CompressFile(serializedFilePath);

            LOG.Debug("Compressed file path: " + compressedFilePath);
            AppendAuditLogEvent("Compressed file path: " + compressedFilePath);

            LOG.Debug("Adding document...");
            AppendAuditLogEvent("Adding document...");
            _documentManager.AddDocument(_dataRequest.TransactionId,
                                         CommonTransactionStatusCode.Processed,
                                         "Request Processed: " + _dataRequest.ToString(),
                                         compressedFilePath);

            if (_submitUsername != null)
            {
                SubmitFile(compressedFilePath, _dataRequest.TransactionId);
            }
            LOG.Debug("OK");
            AppendAuditLogEvent("ProcessQuery: OK");
        }
Example #19
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);
        }