コード例 #1
0
        void RequestNonInventory()
        {
            requestMsgSet.ClearRequests();
            IItemNonInventoryQuery Inventory = requestMsgSet.AppendItemNonInventoryQueryRq();

            //Inventory.IsActive.SetValue(true);
            responseMsgSet = sessionManager.DoRequests(requestMsgSet);
            IResponseList responseList = responseMsgSet.ResponseList;
            IResponse     response     = responseMsgSet.ResponseList.GetAt(0);

            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.rtItemNonInventoryQueryRs)
                    {
                        //upcast to more specific type here, this is safe because we checked with response.Type check above
                        IItemNonInventoryRetList ItemNonInventoryRetList = (IItemNonInventoryRetList)response.Detail;
                        int count = ItemNonInventoryRetList.Count;
                        if (count > 0)
                        {
                            ItemList = new List <Items>();
                        }
                        for (int a = 0; a < count; a++)
                        {
                            ItemList.Add(WalkNonInventoryItem(ItemNonInventoryRetList.GetAt(a)));
                        }
                    }
                }
            }
            else
            {
                throw new QBException(response.StatusCode, response.StatusMessage.ToString(), requestMsgSet.ToXMLString());
            }
        }
コード例 #2
0
        public override List <ITransactionEntity> Import()
        {
            StartSession();

            IMsgSetRequest         request = GetLatestMsgSetRequest();
            IItemNonInventoryQuery query   = request.AppendItemNonInventoryQueryRq();

            query.ORListQueryWithOwnerIDAndClass.ListWithClassFilter.ActiveStatus.SetValue(ENActiveStatus.asAll);
            //IItemQuery query = request.AppendItemQueryRq();
            IResponse res = GetResponse(request);

            //IORItemRetList returnList = res.Detail as IORItemRetList;
            IItemNonInventoryRetList returnList = res.Detail as IItemNonInventoryRetList;

            List <MaestroProduct> plist = new List <MaestroProduct>();

            List <IItemNonInventoryRet> mapSourceList = new List <IItemNonInventoryRet>();

            MaestroUnitType unknowUnitType = new UnitTypeManager(context).GetUnknownItem();


            int cnt = returnList.Count;

            for (int i = 0; i <= cnt - 1; i++)
            {
                IItemNonInventoryRet inv = returnList.GetAt(i);
                if (inv != null)
                {
                    string parentId = string.Empty;
                    if (inv.ParentRef != null)
                    {
                        parentId = ReadQbId(inv.ParentRef.ListID);
                    }

                    if (string.IsNullOrEmpty(parentId))
                    {
                        MaestroProduct product = GetMaestroProduct(inv);
                        plist.Add(product);
                    }

                    mapSourceList.Add(inv);//for late processing

                    /*
                     * if (ReadBool(inv.IsActive))
                     * {
                     *  string parentId = string.Empty;
                     *  if (inv.ParentRef != null)
                     *      parentId = ReadQbId(inv.ParentRef.ListID);
                     *
                     *  if (string.IsNullOrEmpty(parentId))
                     *  {
                     *      MaestroProduct product = GetMaestroProduct(inv);
                     *      plist.Add(product);
                     *  }
                     *
                     *  mapSourceList.Add(inv);//for late processing
                     * }
                     */
                    /*
                     * else
                     * {
                     *  string parentId = string.Empty;
                     *  if (inv.ParentRef != null)
                     *      parentId = ReadQbId(inv.ParentRef.ListID);
                     *
                     *  if (string.IsNullOrEmpty(parentId))
                     *  {
                     *      MaestroProduct product = GetMaestroProduct(inv);
                     *      //plist.Add(product);
                     *
                     *  }
                     *
                     *
                     *
                     *
                     * }*/
                }

                #region commented
                //WalkItemNonInventoryRet(inv);

                //IORItemRet qbc = returnList.GetAt(i);

                /*
                 * if (qbc.ItemNonInventoryRet != null)
                 * {
                 *  WalkItemNonInventoryRet(qbc.ItemNonInventoryRet);
                 *  //GetMaestroProduct(qbc.ItemNonInventoryRet);
                 * }*/
                #endregion commented
            }

            ExecuteBulkInsert(plist);
            ImportMaps(mapSourceList, plist);
            QuickBooksProductMapCache.Instance.Reload(true);

            return(plist.Cast <ITransactionEntity>().ToList());
        }