Ejemplo n.º 1
0
        protected void Insert_Items(MarketplaceWebServiceOrders.MarketplaceWebServiceOrders client)
        {
            ListOrderItemsRequest request = new ListOrderItemsRequest();

            request.SellerId = SellerId;

            Base_BL bbl = new Base_BL();

            aml = new Amazon__BL();
            Amazon_Juchuu_Items = D_AmazonJuchuuItems();
            var dtAmazonOrderId = aml.Select_AllOrderByLastRireki();
            int j = 0; int i = 0;

            foreach (DataRow dr in dtAmazonOrderId.Rows)
            {
                j++;
                request.AmazonOrderId = dr["AmazonOrderId"].ToString();

                ListOrderItemsResponse response = client.ListOrderItems(request);
                if (response.IsSetListOrderItemsResult())
                {
                    ListOrderItemsResult listOrderItemsResult = response.ListOrderItemsResult;
                    if (listOrderItemsResult.IsSetOrderItems())
                    {
                        List <OrderItem> orderItems = listOrderItemsResult.OrderItems;

                        foreach (OrderItem orderItem in orderItems)
                        {
                            i++;
                            Amazon_Juchuu_Items_Add(request.AmazonOrderId, orderItem, j, i);
                            //  strbuff += "商品名:" + orderItem.Title + System.Environment.NewLine;
                        }
                    }
                }
            }


            Amazon__Entity ameDetails = new Amazon__Entity();

            ameDetails.StoreCD       = StoreCD;
            ameDetails.APIKey        = APIKey;
            ameDetails.XmlOrderItems = bbl.DataTableToXml(Amazon_Juchuu_Items);
            if (aml.Amazon_InsertOrderItemDetails(ameDetails))
            {
                Console.Write("All Items are Imported Successffully!!!");
                Console.ReadLine();
            }
        }
Ejemplo n.º 2
0
        public static void Main(string[] args)
        {
            //GetOrderList();

            Console.Title = "Amazon API Console. . . ";
            Console.WriteLine("Started " + "Amazon__API Started" + " . . . ");
            if (loginbl.ReadConfig() == true)
            {
                CommonAPI  api = new CommonAPI();
                Amazon__BL abl = new Amazon__BL();
                if (abl.Allow_Check())
                {
                    api.ListOrders();
                }
                else
                {
                    Environment.Exit(0);
                }
            }
        }
Ejemplo n.º 3
0
        public void ListOrders()
        {
            ame = new Amazon__Entity();
            aml = new Amazon__BL();

            ame = aml.MAPI_DRequest();
            //string SellerId = CommonValue.strMerchantId;
            //string MarketplaceId = CommonValue.strMarketplaceId;
            //string AccessKeyId = CommonValue.strAccessKeyId;
            //string SecretKeyId = CommonValue.strSecretKeyId;
            //string ApplicationVersion = CommonValue.strApplicationVersion;
            //string ApplicationName = CommonValue.strApplicationName;
            //string MWSAuthToken = CommonValue.strMWSAuthToken;
            //string strbuff = string.Empty;
            SellerId      = ame.strMerchantId;
            MarketplaceId = ame.strMarketplaceId;
            AccessKeyId   = ame.strAccessKeyId;
            MWSAuthToken  = ame.strMWSAuthToken;
            SecretKeyId   = ame.strSecretKeyId;
            APIKey        = ame.APIKey;
            StoreCD       = ame.StoreCD;
            string ApplicationVersion = CommonValue.strApplicationVersion;
            string ApplicationName    = CommonValue.strApplicationName;

            DataTable strbuff = new DataTable();

            var LastUpdatedBefore = aml.Amazon_DRequest();

            if (LastUpdatedBefore != null)
            {
                UpdatedTimeBefore = Convert.ToDateTime(LastUpdatedBefore).AddDays(-1);
            }
            else
            {
                UpdatedTimeBefore = DateTime.Now;;
            }
            MarketplaceWebServiceOrdersConfig config = new MarketplaceWebServiceOrdersConfig();

            config.ServiceURL = CommonValue.strServiceURL;
            MarketplaceWebServiceOrders.MarketplaceWebServiceOrders client = new MarketplaceWebServiceOrdersClient(
                AccessKeyId,
                SecretKeyId,
                ApplicationName,
                ApplicationVersion,
                config);
            ListOrdersRequest request = new ListOrdersRequest();

            request.SellerId         = SellerId;
            request.LastUpdatedAfter = UpdatedTimeBefore;

            List <string> lstMarketplace = new List <string>();

            lstMarketplace.Add(MarketplaceId);
            request.MarketplaceId     = lstMarketplace;
            request.MWSAuthToken      = MWSAuthToken;
            request.MaxResultsPerPage = 40;
            ListOrdersResponse response         = client.ListOrders(request);
            ListOrdersResult   listOrdersResult = new ListOrdersResult();

            if (response.IsSetListOrdersResult())
            {
                listOrdersResult = response.ListOrdersResult;
                if (listOrdersResult.IsSetOrders())
                {
                    List <Order> orders = listOrdersResult.Orders;
                    strbuff.Columns.Add("StoreCD");
                    strbuff.Columns.Add("APIKey");
                    strbuff.Columns.Add("SEQ");
                    strbuff.Columns.Add("OrderId");
                    int i = 0;
                    Amazon_Juchuu = D_AmazonJuchuu();
                    foreach (Order o in orders)
                    {
                        i++;
                        strbuff.Rows.Add(StoreCD, APIKey, i, o.AmazonOrderId);
                        GetListOrderdata(o, i);
                    }
                }
                // txtListOrders.Text = strbuff;
            }
            Base_BL bbl = new Base_BL();
            string  OrderDetails = ""; string AmazonOrderId = "";

            OrderDetails  = bbl.DataTableToXml(Amazon_Juchuu);
            AmazonOrderId = bbl.DataTableToXml(strbuff);
            TokenNo       = TokenNo + 1;
            Insert_FirstToken(listOrdersResult, OrderDetails, AmazonOrderId);

            if (listOrdersResult.NextToken != null)
            {
                Insert_NextToken(response.ListOrdersResult.NextToken);
            }

            Insert_Items(client);

            Console.Read();


            //
            //else
            //{
            //    Console.Write("Order Inserted Successfully!!!");
            //    Console.Read();
            //}
        }