예제 #1
0
        private string FormatDiagnosticMessage(string message, params object[] args)
        {
            var formattedMessage = string.Format(message, args);

            return
                ($"Entity: {PrimaryEntityName}, Entity Id: {PrimaryEntityId.ToString()}, Request Id: {PluginExecutionContext.RequestId.ToString()}, Correlation Id: {PluginExecutionContext.CorrelationId.ToString()}, Depth: {Depth}, UserId: {UserId.ToString()}, Initiating User: {InitiatingUserId.ToString()}\n{formattedMessage}");
        }
예제 #2
0
        protected override void Execute(CodeActivityContext executionContext)
        {
            //Create the tracing service
            ITracingService tracingService = executionContext.GetExtension <ITracingService>();

            //Create the context
            IWorkflowContext            context        = executionContext.GetExtension <IWorkflowContext>();
            IOrganizationServiceFactory serviceFactory = executionContext.GetExtension <IOrganizationServiceFactory>();
            IOrganizationService        service        = serviceFactory.CreateOrganizationService(context.UserId);

            tracingService.Trace("Iniciando workflow");


            if (context == null)
            {
                throw new InvalidPluginExecutionException("Failed to retrieve workflow context.");
            }

            //Save off the values
            PrimaryEntityId.Set(executionContext, context.PrimaryEntityId.ToString());

            if (context.RequestId.HasValue)
            {
                RequestId.Set(executionContext, context.RequestId.Value.ToString());
            }

            PrimaryEntityName.Set(executionContext, context.PrimaryEntityName);
            SecondaryEntityName.Set(executionContext, context.SecondaryEntityName);
            CorrelationId.Set(executionContext, context.CorrelationId.ToString());
            InitiatingUserId.Set(executionContext, context.InitiatingUserId.ToString());
            OperationId.Set(executionContext, context.OperationId.ToString());

            Guid guid = new Guid(PrimaryEntityId.Get <string>(executionContext));

            Entity entitlement = service.Retrieve("entitlement", new Guid(PrimaryEntityId.Get <string>(executionContext)), new ColumnSet(new String[] { "name", "statecode", "statuscode", "startdate" }));

            entitlement["statecode"]  = new OptionSetValue(1);
            entitlement["statuscode"] = new OptionSetValue(1);

            service.Update(entitlement);
        }