示例#1
0
        public static Header Read(StandardBusinessDocumentHeader sbdh) // throws SbdhException
        {
            Header header = Header.NewInstance();

            // Sender
            PartnerIdentification senderIdentifier = sbdh.Sender[0].Identifier;

            header = header.SetSender(
                ParticipantIdentifier.Of(senderIdentifier.Value, Scheme.Of(senderIdentifier.Authority)));

            // Receiver
            PartnerIdentification receiverIdentifier = sbdh.Receiver[0].Identifier;

            header = header.SetReceiver(
                ParticipantIdentifier.Of(receiverIdentifier.Value, Scheme.Of(receiverIdentifier.Authority)));

            // Identifier
            header = header.SetIdentifier(InstanceIdentifier.Of(sbdh.DocumentIdentification.InstanceIdentifier));

            // InstanceType
            header = header.SetInstanceType(
                InstanceType.Of(
                    sbdh.DocumentIdentification.Standard,
                    sbdh.DocumentIdentification.Type,
                    sbdh.DocumentIdentification.TypeVersion));

            // CreationTimestamp
            if (sbdh.DocumentIdentification.CreationDateAndTime == null)
            {
                throw new SbdhException("Element 'CreationDateAndTime' is not set or contains invalid value.");
            }

            header = header.SetCreationTimestamp(sbdh.DocumentIdentification.CreationDateAndTime);

            // Scope
            foreach (Scope scope in sbdh.BusinessScope)
            {
                if (scope.Type.Equals("DOCUMENTID"))
                {
                    Scheme scheme = scope.Identifier != null
                                        ? Scheme.Of(scope.Identifier)
                                        : DocumentTypeIdentifier.DefaultScheme;

                    header = header.SetDocumentType(DocumentTypeIdentifier.Of(scope.InstanceIdentifier, scheme));
                }
                else if (scope.Type.Equals("PROCESSID"))
                {
                    Scheme scheme = scope.Identifier != null
                                        ? Scheme.Of(scope.Identifier)
                                        : ProcessIdentifier.DefaultScheme;

                    header = header.SetProcess(ProcessIdentifier.Of(scope.InstanceIdentifier, scheme));
                }
            }

            return(header);
        }
示例#2
0
        public static Partner CreatePartner(ParticipantIdentifier participant)
        {
            PartnerIdentification partnerIdentification = new PartnerIdentification();

            partnerIdentification.Authority = participant.Scheme.Identifier;
            partnerIdentification.Value     = participant.Identifier;

            Partner partner = new Partner();

            partner.Identifier = partnerIdentification;
            return(partner);
        }
示例#3
0
 public Receiver(PartnerIdentification identifier) : base(identifier)
 {
 }
示例#4
0
 public Sender(PartnerIdentification identification) : base(identification)
 {
 }