protected void Initialize(IServiceProvider serviceProvider) { if (_sender_test == null) { _tracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService)); _context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext)); try { IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory)); _service = serviceFactory.CreateOrganizationService(_context.UserId); } catch (Exception exception) { _tracingService.Trace("ofplug: {0}", exception.ToString()); throw; } } if (_context != null && _context.InputParameters != null && _context.InputParameters.Contains("Target") && _context.InputParameters["Target"] is Entity) { _context_entity = (Entity)_context.InputParameters["Target"]; } _config = new crm.Config(_service, _tracingService); _of_connection = new of.Connection(_config.Nrq_of_url, _config.Nrq_of_token); if (_sender_test != null) { _of_connection.Replace_sender(_sender_test); } }
protected void Initialize(CodeActivityContext codeActivityContext) { if (IsTest == false) { _tracingService = codeActivityContext.GetExtension <ITracingService>(); IWorkflowContext workflowContext = codeActivityContext.GetExtension <IWorkflowContext>(); IOrganizationServiceFactory serviceFactory = codeActivityContext.GetExtension <IOrganizationServiceFactory>(); _service = serviceFactory.CreateOrganizationService(workflowContext.UserId); } _config = new crm.Config(_service, _tracingService); _of_connection = new of.Connection(_config.Nrq_of_url, _config.Nrq_of_token); if (IsTest) { _of_connection.Replace_sender(_sender_test); } }