public void BuildCreatedItemInventoryQuery(IMsgSetRequest ItemInventoryRequestMsgSet, int days)
        {
            //when open first time download all, then download from last time to now.

            //
            //Set attributes
            //Set field value for MatchNumericCriterion

            if (days != 1)
            {
                lastDownloadTime = DateTime.Now.AddDays(days * -1);
            }

            if (lastDownloadTime != DateTime.MinValue)
            {
                IItemInventoryQuery ItemInventoryQueryRq = ItemInventoryRequestMsgSet.AppendItemInventoryQueryRq();
                ItemInventoryQueryRq.ORTimeCreatedFilters.TimeCreatedRangeFilter.FromTimeCreated.SetValue(DateTime.Now.AddMinutes(-45),//lastDownloadTime
                                                                                                          false);
                ItemInventoryQueryRq.ORTimeCreatedFilters.TimeCreatedRangeFilter.ToTimeCreated.SetValue(DateTime.Now,
                                                                                                        false);
                //ItemInventoryQueryRq.ORItemNumberFilters.ItemNumberFilter.MatchNumericCriterion.SetValue(ENMatchNumericCriterion.mncEqual);
                //ItemInventoryQueryRq.ORItemNumberFilters.ItemNumberFilter.ItemNumber.SetValue(6315);
            }
            lastDownloadTime = DateTime.Now;
        }
Пример #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);
        }
 public void BuildItemInventoryQueryRq(IMsgSetRequest ItemInventoryRequestMsgSet)
 {
     IItemInventoryQuery ItemInventoryQueryRq = ItemInventoryRequestMsgSet.AppendItemInventoryQueryRq();
     //Set attributes
     //Set field value for MatchNumericCriterion
     //ItemInventoryQueryRq.ORTimeCreatedFilters.TimeCreatedFilter.MatchNumericCriterion.SetValue(ENMatchNumericCriterion.mncGreaterThanEqual);
     ////Set field value for TimeCreated
     //ItemInventoryQueryRq.ORTimeCreatedFilters.TimeCreatedFilter.TimeCreated.SetValue(DateTime.Parse("1/1/2000"), false);
 }
    public static String queryAll(Session sess)
    {
        QBSessionManager sessionManager = new QBSessionManager();
        IMsgSetRequest   requestSet     = sessionManager.CreateMsgSetRequest(sess.getCountry(), sess.getMajorVers(), sess.getMinorVers());

        requestSet.Attributes.OnError = ENRqOnError.roeStop;
        IItemInventoryQuery ItemQ = requestSet.AppendItemInventoryQueryRq();

        ItemQ.iterator.SetValue(ENiterator.itStart);
        ItemQ.ORListQueryWithOwnerIDAndClass.ListWithClassFilter.MaxReturned.SetValue(chunkSize);
        return(requestSet.ToXMLString());
    }
Пример #5
0
        public void BuildItemInventoryQueryRq(IMsgSetRequest ItemInventoryRequestMsgSet, int days)
        {
            IItemInventoryQuery ItemInventoryQueryRq = ItemInventoryRequestMsgSet.AppendItemInventoryQueryRq();
            //Set attributes
            //Set field value for MatchNumericCriterion
            //var startdate = DateTime.Now.AddDays(days * -1);
            //ItemInventoryQueryRq.ORTimeModifiedFilters.TimeModifiedRangeFilter.FromTimeModified.SetValue(startdate, false);
            //ItemInventoryQueryRq.ORTimeModifiedFilters.TimeModifiedRangeFilter.ToTimeModified.SetValue(DateTime.Now, false);

            //ItemInventoryQueryRq.ORTimeCreatedFilters.TimeCreatedRangeFilter.FromTimeCreated.SetValue(startdate, false);
            //ItemInventoryQueryRq.ORTimeCreatedFilters.TimeCreatedRangeFilter.ToTimeCreated.SetValue(DateTime.Now, false);
        }
