|
撸猫侠
发表于 2021-11-15 15:16:39
创建业务对象,赋值业务对象,创建流程,这几件事的顺序,会导致序列号不能自动生成,显示为{SeqNo}
1、创建业务对象->创建流程,没有问题
2、创建业务对象->创建流程->继续赋值业务对象->Update()业务对象,不能自动生成序列号
3、创建业务对象->继续赋值业务对象->Update()业务对象->创建流程,不能自动生成序列号
继续赋值业务对象,这部分逻辑不便于挪到创建之前。
以下是部分代码:
/* 创建一个新的采购订单 */
H3.DataModel.BizObjectSchema orderSchema = this.Request.Engine.BizObjectManager.GetPublishedSchema(idhOrder.ClassName);
orderBo = new H3.DataModel.BizObject(this.Request.Engine, orderSchema, this.Request.UserContext.UserId, this.Request.UserContext.User.ParentId);
orderBo[idhOrder.Factory] = factoryObjectId;
orderBo[idhOrder.NestStep] = "准备采购";
orderBo[idhOrder.State] = "准备采购";
orderBo.CreatedBy = this.Request.UserContext.UserId;
orderBo.OwnerId = this.Request.UserContext.UserId;
orderBo.Status = H3.DataModel.BizObjectStatus.Running;
if(string.IsNullOrEmpty(orderBo.WorkflowInstanceId))
{
orderBo.WorkflowInstanceId = System.Guid.NewGuid().ToString();// 必须在Create()方法调用之前,否则流程何业务对象没有完全关联,流程日志为空
}
orderBo.Create();
/// 继续对orderBo进行写操作,包括写子表项目
orderBo.Update();
///创建流程
H3.Workflow.Instance.WorkflowInstance wInstance = this.Request.Engine.WorkflowInstanceManager.GetWorkflowInstance(orderBo.WorkflowInstanceId);
if(wInstance == null)
{
string workItemID = string.Empty;
string errorMsg = string.Empty;
H3.Workflow.Template.WorkflowTemplate wTemplate = this.Request.Engine.WorkflowTemplateManager.GetDefaultWorkflow(orderBo.Schema.SchemaCode);
this.Request.Engine.Interactor.OriginateInstance(this.Request.UserContext.UserId,
orderBo.Schema.SchemaCode,
wTemplate.WorkflowVersion,
orderBo.ObjectId,
orderBo.WorkflowInstanceId,
H3.Workflow.WorkItem.AccessMethod.Web,
true,// 是否自动提交
string.Empty,
true,
out workItemID,
out errorMsg);
}
|
|