k2画流程-关于用代买生成K2 kprx 文件

问题描述

关于用代买生成K2 kprx 文件

我想在想要用代码来生成K2 KPRX 文件 , 现在的问题是文件已经生成成功,也能够通过代码发布,但是一旦发起流程 ,K2 就会报错 , 错误信息是:Key could not be found in the collection 。

代码如下 :

想请教下高手怎么解决这个问题, 我现在是不知道哪里写错了 。

enter code here

#region 设置节点审核界面
ClientEvent approvalClientEvent = WorkflowFactory.CreateEvent(node.ApprovalNode_Name, WizardNames.DefaultClientEvent);
approvalClientEvent.EventItem.InternetPlatform = "ASP";
approvalClientEvent.EventItem.SendToInternet = true;
////需要绑定smartobject作为审核界面来源
SmartObjectFieldPart smfp = new SmartObjectFieldPart();
//#region 创建locals

                Local localSmart = new Local("Name", K2FieldFactory.CreateK2Field(typeof(string), new ValueTypePart(Config.SmartObjectName)));
                smfp.Properties.Locals.Add("Name", localSmart);
                EnvironmentFieldModel environment = new EnvironmentFieldModel("SmartObject Server", "");
                ArtifactLibraryFieldPart fieldPart = new ArtifactLibraryFieldPart(environment);

                Local localServer = new Local("Server", K2FieldFactory.CreateK2Field(typeof(string), fieldPart));
                smfp.Properties.Locals.Add("Server", localServer);

                Local localMothed = new Local("MethodDisplayName", K2FieldFactory.CreateK2Field(typeof(string), new ValueTypePart(Config.FormUrl)));
                smfp.Properties.Locals.Add("MethodDisplayName", localMothed);

                Local localMothedType = new Local("MethodType", K2FieldFactory.CreateK2Field(typeof(string), new ValueTypePart("read")));
                smfp.Properties.Locals.Add("MethodType", localMothedType);

                Local localDisplayName = new Local("DisplayName", K2FieldFactory.CreateK2Field(typeof(string), new ValueTypePart(Config.SmartObjectName)));
                smfp.Properties.Locals.Add("DisplayName", localDisplayName);

                //Local localIsList = new Local("IsList", K2FieldFactory.CreateK2Field(typeof(bool), new ValueTypePart("False")));
                //smfp.Properties.Locals.Add("IsList", localIsList);

                Local localGuid = new Local("Guid", K2FieldFactory.CreateK2Field(typeof(string), new ValueTypePart(Guid.NewGuid().ToString())));
                smfp.Properties.Locals.Add("Guid", localGuid);

                Local localMethodName = new Local("MethodName", K2FieldFactory.CreateK2Field(typeof(string), new ValueTypePart(Config.FormUrl)));
                smfp.Properties.Locals.Add("MethodName", localMethodName);

                Local localType = new Local("Type", K2FieldFactory.CreateK2Field(typeof(string), new ValueTypePart("SourceCode.SmartFunctions.Syntax.Expressions.SmartObjectExp")));
                smfp.Properties.Locals.Add("Type", localType);
                #endregion
                #region 创建inputs
                Input inputProId = new Input("procId", "procId", "Text", true, K2FieldFactory.CreateK2Field(typeof(string), new DataFieldPart("Process", "RequestID", DataTypes.String, FieldListOption.None)));
                smfp.Properties.Inputs.Add("procId", inputProId);

                Input inputActivityName = new Input("activityName", "activityName", "Text", true, K2FieldFactory.CreateK2Field(typeof(string), new WorkflowContextFieldPart(WorkflowContextProperty.ActivityInstanceName)));
                smfp.Properties.Inputs.Add("activityName", inputActivityName);
                #endregion
                #region 创建returns
                Return returnResult = new Return("result");
                returnResult.DisplayName = "result";
                returnResult.IsSelected = true;
                returnResult.Type = "Text";
                smfp.Properties.Returns.Add("result", returnResult);
                #endregion
                #region 创建properties
                Property pResult = new Property();
                pResult.Name = "result";
                pResult.DisplayName = "result";
                pResult.Type = "Text";
                smfp.Properties.Properties.Add("result", pResult);
                #endregion
                #region
                SourceCode.Workflow.Authoring.K2Field interPart = new K2Field();
                interPart.Parts.Add(smfp);
                interPart.Parts.Add(new ValueTypePart("&"));
                interPart.Parts.Add(new SerialNoFieldPart());
                approvalClientEvent.EventItem.InternetUrl = interPart;

                approvalClientEvent.EventItem.InternetUrl = K2FieldFactory.CreateK2Field(
                    typeof(string),
                    new ValueTypePart("http://webserver/page.aspx?"),
                    new SerialNoFieldPart());
                activity.Events.Add(approvalClientEvent);
                #endregion
                #region 设置节点审核人
                //如何通过smartobject设置审核人
                SimpleDestinationRule destinationRule = new SimpleDestinationRule();
                DestinationSet defaultDestinationSet = new DestinationSet();
                Destination destination = new Destination();
                destination.Type = DestinationTypes.User;
                SmartObjectFieldPart smfpDestination = new SmartObjectFieldPart();

                //smfpDestination.SmartObjectGuid = smartobject.Guid;
                #region 创建locals
                Local localSmartDestination = new Local("Name", K2FieldFactory.CreateK2Field(typeof(string), new ValueTypePart(Config.SmartObjectName)));

                smfpDestination.Properties.Locals.Add("Name", localSmartDestination);

                EnvironmentFieldModel environmentDestination = new EnvironmentFieldModel("SmartObject Server", "");
                ArtifactLibraryFieldPart fieldPartDestination = new ArtifactLibraryFieldPart(environmentDestination);
                Local localServerDestination = new Local("Server", K2FieldFactory.CreateK2Field(typeof(string), fieldPartDestination));
                smfpDestination.Properties.Locals.Add("Server", localServerDestination);

                Local localMothedDestination = new Local("MethodDisplayName", K2FieldFactory.CreateK2Field(typeof(string), new ValueTypePart(Config.GetApproveUserNames)));
                smfpDestination.Properties.Locals.Add("MethodDisplayName", localMothedDestination);

                Local localMothedTypeDestination = new Local("MethodType", K2FieldFactory.CreateK2Field(typeof(string), new ValueTypePart("list")));
                smfpDestination.Properties.Locals.Add("MethodType", localMothedTypeDestination);

                Local localDisplayNameDestination = new Local("DisplayName", K2FieldFactory.CreateK2Field(typeof(string), new ValueTypePart(Config.SmartObjectName)));
                smfpDestination.Properties.Locals.Add("DisplayName", localDisplayNameDestination);

                smfpDestination.Properties.Locals["IsList"].Value = K2FieldFactory.CreateK2Field(typeof(bool), new ValueTypePart("False"));

                Local localGuidDestination = new Local("Guid", K2FieldFactory.CreateK2Field(typeof(string), new ValueTypePart(Guid.NewGuid().ToString())));
                smfpDestination.Properties.Locals.Add("Guid", localGuidDestination);

                Local localMethodNameDestination = new Local("MethodName", K2FieldFactory.CreateK2Field(typeof(string), new ValueTypePart(Config.GetApproveUserNames)));
                smfpDestination.Properties.Locals.Add("MethodName", localMethodNameDestination);

                Local localTypeDestination = new Local("Type", K2FieldFactory.CreateK2Field(typeof(string), new ValueTypePart("SourceCode.SmartFunctions.Syntax.Expressions.SmartObjectExp")));
                smfpDestination.Properties.Locals.Add("Type", localTypeDestination);

                #endregion
                #region 创建inputs
                Input inputProIdDestination = new Input("procId", "procId", "Text", true, K2FieldFactory.CreateK2Field(typeof(string), new DataFieldPart("Process", "RequestID", DataTypes.String, FieldListOption.None)));
                smfpDestination.Properties.Inputs.Add("procId", inputProIdDestination);

                Input inputActivityNameDestination = new Input("activityName", "activityName", "Text", true, K2FieldFactory.CreateK2Field(typeof(string), new WorkflowContextFieldPart(WorkflowContextProperty.ActivityInstanceName)));
                smfpDestination.Properties.Inputs.Add("activityName", inputActivityNameDestination);
                #endregion
                #region 创建returns
                Return returnResultDestination = new Return("result");
                returnResultDestination.DisplayName = "result";
                returnResultDestination.IsSelected = true;
                returnResultDestination.Type = "Text";
                smfpDestination.Properties.Returns.Add("result", returnResultDestination);
                #endregion
                #region 创建properties
                Property pResultDestination = new Property();
                pResultDestination.Name = "result";
                pResultDestination.DisplayName = "result";
                pResultDestination.Type = "Text";
                smfpDestination.Properties.Properties.Add("result", pResultDestination);
                #endregion
                SourceCode.Workflow.Authoring.K2Field destinationField = new K2Field();
                destinationField.Parts.Add(smfpDestination);
                destination.Value = destinationField;
                defaultDestinationSet.Destinations.Add(destination);
                destinationRule.DestinationSets.Add(defaultDestinationSet);

                // Set the destination rule of the activity
                activity.DestinationRule = destinationRule;
                #endregion
                #region 设置节点上的动作
                var lines = BllRulInfo.Fetch(new CriteriaRulInfo { EqStartActId = node.ID });
                foreach (var line in lines)
                {
                    if (!string.IsNullOrEmpty(line.RulAct))
                    {
                        EventAction action = WorkflowFactory.CreateK2Object<EventAction>(line.RulAct);
                        action.Description = line.Id;
                        action.ActionItem = new DefaultOutcomeAction();
                        approvalClientEvent.Actions.Add(action);
                    }
                }
                #endregion
                #region 设置节点上的规则导航
                //相同动作不同规则如何设置
                activity.SucceedingRule = new DefaultOutcomeSucceedingRule();
                PropertyWizardDefinition propWizDefSimple = WorkflowHelpers.FindOfType<SimpleSucceedingRulePropertyWizardDefinition>(activity.WizardDefinition.PropertyWizardDefinitions);
                PropertyWizardDefinition propWizDefOutcome = WorkflowHelpers.FindOfType<OutcomeSucceedingRulePropertyWizardDefinition>(activity.WizardDefinition.PropertyWizardDefinitions);
                if (propWizDefSimple != null && propWizDefOutcome == null)
                {
                    activity.WizardDefinition.PropertyWizardDefinitions.Remove(propWizDefSimple);
                    activity.WizardDefinition.PropertyWizardDefinitions.Add(
                        WorkflowFactory.CreatePropertyWizardDefinition(PropertyWizardNames.OutcomeSucceedingRule));
                }
                #endregion
                #region 设置节点上的动作对应的outcome
                //如何生成一个动作对应多个outcome
                //SourceCode.Workflow.Design.Outcome.Common.GenerateDefaultOutcomesForActions(approvalClientEvent);
                ProcessFactory.GenerateDefaultOutcomesForActions(approvalClientEvent, lines);
                #endregion
                #region 设置节点上的outcome对应的line
                SourceCode.Workflow.Design.Outcome.Common.GenerateDefaultLinesForOutcomes(activity.SucceedingRule as DefaultOutcomeSucceedingRule);
                foreach (var line in lines)
                {
                    if (!string.IsNullOrEmpty(line.RulAct))
                    {
                        DefaultActivity finishActivity = FindActivity(process, nodeNameDic[line.EndActId]);
                        Line pl = FindLine(process, node.ApprovalNode_Name, line.RulAct);
                        if (pl != null)
                            pl.FinishActivity = finishActivity;
                    }
                }
                #endregion
