protected override void Execute(CodeActivityContext context) { ITracingService tracing = context.GetExtension <ITracingService>(); IWorkflowContext workflowContext = context.GetExtension <IWorkflowContext>(); IOrganizationService service = context.GetExtension <IOrganizationServiceFactory>().CreateOrganizationService(workflowContext.InitiatingUserId); FuncLibrary aux = new FuncLibrary(); find_marketingautomationintegration sendGridAccount = aux.GetMailchimpInfo(service); Apihelper.InitializeClient(sendGridAccount.find_SendGridIntegration); ApiRoot apiRoot = new ApiRoot(); List list = service.Retrieve(MarketingList.Get(context).LogicalName, MarketingList.Get(context).Id, new ColumnSet("find_sendgridid")).ToEntity <List>(); Campaign campaign = service.Retrieve(Campaign.Get(context).LogicalName, Campaign.Get(context).Id, new ColumnSet("name")).ToEntity <Campaign>(); EntityReference memberReference = new EntityReference(MemberType.Get(context), new Guid(MemberId.Get(context))); find_metric metric = GetMetricByCampaign(service, campaign); if (HasMetricDetailsToMember(service, metric, memberReference)) { return; } CreateMetricDetails(service, metric, memberReference); SyncMemberTypeToSendGrid(service, memberReference, list, apiRoot, tracing); }
// Module defining this command // Optional custom code for this activity /// <summary> /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run. /// </summary> /// <param name="context">The NativeActivityContext for the currently running activity.</param> /// <returns>A populated instance of Sytem.Management.Automation.PowerShell</returns> /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks> protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context) { System.Management.Automation.PowerShell invoker = global::System.Management.Automation.PowerShell.Create(); System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName); // Initialize the arguments if (InputObject.Expression != null) { targetCommand.AddParameter("InputObject", InputObject.Get(context)); } if (Name.Expression != null) { targetCommand.AddParameter("Name", Name.Get(context)); } if (MemberType.Expression != null) { targetCommand.AddParameter("MemberType", MemberType.Get(context)); } if (View.Expression != null) { targetCommand.AddParameter("View", View.Get(context)); } if (Static.Expression != null) { targetCommand.AddParameter("Static", Static.Get(context)); } if (Force.Expression != null) { targetCommand.AddParameter("Force", Force.Get(context)); } return(new ActivityImplementationContext() { PowerShellInstance = invoker }); }
// Module defining this command // Optional custom code for this activity /// <summary> /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run. /// </summary> /// <param name="context">The NativeActivityContext for the currently running activity.</param> /// <returns>A populated instance of System.Management.Automation.PowerShell</returns> /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks> protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context) { System.Management.Automation.PowerShell invoker = global::System.Management.Automation.PowerShell.Create(); System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName); // Initialize the arguments if (InputObject.Expression != null) { targetCommand.AddParameter("InputObject", InputObject.Get(context)); } if (MemberType.Expression != null) { targetCommand.AddParameter("MemberType", MemberType.Get(context)); } if (Name.Expression != null) { targetCommand.AddParameter("Name", Name.Get(context)); } if (Value.Expression != null) { targetCommand.AddParameter("Value", Value.Get(context)); } if (SecondValue.Expression != null) { targetCommand.AddParameter("SecondValue", SecondValue.Get(context)); } if (TypeName.Expression != null) { targetCommand.AddParameter("TypeName", TypeName.Get(context)); } if (Force.Expression != null) { targetCommand.AddParameter("Force", Force.Get(context)); } if (PassThru.Expression != null) { targetCommand.AddParameter("PassThru", PassThru.Get(context)); } if (NotePropertyName.Expression != null) { targetCommand.AddParameter("NotePropertyName", NotePropertyName.Get(context)); } if (NotePropertyValue.Expression != null) { targetCommand.AddParameter("NotePropertyValue", NotePropertyValue.Get(context)); } if (NotePropertyMembers.Expression != null) { targetCommand.AddParameter("NotePropertyMembers", NotePropertyMembers.Get(context)); } return(new ActivityImplementationContext() { PowerShellInstance = invoker }); }