Esempio n. 1
0
        public override void Execute()
        {
            Trace(string.Format(CultureInfo.InvariantCulture, TraceMessageHelper.EnteredMethod, SystemTypeName, MethodBase.GetCurrentMethod().Name));

            using (OrganizationServiceContext = OrganizationServiceContext ?? new CrmServiceContext(OrganizationService))
                using (CrmService = CrmService ?? new CrmService(OrganizationServiceContext, TracingService))
                    using (InitializeEntityService = InitializeEntityService ?? new InitializeEntityService(CrmService, OrganizationServiceContext, WorkflowContext, TracingService))
                    {
                        Trace(string.Format(CultureInfo.InvariantCulture, "{0} : {1} started at {2} milliseconds", SystemTypeName, MethodBase.GetCurrentMethod().Name, Stopwatch.ElapsedMilliseconds));

                        // Call the business logic
                        InitializedEntity output = InitializeEntityService.InitializeEntity(
                            BusinessEntityPrimaryKey.Get <string>(CodeActivityContext)
                            );

                        // Serialize the output in JSON data format
                        string json = SerializationHelper.SerializeJson(output);

                        // Return the JSON data to the caller
                        InitializedEntity.Set(CodeActivityContext, json);

                        Trace(string.Format(CultureInfo.InvariantCulture, "{0} : {1} ended at {2} milliseconds", SystemTypeName, MethodBase.GetCurrentMethod().Name, Stopwatch.ElapsedMilliseconds));
                    }

            Trace(string.Format(CultureInfo.InvariantCulture, TraceMessageHelper.ExitingMethod, SystemTypeName, MethodBase.GetCurrentMethod().Name));
        }
Esempio n. 2
0
        public override void Validate()
        {
            Trace(string.Format(CultureInfo.InvariantCulture, TraceMessageHelper.EnteredMethod, SystemTypeName, MethodBase.GetCurrentMethod().Name));

            // Exceptions will be handled by the caller
            ThrowsException = false;

            string someEntityPrimaryKey = BusinessEntityPrimaryKey.Get <string>(CodeActivityContext);

            if (string.IsNullOrWhiteSpace(someEntityPrimaryKey))
            {
                throw new InvalidPluginExecutionException(BusinessEntityPrimaryKeyIsRequiredMessage);
            }

            Guid key; bool isValidGuid = Guid.TryParse(someEntityPrimaryKey, out key);

            if (!isValidGuid)
            {
                throw new InvalidPluginExecutionException(BusinessEntityPrimaryKeyIsInvalidMessage);
            }

            Trace(string.Format(CultureInfo.InvariantCulture, TraceMessageHelper.ExitingMethod, SystemTypeName, MethodBase.GetCurrentMethod().Name));
        }