时间: 2024-10-05 19:36:55

k2画流程-关于用代买生成K2 kprx 文件的相关文章

查找k1大到k2大-分治法查找k1到k2大的数

问题描述 分治法查找k1到k2大的数 以下代码用来求一个数组中k1大到k2-大的数-要求数组不能进行完全排序-下面的快排我验证过了没问题-就是后面那个findkk函数-不知道为什么运行到一半的时候就会自动退出,求大神帮忙看看问题出在哪QAQ #include<iostream> using namespace std; void sweap(int &arr1,int &arr2 ){ int temp = arr1; arr1 = arr2; arr2 = temp; } i

画数据库图,然后生成对应的表的疑问

问题描述 我想做一个小程序..功能是画出数据库的表(写上属性,方法,约束)然后根据画的图..生成一个表~~不知该用什么技术??本人很想做出这个小程序...请各位指教~~ 问题补充:laorer 写道 解决方案 你熟悉哪个就用哪个,如果都不熟悉,你可以试下 html + div + javascript(jquery)操作起来比较容易,不过似乎要把生成的内容传给后台去处理,而且各个属性都要动态的存储在相应的div的属性中swing的话,开始可能会有点烦琐,不过可以直接是桌面应用,而且设计成可以一个

ruby生成的excel文件,怎么样可以让它指定文件名自动保存?

