/// <summary>
        /// Main entry point for the business logic that the plug-in is to execute.
        /// </summary>
        /// <param name="serviceProvider">The service provider.</param>
        public void Execute(IServiceProvider serviceProvider)
        {
            if (serviceProvider == null)
            {
                throw new InvalidPluginExecutionException("serviceProvider");
            }

            LocalPluginContext localcontext = new LocalPluginContext(serviceProvider);

            localcontext.Trace($"Entered {this.ChildClassName}.Execute()");

            try
            {
                this.ExecuteCrmPlugin(localcontext);
            }
            catch (FaultException <OrganizationServiceFault> e)
            {
                localcontext.Trace($"Exception: {e.ToString()}");
                Logger.Log(e, localcontext.TracingService);
                throw;
            }
            catch (Exception ex)
            {
                Logger.Log(ex, localcontext.TracingService);
                throw;
            }
            finally
            {
                localcontext.Trace($"Exiting {this.ChildClassName}.Execute()");
            }
        }
Esempio n. 2
0
        protected override void ExecuteCrmPlugin(LocalPluginContext localContext)
        {
            localContext.Trace($"Entered my method .Execute()");
            Contact contact = InputParameters.GetTarget(localContext.PluginExecutionContext).ToEntity <Contact>();

            ContactManager.SetValuesForReadOnlyFieldsOnPreCreate(localContext.OrganizationService, localContext.TracingService, contact);
        }
        protected override void ExecuteCrmPlugin(LocalPluginContext localContext)
        {
            localContext.Trace($"Entered my method Execute()");
            Contact contactPre  = localContext.PluginExecutionContext.PreEntityImages["contactPostOperationUpdatePreImage"].ToEntity <Contact>();
            Contact contactPost = localContext.PluginExecutionContext.PostEntityImages["contactPostOperationUpdatePostImage"].ToEntity <Contact>();

            ContactManager.NotifyClientAboutChanges(localContext.OrganizationService, localContext.PluginExecutionContext, localContext.ServiceProvider, localContext.TracingService, contactPre, contactPost);
        }
 protected override void ExecuteCrmPlugin(LocalPluginContext localContext)
 {
     localContext.Trace($"Entered my method create task .Execute()");
     TaskManager.CreateTaskAboutAFollowUpMeeting(localContext.OrganizationService, localContext.PluginExecutionContext, localContext.TracingService);
 }