Пример #1
0
        /// <summary>
        /// Issue receive advice
        /// </summary>
        private void IssueReceiveAdvice(Act act)
        {
            var receiveMessage = new ReceivingAdviceMessageType();

            receiveMessage.StandardBusinessDocumentHeader = this.m_gs1Util.CreateDocumentHeader("receivingAdvice", act.LoadCollection <ActParticipation>("Participations").FirstOrDefault(o => o.ParticipationRoleKey == ActParticipationKey.Authororiginator).LoadProperty <Entity>("PlayerEntity"));

            var originalOrder = act.LoadCollection <ActRelationship>("Relationships").FirstOrDefault(o => o.RelationshipTypeKey == ActRelationshipTypeKeys.Arrival)?.LoadProperty <Act>("TargetAct");

            Place shipTo   = act.LoadCollection <ActParticipation>("Participations").FirstOrDefault(o => o.ParticipationRoleKey == ActParticipationKey.Location)?.LoadProperty <Place>("PlayerEntity"),
                  shipFrom = originalOrder.LoadCollection <ActParticipation>("Participations").FirstOrDefault(o => o.ParticipationRoleKey == ActParticipationKey.Location)?.LoadProperty <Place>("PlayerEntity");

            // Receive message advice
            receiveMessage.receivingAdvice = new ReceivingAdviceType[]
            {
                new ReceivingAdviceType()
                {
                    creationDateTime              = act.CreationTime.DateTime,
                    documentStatusCode            = DocumentStatusEnumerationType.ORIGINAL,
                    receivingAdviceIdentification = new Ecom_EntityIdentificationType()
                    {
                        entityIdentification = act.Key.ToString()
                    },
                    receivingDateTime = act.ActTime.DateTime,
                    despatchAdvice    = new Ecom_DocumentReferenceType()
                    {
                        entityIdentification      = originalOrder.Identifiers.FirstOrDefault()?.Value ?? originalOrder.Key.Value.ToString(),
                        creationDateTime          = originalOrder.ActTime.DateTime,
                        creationDateTimeSpecified = true,
                        contentOwner = new Ecom_PartyIdentificationType()
                        {
                            additionalPartyIdentification = originalOrder.Identifiers.Count > 0 ? new AdditionalPartyIdentificationType[]
                            {
                                new AdditionalPartyIdentificationType()
                                {
                                    Value = originalOrder.Identifiers.FirstOrDefault()?.Authority.Oid, additionalPartyIdentificationTypeCode = "urn:oid:"
                                },
                            } : null,
                        }
                    },
                    reportingCode = new GoodsReceiptReportingCodeType()
                    {
                        Value = "FULL_DETAILS"
                    },
                    shipper  = this.m_gs1Util.CreateLocation(shipFrom),
                    shipTo   = this.m_gs1Util.CreateLocation(shipTo),
                    receiver = this.m_gs1Util.CreateLocation(shipTo),
                    receivingAdviceLogisticUnit = act.Participations.Where(o => o.ParticipationRoleKey == ActParticipationKey.Consumable).Select(o => this.m_gs1Util.CreateReceiveLineItem(o, originalOrder.Participations.FirstOrDefault(p => p.PlayerEntityKey == o.PlayerEntityKey))).ToArray()
                }
            };

            for (int i = 0; i < receiveMessage.receivingAdvice[0].receivingAdviceLogisticUnit.Length; i++)
            {
                receiveMessage.receivingAdvice[0].receivingAdviceLogisticUnit[i].receivingAdviceLineItem[0].lineItemNumber = (i + 1).ToString();
            }


            // Queue The order on the file system
            this.QueueMessage(receiveMessage);
        }
Пример #2
0
        /// <summary>
        /// Issue an order
        /// </summary>
        public void IssueReceivingAdvice(ReceivingAdviceMessageType advice)
        {
            String boundary = String.Format("------{0:N}", Guid.NewGuid());

            if (this.m_configuration.UseAS2MimeEncoding)
            {
                this.Client.Post <MultipartAttachment, object>("receivingAdvice", String.Format("multipart/form-data; boundary={0}", boundary), this.CreateAttachment(advice));
            }
            else
            {
                this.Client.Post <ReceivingAdviceMessageType, object>("receivingAdvice", "application/xml", advice);
            }
        }