public void Execute(IServiceProvider serviceProvider)
        {
            //Extract the tracing service for use in debugging sandboxed plug-ins.
            ITracingService tracingService =
                (ITracingService)serviceProvider.GetService(typeof(ITracingService));
            FaultException ex1 = new FaultException();
            // Obtain the execution context from the service provider.
            IPluginExecutionContext context = (IPluginExecutionContext)
                                              serviceProvider.GetService(typeof(IPluginExecutionContext));

            try
            {
                IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
                IOrganizationService        service        = serviceFactory.CreateOrganizationService(context.UserId);
                EntityCollection            targets        = (EntityCollection)context.OutputParameters["BusinessEntityCollection"];

                var lang = new UserLocaleHelper(service, context).getUserLanguage();

                if (context.Depth <= 1)
                {
                    foreach (Entity outputEntity in targets.Entities)
                    {
                        var publisherPrefix = outputEntity.LogicalName.Split('_')[0];
                        if (publisherPrefix == outputEntity.LogicalName)
                        {
                            publisherPrefix = "egcs";
                        }
                        Entity entity     = service.Retrieve(outputEntity.LogicalName, outputEntity.Id, new ColumnSet(publisherPrefix + "_nameen", publisherPrefix + "_namefr"));
                        var    translator = new MultiLingual(service, tracingService, context, outputEntity, entity);
                        translator.translateOutput();
                    }
                }
            }
            catch (FaultException <OrganizationServiceFault> ex)
            {
                throw new InvalidPluginExecutionException("An error occurred in the multi lingual plug-in.", ex);
            }
        }
        public void Execute(IServiceProvider serviceProvider)
        {
            //Extract the tracing service for use in debugging sandboxed plug-ins.
            ITracingService tracingService =
                (ITracingService)serviceProvider.GetService(typeof(ITracingService));
            FaultException ex1 = new FaultException();
            // Obtain the execution context from the service provider.
            IPluginExecutionContext context = (IPluginExecutionContext)
                                              serviceProvider.GetService(typeof(IPluginExecutionContext));

            try
            {
                IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
                IOrganizationService        service        = serviceFactory.CreateOrganizationService(context.UserId);
                Entity outputEntity = (Entity)context.OutputParameters["BusinessEntity"];
                // var entityRef = (EntityReference)context.InputParameters["Target"];

                if (outputEntity != null)
                {
                    if (context.Depth > 1)
                    {
                        return;
                    }
                    //get current entity inside this context
                    QueryExpression qe = new QueryExpression(outputEntity.LogicalName);
                    qe.Criteria.AddCondition(outputEntity.LogicalName + "id", ConditionOperator.Equal, outputEntity.Id);
                    qe.ColumnSet = new ColumnSet(true);
                    Entity entity = service.RetrieveMultiple(qe).Entities[0];

                    var translator = new MultiLingual(service, tracingService, context, outputEntity, entity);
                    translator.translateOutput();
                }
            }
            catch (FaultException <OrganizationServiceFault> ex)
            {
                throw new InvalidPluginExecutionException("An error occurred in the multi lingual plug-in.", ex);
            }
        }