示例#1
0
        private static string GetStageDescription(ExecutionStage stage)
        {
            string result = null;

            if (stage == ExecutionStage.OnPromotedMessage)
            {
                result = ServerStrings.FolderRuleStageOnPromotedMessage;
            }
            else if (stage == ExecutionStage.OnCreatedMessage)
            {
                result = ServerStrings.FolderRuleStageOnCreatedMessage;
            }
            else if (stage == ExecutionStage.OnDeliveredMessage)
            {
                result = ServerStrings.FolderRuleStageOnDeliveredMessage;
            }
            else if (stage == ExecutionStage.OnPublicFolderAfter)
            {
                result = ServerStrings.FolderRuleStageOnPublicFolderAfter;
            }
            else if (stage == ExecutionStage.OnPublicFolderBefore)
            {
                result = ServerStrings.FolderRuleStageOnPublicFolderBefore;
            }
            return(result);
        }
 //usefull for custom actions
 protected void RegisterEvent <T>(string eventOperationName, ExecutionStage executionStage, Action <LocalPluginContext> action) where T : Entity
 => RegisteredEvents.Add(
     new Tuple <int, string, string, Action <LocalPluginContext> >(
         (int)executionStage,
         eventOperationName,
         Activator.CreateInstance <T>().LogicalName,
         action));
 protected void RegisterEventOnAllEntities(string eventOperationName, ExecutionStage executionStage, Action <LocalPluginContext> action)
 => RegisteredEvents.Add(
     new Tuple <int, string, string, Action <LocalPluginContext> >(
         (int)executionStage,
         eventOperationName,
         null,
         action));
示例#4
0
        //Post operation - Trigger Sync and Async in that order
        public void TriggerSync(string operation, ExecutionStage stage,
                                object entity, Entity preImage, Entity postImage, PluginContext pluginContext, Core core)
        {
            if (!disableRegisteredPlugins && registeredPlugins.ContainsKey(operation) && registeredPlugins[operation].ContainsKey(stage))
            {
                var toExecute = registeredPlugins[operation][stage].Where(p => p.ShouldExecute(entity, preImage, postImage, pluginContext))
                                .Where(p => p.GetExecutionMode() == ExecutionMode.Synchronous)
                                .OrderBy(p => p.GetExecutionOrder());
                foreach (var plugin in toExecute)
                {
                    plugin.Execute(entity, preImage, postImage, pluginContext, core);
                }
            }

            if (temporaryPlugins.ContainsKey(operation) && temporaryPlugins[operation].ContainsKey(stage))
            {
                var toExecute = temporaryPlugins[operation][stage].Where(p => p.ShouldExecute(entity, preImage, postImage, pluginContext))
                                .Where(p => p.GetExecutionMode() == ExecutionMode.Synchronous)
                                .OrderBy(p => p.GetExecutionOrder());
                foreach (var plugin in toExecute)
                {
                    plugin.Execute(entity, preImage, postImage, pluginContext, core);
                }
            }
        }
示例#5
0
            private void RaiseMetricEtwEvent(ExecutionStage executionStage)
            {
                var timeSpan       = (ulong)(DateTime.UtcNow - startTime).TotalMilliseconds;
                var executionCount = totalExecutionCount;

                WriteFunctionsMetricEvent(executionId, timeSpan, executionCount, executionStage.ToString());
            }
示例#6
0
 /// <summary>
 /// Initialises a new instance of the ExecutionProgress class for numeric execution progress.
 /// </summary>
 /// <param name="executionStage">The operation type.</param>
 /// <param name="executedItemCount">The total number of items that have been executed for the specified execution stage.</param>
 /// <param name="totalItemCount">The total number of items to execute for the specified execution stage.</param>
 public ExecutionProgress(ExecutionStage executionStage, int executedItemCount, int totalItemCount)
 {
     ExecutionStage    = executionStage;
     ExecutedItemCount = executedItemCount;
     TotalItemCount    = totalItemCount;
     ProgressType      = ProgressType.ItemProgress;
 }
 private static IEnumerator _when(Func <bool> expression, Action action, ExecutionStage stage)
 {
     while (!expression())
     {
         yield return(_getYieldStatement(stage));
     }
     action();
 }
 public RunningFunctionInfo(string name, Guid invocationId, DateTime startTime, bool success, ExecutionStage executionStage = ExecutionStage.InProgress)
 {
     Name           = name;
     InvocationId   = invocationId;
     StartTime      = startTime;
     Success        = success;
     ExecutionStage = executionStage;
 }
