Beispiel #1
0
        private IPreferencesRet GetQBPreferencesDetails()
        {
            IPreferencesRet PreferencesRet = null;

            try
            {
                if (sessionManager != null)
                {
                    QBAccount _qbAccount = new QBAccount();

                    IResponseList responseList = _qbAccount.GetPreferences(sessionManager);
                    if (responseList == null)
                    {
                        return(null);
                    }

                    //if we sent only one request, there is only one response.
                    for (int i = 0; i < responseList.Count; i++)
                    {
                        IResponse response = responseList.GetAt(i);
                        //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.rtPreferencesQueryRs)
                                {
                                    //upcast to more specific type here, this is safe because we checked with response.Type check above
                                    PreferencesRet = (IPreferencesRet)response.Detail;
                                }
                            }
                        }
                        else
                        {
                            //*** Error Handling.
                        }
                    }
                }
            }
            catch (Exception e)
            {
            }
            return(PreferencesRet);
        }
Beispiel #2
0
        public void Execute(IJobExecutionContext context)
        {
            IAccountRetList       AccountList          = null;
            IPreferencesRet       PreferencesRet       = null;
            IItemInventoryRetList itemInventoryRetList = null;
            int maxRecords = 0;

            try
            {
                //** 1. To Get TDS Data Using Entity Frame Work.
                //TDSService _tdsService = new TDSService();

                TDSItemInventoryList = GetMetrialData();

                //** 2. If TDS data is grater than zero. than need to creat QBD session.
                if (TDSItemInventoryList != null && TDSItemInventoryList.Any())
                {
                    qbRequestItemSet = new QBRequestItemSet();
                    qbRequestItemSet.QBRequestItemList = new List <QBRequestItem>();
                    var bSessionResult = CreateQBsession();
                    if (bSessionResult)
                    {
                        //** 3. Using the QBD session to get AccountInfo.
                        AccountList = GetQBAccountDetails();

                        if (AccountList != null && AccountList.Count > 0)
                        {
                            qbRequestItemSet.AccountList = AccountList;

                            //** 4. Using the QBD session to get GetPreferences.
                            PreferencesRet = GetQBPreferencesDetails();
                            if (PreferencesRet != null)
                            {
                                qbRequestItemSet.PreferencesRet = PreferencesRet;
                            }


                            //** 5. Using the QBD session to get qbd invertory item list.
                            itemInventoryRetList = GetItemInventoryRetList(maxRecords);
                            if (itemInventoryRetList != null && itemInventoryRetList.Count > 0)
                            {
                                //Parallel.ForEach(itemInventoryRetList,item=>)
                                for (int i = 0; i < itemInventoryRetList.Count; i++)
                                {
                                    var reqdata = itemInventoryRetList.GetAt(i);
                                    if (TDSItemInventoryList.Where(x => x.TRC_CODE.Trim() == reqdata.FullName.GetValue()).SingleOrDefault() != null)
                                    {
                                        var reqitem = TDSItemInventoryList.Where(x => x.TRC_CODE.Trim() == reqdata.FullName.GetValue()).SingleOrDefault();
                                        //var reqitem=itemInventoryRetList.GetAt(i);
                                        double hh = reqdata.QuantityOnHand.GetValue();
                                        if (reqitem.Quantity != reqdata.QuantityOnHand.GetValue())
                                        {
                                            QBRequestItem requestItem = new QBRequestItem();
                                            requestItem.Action = QBAction.Modify;
                                            reqdata.QuantityOnHand.SetValue(Convert.ToDouble(reqitem.Quantity));
                                            requestItem.ItemInventoryRet = reqdata;
                                            qbRequestItemSet.QBRequestItemList.Add(requestItem);
                                        }
                                    }
                                    else
                                    {
                                    }
                                }



                                //** 4. To compare TDS and QBD item list using TRC_CODE code to asume as Name/Number in QBD item inventory list.
                                //** 5. If TRC_CODE is not match in QBD. than need to add to QBD as a new inventory item.
                                //** 6. If TRC_CODE is match in QBD. than need to ajust the quantity in QBD.
                                //** 7. final status need to send to client using email.
                            }
                            else
                            {
                                //** 5. If TRC_CODE is not match in QBD. than need to add to QBD as a new inventory item.
                            }
                        }
                    }
                }
                else
                {
                    //ServiceLog.log.Fatal("TDS Data is empty " + DateTime.Now.ToLongDateString());
                }

                //ServiceLog.GetUserInfo();
                //Email("Execution Execution");
            }
            catch (Exception ex)
            {
                // ServiceLog.Email(ex.ToString());
            }
            finally
            {
                _QBSession.CloseQBConnection(sessionManager);
            }
        }
