/// <summary>
        /// Adds a TaxCode under the specified realm. The realm must be set in the context.
        /// </summary>
        /// <param name="taxCode">TaxCode to Add.</param>
        public void AddTaxCodeAsync(Intuit.Ipp.Data.TaxService taxCode)
        {
            Console.Write("AddAsync started \n");
            this.serviceContext.IppConfiguration.Logger.CustomLogger.Log(Diagnostics.TraceLevel.Info, "Called Method Add Asynchronously.");
            GlobalTaxServiceCallCompletedEventArgs <Intuit.Ipp.Data.TaxService> callCompletedEventArgs = new GlobalTaxServiceCallCompletedEventArgs <Intuit.Ipp.Data.TaxService>();

            Console.Write("callCompletedEventArgs instantiated \n");

            if (!GlobalTaxServiceHelper.IsTypeNull(taxCode))
            {
                IdsException exception = new IdsException(Resources.ParameterNotNullMessage, new ArgumentNullException(Resources.EntityString));
                Console.Write("IdsException instantiated \n");
                this.serviceContext.IppConfiguration.Logger.CustomLogger.Log(Diagnostics.TraceLevel.Error, string.Format(CultureInfo.InvariantCulture, Resources.ExceptionGeneratedMessage, exception.ToString()));
                callCompletedEventArgs.Error = exception;
                this.OnAddTaxCodeAsyncCompleted(this, callCompletedEventArgs);
            }
            else
            {
                try
                {
                    GlobalAsyncTaxService asyncService = new GlobalAsyncTaxService(this.serviceContext);
                    asyncService.OnAddTaxCodeAsyncCompleted += new GlobalTaxServiceCallback <Intuit.Ipp.Data.TaxService> .GlobalTaxServiceCallCompletedEventHandler(this.AddTaxCodeAsyncCompleted);

                    asyncService.AddTaxCodeAsync(taxCode as Intuit.Ipp.Data.TaxService);
                }
                catch (SystemException systemException)
                {
                    this.serviceContext.IppConfiguration.Logger.CustomLogger.Log(TraceLevel.Error, systemException.Message);
                    IdsException idsException = new IdsException(systemException.Message);
                    callCompletedEventArgs.Error = idsException;
                    this.OnAddTaxCodeAsyncCompleted(this, callCompletedEventArgs);
                }
            }
        }
Example #2
0
        /// <summary>
        /// call back method for asynchronously Executing a Report
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="eventArgs">The <see cref="Intuit.Ipp.Core.AsyncCallCompletedEventArgs"/> instance containing the event data.</param>
        private void AddTaxCodeAsyncCompleted(object sender, AsyncCallCompletedEventArgs eventArgs)
        {
            GlobalTaxServiceCallCompletedEventArgs <Intuit.Ipp.Data.TaxService> taxServiceCallCompletedEventArgs = new GlobalTaxServiceCallCompletedEventArgs <Intuit.Ipp.Data.TaxService>();

            if (eventArgs.Error == null)
            {
                try
                {
                    IEntitySerializer responseSerializer = CoreHelper.GetSerializer(this.serviceContext, false);
                    IntuitResponse    restResponse       = (IntuitResponse)responseSerializer.Deserialize <IntuitResponse>(eventArgs.Result);
                    taxServiceCallCompletedEventArgs.TaxService = restResponse.AnyIntuitObject as Intuit.Ipp.Data.TaxService;
                    this.serviceContext.IppConfiguration.Logger.CustomLogger.Log(Diagnostics.TraceLevel.Info, "Finished Executing event AddTaxCodeAsyncCompleted in AyncService object.");
                    this.OnAddTaxCodeAsyncCompleted(this, taxServiceCallCompletedEventArgs);
                }
                catch (SystemException systemException)
                {
                    IdsException idsException = CreateIdsException(systemException);
                    this.serviceContext.IppConfiguration.Logger.CustomLogger.Log(TraceLevel.Error, idsException.ToString());
                    taxServiceCallCompletedEventArgs.Error = idsException;
                    this.OnAddTaxCodeAsyncCompleted(this, taxServiceCallCompletedEventArgs);
                }
            }
            else
            {
                taxServiceCallCompletedEventArgs.Error = eventArgs.Error;
                this.OnAddTaxCodeAsyncCompleted(this, taxServiceCallCompletedEventArgs);
            }
        }
Example #3
0
        /// <summary>
        /// Adds an entity (asynchronously) under the specified realm in an asynchronous manner. The realm must be set in the context.
        /// </summary>
        /// <param name="entity">Entity to Add</param>
        public void AddTaxCodeAsync(Intuit.Ipp.Data.TaxService taxCode)
        {
            this.serviceContext.IppConfiguration.Logger.CustomLogger.Log(Diagnostics.TraceLevel.Info, "Called Method Add Asynchronously.");
            AsyncRestHandler asyncRestHandler = new AsyncRestHandler(this.serviceContext);

            asyncRestHandler.OnCallCompleted += new EventHandler <AsyncCallCompletedEventArgs>(this.AddTaxCodeAsyncCompleted);
            GlobalTaxServiceCallCompletedEventArgs <Intuit.Ipp.Data.TaxService> taxServiceCallCompletedEventArgs = new GlobalTaxServiceCallCompletedEventArgs <Intuit.Ipp.Data.TaxService>();
            string resourceString = taxCode.GetType().Name.ToLower(CultureInfo.InvariantCulture);



            try
            {
                // Builds resource Uri
                string uri = string.Format(CultureInfo.InvariantCulture, "{0}/company/{1}/{2}/taxcode", CoreConstants.VERSION, this.serviceContext.RealmId, resourceString);

                // Create request parameters
                RequestParameters parameters;
                if (this.serviceContext.IppConfiguration.Message.Request.SerializationFormat == Intuit.Ipp.Core.Configuration.SerializationFormat.Json)
                {
                    parameters = new RequestParameters(uri, HttpVerbType.POST, CoreConstants.CONTENTTYPE_APPLICATIONJSON);
                }
                else
                {
                    parameters = new RequestParameters(uri, HttpVerbType.POST, CoreConstants.CONTENTTYPE_APPLICATIONXML);
                }

                // Prepare request
                HttpWebRequest request = asyncRestHandler.PrepareRequest(parameters, taxCode);

                //// get response
                asyncRestHandler.GetResponse(request);
            }
            catch (SystemException systemException)
            {
                this.serviceContext.IppConfiguration.Logger.CustomLogger.Log(TraceLevel.Error, systemException.Message);
                IdsException idsException = new IdsException(systemException.Message);
                taxServiceCallCompletedEventArgs.Error = idsException;
                this.OnAddTaxCodeAsyncCompleted(this, taxServiceCallCompletedEventArgs);
            }
        }
 /// <summary>
 /// Add Asynchronous call back method
 /// </summary>
 /// <param name="sender">Rest handler class</param>
 /// <param name="eventArgs">callback event arguments</param>
 private void AddTaxCodeAsyncCompleted(object sender, GlobalTaxServiceCallCompletedEventArgs <Intuit.Ipp.Data.TaxService> eventArgs)
 {
     this.serviceContext.IppConfiguration.Logger.CustomLogger.Log(Diagnostics.TraceLevel.Info, "Finished Executing Method AddTaxCode Async.");
     this.OnAddTaxCodeAsyncCompleted(sender, eventArgs);
 }