Exemplo n.º 1
0
        private void ParseParams(string instanceId, string itemName, string workItemID)
        {
            // 基本参数
            this.InstanceId = instanceId;
            this.ItemName   = System.Web.HttpUtility.UrlDecode(itemName);
            this.WorkItemID = workItemID;

            // 验证参数
            if (string.IsNullOrEmpty(this.InstanceId) && string.IsNullOrEmpty(this.WorkItemID))
            {
                throw new ArgumentNullException("Param InstanceId and WorkItemID can NOT be null at the same time.");
            }


            // 获得流程或者任务对象
            if (!string.IsNullOrEmpty(this.InstanceId))
            {
                this.InstanceContext = this.Engine.InstanceManager.GetInstanceContext(this.InstanceId);
                if (this.InstanceContext == null)
                {
                    throw new ArgumentNullException("InstanceID invalid.");
                }
            }
            if (!string.IsNullOrEmpty(this.WorkItemID))
            {
                this.WorkItem      = this.Engine.WorkItemManager.GetWorkItem(this.WorkItemID);
                this.CirculateItem = this.Engine.WorkItemManager.GetCirculateItem(this.WorkItemID);

                if (this.WorkItem == null && this.CirculateItem == null)
                {
                    throw new ArgumentNullException("WorkItemID invalid.");
                }
            }

            // 获得流程模板
            this.Workflow = this.Engine.WorkflowManager.GetPublishedTemplate(this.InstanceContext.WorkflowCode, this.InstanceContext.WorkflowVersion);
            //            this.Workflow = this.Engine.WorkflowManager.GetWorkflow(this.InstanceContext.WorkflowPackage, this.InstanceContext.WorkflowName, this.InstanceContext.WorkflowVersion);
            if (this.Workflow == null)
            {
                throw new ArgumentNullException("Workflow Template invalid.");
            }

            // 获得数据定义
            this.WorkflowDataItems = this.Engine.BizObjectManager.GetPublishedSchema(this.Workflow.BizObjectSchemaCode).Properties;
            //this.Workflow.GetDataItem(this.ItemName);

            foreach (DataModel.PropertySchema p in this.WorkflowDataItems)
            {
                if (this.ItemName == p.Name)
                {
                    this.WorkflowDataItem = p;
                    break;
                }
            }

            if (this.WorkflowDataItem == null)
            {
                throw new ArgumentNullException("Workflow Data Item invalid.");
            }
        }
        /// <summary>
        /// 结束流程
        /// </summary>
        /// <param name="instanceId"></param>
        /// <returns></returns>
        public static bool FinishedInstance(string instanceId)
        {
            try
            {
                AppUtility.Engine.LogWriter.Write(DateTime.Now.ToString() + " 根据instanceid强制结束流程开始,流程实例ID:" + instanceId);
                OThinker.H3.Instance.InstanceContext context = AppUtility.Engine.InstanceManager.GetInstanceContext(instanceId);
                if (context == null)
                {
                    return(false);
                }

                OThinker.H3.WorkflowTemplate.PublishedWorkflowTemplate workflow = AppUtility.Engine.WorkflowManager.GetDefaultWorkflow(context.WorkflowCode);

                OThinker.H3.Messages.ActivateActivityMessage activateMessage = new OThinker.H3.Messages.ActivateActivityMessage(
                    OThinker.H3.Messages.MessageEmergencyType.High,
                    instanceId,
                    workflow.EndActivityCode,
                    OThinker.H3.Instance.Token.UnspecifiedID,
                    null,
                    null,
                    false,
                    OThinker.H3.WorkItem.ActionEventType.Adjust
                    );
                AppUtility.Engine.InstanceManager.SendMessage(activateMessage);
                AppUtility.Engine.LogWriter.Write(DateTime.Now.ToString() + " 根据instanceid强制结束流程成功,流程实例ID:" + instanceId);
                return(true);
            }
            catch
            {
                AppUtility.Engine.LogWriter.Write(DateTime.Now.ToString() + " 根据instanceid强制结束流程失败,流程实例ID:" + instanceId);
                return(false);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 提交工作项
        /// </summary>
        /// <param name="workItemId">工作项ID</param>
        /// <param name="approval">审批结果</param>
        /// <param name="commentText">审批意见</param>
        /// <param name="userId">处理人</param>
        public void SubmitItem(string workItemId, OThinker.Data.BoolMatchValue approval, string commentText, string userId)
        {
            //Console.Write("开始提交工作项");
            // 获取工作项
            OThinker.H3.WorkItem.WorkItem        item     = this.Engine.WorkItemManager.GetWorkItem(workItemId);
            OThinker.H3.Instance.InstanceContext instance = this.Engine.InstanceManager.GetInstanceContext(item.InstanceId);
            // 添加意见
            this.AppendComment(instance, item, OThinker.Data.BoolMatchValue.Unspecified, commentText);

            // 结束工作项
            this.Engine.WorkItemManager.FinishWorkItem(
                item.ObjectID,
                userId,
                OThinker.H3.WorkItem.AccessPoint.ExternalSystem,

                null,
                approval,
                commentText,
                null,
                OThinker.H3.WorkItem.ActionEventType.Forward,
                (int)OThinker.H3.Controllers.SheetButtonType.Submit);
            // 需要通知实例事件管理器结束事件
            OThinker.H3.Messages.AsyncEndMessage endMessage = new OThinker.H3.Messages.AsyncEndMessage(
                OThinker.H3.Messages.MessageEmergencyType.Normal,
                item.InstanceId,
                item.ActivityCode,
                item.TokenId,
                approval,
                false,
                approval,
                true,
                null);
            this.Engine.InstanceManager.SendMessage(endMessage);
        }
        /// <summary>
        /// 结束工作任务
        /// </summary>
        /// <param name="MvcPost">MVC表单传递过来的值</param>
        /// <param name="Approval">审核结果</param>
        /// <param name="ActionEventType">事件类型</param>
        /// <param name="ActionButtonType">按钮类型</param>
        public void ForwardWorkItem(
            List <DataItemParam> paramList, string code, string schemaCode, string instanceId, string workItemCode)
        {
            OThinker.H3.Instance.InstanceContext  ic     = this.Engine.InstanceManager.GetInstanceContext(instanceId);
            OThinker.H3.DataModel.BizObjectSchema schema = this.Engine.BizObjectManager.GetPublishedSchema(schemaCode);
            OThinker.H3.DataModel.BizObject       bo     = new OThinker.H3.DataModel.BizObject(Engine, schema, code);
            OThinker.H3.WorkItem.WorkItem         item   = this.Engine.WorkItemManager.GetWorkItem(workItemCode);


            bo.ObjectID = ic.BizObjectId;
            bo.Load();//装载流程数据;

            if (paramList != null)
            {
                // 这里可以在创建流程的时候赋值
                foreach (DataItemParam param in paramList)
                {
                    if (bo.Schema.ContainsField(param.ItemName))
                    {
                        bo[param.ItemName] = param.ItemValue;
                    }
                }
            }

            bo.Update();

            if (!string.IsNullOrEmpty(workItemCode))
            {
                // 结束工作项
                this.Engine.WorkItemManager.FinishWorkItem(
                    workItemCode,
                    code,
                    OThinker.H3.WorkItem.AccessPoint.ExternalSystem,
                    null,
                    OThinker.Data.BoolMatchValue.True,
                    string.Empty,
                    null,
                    OThinker.H3.WorkItem.ActionEventType.Forward,
                    (int)OThinker.H3.Controllers.SheetButtonType.Submit);

                // 需要通知实例事件管理器结束事件
                Messages.AsyncEndMessage endMessage = new OThinker.H3.Messages.AsyncEndMessage(
                    Messages.MessageEmergencyType.Normal,
                    instanceId,
                    item.ActivityCode,
                    item.TokenId,
                    OThinker.Data.BoolMatchValue.True,
                    false,
                    OThinker.Data.BoolMatchValue.True,
                    true,
                    null);
                this.Engine.InstanceManager.SendMessage(endMessage);
            }
        }
        /// <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);
            }
        }
        public List <UserCode> GetParticipants(string ActivityCode, string InstanceID)
        {
            if (!string.IsNullOrEmpty(ActivityCode) && !string.IsNullOrEmpty(InstanceID))
            {
                //流程
                OThinker.H3.Instance.InstanceContext InstanceContext = this.Engine.InstanceManager.GetInstanceContext(InstanceID);
                if (InstanceContext != null)
                {
                    //流程模板
                    OThinker.H3.WorkflowTemplate.PublishedWorkflowTemplate Template = this.Engine.WorkflowManager.GetPublishedTemplate(
                        InstanceContext.WorkflowCode,
                        InstanceContext.WorkflowVersion);
                    if (Template != null)
                    {
                        //活动信息
                        ClientActivityBase Activity = Template.GetActivityByCode(ActivityCode) as ClientActivityBase;

                        OThinker.H3.Instance.InstanceData InstanceData = new OThinker.H3.Instance.InstanceData(this.Engine, InstanceID, null);

                        string[] ParticipantIDs = Activity.ParseParticipants(InstanceData, this.Engine.Organization);
                        OThinker.Organization.Unit[] ParticipantUsers = this.Engine.Organization.GetUnits(ParticipantIDs).ToArray();

                        if (ParticipantUsers != null)
                        {
                            List <UserCode> ParticipantUserNames = new List <UserCode>();
                            foreach (OThinker.Organization.Unit u in ParticipantUsers)
                            {
                                if (u != null && u.UnitType == OThinker.Organization.UnitType.User)
                                {
                                    OThinker.Organization.User user = (OThinker.Organization.User)u;
                                    ParticipantUserNames.Add(new UserCode
                                    {
                                        Name     = user.Name,
                                        Code     = user.Code,
                                        ObjectID = user.ObjectID
                                    });
                                    //ParticipantUserNames.Add(u.Name + "[" + u.Code + "]");
                                }
                            }
                            return(ParticipantUserNames);
                        }
                    }
                }
            }

            return(null);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 驳回工作任务
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="workItemId"></param>
        /// <param name="commentText"></param>
        /// <returns></returns>
        public bool ReturnItem(string userId, string workItemId, string commentText)
        {
            //Console.Write("不回");
            OThinker.Organization.User user = this.Engine.Organization.GetUnit(userId) as OThinker.Organization.User;
            if (user == null)
            {
                return(false);
            }
            // 获取工作项
            OThinker.H3.WorkItem.WorkItem        item    = this.Engine.WorkItemManager.GetWorkItem(workItemId);
            OThinker.H3.Instance.InstanceContext context = this.Engine.InstanceManager.GetInstanceContext(item.InstanceId);
            // ToKen
            OThinker.H3.Instance.IToken Token = context.GetToken(item.TokenId);
            if (Token.PreTokens == null)
            {
                return(false);
            }
            int PreToken = int.Parse(Token.PreTokens[0].ToString());

            OThinker.H3.Instance.IToken PreToken1 = context.GetToken(PreToken);
            string activityName = PreToken1.Activity;

            // 添加意见
            this.AppendComment(context, item, OThinker.Data.BoolMatchValue.False, commentText);
            // 结束工作项
            this.Engine.WorkItemManager.FinishWorkItem(
                item.ObjectID,
                user.ObjectID,
                OThinker.H3.WorkItem.AccessPoint.ExternalSystem,

                null,
                OThinker.Data.BoolMatchValue.False,
                commentText,
                null,
                OThinker.H3.WorkItem.ActionEventType.Backward,
                (int)OThinker.H3.Controllers.SheetButtonType.Return);
            // 准备触发后面Activity的消息
            OThinker.H3.Messages.ActivateActivityMessage activateMessage
                = new OThinker.H3.Messages.ActivateActivityMessage(
                      OThinker.H3.Messages.MessageEmergencyType.Normal,
                      item.InstanceId,
                      activityName,
                      OThinker.H3.Instance.Token.UnspecifiedID,
                      null,
                      new int[] { item.TokenId },
                      false,
                      OThinker.H3.WorkItem.ActionEventType.Backward);

            // 通知该Activity已经完成
            OThinker.H3.Messages.AsyncEndMessage endMessage =
                new OThinker.H3.Messages.AsyncEndMessage(
                    OThinker.H3.Messages.MessageEmergencyType.Normal,
                    item.InstanceId,
                    item.ActivityCode,
                    item.TokenId,
                    OThinker.Data.BoolMatchValue.False,
                    true,
                    OThinker.Data.BoolMatchValue.False,
                    false,
                    activateMessage);
            this.Engine.InstanceManager.SendMessage(endMessage);
            return(true);
        }
        public bool ReturnItem(string userId, string workItemId, string activityCode, string SchemaCode, double xbzjye, string state, DateTime bzjyedysj, string userName, string PassState, double yzzfbzj)
        {
            Organization.User user = this.Engine.Organization.GetUnit(userId) as Organization.User;
            if (user == null)
            {
                return(false);
            }
            // 获取工作项

            OThinker.H3.DataModel.BizObjectSchema schema  = this.Engine.BizObjectManager.GetPublishedSchema(SchemaCode);
            OThinker.H3.WorkItem.WorkItem         item    = this.Engine.WorkItemManager.GetWorkItem(workItemId);
            OThinker.H3.Instance.InstanceContext  context = this.Engine.InstanceManager.GetInstanceContext(item.InstanceId);
            OThinker.H3.DataModel.BizObject       bo      = new OThinker.H3.DataModel.BizObject(Engine, schema, userId);
            bo.ObjectID = context.BizObjectId;
            bo.Load();                            //装载流程数据;

            if (bo.Schema.ContainsField("BZJYE")) //保证金余额
            {
                bo["BZJYE"] = xbzjye;
            }
            if (bo.Schema.ContainsField("LCZT"))
            {
                bo["LCZT"] = state;
            }
            if (bo.Schema.ContainsField("BZJYEDYSJ"))
            {
                bo["BZJYEDYSJ"] = bzjyedysj;
            }
            if (bo.Schema.ContainsField("CWCLR"))
            {
                bo["CWCLR"] = userName;
            }
            if (bo.Schema.ContainsField("CWSPRID"))
            {
                bo["CWSPRID"] = userId;
            }
            //this.AppendComment(item.InstanceId, item, OThinker.Data.BoolMatchValue.Unspecified, "现保证金余额x钱,应再支付X保证金");



            // 结束工作项
            if (PassState == "TG")
            {//财务通过
                this.Engine.WorkItemManager.FinishWorkItem(
                    item.ObjectID,
                    user.ObjectID,
                    H3.WorkItem.AccessPoint.ExternalSystem,
                    null,
                    OThinker.Data.BoolMatchValue.True,
                    string.Empty,
                    null,
                    H3.WorkItem.ActionEventType.Backward,
                    (int)OThinker.H3.Controllers.SheetButtonType.Return);

                if (bo.Schema.ContainsField("CWSPYJDX"))
                {
                    bo["CWSPYJDX"] = "通过";
                }

                this.AppendComment(context, item, OThinker.Data.BoolMatchValue.True, "通过");//财务部通过后,显示通过
            }
            else
            {//财务驳回
                this.Engine.WorkItemManager.FinishWorkItem(
                    item.ObjectID,
                    user.ObjectID,
                    H3.WorkItem.AccessPoint.ExternalSystem,
                    null,
                    OThinker.Data.BoolMatchValue.False,
                    string.Empty,
                    null,
                    H3.WorkItem.ActionEventType.Backward,
                    (int)OThinker.H3.Controllers.SheetButtonType.Return);
                var info = "现保证金余额" + string.Format("{0:N2}", xbzjye) + "元,应再支付" + string.Format("{0:N2}", yzzfbzj) + "保证金";
                this.AppendComment(context, item, OThinker.Data.BoolMatchValue.False, info);

                if (bo.Schema.ContainsField("CWSPYJDX"))
                {
                    bo["CWSPYJDX"] = "驳回";
                }

                try
                {
                    MessageClass ms = new MessageClass();

                    string    sql = @"select distinct a.PARTICIPANT,b.code, d.objectid  , d.code jxsuserCode, e.JXS,e.JXSCODE from Ot_Workitemfinished  a
join Ot_User b on a.PARTICIPANT = b.objectid 
join Ot_Instancecontext c on c.objectid = a.instanceid 
join OT_User d on d.objectid = c.ORIGINATOR 
join I_DealerLoan e on e.objectid = c.bizobjectid
where   ACTIVITYCODE='Activity3' and c.workFlowCode = 'DealerLoan' and instanceid='" + item.InstanceId + "'";
                    DataTable dt  = OThinker.H3.Controllers.AppUtility.Engine.EngineConfig.CommandFactory.CreateCommand().ExecuteDataTable(sql);

                    string msstr1 = dt.Rows[0]["JXS"].ToString() + "(" + dt.Rows[0]["JXSCODE"].ToString() + ") 还需要支付<font color=\"red\">" + string.Format("{0:N2}", yzzfbzj) + "</font> 元 保证金金额才可以进行本次贷款申请,现保证金账户余额 " + string.Format("{0:N2}", xbzjye) + " 元";

                    string msstr2 = "您的账户还需要支付<font color=\"red\">" + string.Format("{0:N2}", yzzfbzj) + "</font> 元 保证金金额才可以进行本次贷款申请,现保证金账户余额 " + string.Format("{0:N2}", xbzjye) + "元";

                    if (dt != null && dt.Rows != null && dt.Rows.Count > 0)
                    {
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            ms.InsertMSG(dt.Rows[i]["PARTICIPANT"].ToString(), dt.Rows[i]["code"].ToString(), msstr1, true, 0, "");
                        }
                    }

                    ms.InsertMSG(dt.Rows[0]["objectid"].ToString(), dt.Rows[0]["jxsCode"].ToString(), msstr2, false, 0, "");
                }
                catch (Exception e)
                {
                }
            }

            bo.Update();
            // 准备触发后面Activity的消息
            OThinker.H3.Messages.ActivateActivityMessage activateMessage
                = new OThinker.H3.Messages.ActivateActivityMessage(
                      OThinker.H3.Messages.MessageEmergencyType.Normal,
                      item.InstanceId,
                      activityCode,
                      OThinker.H3.Instance.Token.UnspecifiedID,
                      null,
                      new int[] { item.TokenId },
                      false,
                      H3.WorkItem.ActionEventType.Backward);

            // 通知该Activity已经完成
            OThinker.H3.Messages.AsyncEndMessage endMessage =
                new OThinker.H3.Messages.AsyncEndMessage(
                    OThinker.H3.Messages.MessageEmergencyType.Normal,
                    item.InstanceId,
                    item.ActivityCode,
                    item.TokenId,
                    OThinker.Data.BoolMatchValue.False,
                    true,
                    OThinker.Data.BoolMatchValue.False,
                    false,
                    activateMessage);
            this.Engine.InstanceManager.SendMessage(endMessage);



            return(true);
        }
        /// <summary>
        /// 结束工作任务
        /// </summary>
        public void ENDWorkItem(string UpdateUserId, string schemaCode, string workItemID, string STATE)
        {
            OThinker.H3.WorkItem.WorkItem item = this.Engine.WorkItemManager.GetWorkItem(workItemID);

            if (!string.IsNullOrEmpty(schemaCode))
            {
                OThinker.H3.DataModel.BizObjectSchema schema = this.Engine.BizObjectManager.GetPublishedSchema(schemaCode);
                OThinker.H3.DataModel.BizObject       bo     = new OThinker.H3.DataModel.BizObject(Engine, schema, UpdateUserId);

                OThinker.H3.Instance.InstanceContext ic = this.Engine.InstanceManager.GetInstanceContext(item.InstanceId);

                if (!string.IsNullOrEmpty(workItemID))
                {
                    bo.ObjectID = ic.BizObjectId;
                    bo.Load();//装载流程数据;

                    if (!string.IsNullOrEmpty(STATE))
                    {
                        if (bo.Schema.ContainsField("LCZT"))
                        {
                            bo["LCZT"] = STATE;
                        }
                        if (bo.Schema.ContainsField("OperationStates"))
                        {
                            bo["OperationStates"] = STATE;
                        }
                        if (bo.Schema.ContainsField("states"))
                        {
                            bo["states"] = STATE;
                        }
                    }

                    bo.Update();
                }
            }

            // 结束工作项
            this.Engine.WorkItemManager.FinishWorkItem(
                workItemID,
                UpdateUserId,
                OThinker.H3.WorkItem.AccessPoint.ExternalSystem,
                null,
                OThinker.Data.BoolMatchValue.True,
                string.Empty,
                null,
                OThinker.H3.WorkItem.ActionEventType.Forward,
                (int)OThinker.H3.Controllers.SheetButtonType.Submit);

            // 需要通知实例事件管理器结束事件
            Messages.AsyncEndMessage endMessage = new OThinker.H3.Messages.AsyncEndMessage(
                Messages.MessageEmergencyType.Normal,
                item.InstanceId,
                item.ActivityCode,
                item.TokenId,
                OThinker.Data.BoolMatchValue.True,
                false,
                OThinker.Data.BoolMatchValue.True,
                true,
                null);
            this.Engine.InstanceManager.SendMessage(endMessage);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.Files.Count == 0)
            {
                Response.End();
            }

            string ID          = Request.Form["ID"];
            string dataField   = Request.Form["dataField"];
            string instanceID  = Request.Form["InstanceID"] + string.Empty;
            string download    = Request.Form["download"] + string.Empty;
            string bizObjectID = Request.Form["BizObjectID"] + string.Empty;
            string schemaCode  = Request.Form["SchemaCode"] + string.Empty;
            string saveType    = Request.Form["SaveType"] + string.Empty;//判断是保存正文还是PDF,doc:正文,pdf:PDF
            //string workflowPackage = Request.Form["WorkflowPackage"] + string.Empty;
            //string workflowName = Request.Form["WorkflowName"] + string.Empty;
            string fileExtension = ".doc";

            if (saveType.ToLower() == "pdf")
            {
                fileExtension = ".pdf";
            }

            //保存 WORD 文档保存的文件名称为 [流程实例名称].doc,如果流程实例名称为空,那么保存为 BizObjectID.doc
            string fileName = bizObjectID;

            if (!string.IsNullOrEmpty(instanceID))
            {
                OThinker.H3.Instance.InstanceContext context = AppUtility.Engine.InstanceManager.GetInstanceContext(instanceID);
                if (context != null)
                {
                    string InstanceName = context.InstanceName;
                    if (!string.IsNullOrEmpty(InstanceName))
                    {
                        fileName = InstanceName;
                    }
                }
                else
                {
                    bizObjectID = instanceID; //发起的时候没有BizObjectID,使用InstanceID,在打开时修改BizObjectID
                }

                AttachmentHeader[] attachs = AppUtility.Engine.BizObjectManager.QueryAttachment(schemaCode, bizObjectID, dataField, OThinker.Data.BoolMatchValue.True, null);
                if (attachs != null && attachs.Length > 0)
                {
                    ID = attachs[0].AttachmentID;
                }
                else
                {
                    ID = Guid.NewGuid().ToString();
                }
            }
            else
            {
                ID = Guid.NewGuid().ToString();
            }

            fileName = fileName + fileExtension;

            byte[] fileValue = new byte[Request.Files[0].ContentLength];
            if (fileValue.Length == 0)
            {
                return;                        // 没有接收到数据,则不做保存
            }
            Request.Files[0].InputStream.Read(fileValue, 0, Request.Files[0].ContentLength);
            OThinker.H3.Data.Attachment attachment = new OThinker.H3.Data.Attachment()
            {
                ObjectID            = ID,
                FileName            = fileName,//HttpUtility.UrlDecode(Request.Files[0].FileName),
                ContentType         = Request.Files[0].ContentType,
                Content             = fileValue,
                DataField           = HttpUtility.UrlDecode(dataField),
                CreatedBy           = this.UserValidator.UserID,
                Downloadable        = true,
                BizObjectId         = bizObjectID,
                BizObjectSchemaCode = schemaCode
            };
            try
            {
                //保存 更新文件
                this.Engine.BizObjectManager.RemoveAttachment(string.Empty,
                                                              schemaCode,
                                                              attachment.BizObjectId,
                                                              attachment.AttachmentID);
                this.Engine.BizObjectManager.AddAttachment(attachment);
            }
            catch (Exception ex)
            {
                this.Engine.LogWriter.Write("WordSave Error:" + ex.ToString());
            }
        }