Exemplo n.º 1
0
        public static void DebugContext(this ITracingService tracingService, IPluginExecutionContext context)
        {
#if DEBUG
            var preEntityImages  = context.PreEntityImages == null ? null : context.PreEntityImages.Values.Select(x => EntityToObject(x));
            var postEntityImages = context.PostEntityImages == null ? null : context.PostEntityImages.Values.Select(x => EntityToObject(x));
            var inputParameters  = new Dictionary <string, object>();
            foreach (var key in context.InputParameters.Keys)
            {
                if (context.InputParameters[key] is Entity x)
                {
                    inputParameters.Add(key, EntityToObject(x));
                }
                else
                {
                    inputParameters.Add(key, context.InputParameters[key]);
                }
            }
            var outputParameters = new Dictionary <string, object>();
            foreach (var key in context.OutputParameters.Keys)
            {
                if (context.OutputParameters[key] is Entity x)
                {
                    outputParameters.Add(key, EntityToObject(x));
                }
                else
                {
                    outputParameters.Add(key, context.OutputParameters[key]);
                }
            }
            var obj = new
            {
                context.BusinessUnitId,
                context.CorrelationId,
                context.Depth,
                context.InitiatingUserId,
                context.IsExecutingOffline,
                context.IsInTransaction,
                context.IsOfflinePlayback,
                context.IsolationMode,
                context.MessageName,
                context.Mode,
                context.OperationCreatedOn,
                context.OperationId,
                context.OrganizationId,
                context.OrganizationName,
                context.OwningExtension,
                context.PrimaryEntityId,
                context.PrimaryEntityName,
                context.RequestId,
                context.SecondaryEntityName,
                context.SharedVariables,
                context.Stage,
                context.UserId,
                InputParameters         = inputParameters,
                OutputParameters        = outputParameters,
                PostEntityImages        = postEntityImages,
                PreEntityImages         = preEntityImages,
                IsAutoTransact          = context.IsAutoTransact(),
                IsWithinMainTransaction = context.IsWithinMainTransaction()
            };
            tracingService.LogMessage(SimpleJson.SerializeObject(obj));
#endif
        }