Beispiel #1
0
 public PluginExecutionContext(IPluginExecutionContext context)
 {
     BusinessUnitId = context.BusinessUnitId;
     //CallerOrigin = context.CallerOrigin;
     CorrelationId = context.CorrelationId;
     //CorrelationUpdatedTime = context.CorrelationUpdatedTime;
     Depth            = context.Depth;
     InitiatingUserId = context.InitiatingUserId;
     InputParameters  = context.InputParameters;
     //InvocationSource = context.InvocationSource;
     IsExecutingInOfflineMode = context.IsExecutingOffline;
     MessageName      = context.MessageName;
     Mode             = context.Mode;
     OrganizationId   = context.OrganizationId;
     OrganizationName = context.OrganizationName;
     OutputParameters = context.OutputParameters;
     if (context.ParentContext != null)
     {
         ParentContext = new PluginExecutionContext(context.ParentContext);
     }
     PostEntityImages    = context.PostEntityImages;
     PreEntityImages     = context.PreEntityImages;
     PrimaryEntityName   = context.PrimaryEntityName;
     SecondaryEntityName = context.SecondaryEntityName;
     SharedVariables     = context.SharedVariables;
     Stage  = context.Stage;
     UserId = context.UserId;
 }
Beispiel #2
0
        /// <summary>
        /// Context is serialized to Xml
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public static string GetContextXml(IPluginExecutionContext context, out int length)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(PluginExecutionContext));

            using (StringWriter writer = new StringWriter(CultureInfo.InvariantCulture))
            {
                PluginExecutionContext c1 = new PluginExecutionContext(context);
                serializer.Serialize(writer, c1);
                StringBuilder sb = writer.GetStringBuilder();
                length = sb.Length;
                if (sb.Length < 10000)
                {
                    return(writer.ToString());
                }
                else
                {
                    sb.Insert(0, "Truncated.");
                    return(sb.ToString(0, 10000));
                }
            }
        }