예제 #1
0
        /// <summary>
        /// Creates the transport document attachment.
        /// </summary>
        /// <returns>Task.</returns>
        public async Task CreateTransportDocumentAttachment()
        {
            long?id = ConsoleApp.AskId("Enter the Id of the CMR for which to upload the attachment");

            if (id.HasValue)
            {
                var    externalId = ConsoleApp.AskStringValue("ExternalId");
                string path       = ConsoleApp.AskStringValue("Enter the file name to the attachment to upload");
                if (!File.Exists(path))
                {
                    Console.WriteLine("File {0} does not exist", path);

                    return;
                }

                byte[] buffer  = File.ReadAllBytes(path);
                string content = Convert.ToBase64String(buffer);

                var attachment = new TransportDocumentAttachment
                {
                    ExternalId  = externalId,
                    DisplayName = Path.GetFileNameWithoutExtension(path),
                    Filename    = Path.GetFileName(path),
                    Content     = content,
                    MimeType    = System.Web.MimeMapping.GetMimeMapping(path),
                    Type        = "Delivery Note"
                };

                var response = await this.client.PostJsonAsync <TransportDocumentReturnState>(
                    new Uri($"{this.oauthSettings.BaseUrl}/api/v2/transportdocuments/{id.Value}/attachments"),
                    attachment);

                Console.WriteLine("Attachment created with id: {0}", response.Id);
            }
        }
예제 #2
0
        /// <summary>
        /// Gets the transport document by external identifier.
        /// </summary>
        /// <returns>Task.</returns>
        public async Task GetTransportDocumentByExternalId()
        {
            string id = ConsoleApp.AskStringValue("Enter the external Id of the CMR to retrieve");

            if (!string.IsNullOrEmpty(id))
            {
                TransportDocument transportDocument = await this.soapClient.GetTransportDocumentByExternalIdAsync(id);

                if (transportDocument != null)
                {
                    Console.WriteLine();
                    Console.WriteLine("CMR with ID " + transportDocument.Id.ToString() + " succesfully retrieved!");
                    Console.WriteLine();
                    Console.WriteLine();
                }
                else
                {
                    Console.WriteLine("CMR with ID {0} not found!", id);
                }
            }
        }
예제 #3
0
        /// <summary>
        /// Gets the transport document by external identifier.
        /// </summary>
        /// <returns>Task.</returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task GetTransportDocumentByExternalId()
        {
            string id = ConsoleApp.AskStringValue("Enter the external Id of the CMR to retrieve");

            if (!string.IsNullOrEmpty(id))
            {
                var result = await GetTransportDocuments($"filter=externalId eq \"{id}\"");

                TransportDocument transportDocument = result.FirstOrDefault();
                if (transportDocument != null)
                {
                    Console.WriteLine();
                    Console.WriteLine("CMR with ID " + transportDocument.Id.ToString() + " succesfully retrieved!");
                    Console.WriteLine();
                    Console.WriteLine();
                }
                else
                {
                    Console.WriteLine("CMR with ID {0} not found!", id);
                }
            }
        }
예제 #4
0
        /// <summary>
        /// Creates the transport document.
        /// </summary>
        /// <returns>Task.</returns>
        public async Task CreateTransportDocument()
        {
            var dossierNumber = ConsoleApp.AskStringValue("DossierNumber");
            var externalId    = ConsoleApp.AskStringValue("ExternalId");

            TransportDocument newDocument = new TransportDocument
            {
                DossierNumber = dossierNumber,
                ExternalId    = externalId,
                IssuedDate    = DateTime.Today,
                Consignor     = new Contact
                {
                    ExternalId = "14-14",
                    Name       = "ACME Bakeries",
                    Address    = new Address
                    {
                        StreetAddress = "Baron de Maerelaan 8",
                        City          = "Zeebrugge",
                        Postalcode    = "8380",
                    },
                    // Use the signature text to provide the information to put into field 14 of the CMR
                    SignatureText = "ACME Bakeries"
                },
                PrimaryCarrier = new Carrier
                {
                    ExternalId = "16-16",
                    Name       = "PIONIRA",
                    Address    = new Address
                    {
                        StreetAddress = "Baron de Maerelaan 15",
                        City          = "Zeebrugge",
                        Postalcode    = "8380"
                    },
                    License = "9999999",
                    // Use the signature text to provide the information to put into field 15 of the CMR
                    SignatureText = "Transport PIONIRA"
                },
                Consignee = new Contact
                {
                    ExternalId = "15-15",
                    Name       = "ACME Warehouse",
                    Address    = new Address
                    {
                        StreetAddress = "Baron de Maerelaan 8",
                        City          = "Gent",
                        Postalcode    = "9000"
                    }
                },
                TransportExecutions = new TransportExecution[]
                {
                    new TransportExecution
                    {
                        Driver = new Driver
                        {
                            Name       = "John Doe",
                            ExternalId = "JOHNDOE_42"
                        },
                        Truck = new Vehicle
                        {
                            ExternalId   = "12345",
                            LicensePlate = "5-JNK-736"
                        },
                        Trailer = new Vehicle
                        {
                            ExternalId   = "67890",
                            LicensePlate = "5-TRV-368"
                        },
                    }
                },
                //GoodsText = "2 pal. bruin brood",
                Goods = new Product[]
                {
                    new Product
                    {
                        Code        = "Code",
                        Description = "u",
                        LotNumber   = "-",
                        Quantity    = 5,
                        Reference   = "8",
                        SealNumber  = "Sealnr",
                        ExternalId  = "4646",
                    },
                    new Product
                    {
                        Code       = "Code2",
                        SealNumber = "Sealnr",
                        ExternalId = "422646",
                    }
                },
                ECmr = true
            };

            TransportDocumentReturnState state = await this.client.PostJsonAsync <TransportDocumentReturnState>(new Uri(this.oauthSettings.BaseUrl + "/api/v2/transportdocuments"), newDocument);

            if (state != null)
            {
                Console.WriteLine("CMR succesfully created!");
                DumpReturnState(state);
            }
        }
