[TestMethod()]//INFO: there is possibility that there is no change in past two days for customer or vendor, then CDC will not return any entities. FIX: make an operation for customer and vendor before calling CDC
        public void CDCTest()
        {
            Customer addedCustomer = dataServiceTestCases.AddEntity(DataServiceTestHelper.CreateCustomer()) as Customer;
            if (addedCustomer == null || addedCustomer.Id == null)
            {
                Assert.Inconclusive("Unable to add customer to verify CDC Test");
            }

            Vendor addedVendor = dataServiceTestCases.AddEntity(DataServiceTestHelper.CreateVendor()) as Vendor;
            if (addedVendor == null || addedVendor.Id == null)
            {
                Assert.Inconclusive("Unable to add vendor to verify CDC Test");
            }

            List<IEntity> entityList = new List<IEntity>() { new Customer(), new Vendor() };

            IntuitCDCResponse cdcResponse = dataServiceTestCases.CDCEntity(entityList, System.DateTime.Today.AddDays(-2));
            try
            {
                List<Customer> customerList = cdcResponse.getEntity("Customer").Cast<Customer>().ToList();
                Assert.IsNotNull(customerList);

                List<Vendor> vendorList = cdcResponse.getEntity("Vendor").Cast<Vendor>().ToList();
                Assert.IsNotNull(customerList);

            }
            catch (System.Exception ex)
            {
                Assert.Fail(ex.ToString());
            }
        }
        internal static List <T> CDC <T>(ServiceContext context, T entity, DateTime changedSince) where T : IEntity
        {
            //Initializing the Dataservice object with ServiceContext
            DataService service = new DataService(context);

            List <IEntity> entityList = new List <IEntity>();

            entityList.Add(entity);

            IntuitCDCResponse response = service.CDC(entityList, changedSince);

            if (response.entities.Count == 0)
            {
                return(null);
            }
            //Retrieving the entity List
            List <T> found = response.getEntity(entity.GetType().Name).Cast <T>().ToList();

            return(found);
        }
示例#3
0
        /// <summary>
        /// Get CDC details
        /// </summary>
        /// <returns></returns>
        internal static IntuitCDCResponse GetCDCDetails(OAuthTokensRealmLastUpdateddto OAuthTokensRealmLastUpdateddto)
        {
            List <IEntity> entityList        = new List <IEntity>();
            string         getEntitiesForCDC = ConfigurationManager.AppSettings["WebhooksEntities"].ToString();

            //Get all configured entities for Webhooks to make cdc call
            //Break config values and then add to list of entities to fecth with CDC operation
            string[] entities = getEntitiesForCDC.Trim().Split(',');
            foreach (string entity in entities)
            {
                switch (entity.ToLower())
                {
                case "customer":
                    entityList.Add(new Customer());
                    break;

                case "invoice":
                    entityList.Add(new Invoice());
                    break;

                case "salesreceipt":
                    entityList.Add(new SalesReceipt());
                    break;

                case "estimate":
                    entityList.Add(new Estimate());
                    break;

                case "vendor":
                    entityList.Add(new Vendor());
                    break;

                case "account":
                    entityList.Add(new Account());
                    break;

                case "payment":
                    entityList.Add(new Payment());
                    break;

                case "class":
                    entityList.Add(new Class());
                    break;

                case "Item":
                    entityList.Add(new Item());
                    break;

                case "billpayment":
                    entityList.Add(new BillPayment());
                    break;

                case "employee":
                    entityList.Add(new Employee());
                    break;

                case "purchase":
                    entityList.Add(new Purchase());
                    break;

                default:
                    break;
                }
            }

            //Create a CDCSyncService object
            CDCSyncService sync = new CDCSyncService(OAuthTokensRealmLastUpdateddto);//check for consumer key n secret

            //Get Dataservice object for calling CDC
            DataService qboService = new DataService(sync.dataserviceFactory.getServiceContext);

            //Make CDC call
            IntuitCDCResponse CDCResponse = qboService.CDC(entityList, OAuthTokensRealmLastUpdateddto.OAuthTokens.realmlastupdated);


            return(CDCResponse);
        }