コード例 #1
0
        public QBResponceList InventoryadjustmentBulkOperation(QBSessionManager sessionManager, QBRequestItemSet qBRequestItemSet)
        {
            QBResponceList qbResponceData  = null;
            QBSession      QBMgr           = null;
            QBResponceItem _qbResponceItem = null;

            QBMgr = new QBSession();
            if (sessionManager == null)
            {
                QBMgr.CreateQBSession(out sessionManager);
            }

            if (sessionManager != null && qBRequestItemSet != null && qBRequestItemSet.QBRequestItemList != null && qBRequestItemSet.QBRequestItemList.Count > 0)
            {
                //Parallel.ForEach(qBRequestItemSet.QBRequestItemList, item => Process(item));
                foreach (var data in qBRequestItemSet.QBRequestItemList)
                {
                    if (data != null)
                    {
                        if (data.Action == QBAction.Modify)
                        {
                            //Update quntity.
                            var responceItem = Inventoryadjustment(sessionManager, qBRequestItemSet.AccountList, qBRequestItemSet.PreferencesRet, data.ItemInventoryRet);
                        }
                        else
                        {
                            //Add Item
                            CreatInventoryItem(sessionManager, qBRequestItemSet.AccountList, qBRequestItemSet.PreferencesRet, data.ItemInventoryRet);
                        }
                    }
                }
            }
            return(qbResponceData);
        }
コード例 #2
0
        public QBResponceItem Inventoryadjustment(QBSessionManager sessionManager, IAccountRetList accountInfo, IPreferencesRet PreferencesRet, IItemInventoryRet inventoryItem)
        {
            QBResponceList qbResponceData  = null;
            QBSession      QBMgr           = null;
            QBResponceItem _qbResponceItem = null;

            try
            {
                QBMgr = new QBSession();
                if (sessionManager == null)
                {
                    QBMgr.CreateQBSession(out sessionManager);
                }

                if (sessionManager != null && inventoryItem != null && accountInfo != null)
                {
                    // Get the RequestMsgSet based on the correct QB Version
                    IMsgSetRequest requestSet = QBMgr.getLatestMsgSetRequest(sessionManager);

                    if (requestSet != null)
                    {
                        // Initialize the message set request object
                        requestSet.Attributes.OnError = ENRqOnError.roeStop;

                        BuildInventoryAdjustmentAddRq(requestSet, accountInfo, PreferencesRet, inventoryItem);

                        // Uncomment the following to view and save the request and response XML
                        //string requestXML = requestSet.ToXMLString();
                        //MessageBox.Show(requestXML);

                        // Do the request and get the response message set object
                        IMsgSetResponse responseSet = sessionManager.DoRequests(requestSet);

                        //string responseXML = responseSet.ToXMLString();
                        //MessageBox.Show(responseXML);

                        _qbResponceItem = WalkInventoryAdjustmentAddRs(responseSet);

                        //Close the session and connection with QuickBooks
                        //QBMgr.CloseQBConnection(sessionManager);
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(_qbResponceItem);
        }
コード例 #3
0
        private QBResponceItem WalkInventoryAdjustmentAddRs(IMsgSetResponse responseMsgSet)
        {
            QBResponceItem _qbResponceItem = null;

            if (responseMsgSet == null)
            {
                return(null);
            }
            IResponseList responseList = responseMsgSet.ResponseList;

            if (responseList == null)
            {
                return(null);
            }
            //if we sent only one request, there is only one response, we'll walk the list for this sample
            for (int i = 0; i < responseList.Count; i++)
            {
                _qbResponceItem = new QBResponceItem();
                IResponse response = responseList.GetAt(i);

                _qbResponceItem.StatusCode     = response.StatusCode;
                _qbResponceItem.StatusMessage  = response.StatusMessage;
                _qbResponceItem.StatusSeverity = response.StatusSeverity;


                //check the status code of the response, 0=ok, >0 is warning
                if (response.StatusCode >= 0)
                {
                    //the request-specific response is in the details, make sure we have some
                    if (response.Detail != null)
                    {
                        //make sure the response is the type we're expecting
                        ENResponseType responseType = (ENResponseType)response.Type.GetValue();
                        if (responseType == ENResponseType.rtInventoryAdjustmentAddRs)
                        {
                            //upcast to more specific type here, this is safe because we checked with response.Type check above
                            IInventoryAdjustmentRet InventoryAdjustmentRet = (IInventoryAdjustmentRet)response.Detail;

                            _qbResponceItem.InventoryItemAdjustment = InventoryAdjustmentRet;
                        }
                    }
                }
            }
            return(_qbResponceItem);
        }