问题描述 ruby生成的excel文件,怎么样可以让它指定文件名自动保存? 问题补充:用ruby脚本写个方法,把生成的excel文件保存起来. excel = WIN32OLE.new("excel.application") excel['Visible'] = TRUE excel.Workbooks.Add()解决方案二:这里主要往excel对象里放数据解决方案三:## line = 1 100.times{|link| excel.Range("a#{line}&qu

rotation-flex 嵌入中文字体后生成的SWF文件太大了

问题描述 flex 嵌入中文字体后生成的SWF文件太大了 我在flex项目中要通过设置某一组件的rotation属性来达到旋转角度的目的.flex规定要达到此效果必须引入外部字体,但是引入外部字体后会明显增加swf文件的大小,特别是我需要引入中文字体时,中文字体一般都有10几M,这太恐怖了,不知道还有什么其他解决方案.既要达到这种旋转效果,又要保证引入中文字体后,swf文件尽可能的小.

FSO生成UTF-8编码文件的解决方法

昨天给aw写一个生成天气预报的xml文件的程序,考虑到通用性,于是选择utf-8编码,我也比较偏好这个编码.最先想到用FSO来写这个xml文件,后来却发现生成的xml文件不能正常显示,仅仅是因为编码的原因.用记事本打开生成的xml文件,另存为utf-8编码的xml文件即可正常显示.于是在网上搜索了一下,结果发现很多人说FSO只能写ANSI编码的文件,不能写utf-8格式的文件,并且只能读写文本文件.很多人都选择用ADODB.STREAM对象来替代FSO对象,因为STREAM类有LOADFROMF