예제 #5
0
        /// <summary>
        /// Creates the transport document.
        /// </summary>
        /// <returns>Task.</returns>
        public async Task CreateTransportDocument()
        {
            var dossierNumber = ConsoleApp.AskStringValue("DossierNumber");
            var externalId    = ConsoleApp.AskStringValue("ExternalId");

            TransportDocument newDocument = new TransportDocument
            {
                DossierNumber = dossierNumber,
                ExternalId    = externalId,
                IssuedDate    = DateTime.Today,
                IssuedPlace   = "Zeebrugge",
                Consignor     = new Contact
                {
                    ExternalId   = "14-14",
                    Name         = "ACME Bakeries",
                    EmailAddress = "*****@*****.**",
                    Address      = new Address
                    {
                        StreetAddress = "Baron de Maerelaan 8",
                        City          = "Zeebrugge",
                        Postalcode    = "8380",
                    },
                    // Use the signature text to provide the information to put into field 14 of the CMR
                    SignatureText = "ACME Bakeries"
                },
                Pickup = new Destination
                {
                    ExternalId = "14-14",
                    Name       = "ACME Bakeries",
                    Address    = new Address
                    {
                        StreetAddress = "Baron de Maerelaan 8",
                        City          = "Zeebrugge",
                        Postalcode    = "8380",
                    },
                    Datetime = DateTime.Now.AddDays(1),
                    // Use the signature text to provide the information to put into field 14 of the CMR
                    SignatureText = "ACME Bakeries"
                },
                PrimaryCarrier = new Carrier
                {
                    ExternalId = "16-16",
                    Name       = "PIONIRA",
                    Address    = new Address
                    {
                        StreetAddress = "Baron de Maerelaan 15",
                        City          = "Zeebrugge",
                        Postalcode    = "8380"
                    },
                    License = "9999999",
                    // Use the signature text to provide the information to put into field 15 of the CMR
                    SignatureText = "Transport PIONIRA"
                },
                Consignee = new Contact
                {
                    ExternalId = "15-15",
                    Name       = "ACME Warehouse",
                    Address    = new Address
                    {
                        StreetAddress = "Baron de Maerelaan 8",
                        City          = "Gent",
                        Postalcode    = "9000"
                    }
                },
                Delivery = new Destination
                {
                    Datetime   = DateTime.Now.AddDays(2),
                    ExternalId = "15-15",
                    Name       = "ACME Warehouse",
                    Address    = new Address
                    {
                        StreetAddress = "Baron de Maerelaan 8",
                        City          = "Gent",
                        Postalcode    = "9000"
                    }
                },
                TransportExecutions = new TransportExecution[]
                {
                    new TransportExecution
                    {
                        Driver = new Driver
                        {
                            Name       = "John Doe",
                            ExternalId = "JOHNDOE_42"
                        },
                        Truck = new Vehicle
                        {
                            ExternalId   = "12345",
                            LicensePlate = "5-JNK-736"
                        },
                        Trailer = new Vehicle
                        {
                            ExternalId   = "67890",
                            LicensePlate = "5-TRV-368"
                        },
                    }
                },
                GoodsText = "2 pal. bruin brood",
                Goods     = new Product[]
                {
                    new Product
                    {
                        Code       = "Code",
                        SealNumber = "Sealnr",
                        ExternalId = "4646",
                    }
                },
                ECmr = true
            };

            TransportDocumentReturnState state = await this.soapClient.CreateTransportDocumentAsync(newDocument);

            if (state != null)
            {
                Console.WriteLine("CMR succesfully created!");
                DumpReturnState(state);
            }
        }