收到并处理了QBPOS导出请求但没有响应

时间:2017-09-13 21:58:26

标签: c# quickbooks

我正在查看qbpossdklog,我可以看到我的请求正在处理中,但我没有收到回复查询信息的回复。我觉得我错过了一些简单的事情。如果您要测试代码,请确保将其平台到x86,否则您将收到COM错误。使用C#和qbposfc3。

using System;
using System.Net;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;
using Interop.qbposfc3;
using System.Xml;


namespace QBPOS
{
    public class PO
    { 
        [STAThread]
        public static void Main(string[] args)
        {
            PO_Query(); 
        }
        public static void PO_Query()
        {
            bool sessionBegun = false;
            bool connectionOpen = false;
            QBPOSSessionManager sessionManager = null;

            try
            {
                sessionManager = new QBPOSSessionManager();

                IMsgSetRequest requestMsgSet = sessionManager.CreateMsgSetRequest(3,0);
                requestMsgSet.Attributes.OnError = ENRqOnError.roeContinue;
                IPurchaseOrderQuery POQ = requestMsgSet.AppendPurchaseOrderQueryRq();

                sessionManager.OpenConnection("appID","PO Export");
                connectionOpen = true;
                sessionManager.BeginSession("");
                sessionBegun = true;

                IMsgSetResponse responseMsgSet = sessionManager.DoRequests(requestMsgSet);
                IResponseList responseList = responseMsgSet.ResponseList;        

                        for(int i = 0; i < responseList.Count; i++)
                        {
                            IResponse response = responseList.GetAt(i);
                            ENResponseType responseType = (ENResponseType)response.Type.GetValue();
                            IPurchaseOrderRetList POR = (IPurchaseOrderRetList)response.Detail; 
                            IPurchaseOrderRet PurchaseOrderRet = POR.GetAt(i);
                            if (PurchaseOrderRet.TxnID != null)
                            {
                                PurchaseOrderRet.TxnID.GetValue();
                            }
                            if (PurchaseOrderRet.TimeCreated != null)
                            {
                                PurchaseOrderRet.TimeCreated.GetValue();
                            }
                            if (PurchaseOrderRet.TimeModified != null)
                            {
                                PurchaseOrderRet.TimeModified.GetValue();
                            }
                            if (PurchaseOrderRet.Associate != null)
                            {
                                PurchaseOrderRet.Associate.GetValue();
                            }
                            if (PurchaseOrderRet.CancelDate != null)
                            {
                                PurchaseOrderRet.CancelDate.GetValue();
                            }
                            if (PurchaseOrderRet.CompanyName != null)
                            {
                                PurchaseOrderRet.CompanyName.GetValue();
                            }
                            if (PurchaseOrderRet.Discount != null)
                            {
                                PurchaseOrderRet.Discount.GetValue();
                            }
                            if (PurchaseOrderRet.DiscountPercent != null)
                            {
                                PurchaseOrderRet.DiscountPercent.GetValue();
                            }
                            if (PurchaseOrderRet.Fee != null)
                            {
                                PurchaseOrderRet.Fee.GetValue();
                            }
                            if (PurchaseOrderRet.Instructions != null)
                            {
                                PurchaseOrderRet.Instructions.GetValue();
                            }
                            if (PurchaseOrderRet.ItemsCount != null)
                            {
                                PurchaseOrderRet.ItemsCount.GetValue();
                            }
                            if (PurchaseOrderRet.PurchaseOrderNumber != null)
                            {
                                PurchaseOrderRet.PurchaseOrderNumber.GetValue();
                            }
                            if (PurchaseOrderRet.PurchaseOrderStatusDesc != null)
                            {
                                PurchaseOrderRet.PurchaseOrderStatusDesc.GetValue();
                            }
                            if (PurchaseOrderRet.QtyDue != null)
                            {
                                PurchaseOrderRet.QtyDue.GetValue();
                            }
                            if (PurchaseOrderRet.QtyOrdered!= null)
                            {
                                PurchaseOrderRet.QtyOrdered.GetValue();
                            }
                            if (PurchaseOrderRet.QtyOrdered!= null)
                            {
                                PurchaseOrderRet.QtyReceived.GetValue();
                            }
                            if (PurchaseOrderRet.SalesOrderNumber != null)
                            {
                                PurchaseOrderRet.SalesOrderNumber.GetValue();
                            }
                            if (PurchaseOrderRet.ShipToStoreNumber != null)
                            {
                                PurchaseOrderRet.ShipToStoreNumber.GetValue();
                            }
                            if (PurchaseOrderRet.StartShipDate != null)
                            {
                                PurchaseOrderRet.StartShipDate.GetValue();
                            }
                            if (PurchaseOrderRet.StoreExchangeStatus != null)
                            {
                                PurchaseOrderRet.StoreExchangeStatus.GetValue();
                            }
                            if (PurchaseOrderRet.StoreNumber != null)
                            {
                                PurchaseOrderRet.StoreNumber.GetValue();
                            }
                            if (PurchaseOrderRet.Subtotal != null)
                            {
                                PurchaseOrderRet.Subtotal.GetValue();
                            }
                            if (PurchaseOrderRet.Terms != null)
                            {
                                PurchaseOrderRet.Terms.GetValue();
                            }
                            if (PurchaseOrderRet.TermsDiscount != null)
                            {
                                PurchaseOrderRet.TermsDiscount.GetValue();
                            }
                            if (PurchaseOrderRet.TermsDiscountDays != null)
                            {
                                PurchaseOrderRet.TermsDiscountDays.GetValue();
                            }
                            if (PurchaseOrderRet.Total != null)
                            {
                                PurchaseOrderRet.Total.GetValue();
                            }
                            if (PurchaseOrderRet.TxnDate != null)
                            {
                                PurchaseOrderRet.TxnDate.GetValue();
                            }
                            if (PurchaseOrderRet.UnfilledPercent != null)
                            {
                                PurchaseOrderRet.UnfilledPercent.GetValue();
                            }
                            if (PurchaseOrderRet.VendorCode != null)
                            {
                                PurchaseOrderRet.VendorCode.GetValue();
                            }
                            if (PurchaseOrderRet.VendorListID != null)
                            {
                                PurchaseOrderRet.VendorListID.GetValue();
                            }

                                    for (int x = 0 ; x < PurchaseOrderRet.PurchaseOrderItemRetList.Count; x++)
                                    {
                                        IPurchaseOrderItemRet PurchaseOrderItemRet = PurchaseOrderRet.PurchaseOrderItemRetList.GetAt(x);
                                        //Get value of ListID
                                        if (PurchaseOrderItemRet.ListID != null)
                                        {
                                            PurchaseOrderItemRet.ListID.GetValue();
                                        }
                                        //Get value of TxnLineID
                                        if (PurchaseOrderItemRet.TxnLineID != null)
                                        {
                                            PurchaseOrderItemRet.TxnLineID.GetValue();
                                        }
                                        //Get value of ALU
                                        if (PurchaseOrderItemRet.ALU != null)
                                        {
                                            PurchaseOrderItemRet.ALU.GetValue();
                                        }
                                        //Get value of Attribute
                                        if (PurchaseOrderItemRet.Attribute != null)
                                        {
                                            PurchaseOrderItemRet.Attribute.GetValue();
                                        }
                                        //Get value of Cost
                                        if (PurchaseOrderItemRet.Cost != null)
                                        {
                                            PurchaseOrderItemRet.Cost.GetValue();
                                        }
                                        //Get value of Desc1
                                        if (PurchaseOrderItemRet.Desc1 != null)
                                        {
                                            PurchaseOrderItemRet.Desc1.GetValue();
                                        }
                                        //Get value of Desc2
                                        if (PurchaseOrderItemRet.Desc2 != null)
                                        {
                                            PurchaseOrderItemRet.Desc2.GetValue();
                                        }
                                        //Get value of ExtendedCost
                                        if (PurchaseOrderItemRet.ExtendedCost != null)
                                        {
                                            PurchaseOrderItemRet.ExtendedCost.GetValue();
                                        }
                                        //Get value of ItemNumber
                                        if (PurchaseOrderItemRet.ItemNumber != null)
                                        {
                                            PurchaseOrderItemRet.ItemNumber.GetValue();
                                        }
                                        //Get value of NumberOfBaseUnits
                                        if (PurchaseOrderItemRet.NumberOfBaseUnits != null)
                                        {
                                            PurchaseOrderItemRet.NumberOfBaseUnits.GetValue();
                                        }
                                        //Get value of Qty
                                        if (PurchaseOrderItemRet.Qty != null)
                                        {
                                            PurchaseOrderItemRet.Qty.GetValue();
                                        }
                                        //Get value of QtyReceived
                                        if (PurchaseOrderItemRet.QtyReceived != null)
                                        {
                                            PurchaseOrderItemRet.QtyReceived.GetValue();
                                        }
                                        //Get value of Size
                                        if (PurchaseOrderItemRet.Size != null)
                                        {
                                            PurchaseOrderItemRet.Size.GetValue();
                                        }
                                        //Get value of UnitOfMeasure
                                        if (PurchaseOrderItemRet.UnitOfMeasure != null)
                                        {
                                            PurchaseOrderItemRet.UnitOfMeasure.GetValue();
                                        }
                                        //Get value of UPC
                                        if (PurchaseOrderItemRet.UPC != null)
                                        {
                                            PurchaseOrderItemRet.UPC.GetValue();
                                        }
                                    }
                        }

                        sessionManager.EndSession();
                        sessionBegun = false;
                        sessionManager.CloseConnection();
                        connectionOpen = false;

            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Error");
                if (sessionBegun)
                {
                sessionManager.EndSession();
                }
                if (connectionOpen)
                {
                sessionManager.CloseConnection();
                }
            }
        }


    }
}

0 个答案:

没有答案