Beispiel #3
0
        private void BuildItemInventoryAddRq(IMsgSetRequest requestMsgSet, IAccountRetList accountInfo, IPreferencesRet PreferencesRet, IItemInventoryRet inventoryItem)
        {
            //IItemInventoryAdd[] AdditemList = new IItemInventoryAdd[2];
            IItemInventoryAdd ItemInventoryAddRq = requestMsgSet.AppendItemInventoryAddRq();

            //Set field value for Name
            ItemInventoryAddRq.Name.SetValue(inventoryItem.Name.GetValue()); //"venky01"

            //Set field value for BarCodeValue
            //ItemInventoryAddRq.BarCode.BarCodeValue.SetValue("ab");
            //Set field value for AssignEvenIfUsed
            //ItemInventoryAddRq.BarCode.AssignEvenIfUsed.SetValue(true);
            //Set field value for AllowOverride
            //ItemInventoryAddRq.BarCode.AllowOverride.SetValue(true);

            //Set field value for IsActive
            ItemInventoryAddRq.IsActive.SetValue(true);

            if (inventoryItem.ClassRef != null)
            {
                ////Set field value for ListID
                //ItemInventoryAddRq.ClassRef.ListID.SetValue("200000-1011023419");
                ////Set field value for FullName
                //ItemInventoryAddRq.ClassRef.FullName.SetValue("ab");
            }

            if (inventoryItem.ParentRef != null)
            {
                ////Set field value for ListID
                //ItemInventoryAddRq.ParentRef.ListID.SetValue("200000-1011023419");
                ////Set field value for FullName
                //ItemInventoryAddRq.ParentRef.FullName.SetValue("ab");
            }

            //Set field value for ManufacturerPartNumber
            ItemInventoryAddRq.ManufacturerPartNumber.SetValue(inventoryItem.ManufacturerPartNumber.GetValue());
            if (inventoryItem.UnitOfMeasureSetRef != null)
            {
                //Set field value for ListID
                // ItemInventoryAddRq.UnitOfMeasureSetRef.ListID.SetValue("200000-1011023419");
                //Set field value for FullName
                //ItemInventoryAddRq.UnitOfMeasureSetRef.FullName.SetValue("ab");
            }

            //Set field value for IsTaxIncluded
            //ItemInventoryAddRq.IsTaxIncluded.SetValue(true);

            if (inventoryItem.SalesTaxCodeRef != null)
            {
                //Set field value for ListID
                //ItemInventoryAddRq.SalesTaxCodeRef.ListID.SetValue("200000-1011023419");
                //Set field value for FullName
                // ItemInventoryAddRq.SalesTaxCodeRef.FullName.SetValue("ab");
            }

            //Set field value for SalesDesc
            ItemInventoryAddRq.SalesDesc.SetValue(inventoryItem.SalesDesc.GetValue());
            //Set field value for SalesPrice
            ItemInventoryAddRq.SalesPrice.SetValue(inventoryItem.SalesPrice.GetValue());

            if (inventoryItem.IncomeAccountRef != null)
            {
                //Set field value for ListID
                ItemInventoryAddRq.IncomeAccountRef.ListID.SetValue(inventoryItem.IncomeAccountRef.ListID.GetValue()); //"80000008-1552559357"
                                                                                                                       //Set field value for FullName
                ItemInventoryAddRq.IncomeAccountRef.FullName.SetValue(inventoryItem.IncomeAccountRef.FullName.GetValue());
            }

            //Set field value for PurchaseDesc
            ItemInventoryAddRq.PurchaseDesc.SetValue(inventoryItem.PurchaseDesc.GetValue());
            //Set field value for PurchaseCost
            ItemInventoryAddRq.PurchaseCost.SetValue(inventoryItem.PurchaseCost.GetValue());

            //Set field value for ListID
            // ItemInventoryAddRq.PurchaseTaxCodeRef.ListID.SetValue("200000-1011023419");
            //Set field value for FullName
            // ItemInventoryAddRq.PurchaseTaxCodeRef.FullName.SetValue("ab");

            if (inventoryItem.COGSAccountRef != null)
            {
                //Set field value for ListID
                ItemInventoryAddRq.COGSAccountRef.ListID.SetValue(inventoryItem.COGSAccountRef.ListID.GetValue());
                //Set field value for FullName
                ItemInventoryAddRq.COGSAccountRef.FullName.SetValue(inventoryItem.COGSAccountRef.FullName.GetValue());
            }

            if (inventoryItem.PrefVendorRef != null)
            {
                //Set field value for ListID
                ItemInventoryAddRq.PrefVendorRef.ListID.SetValue(inventoryItem.PrefVendorRef.ListID.GetValue());
                //Set field value for FullName
                ItemInventoryAddRq.PrefVendorRef.FullName.SetValue(inventoryItem.PrefVendorRef.FullName.GetValue());
            }

            if (inventoryItem.AssetAccountRef != null)
            {
                //Set field value for ListID
                ItemInventoryAddRq.AssetAccountRef.ListID.SetValue(inventoryItem.AssetAccountRef.ListID.GetValue());
                //Set field value for FullName
                ItemInventoryAddRq.AssetAccountRef.FullName.SetValue(inventoryItem.AssetAccountRef.FullName.GetValue());
            }

            //Set field value for ReorderPoint
            // ItemInventoryAddRq.ReorderPoint.SetValue(2);
            //Set field value for Max
            // ItemInventoryAddRq.Max.SetValue(2);
            //Set field value for QuantityOnHand
            ItemInventoryAddRq.QuantityOnHand.SetValue(inventoryItem.QuantityOnHand.GetValue());
            //Set field value for TotalValue
            //ItemInventoryAddRq.TotalValue.SetValue(1500);
            //Set field value for InventoryDate
            //ItemInventoryAddRq.InventoryDate.SetValue(DateTime.Now);
            //ItemInventoryAddRq.InventoryDate.SetValue(DateTime.Parse("19-03-2019"));

            //Set field value for ExternalGUID
            //ItemInventoryAddRq.ExternalGUID.SetValue(Guid.NewGuid().ToString());

            //Set field value for IncludeRetElementList
            //May create more than one of these if needed
            //ItemInventoryAddRq.IncludeRetElementList.Add("ab");
        }
