/// <summary>
        /// Executes the plug-in.
        /// </summary>
        /// <param name="localContext">The <see cref="LocalPluginContext"/> which contains the
        /// <see cref="IPluginExecutionContext"/>,
        /// <see cref="IOrganizationService"/>
        /// and <see cref="ITracingService"/>
        /// </param>
        /// <remarks>
        /// For improved performance, Microsoft Dynamics CRM caches plug-in instances.
        /// The plug-in's Execute method should be written to be stateless as the constructor
        /// is not called for every invocation of the plug-in. Also, multiple system threads
        /// could execute the plug-in at the same time. All per invocation state information
        /// is stored in the context. This means that you should not use global variables in plug-ins.
        /// </remarks>
        protected void ExecutePostTaxMaintenanceCreate(LocalPluginContext localContext)
        {
            if (localContext == null)
            {
                throw new ArgumentNullException("localContext");
            }

            IPluginExecutionContext context = localContext.PluginExecutionContext;
            IOrganizationService    service = localContext.OrganizationService;
            ITracingService         trace   = localContext.TracingService;
            Entity taxMaintenance           = (Entity)context.InputParameters["Target"];


            try
            {
                Boolean TaxDefault = taxMaintenance.GetAttributeValue <Boolean>("gsc_isdefault");
                //Boolean postImageTaxDefault = postImageEntity.GetAttributeValue<Boolean>("gsc_isdefault");
                if (TaxDefault == true)
                {
                    trace.Trace("yes");
                    TaxMaintenanceHandler TaxMaintenanceHandler = new TaxMaintenanceHandler(service, trace);
                    TaxMaintenanceHandler.TaxDefaultUpdate(taxMaintenance);
                }
            }
            catch (Exception ex)
            {
                throw new InvalidPluginExecutionException(String.Concat(ex.Message));
            }
        }
        /// <summary>
        /// Executes the plug-in.
        /// </summary>
        /// <param name="localContext">The <see cref="LocalPluginContext"/> which contains the
        /// <see cref="IPluginExecutionContext"/>,
        /// <see cref="IOrganizationService"/>
        /// and <see cref="ITracingService"/>
        /// </param>
        /// <remarks>
        /// For improved performance, Microsoft Dynamics CRM caches plug-in instances.
        /// The plug-in's Execute method should be written to be stateless as the constructor
        /// is not called for every invocation of the plug-in. Also, multiple system threads
        /// could execute the plug-in at the same time. All per invocation state information
        /// is stored in the context. This means that you should not use global variables in plug-ins.
        /// </remarks>
        protected void ExecutePostTaxMaintenanceUpdate(LocalPluginContext localContext)
        {
            if (localContext == null)
            {
                throw new ArgumentNullException("localContext");
            }

            IPluginExecutionContext context         = localContext.PluginExecutionContext;
            IOrganizationService    service         = localContext.OrganizationService;
            ITracingService         _tracingService = localContext.TracingService;

            Entity preImageEntity  = (context.PreEntityImages != null && context.PreEntityImages.Contains(this.preImageAlias)) ? context.PreEntityImages[this.preImageAlias] : null;
            Entity postImageEntity = (context.PostEntityImages != null && context.PostEntityImages.Contains(this.postImageAlias)) ? context.PostEntityImages[this.postImageAlias] : null;

            Entity taxMaintenance = (Entity)context.InputParameters["Target"];

            if (!(context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity))
            {
                return;
            }
            if (taxMaintenance.LogicalName != "gsc_cmn_taxmaintenance")
            {
                return;
            }
            if (context.Mode == 0)
            {
                try
                {
                    Boolean preImageTaxDefault = preImageEntity.GetAttributeValue <Boolean>("gsc_isdefault");
                    var     preImageRate       = preImageEntity.Contains("gsc_rate") ? preImageEntity.GetAttributeValue <double>("gsc_rate")
                        : 0;


                    Boolean postImageTaxDefault = postImageEntity.GetAttributeValue <Boolean>("gsc_isdefault");
                    var     postImagerate       = postImageEntity.Contains("gsc_rate") ? postImageEntity.GetAttributeValue <double>("gsc_rate")
                        : 0;

                    TaxMaintenanceHandler TaxMaintenanceHandler = new TaxMaintenanceHandler(service, _tracingService);
                    if ((preImageTaxDefault != postImageTaxDefault) && (postImageTaxDefault == true))
                    {
                        _tracingService.Trace("yes");

                        TaxMaintenanceHandler.TaxDefaultUpdate(postImageEntity);
                    }

                    //Run functions when tax rate is updated
                    if (preImageRate != postImagerate)
                    {
                        TaxMaintenanceHandler.UpdateVehicleTaxRate(postImageEntity);
                    }
                }

                catch (Exception ex)
                {
                    //throw new InvalidPluginExecutionException(String.Concat("(Exception)\n", ex.Message, Environment.NewLine, ex.StackTrace, Environment.NewLine, error));
                    throw new InvalidPluginExecutionException(ex.Message);
                }
            }
        }