Пример #1
0
        private void OnExecute(IPluginExecutionContext executionContext)
        {
            var parameters      = new ParametersWrapper <T>(executionContext);
            var parentContext   = executionContext.ParentContext;
            var prop            = executionContext.GetType().GetProperty("MessageCategory");
            var messageCategory = string.Empty;

            if (prop != null)
            {
                messageCategory = (string)prop.GetValue(executionContext);
            }

            string messageName;

            if (messageCategory == MessageCategory.CustomOperation)
            {
                messageName = MessageCategory.CustomOperation;
            }
            else
            {
                messageName = parentContext == null ? executionContext.MessageName : parentContext.MessageName;
            }

            if (eventHandlers.TryGetValue(messageName, out Action <IPluginExecutionContext, ParametersWrapper <T> > pluginAction))
            {
                pluginAction(executionContext, parameters);
            }
        }
Пример #2
0
 public static BaseData CreateCustomEventData(BaseData data, IPluginExecutionContext context)
 {
     data.measurements = new Dictionary <string, int>()
     {
         { "depth", context.Depth },
         { "measure2", 222 }
     };
     data.properties = new Dictionary <string, string>();
     data.properties.Add("Source", "Plugin");
     data.properties.Add("InitiatingUserId", context.InitiatingUserId.ToString());
     data.properties.Add("OperationId", context.OperationId.ToString());
     data.properties.Add("MessageName", context.MessageName);
     data.properties.Add("OrganizationId", context.OrganizationId.ToString());
     data.properties.Add("PrimaryEntityId", context.PrimaryEntityId.ToString());
     data.properties.Add("Stage", context.Stage.ToString());
     data.properties.Add("UserId", context.UserId.ToString());
     //Plugin Trace Log record fields
     data.properties.Add("TypeName", context.OwningExtension.Name);
     data.properties.Add("PrimaryEntityName", context.PrimaryEntityName);
     data.properties.Add("PluginStepId", context.OwningExtension.Id.ToString());
     data.properties.Add("OperationType", context.GetType().FullName);
     data.properties.Add("Depth", context.Depth.ToString());
     data.properties.Add("Synchorous", context.Mode.ToString());
     data.properties.Add("CorrelationId", context.CorrelationId.ToString());
     data.properties.Add("RequestId", context.RequestId.ToString());
     return(data);
 }
