示例#1
0
        // private static volatile QBPOS instance;

        public static List <ItemInventoryRet> GetInventoryItemQuery(string QBCompanyFile, int days = 1)
        {
            var modxml     = ItemInventoryViewModel.BuildModifiedItemInventoryQuery(days);
            var createdxml = ItemInventoryViewModel.BuildCreatedItemInventoryQuery(days);

            var modres     = QBPosContext.ProcessXML(modxml.OuterXml, QBCompanyFile);
            var createdres = QBPosContext.ProcessXML(createdxml.OuterXml, QBCompanyFile);
            //if(sessionBegun == true)

            var lst = new List <ItemInventoryRet>();

            lst.AddRange(GetQBInventoryItems(modres));

            lst.AddRange(GetQBInventoryItems(createdres));

            return(lst.GroupBy(x => x.ListID).Select(grp => grp.First()).ToList());
        }
示例#2
0
        public List <ItemInventoryRet> GetInventoryItemQuery(int days = 1)
        {
            if (sessionManager != null)
            {
                IMsgSetRequest ItemModifiedInventoryRequestMsgSet = sessionManager.CreateMsgSetRequest(3, 0);
                IMsgSetRequest ItemCreatedInventoryRequestMsgSet  = sessionManager.CreateMsgSetRequest(3, 0);
                ItemModifiedInventoryRequestMsgSet.Attributes.OnError = ENRqOnError.roeContinue;
                ItemCreatedInventoryRequestMsgSet.Attributes.OnError  = ENRqOnError.roeContinue;
                ItemInventoryViewModel inventoryVM = new ItemInventoryViewModel();
                inventoryVM.BuildModifiedItemInventoryQuery(ItemModifiedInventoryRequestMsgSet, days);
                inventoryVM.BuildCreatedItemInventoryQuery(ItemCreatedInventoryRequestMsgSet, days);
                //if(sessionBegun == false)
                //    BeginSession();
                ////Send the request and get the response from QuickBooks
                IMsgSetResponse ModifiedItemsLst = sessionManager.DoRequests(ItemModifiedInventoryRequestMsgSet);
                IMsgSetResponse CreatedItemsLst  = sessionManager.DoRequests(ItemCreatedInventoryRequestMsgSet);
                //if(sessionBegun == true)

                var lst  = new List <ItemInventoryRet>();
                var tlst = new TrackableCollection <ItemInventoryRet>(null);

                if (ModifiedItemsLst != null)
                {
                    tlst = inventoryVM.WalkItemInventoryQueryRs(ModifiedItemsLst);
                }

                if (tlst != null)
                {
                    lst.AddRange(tlst.ToList());
                }

                if (CreatedItemsLst != null)
                {
                    tlst = inventoryVM.WalkItemInventoryQueryRs(CreatedItemsLst);
                }

                if (tlst != null)
                {
                    lst.AddRange(tlst.ToList());
                }

                return(lst.GroupBy(x => x.ListID).Select(grp => grp.First()).ToList());
            }
            return(new List <ItemInventoryRet>());
        }