Ejemplo n.º 1
0
 private static void RespondToDocumentNotify(string qMessage, string messageId)
 {
     try
     {
         var queueInfo = new QueueInfo
         {
             Manager        = LMApplicationConfigurationdetails.ResponseManger,
             Channel        = LMApplicationConfigurationdetails.ResponseChannel,
             UseManagerName = false,
             Port           = LMApplicationConfigurationdetails.ResponsePort,
             HostName       = LMApplicationConfigurationdetails.ResponseHostName,
             QueueName      = LMApplicationConfigurationdetails.ResponseQueueName,
             CorrelationId  = messageId,
             Message        = qMessage
         };
         FdrMessaging.SendMessageToQueue(queueInfo);
         try
         {
             FdrCommon.SaveMessage(qMessage, @"\\ptadviis06\TaxDirectives\FDR\FILES\OUT");
         }
         catch (Exception exception)
         {
             FdrCommon.LogEvent(exception, EventLogEntryType.Error);
         }
     }
     catch (Exception exception)
     {
         FdrCommon.LogEvent(exception, EventLogEntryType.Error);
     }
 }
Ejemplo n.º 2
0
        private static void OnFilesReceived(IMessage msg)
        {
            try
            {
                var textMsg = (ITextMessage)msg;
                FdrCommon.SaveMessage(textMsg.Text, @"\\ptadviis06\TaxDirectives\FDR\FILES\IN");
                var message = textMsg.Text;



                var doc = new XmlDocument();
                doc.LoadXml(message);
                var ns = new XmlNamespaceManager(doc.NameTable);
                ns.AddNamespace("soap12", "http://www.w3.org/2003/05/soap-envelope");
                ns.AddNamespace("ContMgt", "http://www.sars.gov.za/enterpriseMessagingModel/ContentManagement/xml/schemas/version/1.8");

                var header  = doc.SelectSingleNode("//soap12:Header", ns);
                var request = doc.SelectSingleNode("//ContMgt:ContentManagementRequest", ns);
                if (header == null || request == null)
                {
                    FdrCommon.LogEvent("header == null || request == null", EventLogEntryType.Warning);
                    return;
                }

                var dataValidation = IsMasterLocalFileRequestValid(message);
                if (!dataValidation.IsValid)
                {
                    var xml = FdrCommon.FormatXml(CreateFaultXml(header.OuterXml, dataValidation.ErrorXml));
                    RespondToDocumentNotify(xml, msg.JMSMessageID);
                    return;
                }


                var supportingDocs =
                    Sars.Systems.Serialization.XmlObjectSerializer.ConvertXmlToObject <SupportingDocumentManagementRequestStructure>(request.OuterXml);
                var xmlToSend    = string.Empty;
                var deserialized = supportingDocs != null && supportingDocs.Contents != null &&
                                   supportingDocs.Contents.Any();
                if (deserialized)
                {
                    var responseStructure = new SupportingDocumentManagementResponseStructure
                    {
                        Contents = supportingDocs.Contents
                    };
                    xmlToSend = Sars.Systems.Serialization.XmlObjectSerializer.GetXmlWithNoDeclaration(responseStructure, "ContMgt", "http://www.sars.gov.za/enterpriseMessagingModel/ContentManagement/xml/schemas/version/1.8");
                }
                if (!string.IsNullOrEmpty(xmlToSend))
                {
                    var messageToSend = CreateXml(header.OuterXml, xmlToSend);
                    messageToSend = FdrCommon.RemoveEmptyElements(messageToSend);
                    RespondToDocumentNotify(messageToSend, msg.JMSMessageID);
                }
                if (deserialized)
                {
                    if (!supportingDocs.Contents[0].ContentLocation.ToUpper().EndsWith(AppConfig.SecondaryFileLocation))
                    {
                        var submissionId = ContentManagementRequest(message);
                        if (submissionId > 0)
                        {
                            SendNotification(submissionId);
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                FdrCommon.LogEvent(exception, EventLogEntryType.Error);
            }
        }