public ProcessCustomerService(PayloadCustomer payloadCustomer) { if (payloadCustomer == null) { throw new InvalidPluginExecutionException("Cannot create instance of Service - customer payload instance is null."); } this.payloadCustomer = payloadCustomer; trace = payloadCustomer.Trace; crmService = payloadCustomer.CrmService; }
protected override void Execute(CodeActivityContext executionContext) { ITracingService tracingService = executionContext.GetExtension <ITracingService>(); IWorkflowContext context = executionContext.GetExtension <IWorkflowContext>(); IOrganizationServiceFactory serviceFactory = executionContext.GetExtension <IOrganizationServiceFactory>(); IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId); try { var customerJson = CustomerInfo.Get <string>(executionContext); var operationType = OperationType.Get <string>(executionContext); PayloadCustomer payloadCustomer = new PayloadCustomer(tracingService, service); payloadCustomer.Customer = JsonHelper.DeserializeCustomerJson(customerJson, tracingService); payloadCustomer.OperationType = operationType; ProcessCustomerService process = new ProcessCustomerService(payloadCustomer); Response.Set(executionContext, process.processPayload()); } catch (FaultException <OrganizationServiceFault> ex) { tracingService.Trace(ex.ToString()); throw new InvalidPluginExecutionException(ex.ToString()); } catch (InvalidPluginExecutionException ex) { tracingService.Trace(ex.ToString()); throw new InvalidPluginExecutionException(ex.ToString()); } catch (TimeoutException ex) { tracingService.Trace(ex.ToString()); throw new InvalidPluginExecutionException(ex.ToString()); } catch (Exception ex) { tracingService.Trace(ex.ToString()); throw new InvalidPluginExecutionException(ex.ToString()); } }
public void ProcessCustomerService_PayloadCustomerNullCheck() { PayloadCustomer customer = null; ProcessCustomerService cs = new ProcessCustomerService(customer); }