示例#1
0
        /// <summary>
        /// Continues pagination over a resultset of inventory data for inventory
        /// items.
        ///
        /// This operation is used in conjunction with ListUpdatedInventorySupply.
        /// Please refer to documentation for that operation for further details.
        ///
        /// </summary>
        /// <param name="service">Instance of FBAInventoryServiceMWS service</param>
        /// <param name="request">ListInventorySupplyByNextTokenRequest request</param>
        public static void InvokeListInventorySupplyByNextToken(FBAInventoryServiceMWS service, ListInventorySupplyByNextTokenRequest request)
        {
            try
            {
                ListInventorySupplyByNextTokenResponse response = service.ListInventorySupplyByNextToken(request);


                Console.WriteLine("Service Response");
                Console.WriteLine("=============================================================================");
                Console.WriteLine();

                Console.WriteLine("        ListInventorySupplyByNextTokenResponse");
                if (response.IsSetListInventorySupplyByNextTokenResult())
                {
                    Console.WriteLine("            ListInventorySupplyByNextTokenResult");
                    ListInventorySupplyByNextTokenResult listInventorySupplyByNextTokenResult = response.ListInventorySupplyByNextTokenResult;
                    if (listInventorySupplyByNextTokenResult.IsSetInventorySupplyList())
                    {
                        Console.WriteLine("                InventorySupplyList");
                        InventorySupplyList    inventorySupplyList = listInventorySupplyByNextTokenResult.InventorySupplyList;
                        List <InventorySupply> memberList          = inventorySupplyList.member;
                        foreach (InventorySupply member in memberList)
                        {
                            Console.WriteLine("                    member");
                            if (member.IsSetSellerSKU())
                            {
                                Console.WriteLine("                        SellerSKU");
                                Console.WriteLine("                            {0}", member.SellerSKU);
                            }
                            if (member.IsSetFNSKU())
                            {
                                Console.WriteLine("                        FNSKU");
                                Console.WriteLine("                            {0}", member.FNSKU);
                            }
                            if (member.IsSetASIN())
                            {
                                Console.WriteLine("                        ASIN");
                                Console.WriteLine("                            {0}", member.ASIN);
                            }
                            if (member.IsSetCondition())
                            {
                                Console.WriteLine("                        Condition");
                                Console.WriteLine("                            {0}", member.Condition);
                            }
                            if (member.IsSetTotalSupplyQuantity())
                            {
                                Console.WriteLine("                        TotalSupplyQuantity");
                                Console.WriteLine("                            {0}", member.TotalSupplyQuantity);
                            }
                            if (member.IsSetInStockSupplyQuantity())
                            {
                                Console.WriteLine("                        InStockSupplyQuantity");
                                Console.WriteLine("                            {0}", member.InStockSupplyQuantity);
                            }
                            if (member.IsSetEarliestAvailability())
                            {
                                Console.WriteLine("                        EarliestAvailability");
                                Timepoint earliestAvailability = member.EarliestAvailability;
                                if (earliestAvailability.IsSetTimepointType())
                                {
                                    Console.WriteLine("                            TimepointType");
                                    Console.WriteLine("                                {0}", earliestAvailability.TimepointType);
                                }
                                if (earliestAvailability.IsSetDateTime())
                                {
                                    Console.WriteLine("                            DateTime");
                                    Console.WriteLine("                                {0}", earliestAvailability.DateTime);
                                }
                            }
                            if (member.IsSetSupplyDetail())
                            {
                                Console.WriteLine("                        SupplyDetail");
                                InventorySupplyDetailList    supplyDetail = member.SupplyDetail;
                                List <InventorySupplyDetail> member1List  = supplyDetail.member;
                                foreach (InventorySupplyDetail member1 in member1List)
                                {
                                    Console.WriteLine("                            member");
                                    if (member1.IsSetQuantity())
                                    {
                                        Console.WriteLine("                                Quantity");
                                        Console.WriteLine("                                    {0}", member1.Quantity);
                                    }
                                    if (member1.IsSetSupplyType())
                                    {
                                        Console.WriteLine("                                SupplyType");
                                        Console.WriteLine("                                    {0}", member1.SupplyType);
                                    }
                                    if (member1.IsSetEarliestAvailableToPick())
                                    {
                                        Console.WriteLine("                                EarliestAvailableToPick");
                                        Timepoint earliestAvailableToPick = member1.EarliestAvailableToPick;
                                        if (earliestAvailableToPick.IsSetTimepointType())
                                        {
                                            Console.WriteLine("                                    TimepointType");
                                            Console.WriteLine("                                        {0}", earliestAvailableToPick.TimepointType);
                                        }
                                        if (earliestAvailableToPick.IsSetDateTime())
                                        {
                                            Console.WriteLine("                                    DateTime");
                                            Console.WriteLine("                                        {0}", earliestAvailableToPick.DateTime);
                                        }
                                    }
                                    if (member1.IsSetLatestAvailableToPick())
                                    {
                                        Console.WriteLine("                                LatestAvailableToPick");
                                        Timepoint latestAvailableToPick = member1.LatestAvailableToPick;
                                        if (latestAvailableToPick.IsSetTimepointType())
                                        {
                                            Console.WriteLine("                                    TimepointType");
                                            Console.WriteLine("                                        {0}", latestAvailableToPick.TimepointType);
                                        }
                                        if (latestAvailableToPick.IsSetDateTime())
                                        {
                                            Console.WriteLine("                                    DateTime");
                                            Console.WriteLine("                                        {0}", latestAvailableToPick.DateTime);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if (listInventorySupplyByNextTokenResult.IsSetNextToken())
                    {
                        Console.WriteLine("                NextToken");
                        Console.WriteLine("                    {0}", listInventorySupplyByNextTokenResult.NextToken);
                    }
                }
                if (response.IsSetResponseMetadata())
                {
                    Console.WriteLine("            ResponseMetadata");
                    ResponseMetadata responseMetadata = response.ResponseMetadata;
                    if (responseMetadata.IsSetRequestId())
                    {
                        Console.WriteLine("                RequestId");
                        Console.WriteLine("                    {0}", responseMetadata.RequestId);
                    }
                }
            }
            catch (FBAInventoryServiceMWSException ex)
            {
                Console.WriteLine("Caught Exception: " + ex.Message);
                Console.WriteLine("Response Status Code: " + ex.StatusCode);
                Console.WriteLine("Error Code: " + ex.ErrorCode);
                Console.WriteLine("Error Type: " + ex.ErrorType);
                Console.WriteLine("Request ID: " + ex.RequestId);
                Console.WriteLine("XML: " + ex.XML);
            }
        }
        public DataSet InvokeListInventorySupply(FBAInventoryServiceMWS.FBAInventoryServiceMWS service, ListInventorySupplyRequest request)
        {
            try
            {
                ListInventorySupplyResponse response = service.ListInventorySupply(request);
                DebugLogHandler.DebugLogHandler.WriteLog(_sLogPath, _sClass, "InvokeListInventorySupply() reponse:" + response.ToXML());
                if (response.IsSetListInventorySupplyResult())
                {
                    ListInventorySupplyResult listInventorySupplyResult = response.ListInventorySupplyResult;
                    if (listInventorySupplyResult.IsSetInventorySupplyList())
                    {
                        InventorySupplyList    inventorySupplyList = listInventorySupplyResult.InventorySupplyList;
                        List <InventorySupply> memberList          = inventorySupplyList.member;
                        foreach (InventorySupply member in memberList)
                        {
                            int InboundCount  = 0;
                            int InStockCount  = 0;
                            int TransferCount = 0;
                            //Console.WriteLine("                    member");
                            DataRow InventoryRow = InventorySupplyTable.NewRow();
                            InventoryRow["FNSKU"]     = "N/A";
                            InventoryRow["SellerSKU"] = "N/A";
                            InventoryRow["ASIN"]      = "N/A";
                            InventoryRow["Inbound"]   = InboundCount;
                            InventoryRow["InStock"]   = InStockCount;
                            InventoryRow["Transfer"]  = TransferCount;
                            if (member.IsSetSellerSKU())
                            {
                                InventoryRow["SellerSKU"] = member.SellerSKU;
                                //Console.WriteLine("                        SellerSKU");
                                //Console.WriteLine("                            {0}", member.SellerSKU);
                            }
                            if (member.IsSetFNSKU())
                            {
                                InventoryRow["FNSKU"] = member.FNSKU;
                                //Console.WriteLine("                        FNSKU");
                                //Console.WriteLine("                            {0}", member.FNSKU);
                            }
                            if (member.IsSetASIN())
                            {
                                InventoryRow["ASIN"] = member.ASIN;
                                //Console.WriteLine("                        ASIN");
                                // Console.WriteLine("                            {0}", member.ASIN);
                            }
                            if (member.IsSetCondition())
                            {
                                //Console.WriteLine("                        Condition");
                                //Console.WriteLine("                            {0}", member.Condition);
                            }
                            if (member.IsSetTotalSupplyQuantity())
                            {
                                //InventoryRow["TotalSupplyQuantity"] = member.TotalSupplyQuantity;
                                //Console.WriteLine("                        TotalSupplyQuantity");
                                //Console.WriteLine("                            {0}", member.TotalSupplyQuantity);
                            }
                            if (member.IsSetInStockSupplyQuantity())
                            {
                                //InventoryRow["InStockSupplyQuantity"] = member.InStockSupplyQuantity;
                                //Console.WriteLine("                        InStockSupplyQuantity");
                                //Console.WriteLine("                            {0}", member.InStockSupplyQuantity);
                            }
                            if (member.IsSetEarliestAvailability())
                            {
                                //Console.WriteLine("                        EarliestAvailability");
                                Timepoint earliestAvailability = member.EarliestAvailability;
                                if (earliestAvailability.IsSetTimepointType())
                                {
                                    //Console.WriteLine("                            TimepointType");
                                    //Console.WriteLine("                                {0}", earliestAvailability.TimepointType);
                                }
                                if (earliestAvailability.IsSetDateTime())
                                {
                                    //Console.WriteLine("                            DateTime");
                                    //Console.WriteLine("                                {0}", earliestAvailability.DateTime);
                                }
                            }
                            if (member.IsSetSupplyDetail())
                            {
                                //Console.WriteLine("                        SupplyDetail");
                                InventorySupplyDetailList    supplyDetail = member.SupplyDetail;
                                List <InventorySupplyDetail> member1List  = supplyDetail.member;
                                foreach (InventorySupplyDetail member1 in member1List)
                                {
                                    //Console.WriteLine("                            member");
                                    if (member1.IsSetQuantity())
                                    {
                                        if (member1.SupplyType == "InStock")
                                        {
                                            InStockCount += Int32.Parse(member1.Quantity.ToString());
                                        }
                                        if (member1.SupplyType == "Inbound")
                                        {
                                            InboundCount += Int32.Parse(member1.Quantity.ToString());
                                        }
                                        if (member1.SupplyType == "Transfer")
                                        {
                                            TransferCount = Int32.Parse(member.TotalSupplyQuantity.ToString()) - Int32.Parse(member1.Quantity.ToString());
                                        }
                                        //InventoryRow[member1.SupplyType] = member1.Quantity;
                                        //Console.WriteLine("                                Quantity");
                                        //Console.WriteLine("                                    {0}", member1.Quantity);
                                    }
                                    if (member1.IsSetSupplyType())
                                    {
                                        //Console.WriteLine("                                SupplyType");
                                        //Console.WriteLine("                                    {0}", member1.SupplyType);
                                    }
                                    if (member1.IsSetEarliestAvailableToPick())
                                    {
                                        //Console.WriteLine("                                EarliestAvailableToPick");
                                        //Timepoint earliestAvailableToPick = member1.EarliestAvailableToPick;
                                        //if (earliestAvailableToPick.IsSetTimepointType())
                                        //{
                                        //    Console.WriteLine("                                    TimepointType");
                                        //    Console.WriteLine("                                        {0}", earliestAvailableToPick.TimepointType);
                                        //}
                                        //if (earliestAvailableToPick.IsSetDateTime())
                                        //{
                                        //    Console.WriteLine("                                    DateTime");
                                        //    Console.WriteLine("                                        {0}", earliestAvailableToPick.DateTime);
                                        //}
                                    }
                                    if (member1.IsSetLatestAvailableToPick())
                                    {
                                        //Console.WriteLine("                                LatestAvailableToPick");
                                        //Timepoint latestAvailableToPick = member1.LatestAvailableToPick;
                                        //if (latestAvailableToPick.IsSetTimepointType())
                                        //{
                                        //    Console.WriteLine("                                    TimepointType");
                                        //    Console.WriteLine("                                        {0}", latestAvailableToPick.TimepointType);
                                        //}
                                        //if (latestAvailableToPick.IsSetDateTime())
                                        //{
                                        //    Console.WriteLine("                                    DateTime");
                                        //    Console.WriteLine("                                        {0}", latestAvailableToPick.DateTime);
                                        //}
                                    }
                                }
                            }//end of foreach member1 list

                            InventoryRow["Inbound"]  = InboundCount;
                            InventoryRow["InStock"]  = InStockCount;
                            InventoryRow["Transfer"] = TransferCount;

                            InventorySupplyTable.Rows.Add(InventoryRow);
                        } // end of foreach member list
                    }
                    if (listInventorySupplyResult.IsSetNextToken())
                    {
                        //Console.WriteLine("                NextToken");
                        //Console.WriteLine("                    {0}", listInventorySupplyResult.NextToken);
                        ListInventorySupplyByNextTokenRequest nextTokenRequest = new ListInventorySupplyByNextTokenRequest();
                        nextTokenRequest.SellerId    = request.SellerId;
                        nextTokenRequest.Marketplace = request.Marketplace;
                        nextTokenRequest.NextToken   = listInventorySupplyResult.NextToken;
                        InvokeListInventorySupplyByNextToken(service, nextTokenRequest);
                    }
                }
                if (response.IsSetResponseMetadata())
                {
                    Console.WriteLine("            ResponseMetadata");
                    ResponseMetadata responseMetadata = response.ResponseMetadata;
                    if (responseMetadata.IsSetRequestId())
                    {
                        //Console.WriteLine("                RequestId");
                        //Console.WriteLine("                    {0}", responseMetadata.RequestId);
                    }
                }
            }
            catch (FBAInventoryServiceMWSException ex)
            {
                Console.WriteLine("Caught Exception: " + ex.Message);
                Console.WriteLine("Response Status Code: " + ex.StatusCode);
                Console.WriteLine("Error Code: " + ex.ErrorCode);
                Console.WriteLine("Error Type: " + ex.ErrorType);
                Console.WriteLine("Request ID: " + ex.RequestId);
                Console.WriteLine("XML: " + ex.XML);
                DebugLogHandler.DebugLogHandler.WriteLog(_sLogPath, _sClass, "Caught Exception: " + ex.Message);
                DebugLogHandler.DebugLogHandler.WriteLog(_sLogPath, _sClass, "Response Status Code: " + ex.StatusCode);
                DebugLogHandler.DebugLogHandler.WriteLog(_sLogPath, _sClass, "Error Code: " + ex.ErrorCode);
                DebugLogHandler.DebugLogHandler.WriteLog(_sLogPath, _sClass, "Error Type: " + ex.ErrorType);
                DebugLogHandler.DebugLogHandler.WriteLog(_sLogPath, _sClass, "Request ID: " + ex.RequestId);
                DebugLogHandler.DebugLogHandler.WriteLog(_sLogPath, _sClass, "XML: " + ex.XML);
            }

            return(InventorySupplyDataSet);
        }