示例#9
0
 public PluginStepConfig(EventOperation eventOperation, ExecutionStage executionStage)
 {
     this.LogicalName    = Activator.CreateInstance <T>().LogicalName;
     this.EventOperation = eventOperation.ToString();
     this.ExecutionStage = (int)executionStage;
     this.Deployment     = (int)Plugins.Deployment.ServerOnly;
     this.ExecutionMode  = (int)Plugins.ExecutionMode.Synchronous;
     this.ExecutionOrder = 1;
 }
示例#10
0
 public ContainerFunctionExecutionActivity(DateTime eventTime, string functionName,
                                           ExecutionStage executionStage, string triggerType, bool success)
 {
     EventTime      = eventTime;
     FunctionName   = functionName;
     ExecutionStage = executionStage;
     TriggerType    = triggerType;
     Success        = success;
 }
 public void Execute(ExecutionStage stage)
 {
     this.context.DeliveryFolder = this.TargetFolder;
     this.context.ExecutionStage = stage;
     foreach (FolderEvaluationResult folderEvaluationResult in this.folderResults)
     {
         folderEvaluationResult.Execute(stage);
     }
 }
示例#12
0
 /// <summary>
 /// Trigger all plugin steps which match the given parameters.
 /// </summary>
 /// <param name="operation"></param>
 /// <param name="stage"></param>
 /// <param name="entity"></param>
 /// <param name="preImage"></param>
 /// <param name="postImage"></param>
 /// <param name="pluginContext"></param>
 /// <param name="core"></param>
 public void Trigger(EventOperation operation, ExecutionStage stage,
                     object entity, Entity preImage, Entity postImage, PluginContext pluginContext, Core core)
 {
     //Parallel.ForEach(asynchronousWorkflows, (x => ExecuteIfMatch(x, operation, stage, entity,
     //        preImage, postImage, pluginContext, crm)));
     synchronousWorkflows.ForEach((x => ExecuteIfMatch(x, operation, stage, entity,
                                                       preImage, postImage, pluginContext, core)));
     asynchronousWorkflows.ForEach(x => ExecuteIfMatch(x, operation, stage, entity,
                                                       preImage, postImage, pluginContext, core));
 }
示例#13
0
 public PluginStepConfig(EventOperation eventOperation, ExecutionStage executionStage)
 {
     this._LogicalName    = Activator.CreateInstance <T>().LogicalName;
     this._EventOperation = eventOperation.ToString();
     this._ExecutionStage = (int)executionStage;
     this._Deployment     = (int)Deployment.ServerOnly;
     this._ExecutionMode  = (int)ExecutionMode.Synchronous;
     this._ExecutionOrder = 1;
     this._UserContext    = Guid.Empty;
 }
示例#14
0
        /// <summary>
        /// Trigger all plugin steps which match the given parameters.
        /// </summary>
        /// <param name="operation"></param>
        /// <param name="stage"></param>
        /// <param name="entity"></param>
        /// <param name="preImage"></param>
        /// <param name="postImage"></param>
        /// <param name="pluginContext"></param>
        /// <param name="core"></param>
        public void TriggerSync(string operation, ExecutionStage stage,
                                object entity, Entity preImage, Entity postImage, PluginContext pluginContext, Core core)
        {
            var toExecute = synchronousWorkflows.Where(x => ShouldExecute(x, operation, stage, entity, pluginContext)).ToList();

            foreach (var workflow in toExecute)
            {
                Execute(workflow, operation, entity, preImage, postImage, pluginContext, core);
            }
        }
