public bool AmazonAPI_Insert_NextToken(Amazon__Entity ame)
        {
            Dictionary <string, ValuePair> dic = new Dictionary <string, ValuePair>
            {
                { "@StoreCD", new ValuePair {
                      value1 = SqlDbType.VarChar, value2 = ame.StoreCD
                  } },
                { "@API_Key", new ValuePair {
                      value1 = SqlDbType.TinyInt, value2 = ame.APIKey
                  } },

                { "@LastUpdatedBefore", new ValuePair {
                      value1 = SqlDbType.DateTime, value2 = ame.LastUpdatedBefore
                  } },
                { "@LastUpdatedAfter", new ValuePair {
                      value1 = SqlDbType.DateTime, value2 = ame.LastUpdatedAfter
                  } },

                { "@xmldetail", new ValuePair {
                      value1 = SqlDbType.Xml, value2 = ame.Xmldetails
                  } },
                { "@xml", new ValuePair {
                      value1 = SqlDbType.Xml, value2 = ame.XmlOrder
                  } }
            };

            UseTransaction = true;
            return(InsertUpdateDeleteData(dic, "Amazon_API_Insert_NextToken"));
        }
        public Amazon__Entity MAPI_DRequest()
        {
            Amazon__Entity ame = new Amazon__Entity();
            DataTable      dt  = adl.MAPI_DRequest();

            ame.strMerchantId    = dt.Rows[0]["SellerId"].ToString();
            ame.strMarketplaceId = dt.Rows[0]["MarketplaceId"].ToString();
            ame.strMWSAuthToken  = dt.Rows[0]["MWSAuthToken"].ToString();
            ame.strAccessKeyId   = dt.Rows[0]["AccessKeyId"].ToString();
            ame.strSecretKeyId   = dt.Rows[0]["ServiceSecret"].ToString();
            ame.APIKey           = dt.Rows[0]["APIKey"].ToString();
            ame.StoreCD          = dt.Rows[0]["StoreCD"].ToString();
            return(ame);
        }
        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();
            }
        }
        public bool Amazon_InsertOrderItemDetails(Amazon__Entity ame)
        {
            Dictionary <string, ValuePair> dic = new Dictionary <string, ValuePair>
            {
                { "@StoreCD", new ValuePair {
                      value1 = SqlDbType.VarChar, value2 = ame.StoreCD
                  } },
                { "@API_Key", new ValuePair {
                      value1 = SqlDbType.TinyInt, value2 = ame.APIKey
                  } },
                { "@xml", new ValuePair {
                      value1 = SqlDbType.Xml, value2 = ame.XmlOrderItems
                  } }
            };

            UseTransaction = true;
            return(InsertUpdateDeleteData(dic, "Amazon_InsertOrderItemDetails"));
        }
        protected void Insert_FirstToken(ListOrdersResult respone, string OrderDetails, string AmazonOrderId)
        {
            Amazon__Entity ameDetails = new Amazon__Entity();

            ameDetails.StoreCD           = StoreCD;
            ameDetails.APIKey            = APIKey;
            ameDetails.LastUpdatedAfter  = UpdatedTimeBefore.ToString();
            ameDetails.LastUpdatedBefore = respone.LastUpdatedBefore.ToString();
            ameDetails.Xmldetails        = OrderDetails;
            ameDetails.XmlOrder          = AmazonOrderId;
            if (aml.AmazonAPI_InsertOrderDetails(ameDetails))
            {
                Console.WriteLine("Successfully Inserted Token " + (TokenNo).ToString() + "Times");
            }
            else
            {
                Console.WriteLine("Unfortunately Inserted Failed Token " + (TokenNo).ToString() + "Times");
            }
        }
 public bool Amazon_InsertOrderItemDetails(Amazon__Entity OrderItems)
 {
     return(adl.Amazon_InsertOrderItemDetails(OrderItems));
 }
 public bool AmazonAPI_Insert_NextToken(Amazon__Entity ame)
 {
     return(adl.AmazonAPI_Insert_NextToken(ame));
 }
 public bool AmazonAPI_InsertOrderDetails(Amazon__Entity ame)
 {
     return(adl.AmazonAPI_InsertOrderDetails(ame));
 }
        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();
            //}
        }
Esempio n. 10
0
        public void Insert_NextToken(string token = null)
        {
            Amazon_Juchuu_NextToken = D_AmazonJuchuu();
            Base_BL   bbl     = new Base_BL();
            DataTable strbuff = new DataTable();

            strbuff.Columns.Add("StoreCD");
            strbuff.Columns.Add("APIKey");
            strbuff.Columns.Add("SEQ");
            strbuff.Columns.Add("OrderId");
            MarketplaceWebServiceOrdersConfig config = new MarketplaceWebServiceOrdersConfig();

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

            if (token != null)
            {
                ListOrdersByNextTokenRequest request1 = new ListOrdersByNextTokenRequest();
                ListOrdersByNextTokenResult  listOrdersByNextResult = new ListOrdersByNextTokenResult();
                request1.SellerId     = SellerId;
                request1.MWSAuthToken = MWSAuthToken;
                request1.NextToken    = token;
                ListOrdersByNextTokenResponse response1 = client.ListOrdersByNextToken(request1);
                if (response1.IsSetListOrdersByNextTokenResult())
                {
                    listOrdersByNextResult = response1.ListOrdersByNextTokenResult;
                    if (listOrdersByNextResult.IsSetOrders())
                    {
                        List <Order> orders = listOrdersByNextResult.Orders;
                        int          i      = 0;
                        foreach (Order o in orders)
                        {
                            i++;
                            strbuff.Rows.Add(StoreCD, APIKey, i, o.AmazonOrderId);
                            GetListOrderdata(o, i, false);
                        }
                    }
                }
                Amazon__Entity ameDetails = new Amazon__Entity();
                ameDetails.StoreCD           = StoreCD;
                ameDetails.APIKey            = APIKey;
                ameDetails.LastUpdatedAfter  = UpdatedTimeBefore.ToString();
                ameDetails.LastUpdatedBefore = listOrdersByNextResult.LastUpdatedBefore.ToString();
                ameDetails.Xmldetails        = bbl.DataTableToXml(Amazon_Juchuu_NextToken);
                ameDetails.XmlOrder          = bbl.DataTableToXml(strbuff);

                TokenNo = TokenNo + 1;
                if (aml.AmazonAPI_Insert_NextToken(ameDetails))
                {
                    Console.WriteLine("Successfully Inserted Token " + (TokenNo).ToString() + "Times");
                }
                else
                {
                    Console.WriteLine("Unfortunately Inserted Failed Token " + (TokenNo).ToString() + "Times");
                }
                Insert_NextToken(listOrdersByNextResult.NextToken);
            }
            else/// To be Continued. . . Insert
            {
                Console.Write("Order inserted Successfully!!!");
                Console.Read();
            }
        }