示例#1
0
        private static void EnrichSalesOrder(BasicSalesOrder basicSalesOrder, string id)
        {
            var authApi         = new AuthApi(SiteURL);
            var cookieContainer = new CookieContainer();

            authApi.Configuration.ApiClient.RestClient.CookieContainer = cookieContainer;
            try {
                LogIn(authApi);

                var soApi = new SalesOrderApi();

                List <SalesOrder> soOrders = soApi.SalesOrderGetList(filter: $"OrderNbr eq '{basicSalesOrder.OrderNbr}'");

                Console.WriteLine($"Enriched SOOrder for OrderNbr {basicSalesOrder.OrderNbr}");
                Console.WriteLine($"Id: {soOrders[0].Id.Value}");
                Console.WriteLine($"Status: {soOrders[0].Status.Value}");
                Console.WriteLine($"Order Number: {soOrders[0].OrderNbr.Value}");
                Console.WriteLine($"Order Type: {soOrders[0].OrderType.Value}");
                Console.WriteLine($"Order Quantity: {soOrders[0].OrderedQty.Value}");
                Console.WriteLine($"Order Total: {soOrders[0].OrderTotal.Value}");
                Console.WriteLine($"CustomerId: {soOrders[0].CustomerID.Value}");
                Console.WriteLine($"Last Modified: {soOrders[0].LastModified.Value}");
            }
            catch (Exception e) {
                Console.WriteLine(e.Message);
            }
            finally {
                //we use logout in finally block because we need to always logut, even if the request failed for some reason
                authApi.AuthLogout();
            }
        }
        public static void ExampleMethod(string siteURL, string username, string password, string tenant = null, string branch = null, string locale = null)
        {
            var authApi = new AuthApi(siteURL);

            try
            {
                var configuration = LogIn(authApi, siteURL, username, password, tenant, branch, locale);

                Console.WriteLine("Reading Accounts...");
                var accountApi = new AccountApi(configuration);
                var accounts   = accountApi.GetList(top: 5);
                foreach (var account in accounts)
                {
                    Console.WriteLine("Account Nbr: " + account.AccountCD.Value + ";");
                }

                Console.WriteLine("Reading Sales Order by Keys...");
                var salesOrderApi = new SalesOrderApi(configuration);
                var order         = salesOrderApi.GetByKeys(new List <string>()
                {
                    "SO", "SO005207"
                });
                Console.WriteLine("Order Total: " + order.OrderTotal.Value);


                var shipmentApi = new ShipmentApi(configuration);
                var shipment    = shipmentApi.GetByKeys(new List <string>()
                {
                    "002805"
                });
                Console.WriteLine("ConfirmShipment");
                shipmentApi.WaitActionCompletion(shipmentApi.InvokeAction(new ConfirmShipment(shipment)));

                Console.WriteLine("CorrectShipment");
                shipmentApi.WaitActionCompletion(shipmentApi.InvokeAction(new CorrectShipment(shipment)));
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                //we use logout in finally block because we need to always logut, even if the request failed for some reason
                authApi.AuthLogout();
                Console.WriteLine("Logged Out...");
            }
        }
 public void Dispose()
 {
     _auth.AuthLogout();
 }