public void InsertNewActivity(AddWorkflowActivityRequest request)
        {
            //插入新活动前,先保存当前所处活动
            WorkflowActivity activityBeforUpdate = GetCurrentActivity(request.ObjectId);

            WorkflowActivity activity = new WorkflowActivity(request.ObjectId, request.ObjectTypeId, request.WorkflowNodeId, request.CreateUserId, activityBeforUpdate);

            this._workflowActivityRepository.Save(activity);

            if (activityBeforUpdate != null)
            {
                activityBeforUpdate.EndTime = DateTime.Now;
                this._workflowActivityRepository.Save(activityBeforUpdate);
            }
            this._uow.Commit();
        }
        /// <summary>
        /// 添加到货单
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public bool AddArrivalReceiptDetail(AddArrivalReceiptDetailRequest request)
        {
            //获取通知到货明细
            ArrivalNoticeDetail model = this._arrivalNoticeDetailRepository.FindBy(request.ArrivalNoticeId);

            if (model == null)
            {
                throw new EntityIsInvalidException <string>(request.PurchaseOrderDetailId.ToString());
            }

            //添加到货单
            AddArrivalReceiptRequest addreceipt = new AddArrivalReceiptRequest();

            addreceipt.CreateUserId = request.CreateUserId;
            addreceipt.Note         = "";
            ArrivalReceipt receipt = this._arrivalReceiptService.AddArrivalReceipt(addreceipt);

            //添加到货明细
            model.AddReceiptDetail(receipt, request.Qty, request.Note, request.CreateUserId);
            this._arrivalNoticeDetailRepository.Save(model);
            this._uow.Commit();

            //看看到货单的所有产品是否已经都到货了
            ArrivalNotice notice = this._arrivalNoticeRepository.FindBy(model.ArrivalNotice.Id);

            if (notice.State == 1)
            {
                //刷新通知到货单状态
                notice.RefreshState();
                if (notice.State == 2)
                {
                    //调整采购单状态
                    AddWorkflowActivityRequest request_ac = new AddWorkflowActivityRequest();
                    request_ac.ObjectId       = notice.ObjectId.ToString();
                    request_ac.ObjectTypeId   = "PurchaseOrder";
                    request_ac.WorkflowNodeId = "PO-005";
                    request_ac.Note           = "货物到齐全自动完结";
                    request_ac.CreateUserId   = request.CreateUserId;
                    this._workflowActivityService.InsertNewActivity(request_ac);
                }
            }
            return(true);
        }