Beispiel #1
0
        /// <summary>
        /// 通过Activator.CreateInstance或者调研静态函数方法 methodInfo.Invoke执行函数
        /// </summary>
        /// <param name="method"></param>
        /// <param name="response"></param>
        /// <param name="parameterContainer"></param>
        private void ExecuteMethod(ExecutionRequestParameters.MethodToExecuteInfo method,
                                   ExecutionResponseParametersComplete response, ParameterContainerInfo[] parameterContainer)
        {
            var type = Type.GetType(method.Type);

            if (type == null)
            {
                throw new InvalidOperationException();
            }

            var types = method.InputParameters.OrderBy(ip => ip.Order).Select(ip => ip.Type).ToList();

            types.AddRange(method.OutputParameters.OrderBy(ip => ip.Order).Select(ip => ip.Type.MakeByRefType()));

            var values = method.InputParameters.OrderBy(ip => ip.Order).Select(ip => GetParameterValue(parameterContainer, ip)).ToList();

            values.AddRange(method.OutputParameters.OrderBy(ip => ip.Order).Select(ip => GetParameterValueNullable(parameterContainer, ip.Name, ip.Type)));

            var valuesArr = values.ToArray();

            var methodInfo = type.GetMethod(method.MethodName, types.ToArray());


            if (methodInfo.IsStatic)
            {
                var a = methodInfo.Invoke(null, valuesArr);
            }
            else
            {
                var obj = Activator.CreateInstance(type, BindingFlags.NonPublic);
                methodInfo.Invoke(obj, valuesArr);
            }

            response.AddNewParameterValues(method.OutputParameters.OrderBy(output => output.Order).ToList(), valuesArr.Skip(method.InputParameters.Count()).ToList());
        }
		public static ExecutionResponseParametersComplete Create(OptimaJet.Workflow.Core.Model.ProcessInstance processInstance, string executedActivityName, string executedTransitionName)
		{
			ExecutionResponseParametersComplete executionResponseParametersComplete = new ExecutionResponseParametersComplete()
			{
				ProcessInstance = processInstance,
				ExecutedTransitionName = executedTransitionName,
				IsEmplty = false,
				ExecutedActivityName = executedActivityName
			};
			return executionResponseParametersComplete;
		}
Beispiel #3
0
        private void ExecuteMethod(ExecutionRequestParameters.MethodToExecuteInfo method,
                                         ExecutionResponseParametersComplete response, ParameterContainerInfo[] parameterContainer )
        {
            var type = Type.GetType(method.Type);
            if (type == null)
                throw new InvalidOperationException();

            var types = method.InputParameters.OrderBy(ip => ip.Order).Select(ip => ip.Type).ToList();
            types.AddRange(method.OutputParameters.OrderBy(ip => ip.Order).Select(ip => ip.Type.MakeByRefType()));

            var values = method.InputParameters.OrderBy(ip => ip.Order).Select(ip => GetParameterValue(parameterContainer, ip)).ToList();
            values.AddRange(method.OutputParameters.OrderBy(ip => ip.Order).Select(ip => GetParameterValueNullable(parameterContainer, ip.Name, ip.Type)));

            var valuesArr = values.ToArray();

            var methodInfo = type.GetMethod(method.MethodName, types.ToArray());

            if (methodInfo.IsStatic)
            {
                var a = methodInfo.Invoke(null, valuesArr);
            }
            else
            {
                var obj = Activator.CreateInstance(type, BindingFlags.NonPublic);
                methodInfo.Invoke(obj, valuesArr);
            }

            response.AddNewParameterValues(method.OutputParameters.OrderBy(output => output.Order).ToList(), valuesArr.Skip(method.InputParameters.Count()).ToList());
        }
Beispiel #4
0
        private void FillParameters(ProcessInstance instance, ExecutionResponseParametersComplete newParameters)
        {
            foreach (var parameter in newParameters.ParameterContainer)
            {
                var parameterDefinition = instance.ProcessScheme.GetNullableParameterDefinition(parameter.Name);
                if (parameterDefinition != null)
                {
                    var parameterDefinitionWithValue = ParameterDefinition.Create(parameterDefinition, parameter.Value);

                    instance.AddParameter(parameterDefinitionWithValue);
                }
            }
        }
Beispiel #5
0
		private void ExecuteMethod(ActionDefinitionReference method, ExecutionResponseParametersComplete response)
		{
			CodeActionsInvoker codeActionsInvoker = response.ProcessInstance.ProcessScheme.CodeActionsInvoker;
			if (this.GlobalActionsInvoker.ExistsAction(method.ActionName))
			{
				this.GlobalActionsInvoker.InvokeAction(method.ActionName, response.ProcessInstance, this._runtime, method.ActionParameter);
				return;
			}
			if (codeActionsInvoker.ExistsAction(method.ActionName))
			{
				codeActionsInvoker.InvokeAction(method.ActionName, response.ProcessInstance, this._runtime, method.ActionParameter);
				return;
			}
			this.ActionProvider.ExecuteAction(method.ActionName, response.ProcessInstance, this._runtime, method.ActionParameter);
		}