Esempio n. 1
0
        /// <summary>
        /// Sends request for timer value for all timer transitions that are outgoing from the CurrentActivity if timer value is equal 0 or -1
        /// </summary>
        /// <param name="processInstance">Process instance</param>
        public void RequestTimerValue(ProcessInstance processInstance, ActivityDefinition activity = null)
        {
            if (NeedTimerValue == null)
            {
                return;
            }

            var notDefinedTimerTransitions =
                processInstance.ProcessScheme.GetTimerTransitionForActivity(activity ?? processInstance.CurrentActivity, ForkTransitionSearchType.Both)
                .Where(
                    t =>
                    (t.Trigger.Timer.Value.Equals(ImmediateTimerValue) || t.Trigger.Timer.Value.Equals(InfinityTimerValue)) &&
                    !processInstance.IsParameterExisting(GetTimerValueParameterName(t.Trigger.Timer))).ToList();

            if (!notDefinedTimerTransitions.Any())
            {
                return;
            }

            var eventArgs = new NeedTimerValueEventArgs(processInstance, notDefinedTimerTransitions);

            NeedTimerValue(this, eventArgs);

            foreach (var request in eventArgs.TimerValueRequests)
            {
                if (request.NewValue.HasValue)
                {
                    processInstance.SetParameter(GetTimerValueParameterName(request.Definition), request.NewValue.Value, ParameterPurpose.Persistence);
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Resets value of named timer
        /// </summary>
        /// <param name="processInstance">Process instance</param>
        /// <param name="timerName">Timer name in Scheme</param>
        public void ResetTimerValue(ProcessInstance processInstance, string timerName)
        {
            var parameterName = GetTimerValueParameterName(timerName);

            if (!processInstance.IsParameterExisting(parameterName))
            {
                return;
            }

            processInstance.SetParameter <DateTime?>(parameterName, null, ParameterPurpose.Persistence);
        }
        private static void MergeWorkflowParameter(ProcessInstance processInstance, string name, JObject value)
        {
            var     workflowParams = GetWorkflowParameters(processInstance, null);
            JObject newParams      = value;

            if (workflowParams.ContainsKey(name))
            {
                newParams = workflowParams[name] as JObject;
                newParams.Merge(value, new JsonMergeSettings {
                    MergeArrayHandling = MergeArrayHandling.Merge
                });
            }
            var json = JsonConvert.SerializeObject(newParams);

            processInstance.SetParameter(name, json, ParameterPurpose.Persistence);
        }
Esempio n. 4
0
        /// <summary>
        /// Sets new value of named timer
        /// </summary>
        /// <param name="processInstance">Process instance</param>
        /// <param name="timerName">Timer name in Scheme</param>
        /// <param name="newValue">New value of the timer</param>
        public void SetTimerValue(ProcessInstance processInstance, string timerName, DateTime newValue)
        {
            var parameterName = GetTimerValueParameterName(timerName);

            processInstance.SetParameter(parameterName, newValue, ParameterPurpose.Persistence);
        }