当前位置: 首页>>代码示例>>C#>>正文


C# IDataObject.Validate方法代码示例

本文整理汇总了C#中IDataObject.Validate方法的典型用法代码示例。如果您正苦于以下问题:C# IDataObject.Validate方法的具体用法?C# IDataObject.Validate怎么用?C# IDataObject.Validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IDataObject的用法示例。


在下文中一共展示了IDataObject.Validate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetTaskInputData

        /// <summary>
        /// Set task input data (validation included)
        /// </summary>
        /// <param name="inputData"></param>
        public virtual void SetTaskInputData(IDataObject inputData)
        {
            StructDef sd = ProcessTask.GetTaskInputDataSchema();
            inputData.Validate(sd);
            DataObject taskData = new DataObject();
            IScriptContext ctx = CreateTaskScriptContext();
            ctx.SetItem("data", ContextItem.Variable, new DOBMutant(taskData));

            foreach (VariableDef vd in ProcessTask.TaskVariables)
            {
                if (vd.VariableDir == VariableDef.Dir.In ||
                    vd.VariableDir == VariableDef.Dir.InOut)
                {
                    taskData[vd.Name] = inputData[vd.Name];
                }
                else
                {
                    if (vd.DefaultValueExpr != null && vd.DefaultValueExpr.Length > 0)
                    {
                        taskData[vd.Name] = Script.RunCode(vd.DefaultValueExpr, ctx);
                    }
                }
            }
            StructDef internalSchema = GetTaskInternalDataSchema();
            taskData.Validate(internalSchema);
            _taskData = taskData;
        }
开发者ID:alasdairhurst,项目名称:nginn,代码行数:31,代码来源:ActiveTransition.cs

示例2: InitializeTaskData

        /// <summary>
        /// Prepare task data - validate the input and initialize task variables. Throws exception if input data structure
        /// does not validate against task data schema.
        /// </summary>
        /// <param name="inputData"></param>
        protected void InitializeTaskData(IDataObject inputData)
        {
            StructDef sd = Context.TaskDefinition.GetTaskInputDataSchema();
            inputData.Validate(sd);
            DataObject taskData = new DataObject();
            ITaskScript ts = CreateScriptContext(taskData);

            foreach (VariableDef vd in Context.TaskDefinition.TaskVariables)
            {
                if (vd.VariableDir == VariableDef.Dir.In ||
                    vd.VariableDir == VariableDef.Dir.InOut)
                {
                    taskData[vd.Name] = inputData[vd.Name];
                }
                else
                {
                    if (vd.DefaultValueExpr != null && vd.DefaultValueExpr.Length > 0)
                    {
                        object defVal = ts.GetDefaultVariableValue(vd.Name);
                        taskData[vd.Name] = defVal;
                    }
                }
            }
            StructDef internalSchema = Context.TaskDefinition.GetTaskInternalDataSchema();
            taskData.Validate(internalSchema);
            this._taskData = taskData;
        }
开发者ID:alasdairhurst,项目名称:nginn,代码行数:32,代码来源:ActiveTaskBase.cs

示例3: SetProcessInputData

        /// <summary>
        /// Set process input data
        /// </summary>
        /// <param name="data"></param>
        public void SetProcessInputData(IDataObject data)
        {
            StructDef procInput = Definition.GetProcessInputDataSchema();
            data.Validate(procInput);
            DataObject dob = new DataObject();

            IProcessScript ctx = CreateProcessScriptContext();

            foreach (VariableDef vd in Definition.ProcessVariables)
            {
                if (data.ContainsKey(vd.Name))
                {
                    dob[vd.Name] = data[vd.Name];
                }
                else
                {
                    if (vd.DefaultValueExpr == null || vd.DefaultValueExpr.Length == 0)
                    {
                        if (vd.IsRequired && (vd.VariableDir == VariableDef.Dir.In || vd.VariableDir == VariableDef.Dir.InOut))
                            throw new ApplicationException("Missing required input variable: " + vd.Name);
                    }
                    else
                    {
                        object val = ctx.GetDefaultVariableValue(vd.Name);
                        dob[vd.Name] = val;
                    }
                }
            }
            StructDef internalSchema = GetProcessInternalDataSchema();
            dob.Validate(internalSchema);
            _processInstanceData = new DataObject();
            _processInstanceData["variables"] = dob;
            _processInstanceData["instanceInfo"] = new DataObject();
        }
开发者ID:alasdairhurst,项目名称:nginn,代码行数:38,代码来源:ProcessInstance.cs

示例4: StartProcessInstance

        public string StartProcessInstance(string definitionId, IDataObject inputData, string userId, string correlationId)
        {
            try
            {
                ProcessDefinition pd = PackageRepository.GetProcess(definitionId);
                if (pd == null) throw new ApplicationException("Process definition not found: " + definitionId);
                StructDef sd = pd.GetProcessInputDataSchema();
                inputData.Validate(sd);
                using (TransactionScope ts = new TransactionScope(_transactionOption))
                {
                    ProcessInstance pi = new ProcessInstance();
                    pi.StartDate = DateTime.Now;
                    pi.StartedBy = System.Threading.Thread.CurrentPrincipal.Identity.Name;
                    pi.InstanceId = Guid.NewGuid().ToString("N");
                    pi.ProcessDefinitionId = definitionId;
                    pi.Environment = this;
                    pi.CorrelationId = correlationId;
                    pi.Activate();

                    log.Info("Created new process instance for process {0}.{1}: {2}", pd.Name, pd.Version, pi.InstanceId);
                    pi.SetProcessInputData(inputData);
                    pi.CreateStartToken();
                    pi.Passivate();
                    InstanceRepository.InsertNewProcessInstance(pi);
                    ts.Complete();
                    NotifyReadyProcessSaved();
                    return pi.InstanceId;
                }

            }
            catch (Exception ex)
            {
                log.Error(string.Format("Error starting process: {0}", ex));
                throw;
            }
        }
开发者ID:alasdairhurst,项目名称:nginn,代码行数:36,代码来源:NGEnvironment.cs


注:本文中的IDataObject.Validate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。