Beispiel #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);
        }
Beispiel #2
0
        public IResponseList LoadQBItemInventoryList(int maxRecords, QBSessionManager sessionManager)
        {
            // IMsgSetRequest requestMsgSet = null;
            QBSession     QBMgr        = null;
            IResponseList responseList = null;

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

                if (sessionManager != 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;

                        IItemInventoryQuery itemInventory = requestSet.AppendItemInventoryQueryRq();

                        //Set field value for metaData
                        itemInventory.metaData.SetValue(ENmetaData.mdMetaDataAndResponseData); //"IQBENmetaDataType"

                        // Optionally, you can put filter on it.
                        if (maxRecords != 0)
                        {
                            itemInventory.ORListQueryWithOwnerIDAndClass.ListWithClassFilter.MaxReturned.SetValue(maxRecords);
                        }

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

                        //IItemInventoryRetList itemInventoryRetList = null;
                        if (responseMsgSet == null)
                        {
                            return(null);
                        }
                        responseList = responseMsgSet.ResponseList;
                        if (responseList == null)
                        {
                            return(null);
                        }

                        // string responseXML = responseMsgSet.ToXMLString();
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(responseList);
        }
Beispiel #3
0
        public IResponseList GetPreferences(QBSessionManager sessionManager)
        {
            IMsgSetRequest requestMsgSet = null;
            QBSession      QBMgr         = null;
            IResponseList  responseList  = null;

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

                if (sessionManager != 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;

                        BuildPreferencesQueryRq(requestSet);

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

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

                        //WalkPreferencesQueryRs(responseSet);

                        //Close the session and connection with QuickBooks
                        //QBMgr.CloseQBConnection(sessionManager);
                    }
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
            }
            return(responseList);
        }
Beispiel #4
0
        public IResponseList GetQBAccountInfo(QBSessionManager sessionManager)
        {
            //bool sessionBegun = false;
            //bool connectionOpen = false;
            QBSession     QBMgr        = null;
            IResponseList responseList = null;

            try
            {
                QBMgr = new QBSession();
                if (sessionManager == null)
                {
                    //Create the session Manager object
                    QBMgr.CreateQBSession(out sessionManager);
                }

                // Get the RequestMsgSet based on the correct QB Version
                IMsgSetRequest requestMsgSet = QBMgr.getLatestMsgSetRequest(sessionManager);

                requestMsgSet.Attributes.OnError = ENRqOnError.roeContinue;

                // BuildAccountQueryRq(requestMsgSet);

                IAccountQuery AccountQueryRq = requestMsgSet.AppendAccountQueryRq();

                //Send the request and get the response from QuickBooks
                IMsgSetResponse responseMsgSet = sessionManager.DoRequests(requestMsgSet);

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


                //WalkAccountQueryRs(responseMsgSet);

                //End the session and close the connection to QuickBooks
                //Close the session and connection with QuickBooks
                //QBMgr.CloseQBConnection(sessionManager);
            }
            catch (Exception ex)
            {
            }
            finally
            {
            }
            return(responseList);
        }
Beispiel #5
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);
        }
Beispiel #6
0
        public void CreatInventoryItem(QBSessionManager sessionManager, IAccountRetList accountInfo, IPreferencesRet PreferencesRet, IItemInventoryRet inventoryItem)
        {
            IMsgSetRequest requestMsgSet = null;
            QBSession      QBMgr         = null;

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

                if (sessionManager != 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;

                        BuildItemInventoryAddRq(requestSet, accountInfo, PreferencesRet, inventoryItem);

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

                        //WalkItemInventoryAddRs(responseSet);
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
Beispiel #7
0
        public IResponseList GetItemInventor(string fullName, QBSessionManager sessionManager)
        {
            QBSession     QBMgr        = null;
            IResponseList responseList = null;

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


                if (sessionManager != 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;

                        IItemInventoryQuery itemInventory = requestSet.AppendItemInventoryQueryRq();

                        //Set field value for metaData
                        itemInventory.metaData.SetValue(ENmetaData.mdMetaDataAndResponseData);

                        //Set field value for ActiveStatus
                        //itemInventory.ORListQueryWithOwnerIDAndClass.ListWithClassFilter.ActiveStatus.SetValue(ENActiveStatus.asActiveOnly);

                        //Set field value for iterator
                        //itemInventory.iterator.SetValue(ENiterator.itContinue); //"IQBENiteratorType"

                        //May create more than one of these if needed
                        //itemInventory.ORListQueryWithOwnerIDAndClass.ListIDList.Add("80000004-1552565462");

                        //May create more than one of these if needed
                        itemInventory.ORListQueryWithOwnerIDAndClass.FullNameList.Add(fullName);



                        // Optionally, you can put filter on it.
                        //itemInventory.ORListQueryWithOwnerIDAndClass.ListWithClassFilter.MaxReturned.SetValue(50);

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


                        if (responseMsgSet == null)
                        {
                            return(null);
                        }
                        responseList = responseMsgSet.ResponseList;
                        if (responseList == null)
                        {
                            return(null);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(responseList);
        }