Esempio n. 1
0
        protected void output_bindings_code(Func <SC.IDictionary> fun, string codeStr)
        {
            TaskDef tsk = _curTask != null ? _curTask : (TaskDef)_currentCompositeTask;
            string  k   = DslUtil.TaskOutputDataBindingKey(tsk.Id);

            _variableBinds[k] = fun;
        }
Esempio n. 2
0
        public Dictionary <string, object> GatherOutputData(TaskInstance ti, ITaskExecutionContext ctx)
        {
            _pd.SetTaskInstanceInfo(ti, ctx);
            string ks = DslUtil.TaskScriptKey(ti.TaskId, "_variableUpdateOnComplete");

            if (_pd._taskScripts.ContainsKey(ks))
            {
                _pd._taskScripts[ks]();
            }
            var td = _def.GetRequiredTask(ti.TaskId);

            foreach (var bd in td.OutputParameterBindings)
            {
                string k = DslUtil.TaskParamOutBindingKey(td.Id, bd.Target);
                if (bd.BindType == DataBindingType.Expr)
                {
                    ti.TaskData[bd.Target] = _pd._variableBinds[k]();
                }
                else if (bd.BindType == DataBindingType.CopyVar)
                {
                    var pi = ti.GetType().GetProperty(bd.Source);
                    if (pi == null)
                    {
                        throw new NGinnBPM.ProcessModel.Exceptions.TaskParameterInvalidException(bd.Source, "Property not found: " + bd.Source).SetTaskId(ti.TaskId);
                    }
                    ti.TaskData[bd.Target] = pi.GetValue(ti, null);
                }
                else if (bd.BindType == DataBindingType.Literal)
                {
                    ti.TaskData[bd.Target] = bd.Source; //todo: type convert
                }
                else
                {
                    throw new Exception();
                }
            }

            string k2 = DslUtil.TaskOutputDataBindingKey(td.Id);

            if (_pd._variableBinds.ContainsKey(k2))
            {
                SC.IDictionary dic = (SC.IDictionary)_pd._variableBinds[k2]();
                return(ToTaskData(dic));
            }
            Dictionary <string, object> ret = new Dictionary <string, object>();

            foreach (var vd in td.Variables.Where(x => x.VariableDir == ProcessModel.Data.VariableDef.Dir.Out || x.VariableDir == ProcessModel.Data.VariableDef.Dir.InOut))
            {
                ret[vd.Name] = ti.TaskData[vd.Name];
            }
            return(ret);
        }