Example #1
0
        /// <summary>
        /// Create a domain identifier list
        /// </summary>
        //internal static List<DomainIdentifier> CreateDomainIdentifierList(List<MARC.Everest.RMIM.CA.R020403.REPC_MT500006CA.RecordId> list)
        //{
        //    List<DomainIdentifier> retVal = new List<DomainIdentifier>();
        //    foreach (var recId in list)
        //        retVal.Add(new DomainIdentifier()
        //        {
        //            Domain = recId.Value.Root,
        //            Identifier = recId.Value.Extension
        //        });
        //    return retVal;
        //}

        /// <summary>
        /// Validates common transport wrapper flags
        /// </summary>
        public static void ValidateTransportWrapper(IInteraction interaction, ISystemConfigurationService config, List <IResultDetail> dtls)
        {
            // Check the response mode code
            string rspMode  = Util.ToWireFormat((interaction as IImplementsResponseModeCode <ResponseMode>).ResponseModeCode);
            string procMode = Util.ToWireFormat((interaction as IImplementsProcessingCode <ProcessingID>).ProcessingCode);

            var profile = interaction as IImplementsProfileId;

            // Check response mode
            if (rspMode != "I")
            {
                dtls.Add(new UnsupportedResponseModeResultDetail(rspMode));
            }
            //// Check processing id
            //if (procMode != "P" && procMode != "D")
            //    dtls.Add(new UnsupportedProcessingModeResultDetail(procMode));

            // Check version identifier
            if (!interaction.VersionCode.CodeValue.Equals("V3-2008N"))
            {
                dtls.Add(new UnsupportedVersionResultDetail(String.Format("Version '{0}' is not supported by this endpoint", interaction.VersionCode)));
            }
            else if (profile == null || profile.ProfileId.Count(o => II.Comparator(o, MCCI_IN000002CA.GetProfileId()[0]) == 0) == 0)
            {
                dtls.Add(new UnsupportedVersionResultDetail(String.Format("Supplied profile identifier does not match any profile identifier this endpoint can reliably process")));
            }


            Sender sndr = interaction.GetType().GetProperty("Sender").GetValue(interaction, null) as Sender;

            if (sndr == null || sndr.NullFlavor != null || sndr.Device == null || sndr.Device.NullFlavor != null || sndr.Device.Id == null || sndr.Device.Id.IsNull)
            {
                dtls.Add(new MandatoryElementMissingResultDetail(ResultDetailType.Error, "Sender information is missing from message", null));
            }
            else
            {
                var sndrId = new DomainIdentifier()
                {
                    Domain = sndr.Device.Id.Root, Identifier = sndr.Device.Id.Extension
                };
                if (!config.IsRegisteredDevice(sndrId))
                {
                    dtls.Add(new UnrecognizedSenderResultDetail(sndrId));
                }
            }
        }