/// <summary> /// 给工作项添加审批意见 /// </summary> /// <param name="item">工作项</param> /// <param name="approval">审批结果</param> /// <param name="commentText">审批意见</param> private void AppendComment(OThinker.H3.Instance.InstanceContext Instance, OThinker.H3.WorkItem.WorkItem item, OThinker.Data.BoolMatchValue approval, string commentText) { // 添加一个审批意见 WorkflowTemplate.PublishedWorkflowTemplate workflow = this.Engine.WorkflowManager.GetPublishedTemplate( item.WorkflowCode, item.WorkflowVersion); // 审批字段 string approvalDataItem = null; if (workflow != null) { OThinker.H3.DataModel.BizObjectSchema schema = this.Engine.BizObjectManager.GetPublishedSchema(item.WorkflowCode); approvalDataItem = workflow.GetDefaultCommentDataItem(schema, item.ActivityCode); } if (approvalDataItem != null) { // 创建审批 OThinker.H3.Data.Comment comment = new Data.Comment(); comment.Activity = item.ActivityCode; comment.Approval = approval; comment.CreatedTime = System.DateTime.Now; comment.DataField = approvalDataItem; comment.InstanceId = item.InstanceId; comment.BizObjectId = Instance.BizObjectId; comment.BizObjectSchemaCode = Instance.BizObjectSchemaCode; comment.OUName = this.Engine.Organization.GetName(this.Engine.Organization.GetParent(item.Participant)); comment.Text = commentText; comment.TokenId = item.TokenId; comment.UserID = item.Participant; comment.UserName = item.ParticipantName; // 设置用户的默认签章 Organization.Signature[] signs = this.Engine.Organization.GetSignaturesByUnit(item.Participant); if (signs != null && signs.Length > 0) { foreach (Organization.Signature sign in signs) { if (sign.IsDefault) { comment.SignatureId = sign.ObjectID; break; } } } this.Engine.BizObjectManager.AddComment(comment); } }
private void AppendComment(WorkItem.WorkItem Item, OThinker.Data.BoolMatchValue Approval, string Comment) { WorkflowTemplate.PublishedWorkflowTemplate workflow = GetWorkflowTemplate(Item.WorkflowCode, Item.WorkflowVersion); // 审批字段 string approvalDataItem = null; if (workflow != null) { PublishedWorkflowTemplate workflowTemplate = this.Engine.WorkflowManager.GetPublishedTemplate(Item.WorkflowCode, Item.WorkflowVersion); OThinker.H3.DataModel.BizObjectSchema schema = GetSchema(workflowTemplate.BizObjectSchemaCode); approvalDataItem = workflow.GetDefaultCommentDataItem(schema, Item.ActivityCode); } if (approvalDataItem != null) { // 创建审批 //TODO:此处待修改,Item.BizObjectId不存在,通过 OT_InstanceContext获取 Instance.InstanceContext InstanceContext = this.Engine.InstanceManager.GetInstanceContext(Item.InstanceId); string BizObjectId = InstanceContext == null ? string.Empty : InstanceContext.BizObjectId; Data.Comment comment = new Data.Comment(); comment.Activity = Item.ActivityCode; comment.Approval = Approval; comment.CreatedTime = System.DateTime.Now; comment.DataField = approvalDataItem; comment.InstanceId = Item.InstanceId; comment.OUName = this.Engine.Organization.GetName(this.Engine.Organization.GetParent(Item.Participant)); comment.Text = Comment; comment.TokenId = Item.TokenId; comment.UserID = Item.Participant; comment.UserName = Item.ParticipantName; //comment.BizObjectId = Item.BizObjectId; comment.BizObjectId = BizObjectId; comment.BizObjectSchemaCode = Item.WorkflowCode; this.Engine.BizObjectManager.AddComment(comment); } }