ASP生成静态Html文件技术

网页生成静态Html文件有许多好处,比如生成html网页有利于被搜索引擎收录,不仅被收录的快还收录的全.前台脱离了数据访问,减轻对数据库访问的压力,加快网页打开速度.   像www.aspid.cn的主站就采用了TSYS生成html文件!所以吟清最近对生成html比较感兴趣,看了不少文章,也有一点点收获. 1,下面这个例子直接利用FSO把html代码写入到文件中然后生成.html格式的文件 <%filename="test.htm"if request("body&qu

比较ASP生成静态HTML文件的几种方法

将动态页面转换生成静态Html文件有许多好处,比如生成html网页有利于被搜索引擎收录(特别是对接受动态参数的页面).前台访问时,脱离了数据访问,减轻对数据库访问的压力,加快网页打开速度. 当然,凡事有利必有弊,生成HTML页面无形中也耗费大量的磁盘空间以存放这些静态文件,在编辑页面过程中除读写数据库外,也要读写服务器磁盘,页面样式的改动必须重新生成全部HTML文件,等等. 像很多搜索引擎,都可以提交网站的页面地址列表,动态文件的收录问题已经不算是个问题了(如google sitemap).得失

ASP生成静态HTML文件的几种方法比较

比较|静态 将动态页面转换生成静态Html文件有许多好处,比如生成html网页有利于被搜索引擎收录(特别是对接受动态参数的页面).前台访问时,脱离了数据访问,减轻对数据库访问的压力,加快网页打开速度. 当然,凡事有利必有弊,生成HTML页面无形中也耗费大量的磁盘空间以存放这些静态文件,在编辑页面过程中除读写数据库外,也要读写服务器磁盘,页面样式的改动必须重新生成全部HTML文件,等等. 像很多搜索引擎,都可以提交网站的页面地址列表,动态文件的收录问题已经不算是个问题了(如google sitem

生成excel的文件

excel|生成excel <? header("Content-type:application/vnd.ms-excel");header("Content-Disposition:filename=test.xls"); $sql = "select ";if ( $HTTP_POST_VARS["C1"] == "ON" ) $sql .= "hdid, ";if ( $C