示例#15
0
 /// <summary>
 /// Trigger all plugin steps which match the given parameters.
 /// </summary>
 /// <param name="operation"></param>
 /// <param name="stage"></param>
 /// <param name="entity"></param>
 /// <param name="preImage"></param>
 /// <param name="postImage"></param>
 /// <param name="pluginContext"></param>
 /// <param name="core"></param>
 public void Trigger(EventOperation operation, ExecutionStage stage,
                     object entity, Entity preImage, Entity postImage, PluginContext pluginContext, Core core)
 {
     if (!disableRegisteredPlugins && registeredPlugins.ContainsKey(operation) && registeredPlugins[operation].ContainsKey(stage))
     {
         registeredPlugins[operation][stage].ForEach(p => p.ExecuteIfMatch(entity, preImage, postImage, pluginContext, core));
     }
     if (temporaryPlugins.ContainsKey(operation) && temporaryPlugins[operation].ContainsKey(stage))
     {
         temporaryPlugins[operation][stage].ForEach(p => p.ExecuteIfMatch(entity, preImage, postImage, pluginContext, core));
     }
 }
示例#16
0
 public void AddTrigger(EventOperation operation, ExecutionStage stage, PluginTrigger trigger, Dictionary <EventOperation, Dictionary <ExecutionStage, List <PluginTrigger> > > register)
 {
     if (!register.ContainsKey(operation))
     {
         register.Add(operation, new Dictionary <ExecutionStage, List <PluginTrigger> >());
     }
     if (!register[operation].ContainsKey(stage))
     {
         register[operation].Add(stage, new List <PluginTrigger>());
     }
     register[operation][stage].Add(trigger);
 }
        private static YieldInstruction _getYieldStatement(ExecutionStage stage)
        {
            switch (stage)
            {
            case ExecutionStage.LateUpdate: return(_waitForEndOfFrame);

            case ExecutionStage.FixedUpdate: return(_waitForFixedUpdate);

            case ExecutionStage.Update:
            default:
                return(null);
            }
        }
示例#18
0
        public void TriggerSystem(EventOperation operation, ExecutionStage stage,
                                  object entity, Entity preImage, Entity postImage, PluginContext pluginContext, Core core)
        {
            if (!this.registeredSystemPlugins.ContainsKey(operation))
            {
                return;
            }
            if (!this.registeredSystemPlugins[operation].ContainsKey(stage))
            {
                return;
            }

            registeredSystemPlugins[operation][stage].ForEach(p => p.ExecuteIfMatch(entity, preImage, postImage, pluginContext, core));
        }
示例#19
0
 //Post operation - Trigger Sync and Async in that order
 public void TriggerSync(EventOperation operation, ExecutionStage stage,
                         object entity, Entity preImage, Entity postImage, PluginContext pluginContext, Core core)
 {
     if (!disableRegisteredPlugins && registeredPlugins.ContainsKey(operation) && registeredPlugins[operation].ContainsKey(stage))
     {
         registeredPlugins[operation][stage].Where(p => p.GetExecutionMode() == ExecutionMode.Synchronous)
         .OrderBy(p => p.GetExecutionOrder()).ToList().ForEach(p => p.ExecuteIfMatch(entity, preImage, postImage, pluginContext, core));
     }
     if (temporaryPlugins.ContainsKey(operation) && temporaryPlugins[operation].ContainsKey(stage))
     {
         temporaryPlugins[operation][stage].Where(p => p.GetExecutionMode() == ExecutionMode.Synchronous)
         .OrderBy(p => p.GetExecutionOrder()).ToList().ForEach(p => p.ExecuteIfMatch(entity, preImage, postImage, pluginContext, core));
     }
 }
        private static IEnumerator _whenever(Func <bool> expression, Action action, ExecutionStage stage)
        {
            bool state = false;

            while (true)
            {
                bool newState = expression();
                if (newState && !state)
                {
                    action();
                }
                state = newState;
                yield return(_getYieldStatement(stage));
            }
        }