Пример #6
0
        public static string queryNext(Session sess)
        {
            QBSessionManager sessionManager = new QBSessionManager();
            IMsgSetRequest   requestSet     = sessionManager.CreateMsgSetRequest(sess.getCountry(), sess.getMajorVers(), sess.getMinorVers());

            requestSet.Attributes.OnError = ENRqOnError.roeStop;
            IItemInventoryQuery ItemQ = requestSet.AppendItemInventoryQueryRq();

            ItemQ.iterator.SetValue(ENiterator.itContinue);
            ItemQ.iteratorID.SetValue(sess.getProperty("queryContext").ToString());
            //ItemQ.ORListQuery.ListFilter.MaxReturned.SetValue(chunkSize);
            return(requestSet.ToXMLString());
        }
        public void BuildItemInventoryQueryRq(IMsgSetRequest ItemInventoryRequestMsgSet, int FromItemNumber,
                                              int ToItemNumber)
        {
            var ItemInventoryQueryRq = ItemInventoryRequestMsgSet.AppendItemInventoryQueryRq();

            //Set attributes

            //Set field value for FromItemNumber
            ItemInventoryQueryRq.ORItemNumberFilters.ItemNumberRangeFilter.FromItemNumber.SetValue(FromItemNumber);
            //Set field value for ToItemNumber
            ItemInventoryQueryRq.ORItemNumberFilters.ItemNumberRangeFilter.ToItemNumber.SetValue(ToItemNumber);


            ItemInventoryQueryRq.OwnerIDList.Add("0");
        }
Пример #8
0
        public static void Main()
        {
            QBSessionManager sessionManager = new QBSessionManager();

            try
            {
                IMsgSetRequest requestMsgSet = sessionManager.CreateMsgSetRequest("US", 13, 0);
                sessionManager.OpenConnection("", "TEST");
                sessionManager.BeginSession("", ENOpenMode.omDontCare);
                requestMsgSet.Attributes.OnError = ENRqOnError.roeContinue;
                IItemInventoryQuery ItemInventoryQueryRq = requestMsgSet.AppendItemInventoryQueryRq();
                IMsgSetResponse     responseMsgSet       = sessionManager.DoRequests(requestMsgSet);
                if (responseMsgSet == null)
                {
                    return;
                }
                IResponseList responseList = responseMsgSet.ResponseList;
                if (responseList == null)
                {
                    return;
                }
                for (int i = 0; i < responseList.Count; i++)
                {
                    IResponse response = responseList.GetAt(i);
                    if (response.StatusCode >= 0)
                    {
                        if (response.Detail != null)
                        {
                            ENResponseType responseType = (ENResponseType)response.Type.GetValue();
                            if (responseType == ENResponseType.rtItemInventoryQueryRs)
                            {
                                IItemInventoryRetList ItemInventoryRet = (IItemInventoryRetList)response.Detail;
                                for (int j = 0; j < ItemInventoryRet.Count; j++)
                                {
                                    if (ItemInventoryRet.GetAt(j).UnitOfMeasureSetRef != null)
                                    {
                                        string itemListId   = ItemInventoryRet.GetAt(j).ListID.GetValue();
                                        string itemFullName = ItemInventoryRet.GetAt(j).FullName.GetValue();
                                        short  ItemType     = ItemInventoryRet.GetAt(j).Type.GetValue();
                                        string unitOfMeasurementRefListId   = ItemInventoryRet.GetAt(j).UnitOfMeasureSetRef.ListID.GetValue();
                                        string unitOfMeasurementRefFullName = ItemInventoryRet.GetAt(j).UnitOfMeasureSetRef.FullName.GetValue();
                                        short  unitOfMeasurementRefType     = ItemInventoryRet.GetAt(j).UnitOfMeasureSetRef.Type.GetValue();
                                        Console.WriteLine($"Item Id: {itemListId}\r\nItem Full Name: {itemFullName}\r\n{ItemType}\r\nUnit of Measurement List Id: {unitOfMeasurementRefListId}\r\nUnit of Measurement Full Name: {unitOfMeasurementRefFullName}\r\nUnit of Measurement Type: {unitOfMeasurementRefType}\r\n");
                                        IMsgSetRequest         uomRequestMsgSet        = sessionManager.CreateMsgSetRequest("US", 13, 0);
                                        IUnitOfMeasureSetQuery UnitOfMeasureSetQueryRq = uomRequestMsgSet.AppendUnitOfMeasureSetQueryRq();
                                        UnitOfMeasureSetQueryRq.ORListQuery.ListIDList.Add(ItemInventoryRet.GetAt(j).UnitOfMeasureSetRef.ListID.GetValue());
                                        IMsgSetResponse unitOfMeaurementResponseMsgSet = sessionManager.DoRequests(uomRequestMsgSet);
                                        WalkUnitOfMeasureSetQueryRs(unitOfMeaurementResponseMsgSet);
                                    }
                                }
                            }
                        }
                    }
                }
                sessionManager.EndSession();
                sessionManager.CloseConnection();
                Console.ReadLine();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message, "Error");
                sessionManager.EndSession();
                sessionManager.CloseConnection();
                Console.ReadLine();
            }
        }
Пример #9
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);
        }