Beispiel #4
0
        private void BuildInventoryAdjustmentAddRq(IMsgSetRequest requestMsgSet, IAccountRetList accountInfo, IPreferencesRet PreferencesRet, IItemInventoryRet inventoryItem)
        {
            IInventoryAdjustmentAdd InventoryAdjustmentAddRq = requestMsgSet.AppendInventoryAdjustmentAddRq();

            //Set attributes
            //Set field value for defMacro
            InventoryAdjustmentAddRq.defMacro.SetValue("IQBStringType");
            //Set field value for ListID
            InventoryAdjustmentAddRq.AccountRef.ListID.SetValue(inventoryItem.AssetAccountRef.ListID.GetValue());;    //"80000022-1552565294"
            //Set field value for FullName
            InventoryAdjustmentAddRq.AccountRef.FullName.SetValue(inventoryItem.AssetAccountRef.FullName.GetValue()); //"Inventory Asset"

            //Set field value for TxnDate
            InventoryAdjustmentAddRq.TxnDate.SetValue(DateTime.Now); //"20-03-2019"

            //Set field value for RefNumber
            //InventoryAdjustmentAddRq.RefNumber.SetValue("ab");
            //Set field value for ListID
            //InventoryAdjustmentAddRq.InventorySiteRef.ListID.SetValue("200000-1011023419");
            //Set field value for FullName
            //InventoryAdjustmentAddRq.InventorySiteRef.FullName.SetValue("ab");
            //Set field value for ListID
            //InventoryAdjustmentAddRq.CustomerRef.ListID.SetValue("200000-1011023419");
            //Set field value for FullName
            //InventoryAdjustmentAddRq.CustomerRef.FullName.SetValue("ab");
            //Set field value for ListID
            // InventoryAdjustmentAddRq.ClassRef.ListID.SetValue("200000-1011023419");
            //Set field value for FullName
            //InventoryAdjustmentAddRq.ClassRef.FullName.SetValue("ab");
            //Set field value for Memo
            // InventoryAdjustmentAddRq.Memo.SetValue("ab");
            //Set field value for ExternalGUID
            //InventoryAdjustmentAddRq.ExternalGUID.SetValue(Guid.NewGuid().ToString());
            IInventoryAdjustmentLineAdd InventoryAdjustmentLineAdd10753 = InventoryAdjustmentAddRq.InventoryAdjustmentLineAddList.Append();

            //Set field value for ListID
            InventoryAdjustmentLineAdd10753.ItemRef.ListID.SetValue(inventoryItem.ListID.GetValue());     //"8000000B-1553066645" Item List Id
            //Set field value for FullName
            InventoryAdjustmentLineAdd10753.ItemRef.FullName.SetValue(inventoryItem.FullName.GetValue()); //"venky04" Item Name
            string ORTypeAdjustmentElementType10754 = "QuantityAdjustment";

            if (ORTypeAdjustmentElementType10754 == "QuantityAdjustment")
            {
                string ORQuantityAdjustmentElementType10755 = "NewQuantity";
                if (ORQuantityAdjustmentElementType10755 == "NewQuantity")
                {
                    //Set field value for NewQuantity
                    InventoryAdjustmentLineAdd10753.ORTypeAdjustment.QuantityAdjustment.ORQuantityAdjustment.NewQuantity.SetValue(inventoryItem.QuantityOnHand.GetValue());
                }
                //if (ORQuantityAdjustmentElementType10755 == "QuantityDifference")
                //{
                //    //Set field value for QuantityDifference
                //    InventoryAdjustmentLineAdd10753.ORTypeAdjustment.QuantityAdjustment.ORQuantityAdjustment.QuantityDifference.SetValue(10);
                //}

                //string ORSerialLotNumberElementType10756 = "SerialNumber";
                //if (ORSerialLotNumberElementType10756 == "SerialNumber")
                //{
                //    //Set field value for SerialNumber
                //    InventoryAdjustmentLineAdd10753.ORTypeAdjustment.QuantityAdjustment.ORSerialLotNumber.SerialNumber.SetValue("12345");
                //}
                //if (ORSerialLotNumberElementType10756 == "LotNumber")
                //{
                //    //Set field value for LotNumber
                //    InventoryAdjustmentLineAdd10753.ORTypeAdjustment.QuantityAdjustment.ORSerialLotNumber.LotNumber.SetValue("ab");
                //}

                ////Set field value for ListID
                //InventoryAdjustmentLineAdd10753.ORTypeAdjustment.QuantityAdjustment.InventorySiteLocationRef.ListID.SetValue("200000-1011023419");
                ////Set field value for FullName
                //InventoryAdjustmentLineAdd10753.ORTypeAdjustment.QuantityAdjustment.InventorySiteLocationRef.FullName.SetValue("ab");
            }
            if (ORTypeAdjustmentElementType10754 == "ValueAdjustment")
            {
                string ORQuantityAdjustmentElementType10757 = "NewQuantity";
                if (ORQuantityAdjustmentElementType10757 == "NewQuantity")
                {
                    //Set field value for NewQuantity
                    InventoryAdjustmentLineAdd10753.ORTypeAdjustment.ValueAdjustment.ORQuantityAdjustment.NewQuantity.SetValue(2);
                }
                if (ORQuantityAdjustmentElementType10757 == "QuantityDifference")
                {
                    //Set field value for QuantityDifference
                    InventoryAdjustmentLineAdd10753.ORTypeAdjustment.ValueAdjustment.ORQuantityAdjustment.QuantityDifference.SetValue(2);
                }
                string ORValueAdjustmentElementType10758 = "NewValue";
                if (ORValueAdjustmentElementType10758 == "NewValue")
                {
                    //Set field value for NewValue
                    InventoryAdjustmentLineAdd10753.ORTypeAdjustment.ValueAdjustment.ORValueAdjustment.NewValue.SetValue(10.01);
                }
                if (ORValueAdjustmentElementType10758 == "ValueDifference")
                {
                    //Set field value for ValueDifference
                    InventoryAdjustmentLineAdd10753.ORTypeAdjustment.ValueAdjustment.ORValueAdjustment.ValueDifference.SetValue(10.01);
                }
            }
            if (ORTypeAdjustmentElementType10754 == "SerialNumberAdjustment")
            {
                string ORSerialNumberAdjustmentElementType10759 = "AddSerialNumber";
                if (ORSerialNumberAdjustmentElementType10759 == "AddSerialNumber")
                {
                    //Set field value for AddSerialNumber
                    InventoryAdjustmentLineAdd10753.ORTypeAdjustment.SerialNumberAdjustment.ORSerialNumberAdjustment.AddSerialNumber.SetValue("ab");
                }
                if (ORSerialNumberAdjustmentElementType10759 == "RemoveSerialNumber")
                {
                    //Set field value for RemoveSerialNumber
                    InventoryAdjustmentLineAdd10753.ORTypeAdjustment.SerialNumberAdjustment.ORSerialNumberAdjustment.RemoveSerialNumber.SetValue("ab");
                }
                //Set field value for ListID
                InventoryAdjustmentLineAdd10753.ORTypeAdjustment.SerialNumberAdjustment.InventorySiteLocationRef.ListID.SetValue("200000-1011023419");
                //Set field value for FullName
                InventoryAdjustmentLineAdd10753.ORTypeAdjustment.SerialNumberAdjustment.InventorySiteLocationRef.FullName.SetValue("ab");
            }
            if (ORTypeAdjustmentElementType10754 == "LotNumberAdjustment")
            {
                //Set field value for LotNumber
                InventoryAdjustmentLineAdd10753.ORTypeAdjustment.LotNumberAdjustment.LotNumber.SetValue("ab");
                //Set field value for CountAdjustment
                InventoryAdjustmentLineAdd10753.ORTypeAdjustment.LotNumberAdjustment.CountAdjustment.SetValue(6);
                //Set field value for ListID
                InventoryAdjustmentLineAdd10753.ORTypeAdjustment.LotNumberAdjustment.InventorySiteLocationRef.ListID.SetValue("200000-1011023419");
                //Set field value for FullName
                InventoryAdjustmentLineAdd10753.ORTypeAdjustment.LotNumberAdjustment.InventorySiteLocationRef.FullName.SetValue("ab");
            }
            if (ORTypeAdjustmentElementType10754 == "")
            {
            }
            //Set field value for IncludeRetElementList
            //May create more than one of these if needed
            // InventoryAdjustmentAddRq.IncludeRetElementList.Add("ab");
        }
Beispiel #5
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 #6
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);
        }