Пример #3
0
        private static String contextToString(IPluginExecutionContext context)
        {
            StringBuilder s = new StringBuilder();

            s.AppendFormat(" Depth              : {0}", RRUtils.stringVal(context.Depth)); s.AppendLine();
            s.AppendFormat(" CorrelationId      : {0}", RRUtils.stringVal(context.CorrelationId)); s.AppendLine();
            s.AppendFormat(" InitiatingUserId   : {0}", RRUtils.stringVal(context.InitiatingUserId)); s.AppendLine();
            s.AppendFormat(" IsExecutingOffline : {0}", RRUtils.stringVal(context.IsExecutingOffline)); s.AppendLine();
            s.AppendFormat(" IsInTransaction    : {0}", RRUtils.stringVal(context.IsInTransaction)); s.AppendLine();
            s.AppendFormat(" IsOfflinePlayback  : {0}", RRUtils.stringVal(context.IsOfflinePlayback)); s.AppendLine();
            s.AppendFormat(" IsolationMode      : {0}", RRUtils.stringVal(context.IsolationMode)); s.AppendLine();
            s.AppendFormat(" MessageName        : {0}", RRUtils.stringVal(context.MessageName)); s.AppendLine();
            s.AppendFormat(" Mode               : {0}", RRUtils.stringVal(context.Mode)); s.AppendLine();
            s.AppendFormat(" OperationCreatedOn : {0}", RRUtils.stringVal(context.OperationCreatedOn)); s.AppendLine();
            s.AppendFormat(" OperationId        : {0}", RRUtils.stringVal(context.OperationId)); s.AppendLine();
            s.AppendFormat(" OrganizationId     : {0}", RRUtils.stringVal(context.OrganizationId)); s.AppendLine();
            s.AppendFormat(" OrganizationName   : {0}", RRUtils.stringVal(context.OrganizationName)); s.AppendLine();
            s.AppendFormat(" OwningExtension    : {0}", RRUtils.stringVal(context.OwningExtension)); s.AppendLine();
            s.AppendFormat(" ParentContext      : {0}", RRUtils.stringVal(context.ParentContext)); s.AppendLine();
            s.AppendFormat(" PrimaryEntityId    : {0}", RRUtils.stringVal(context.PrimaryEntityId)); s.AppendLine();
            s.AppendFormat(" PrimaryEntityName  : {0}", RRUtils.stringVal(context.PrimaryEntityName)); s.AppendLine();
            s.AppendFormat(" RequestId          : {0}", RRUtils.stringVal(context.RequestId)); s.AppendLine();
            s.AppendFormat(" SecondaryEntityName: {0}", RRUtils.stringVal(context.SecondaryEntityName)); s.AppendLine();
            s.AppendFormat(" Stage              : {0}", RRUtils.stringVal(context.Stage)); s.AppendLine();
            s.AppendFormat(" UserId             : {0}", RRUtils.stringVal(context.UserId)); s.AppendLine();
            s.AppendFormat(" BusinessUnitId     : {0}", RRUtils.stringVal(context.BusinessUnitId)); s.AppendLine();
            s.AppendFormat(" Type               : {0}", context.GetType().ToString()); s.AppendLine();

            s.AppendLine("");
            s.AppendLine("Input Parameters");
            foreach (KeyValuePair <String, Object> pair in context.InputParameters)
            {
                s.AppendFormat("{0} : {1}", RRUtils.stringVal(pair.Key), RRUtils.stringVal(pair.Value));
                s.AppendLine();
            }
            s.AppendLine("");
            s.AppendLine("Output Parameters");
            foreach (KeyValuePair <String, Object> pair in context.OutputParameters)
            {
                s.AppendFormat("{0} : {1}", RRUtils.stringVal(pair.Key), RRUtils.stringVal(pair.Value));
                s.AppendLine();
            }

            s.AppendLine("");
            s.AppendLine("Shared Variables");
            foreach (KeyValuePair <String, Object> pair in context.SharedVariables)
            {
                s.AppendFormat("{0} : {1}", RRUtils.stringVal(pair.Key), RRUtils.stringVal(pair.Value));
                s.AppendLine();
            }

            return(s.ToString());
        }
        public static bool ObterApplicationOrigin(this IPluginExecutionContext context)
        {
            var propertyInfo = context.GetType().GetProperty("CallerOrigin");

            if (propertyInfo != null)
            {
                var value = propertyInfo.GetValue(context, null);

                if (value is ApplicationOrigin)
                {
                    return(true);
                }
            }
            return(false);
        }
Пример #5
0
        private void OnExecute(IPluginExecutionContext executionContext)
        {
            var parameters      = new ParametersWrapper <T>(executionContext);
            var parentContext   = executionContext.ParentContext;
            var prop            = executionContext.GetType().GetProperty("MessageCategory");
            var messageCategory = string.Empty;

            if (prop != null)
            {
                messageCategory = (string)prop.GetValue(executionContext);
            }

            string messageName;

            if (messageCategory == MessageCategory.CustomOperation)
            {
                messageName = MessageCategory.CustomOperation;
            }
            else if (parentContext != null &&
                     (parentContext.MessageName == PluginVirtualMessageName.ExportToExcel ||
                      parentContext.MessageName == PluginVirtualMessageName.ExportDynamicToExcel))
            {
                messageName = parentContext.MessageName;
            }
            else
            {
                messageName = executionContext.MessageName;
            }

            Action <IPluginExecutionContext, ParametersWrapper <T> > pluginAction;

            if (eventHandlers.TryGetValue(messageName, out pluginAction))
            {
                pluginAction(executionContext, parameters);
            }
        }