Ejemplo n.º 1
0
        /// <summary>
        /// Create a custodianship node
        /// </summary>
        //public static Custodian CreateCustodian(ISystemConfigurationService configService)
        //{

        //    var retVal = new MARC.Everest.RMIM.CA.R020403.REPC_MT230003CA.Custodian();
        //    retVal.AssignedDevice = new MARC.Everest.RMIM.CA.R020403.COCT_MT090310CA.AssignedDevice(
        //        new II(configService.Custodianship.Id.Domain, configService.Custodianship.Id.Identifier),
        //        new MARC.Everest.RMIM.CA.R020403.COCT_MT090310CA.Repository(configService.Custodianship.Name),
        //        new MARC.Everest.RMIM.CA.R020403.COCT_MT090310CA.RepositoryJurisdiction(
        //            configService.JurisdictionData.Name)
        //            );
        //    return retVal;
        //}

        /// <summary>
        /// Create ack details
        /// </summary>
        internal static IEnumerable <MARC.Everest.RMIM.UV.NE2008.MCCI_MT100200UV01.AcknowledgementDetail> CreateAckDetailsUv(DetectedIssue[] detectedIssue)
        {
            List <AcknowledgementDetail> retVal = new List <AcknowledgementDetail>(10);

            foreach (DetectedIssue dtl in detectedIssue ?? new DetectedIssue[0])
            {
                // Acknowledgement detail
                var ackDetail = new AcknowledgementDetail()
                {
                    TypeCode =
                        dtl.Priority == IssuePriorityType.Error ? AcknowledgementDetailType.Error :
                        dtl.Priority == IssuePriorityType.Warning ? AcknowledgementDetailType.Warning : AcknowledgementDetailType.Information
                };

                // Determine the type of acknowledgement
                var typ = TranslateDetectedIssueCode(dtl.Type);
                ackDetail.Code = new CE <string>(Util.ToWireFormat(typ.Code), typ.CodeSystem);
                ackDetail.Text = dtl.Text;
                // Mesage
                retVal.Add(ackDetail);
            }

            return(retVal);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Create a list of ack details from the supplied list of details
        /// </summary>
        public static List <AcknowledgementDetail> CreateAckDetails(IEnumerable <IResultDetail> details)
        {
            List <AcknowledgementDetail> retVal = new List <AcknowledgementDetail>(10);

            foreach (IResultDetail dtl in details ?? new IResultDetail[0])
            {
                // Acknowledgement detail
                var ackDetail = new AcknowledgementDetail(
                    dtl.Type == ResultDetailType.Error ? AcknowledgementDetailType.Error :
                    dtl.Type == ResultDetailType.Warning ? AcknowledgementDetailType.Warning : AcknowledgementDetailType.Information);

                // Determine the type of acknowledgement
                if (dtl is InsufficientRepetitionsResultDetail)
                {
                    ackDetail.Code = Util.ToWireFormat(MARC.Everest.RMIM.CA.R020402.Vocabulary.AcknowledgementDetailCode.InsufficientRepetitions);
                }
                else if (dtl is MandatoryElementMissingResultDetail)
                {
                    ackDetail.Code = Util.ToWireFormat(MARC.Everest.RMIM.CA.R020402.Vocabulary.AcknowledgementDetailCode.MandatoryElementWithNullValue);
                }
                else if (dtl is NotImplementedElementResultDetail)
                {
                    ackDetail.Code = Util.ToWireFormat(MARC.Everest.RMIM.CA.R020402.Vocabulary.AcknowledgementDetailCode.SyntaxError);
                }
                else if (dtl is RequiredElementMissingResultDetail)
                {
                    ackDetail.Code = Util.ToWireFormat(MARC.Everest.RMIM.CA.R020402.Vocabulary.AcknowledgementDetailCode.RequiredElementMissing);
                }
                else if (dtl is PersistenceResultDetail)
                {
                    ackDetail.Code = Util.ToWireFormat(MARC.Everest.RMIM.CA.R020402.Vocabulary.AcknowledgementDetailCode.NoStorageSpaceForMessage);
                }
                else if (dtl is VocabularyIssueResultDetail)
                {
                    ackDetail.Code = Util.ToWireFormat(MARC.Everest.RMIM.CA.R020402.Vocabulary.AcknowledgementDetailCode.TerminologyError);
                }
                else if (dtl is FixedValueMisMatchedResultDetail)
                {
                    ackDetail.Code = Util.ToWireFormat(MARC.Everest.RMIM.CA.R020402.Vocabulary.AcknowledgementDetailCode.ValueDoesNotMatchFixedValue);
                }
                else if (dtl is UnsupportedProcessingModeResultDetail)
                {
                    ackDetail.Code = Util.ToWireFormat(MARC.Everest.RMIM.CA.R020402.Vocabulary.AcknowledgementDetailCode.UnsupportedProcessingMode);
                }
                else if (dtl is UnsupportedResponseModeResultDetail)
                {
                    ackDetail.Code = Util.ToWireFormat(MARC.Everest.RMIM.CA.R020402.Vocabulary.AcknowledgementDetailCode.UnsupportedProcessingId);
                }
                else if (dtl is UnsupportedVersionResultDetail)
                {
                    ackDetail.Code = Util.ToWireFormat(MARC.Everest.RMIM.CA.R020402.Vocabulary.AcknowledgementDetailCode.UnsupportedVersionId);
                }
                else if (dtl.Exception is NotImplementedException)
                {
                    ackDetail.Code = Util.ToWireFormat(MARC.Everest.RMIM.CA.R020402.Vocabulary.AcknowledgementDetailCode.UnsupportedInteraction);
                }
                else if (dtl is UnrecognizedSenderResultDetail)
                {
                    ackDetail.Code = Util.ToWireFormat(MARC.Everest.RMIM.CA.R020402.Vocabulary.AcknowledgementDetailCode.UnknownSender);
                }
                else if (dtl is DetectedIssueResultDetail) // Don't handle these
                {
                    continue;
                }
                else
                {
                    ackDetail.Code = Util.ToWireFormat(MARC.Everest.RMIM.CA.R020402.Vocabulary.AcknowledgementDetailCode.InternalSystemError);
                }

                // Mesage
                ackDetail.Location = dtl.Location == null ? null : new SET <ST>((ST)dtl.Location, (a, b) => ST.Comparator(a, b));
                ackDetail.Text     = dtl.Message;
                if (dtl.Exception != null)
                {
                    ackDetail.Text += String.Format("({0})", dtl.Exception.Message);
                }

                retVal.Add(ackDetail);
            }

            return(retVal);
        }
Ejemplo n.º 3
0
        // Delegate handles the message available event
        static void connector_MessageAvailable(object sender,
                                               UnsolicitedDataEventArgs e)
        {
            // Cast connector
            WcfServerConnector connector = sender as WcfServerConnector;

            connector.InvalidResponse += new
                                         EventHandler <MessageEventArgs>(connector_InvalidResponse);
            // Receive the structure
            WcfReceiveResult rcvResult = connector.Receive() as WcfReceiveResult;

            if (rcvResult.Structure != null)
            {
                Console.WriteLine(rcvResult.Structure.GetType().Name);
            }

            // Prepare acknowledgement structure
            Acknowledgement acknowledgement = new Acknowledgement();

            // Assign the correlation
            acknowledgement.TargetMessage = new TargetMessage(
                (rcvResult.Structure as IIdentifiable).Id
                );

            // Determine the deserialization outcome
            if (rcvResult.Code != ResultCode.Accepted &&
                rcvResult.Code != ResultCode.AcceptedNonConformant)
            {
                // There were problems parsing the request message
                acknowledgement.TypeCode =
                    AcknowledgementType.AcceptAcknowledgementCommitError;
            }
            else
            {
                // Message is all good
                acknowledgement.TypeCode =
                    AcknowledgementType.AcceptAcknowledgementCommitAccept;
            }

            // Append all details
            foreach (IResultDetail dtl in rcvResult.Details)
            {
                AcknowledgementDetail detail = new AcknowledgementDetail(
                    AcknowledgementDetailType.Information,
                    AcknowledgementDetailCode.SyntaxError,
                    dtl.Message,
                    new SET <ST>((ST)dtl.Location)
                    );
                acknowledgement.AcknowledgementDetail.Add(detail);
            }

            // Create a response
            MCCI_IN000002CA response = new MCCI_IN000002CA(
                new II(Guid.NewGuid()),
                DateTime.Now,
                ResponseMode.Immediate,
                MCCI_IN000002CA.GetInteractionId(),
                MCCI_IN000002CA.GetProfileId(),
                ProcessingID.Production,
                AcknowledgementCondition.Never,
                new Receiver(
                    new Device2(
                        new II()
                        )
                    ),
                new Sender(
                    new
                    Device1(
                        new II("1.1.1.1.1")
                        )
                    ),
                acknowledgement
                );

            // Send the result
            connector.Send(response, rcvResult);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Create a list of ack details from the supplied list of details
        /// </summary>
        public static List <AcknowledgementDetail> CreateAckDetailsUv(IEnumerable <IResultDetail> details)
        {
            List <AcknowledgementDetail> retVal = new List <AcknowledgementDetail>(10);

            foreach (IResultDetail dtl in details ?? new IResultDetail[0])
            {
                // Acknowledgement detail
                var ackDetail = new AcknowledgementDetail()
                {
                    TypeCode =
                        dtl.Type == ResultDetailType.Error ? AcknowledgementDetailType.Error :
                        dtl.Type == ResultDetailType.Warning ? AcknowledgementDetailType.Warning : AcknowledgementDetailType.Information
                };

                // Determine the type of acknowledgement
                if (dtl is InsufficientRepetitionsResultDetail)
                {
                    ackDetail.Code = new CE <string>(Util.ToWireFormat(MARC.Everest.RMIM.CA.R020402.Vocabulary.AcknowledgementDetailCode.InsufficientRepetitions), "2.16.840.1.113883.5.1100");
                }
                else if (dtl is MandatoryElementMissingResultDetail)
                {
                    ackDetail.Code = new CE <string>(Util.ToWireFormat(MARC.Everest.RMIM.CA.R020402.Vocabulary.AcknowledgementDetailCode.MandatoryElementWithNullValue), "2.16.840.1.113883.5.1100");
                }
                else if (dtl is NotImplementedElementResultDetail)
                {
                    ackDetail.Code = new CE <string>(Util.ToWireFormat(MARC.Everest.RMIM.CA.R020402.Vocabulary.AcknowledgementDetailCode.SyntaxError), "2.16.840.1.113883.5.1100");
                }
                else if (dtl is RequiredElementMissingResultDetail)
                {
                    ackDetail.Code = new CE <string>(Util.ToWireFormat(MARC.Everest.RMIM.CA.R020402.Vocabulary.AcknowledgementDetailCode.RequiredElementMissing), "2.16.840.1.113883.5.1100");
                }
                else if (dtl is PersistenceResultDetail)
                {
                    ackDetail.Code = new CE <string>(Util.ToWireFormat(MARC.Everest.RMIM.CA.R020402.Vocabulary.AcknowledgementDetailCode.NoStorageSpaceForMessage), "2.16.840.1.113883.5.1100");
                }
                else if (dtl is VocabularyIssueResultDetail)
                {
                    ackDetail.Code = new CE <string>(Util.ToWireFormat(MARC.Everest.RMIM.CA.R020402.Vocabulary.AcknowledgementDetailCode.TerminologyError), "2.16.840.1.113883.5.1100");
                }
                else if (dtl is FixedValueMisMatchedResultDetail)
                {
                    ackDetail.Code = new CE <string>(Util.ToWireFormat(MARC.Everest.RMIM.CA.R020402.Vocabulary.AcknowledgementDetailCode.ValueDoesNotMatchFixedValue), "2.16.840.1.113883.5.1100");
                }
                else if (dtl is UnsupportedProcessingModeResultDetail)
                {
                    ackDetail.Code = new CE <string>(Util.ToWireFormat(MARC.Everest.RMIM.CA.R020402.Vocabulary.AcknowledgementDetailCode.UnsupportedProcessingMode), "2.16.840.1.113883.5.1100");
                }
                else if (dtl is UnsupportedResponseModeResultDetail)
                {
                    ackDetail.Code = new CE <string>(Util.ToWireFormat(MARC.Everest.RMIM.CA.R020402.Vocabulary.AcknowledgementDetailCode.UnsupportedProcessingId), "2.16.840.1.113883.5.1100");
                }
                else if (dtl is UnsupportedVersionResultDetail)
                {
                    ackDetail.Code = new CE <string>(Util.ToWireFormat(MARC.Everest.RMIM.CA.R020402.Vocabulary.AcknowledgementDetailCode.UnsupportedVersionId), "2.16.840.1.113883.5.1100");
                }
                else if (dtl.Exception is NotImplementedException)
                {
                    ackDetail.Code = new CE <string>(Util.ToWireFormat(MARC.Everest.RMIM.CA.R020402.Vocabulary.AcknowledgementDetailCode.UnsupportedInteraction), "2.16.840.1.113883.5.1100");
                }
                else if (dtl is UnrecognizedSenderResultDetail)
                {
                    ackDetail.Code = new CE <string>(Util.ToWireFormat(MARC.Everest.RMIM.CA.R020402.Vocabulary.AcknowledgementDetailCode.UnknownSender), "2.16.840.1.113883.5.1100");
                }
                else if (dtl is PatientNotFoundResultDetail || dtl is UnrecognizedTargetDomainResultDetail)
                {
                    ackDetail.Code = new CE <string>("204");
                }
                else if (dtl is DetectedIssueResultDetail) // Don't handle these
                {
                    continue;
                }
                else
                {
                    ackDetail.Code = new CE <string>(Util.ToWireFormat(MARC.Everest.RMIM.CA.R020402.Vocabulary.AcknowledgementDetailCode.InternalSystemError), "2.16.840.1.113883.5.1100");
                }

                // Correct the Xpath
                if (!String.IsNullOrEmpty(dtl.Location))
                {
                    dtl.Location += "/";
                    StringBuilder xPath = new StringBuilder();
                    Regex         regEx = new Regex(@"^(\/\/?)(.*?)#(.*?)(\[.*?])?/");
                    while (regEx.IsMatch(dtl.Location))
                    {
                        var match = regEx.Match(dtl.Location);
                        if (match.Groups.Count > 3)
                        {
                            xPath.AppendFormat("{0}*[namespace-uri() = '{1}' and local-name() = '{2}']", match.Groups[1].Value, match.Groups[2].Value, match.Groups[3].Value);
                        }
                        if (match.Groups.Count > 4)
                        {
                            xPath.Append(match.Groups[4].Value);
                        }
                        dtl.Location = regEx.Replace(dtl.Location, "/");
                    }
                    dtl.Location = xPath.ToString();
                }

                // Mesage
                ackDetail.Location = dtl.Location == null ? null : new SET <ST>((ST)dtl.Location, (a, b) => ST.Comparator(a, b));
                ackDetail.Text     = dtl.Message;
                if (dtl.Exception != null)
                {
                    if (ackDetail.Location == null)
                    {
                        ackDetail.Location = new SET <ST>();
                    }
                    ackDetail.Location.Add((ST)String.Format("({0})", dtl.Exception.StackTrace));
                }
                retVal.Add(ackDetail);
            }

            return(retVal);
        }
Ejemplo n.º 5
0
        // Delegate handles the message available event
        static void connector_MessageAvailable(object sender,
                 UnsolicitedDataEventArgs e)
        {
            // Cast connector
            WcfServerConnector connector = sender as WcfServerConnector;
            connector.InvalidResponse += new
                EventHandler<MessageEventArgs>(connector_InvalidResponse);
            // Receive the structure
            WcfReceiveResult rcvResult = connector.Receive() as WcfReceiveResult;

            if (rcvResult.Structure != null)
                Console.WriteLine(rcvResult.Structure.GetType().Name);

            // Prepare acknowledgement structure
            Acknowledgement acknowledgement = new Acknowledgement();

            // Assign the correlation
            acknowledgement.TargetMessage = new TargetMessage(
                     (rcvResult.Structure as IIdentifiable).Id
            );

            // Determine the deserialization outcome
            if (rcvResult.Code != ResultCode.Accepted &&
                rcvResult.Code != ResultCode.AcceptedNonConformant)
                // There were problems parsing the request message
                acknowledgement.TypeCode =
                    AcknowledgementType.AcceptAcknowledgementCommitError;
            else
                // Message is all good
                acknowledgement.TypeCode =
                   AcknowledgementType.AcceptAcknowledgementCommitAccept;

            // Append all details
            foreach (IResultDetail dtl in rcvResult.Details)
            {
                AcknowledgementDetail detail = new AcknowledgementDetail(
                        AcknowledgementDetailType.Information,
                        AcknowledgementDetailCode.SyntaxError,
                        dtl.Message, 
                        new SET<ST>((ST)dtl.Location)
                        );
                acknowledgement.AcknowledgementDetail.Add(detail);
            }

            // Create a response
            MCCI_IN000002CA response = new MCCI_IN000002CA(
                new II(Guid.NewGuid()),
                DateTime.Now,
                ResponseMode.Immediate,
                MCCI_IN000002CA.GetInteractionId(),
                MCCI_IN000002CA.GetProfileId(),
                ProcessingID.Production,
                AcknowledgementCondition.Never,
                new Receiver(
                    new Device2(
                        new II()
                 )
                ),
                new Sender(
                 new
                  Device1(
                        new II("1.1.1.1.1")
                 )
                ),
                acknowledgement
            );

            // Send the result
            connector.Send(response, rcvResult);
        }