Esempio n. 1
0
        /// <summary>
        /// Handles a received message
        /// </summary>
        public MARC.Everest.Interfaces.IGraphable HandleMessageReceived(object sender, UnsolicitedDataEventArgs e, MARC.Everest.Connectors.IReceiveResult receivedMessage)
        {
            // audit the error
            IAuditorService auditor = Context.GetService(typeof(IAuditorService)) as IAuditorService;
            AuditData       ad      = new AuditData(
                DateTime.Now, ActionType.Execute, OutcomeIndicator.EpicFail, EventIdentifierType.ApplicationActivity, new CodeValue(String.Format("{0}", receivedMessage.Structure))
                );

            ad.Actors.AddRange(new List <AuditActorData>(10)
            {
                new AuditActorData()
                {
                    NetworkAccessPointId = e.ReceiveEndpoint.ToString(), NetworkAccessPointType = NetworkAccessPointType.IPAddress, UserIsRequestor = false
                },
                new AuditActorData()
                {
                    NetworkAccessPointType = NetworkAccessPointType.MachineName, NetworkAccessPointId = Environment.MachineName, UserIsRequestor = false
                }
            }
                               );
            ad.AuditableObjects.Add(new AuditableObject()
            {
                IDTypeCode = AuditableObjectIdType.ReportNumber, LifecycleType = AuditableObjectLifecycle.Verification, ObjectId = (receivedMessage.Structure as IIdentifiable).Id.Root, Role = AuditableObjectRole.Subscriber, Type = AuditableObjectType.SystemObject
            });
            if (auditor != null)
            {
                auditor.SendAudit(ad);
            }

            IInteraction solicitation = receivedMessage.Structure as IInteraction;

            // get the configuration
            ISystemConfigurationService configService = Context.GetService(typeof(ISystemConfigurationService)) as ISystemConfigurationService;

            // construct a generic response
            MCCI_IN000002CA response = new MCCI_IN000002CA(
                Guid.NewGuid(),
                DateTime.Now,
                new CV <ResponseMode>(ResponseMode.Immediate),
                MCCI_IN000002CA.GetInteractionId(),
                MCCI_IN000002CA.GetProfileId(),
                ProcessingID.Debugging,
                AcknowledgementCondition.Never,
                null,
                MessageUtil.CreateSender(e.ReceiveEndpoint, configService),
                new Acknowledgement(
                    AcknowledgementType.ApplicationAcknowledgementReject,
                    new TargetMessage(
                        (receivedMessage.Structure as IIdentifiable).Id
                        )
                    )
                );

            // Add a detail
            if (solicitation.InteractionId != null && solicitation.InteractionId.Extension != receivedMessage.Structure.GetType().Name)
            {
                response.Acknowledgement.AcknowledgementDetail.Add(
                    new AcknowledgementDetail(
                        AcknowledgementDetailType.Error,
                        Util.ToWireFormat(MARC.Everest.RMIM.CA.R020402.Vocabulary.AcknowledgementDetailCode.ValueDoesNotMatchFixedValue),
                        String.Format("Interaction ID '{0}' not supported for message type '{1}'", solicitation.InteractionId.Extension, receivedMessage.Structure.GetType().Name),
                        null));
            }
            else
            {
                response.Acknowledgement.AcknowledgementDetail.Add(
                    new AcknowledgementDetail(
                        AcknowledgementDetailType.Error,
                        Util.ToWireFormat(MARC.Everest.RMIM.CA.R020402.Vocabulary.AcknowledgementDetailCode.UnsupportedInteraction),
                        "Cannot process this interaction",
                        null)
                    );
            }

            // Validation detils
            response.Acknowledgement.AcknowledgementDetail.AddRange(MessageUtil.CreateGenAckDetails(receivedMessage.Details));

            // Populate the receiver
            Sender   originalSolicitor = solicitation.GetType().GetProperty("Sender").GetValue(solicitation, null) as Sender;
            Receiver receiver          = MessageUtil.CreateReceiver(originalSolicitor);

            response.Receiver = receiver;

            return(response);
        }