示例#21
0
 public void StageAsync(EventOperation operation, ExecutionStage stage,
                        object entity, Entity preImage, Entity postImage, PluginContext pluginContext, Core core)
 {
     if (!disableRegisteredPlugins && registeredPlugins.ContainsKey(operation) && registeredPlugins[operation].ContainsKey(stage))
     {
         var asyncExecutors = registeredPlugins[operation][stage].Where(p => p.GetExecutionMode() == ExecutionMode.Asynchronous)
                              .OrderBy(p => p.GetExecutionOrder()).ToList().Select(p => p.ToPluginExecution(entity, preImage, postImage, pluginContext, core));
         asyncExecutors.ToList().ForEach(x => pendingAsyncPlugins.Enqueue(x));
     }
     if (temporaryPlugins.ContainsKey(operation) && temporaryPlugins[operation].ContainsKey(stage))
     {
         var asyncExecutors = temporaryPlugins[operation][stage].Where(p => p.GetExecutionMode() == ExecutionMode.Asynchronous)
                              .OrderBy(p => p.GetExecutionOrder()).ToList().Select(p => p.ToPluginExecution(entity, preImage, postImage, pluginContext, core));
         asyncExecutors.ToList().ForEach(x => pendingAsyncPlugins.Enqueue(x));
     }
 }
示例#22
0
            public PluginTrigger(EventOperation operation, ExecutionStage stage,
                                 Action <MockupServiceProviderAndFactory> pluginExecute, Tuple <StepConfig, ExtendedStepConfig,
                                                                                                IEnumerable <ImageTuple> > stepConfig, Dictionary <string, EntityMetadata> metadata)
            {
                this.pluginExecute = pluginExecute;
                this.entityName    = stepConfig.Item1.Item4;
                this.operation     = operation;
                this.stage         = stage;
                this.mode          = (ExecutionMode)stepConfig.Item2.Item2;
                this.order         = stepConfig.Item2.Item4;
                this.images        = stepConfig.Item3;
                this.metadata      = metadata;

                var attrs = stepConfig.Item2.Item5 ?? "";

                this.attributes = String.IsNullOrWhiteSpace(attrs) ? new HashSet <string>() : new HashSet <string>(attrs.Split(','));
            }
示例#23
0
        protected PluginStepConfig <T> RegisterPluginStep <T>(
            EventOperation eventOperation, ExecutionStage executionStage, Action <LocalPluginContext> action)
            where T : Entity
        {
            PluginStepConfig <T> stepConfig = new PluginStepConfig <T>(eventOperation, executionStage);

            this.PluginStepConfigs.Add((IPluginStepConfig)stepConfig);

            this.RegisteredEvents.Add(
                new Tuple <int, string, string, Action <LocalPluginContext> >(
                    stepConfig._ExecutionStage,
                    stepConfig._EventOperation,
                    stepConfig._LogicalName,
                    new Action <LocalPluginContext>(action)));

            return(stepConfig);
        }
示例#24
0
        public void TriggerSystem(string operation, ExecutionStage stage,
                                  object entity, Entity preImage, Entity postImage, PluginContext pluginContext, Core core)
        {
            if (!this.registeredSystemPlugins.ContainsKey(operation))
            {
                return;
            }
            if (!this.registeredSystemPlugins[operation].ContainsKey(stage))
            {
                return;
            }

            var toExecute = registeredSystemPlugins[operation][stage].Where(p => p.ShouldExecute(entity, preImage, postImage, pluginContext));

            foreach (var plugin in toExecute)
            {
                plugin.Execute(entity, preImage, postImage, pluginContext, core);
            }
        }
示例#25
0
 public void Execute(ExecutionStage stage)
 {
     foreach (WorkItem workItem in this.workItems)
     {
         if ((stage & workItem.Stage) != (ExecutionStage)0)
         {
             string stageDescription = FolderEvaluationResult.GetStageDescription(stage);
             try
             {
                 this.context.CurrentRule = workItem.Rule;
                 RuleUtil.FaultInjection((FaultInjectionLid)4175834429U);
                 workItem.Execute();
                 this.context.LogWorkItemExecution(workItem);
             }
             catch (InvalidRuleException exception)
             {
                 this.context.RecordError(exception, stageDescription);
                 this.context.DisableAndMarkRuleInError(workItem.Rule, workItem.Rule.Actions[workItem.ActionIndex].ActionType, workItem.ActionIndex, DeferredError.RuleError.Execution);
             }
             catch (StoragePermanentException exception2)
             {
                 this.context.RecordError(exception2, stageDescription);
             }
             catch (ExchangeDataException exception3)
             {
                 this.context.RecordError(exception3, stageDescription);
             }
             catch (MapiPermanentException exception4)
             {
                 this.context.RecordError(exception4, stageDescription);
             }
             catch (DataValidationException exception5)
             {
                 this.context.RecordError(exception5, stageDescription);
             }
             finally
             {
                 this.context.CurrentRule = null;
             }
         }
     }
 }
