Print Order [pending]

-1

Good afternoon,

I'm using the Jasmin API to automatically perform Orders.

Once the order has been placed, if you enter Jasmin and try to print the same it will be in loading and will not print, if you try to send by email it even says that the file does not exist.

I'm testing with the sample code that is in github.

I've also gone to Setup - > System - > Models - > Document template - > and removed the logo (as a colleague on another topic indicated to do).

If you place the order manually in Jasmin it already prints normal.

I have a function that goes to a DB and creates an Order and then invokes the API.

 foreach (DataRow row in ds.Tables["getFacturas"].Rows)
        {
            Entities.Order order = new Entities.Order();

            order.Company = "DEFAULT";
            order.DocumentType = "ECL";
            order.DocumentDate = DateTime.UtcNow;
            order.CustomerId = row["Cliente"].ToString();
            order.Currency = "EUR";

            sqlCmd = new SqlCommand();
            sqlCmd.CommandType = System.Data.CommandType.StoredProcedure;
            sqlCmd.CommandText = "getLinhasFacturas";
            sqlCmd.Parameters.Add(new SqlParameter("@Cliente", row["Cliente"].ToString()));
            sqlCmd.Connection = conn;
            conn.Open();
            SqlDataAdapter da1 = new SqlDataAdapter(sqlCmd);
            da1.Fill(ds, "getLinhasFacturas");
            conn.Close();

            List<OrderLine> linhasFactura = new List<OrderLine>();
            foreach (DataRow rowLinhas in ds.Tables["getLinhasFacturas"].Rows)
            {
                Price price = new Price();
                price.Value = double.Parse(rowLinhas["Valor"].ToString());
                price.Currency = "€";

                OrderLine orderLine = new OrderLine();
                orderLine.ItemId = rowLinhas["Produto"].ToString();
                orderLine.Quantity = int.Parse(rowLinhas["Quantidade"].ToString());
                orderLine.Type = 1;
                orderLine.Price = price;

                linhasFactura.Add(orderLine);
            }

            ds.Tables["getLinhasFacturas"].Clear();

            order.Lines = linhasFactura;
            await OrdersController.CreateOrderAsync(order);
        }

Invoke API

public static async Task CreateOrderAsync(Entities.Order order)
    {
        // Build the order that should be created


        try
        {


            // Create the HTTP client to perform the request

            using (HttpClient client = new HttpClient())
            {
                // Build the request

                string request = "sales/orders";
                string resourceLocation = string.Format("{0}/api/{1}/{2}/{3}/", Constants.Constants.baseAppUrl, AccountKey, SubscriptionKey, request);

                client.DefaultRequestHeaders.Accept.Clear();

                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Token);

                HttpRequestMessage postOrderMessage = new HttpRequestMessage(HttpMethod.Post, resourceLocation);

                string invoiceRequest = JsonConvert.SerializeObject(order);

                postOrderMessage.Content = new StringContent(invoiceRequest, Encoding.UTF8, "application/json");

                // Send

                using (HttpResponseMessage responseContent = await client.SendAsync(postOrderMessage))
                {
                    // Get the response

                    if (responseContent.IsSuccessStatusCode)
                    {
                        string result = await ((StreamContent)responseContent.Content).ReadAsStringAsync();
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.WriteLine(string.Concat("Order created: ", result));
                    }
                    else
                    {
                        Console.WriteLine(string.Concat("Failed. ", responseContent.ToString()));
                        string result = await ((StreamContent)responseContent.Content).ReadAsStringAsync();
                        Console.WriteLine(string.Concat("Content: ", result));

                        throw new Exception("Unable to create the order.");
                    }
                }
            }
        }
        catch (Exception)
        {
            throw new Exception("Error creating the order.");
        }
    }
    
asked by anonymous 04.01.2019 / 14:12

0 answers