示例#26
0
            public PluginTrigger(string operation, ExecutionStage stage,
                                 Action <MockupServiceProviderAndFactory> pluginExecute, PluginStepConfig stepConfig, Dictionary <string, EntityMetadata> metadata)
            {
                this.pluginExecute = pluginExecute;
                this.entityName    = stepConfig.StepConfig.LogicalName;
                this.operation     = operation.ToLower();
                this.stage         = stage;
                this.mode          = (ExecutionMode)stepConfig.ExtendedStepConfig.ExecutionMode;
                this.order         = stepConfig.ExtendedStepConfig.ExecutionOrder;
                if (stepConfig.ImageConfigs != null)
                {
                    this.images.AddRange(stepConfig.ImageConfigs);
                }
                this.metadata            = metadata;
                this.impersonatingUserId = stepConfig.ExtendedStepConfig.ImpersonatingUserId;

                var attrs = stepConfig.ExtendedStepConfig.FilteredAttributes ?? "";

                this.attributes = String.IsNullOrWhiteSpace(attrs) ? new HashSet <string>() : new HashSet <string>(attrs.Split(','));
            }
 private void RaiseMetricEtwEvent(ExecutionStage executionStage)
 {
     var timeSpan = (ulong)(DateTime.UtcNow - startTime).TotalMilliseconds;
     var executionCount = totalExecutionCount;
     WriteFunctionsMetricEvent(executionId, timeSpan, executionCount, executionStage.ToString());
 }
 public FunctionMetrics(string functionName, ExecutionStage executionStage, long executionTimeInMS)
 {
     _functionName = functionName;
     _executionStage = executionStage;
     _executionTimeInMS = executionTimeInMS;
 }
        private static IEnumerator _watch <T>(Func <T> expression, Action <T> action, ExecutionStage stage)
        {
            T state = expression();

            action(state);
            while (true)
            {
                T newState = expression();
                if (!EqualityComparer <T> .Default.Equals(state, newState))
                {
                    state = newState;
                    action(state);
                }
            }
        }
 public static Coroutine Whenever(this MonoBehaviour context, Func <bool> expression, Action action, ExecutionStage stage = ExecutionStage.Update)
 {
     return(context.StartCoroutine(_whenever(expression, action, stage)));
 }
 public RunningFunctionInfo(string name, Guid invocationId, DateTime startTime, bool success, ExecutionStage executionStage = ExecutionStage.InProgress)
 {
     Name = name;
     InvocationId = invocationId;
     StartTime = startTime;
     Success = success;
     ExecutionStage = executionStage;
 }
        public void Comparison_Returns_Expected_Results(bool expected, string functionName1, string functionName2, ExecutionStage stage1, ExecutionStage stage2, string triggerType1, string triggerType2, bool success1, bool success2)
        {
            var activity1 = new ContainerFunctionExecutionActivity(DateTime.MinValue, functionName1, stage1, triggerType1, success1);
            var activity2 = new ContainerFunctionExecutionActivity(DateTime.MaxValue, functionName2, stage2, triggerType2, success2);

            var hashSet = new HashSet <ContainerFunctionExecutionActivity> {
                activity1, activity2
            };

            Assert.Equal(expected, activity1.Equals(activity2));
            Assert.Equal(expected ? 1 : 2, hashSet.Count);
        }
 public static Coroutine Watch <T>(this MonoBehaviour context, Func <T> expression, Action <T> action, ExecutionStage stage = ExecutionStage.Update)
 {
     return(context.StartCoroutine(_watch <T>(expression, action, stage)));
 }