/// <summary>
        /// 更新
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public InvokeResult CirculateComplete(int flowInstanceId, int userId, int stepId, string remark)
        {
            InvokeResult result = new InvokeResult();

            try
            {
                var updateQuery = string.Format("flowInstanceId={0}&givenUserId={1}&status=0", flowInstanceId, userId);
                var bsonList    = dataOp.FindAllByQueryStr("BusinessFlowCirculation", updateQuery).ToList();
                if (bsonList.Count() > 0)
                {
                    result = dataOp.QuickUpdate("BusinessFlowCirculation", bsonList, "status=1");
                }
                if (result.Status == Status.Successful)
                {
                    BsonDocument flowTrace = new BsonDocument();
                    flowTrace.Add("flowInstanceId", flowInstanceId);
                    flowTrace.Add("traceType", 8);
                    flowTrace.Add("remark", remark);
                    flowTrace.Add("preStepId", stepId);
                    flowTrace.Add("result", string.Format("进行了阅毕确认"));
                    var traceResult = BusFlowTraceBll._(dataOp).Insert(flowTrace);
                }
            }
            catch (Exception ex)
            {
                result.Status  = Status.Failed;
                result.Message = ex.Message;
            }

            return(result);
        }
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public InvokeResult Insert(BsonDocument entity, BsonDocument instance, int userId)
        {
            InvokeResult result = new InvokeResult();


            if (entity == null || instance == null)
            {
                throw new ArgumentNullException();
            }


            if (HasExistObj(entity.Int("flowInstanceId"), entity.Int("stepId"), entity.Int("grantUserId"), entity.Int("givenUserId")).Count() > 0)
            {
                result.Status  = Status.Failed;
                result.Message = "不能重复传阅给同一个人";
                return(result);
            }

            var hitDisabledQuery = FindAll().Where(c => c.Int("givenUserId") == entity.Int("grantUserId")).OrderByDescending(c => c.Date("createDate"));

            using (TransactionScope tran = new TransactionScope())
            {
                try
                {
                    result = dataOp.Insert("BusinessFlowCirculation", entity);

                    var          givenUserName = dataOp.FindOneByKeyVal("SysUser", "userId", entity.Text("givenUserId"));
                    BsonDocument flowTrace     = new BsonDocument();
                    flowTrace.Add("flowInstanceId", instance.Int("flowInstanceId"));
                    flowTrace.Add("traceType", 8);
                    flowTrace.Add("remark", entity.Text("remark"));
                    flowTrace.Add("preStepId", instance.Int("stepId"));
                    flowTrace.Add("result", string.Format("将操作权传阅给了{0}", givenUserName != null ? givenUserName.Text("name") : string.Empty));
                    var traceResult = BusFlowTraceBll._(dataOp).Insert(flowTrace);
                    if (traceResult.Status == Status.Successful)
                    {
                        tran.Complete();
                    }
                    else
                    {
                        result.Status  = Status.Failed;
                        result.Message = "传入参数有误";
                    }
                }
                catch (NullReferenceException ex)
                {
                    result.Status  = Status.Failed;
                    result.Message = "传入参数有误";
                }
                catch (Exception ex)
                {
                    result.Status  = Status.Failed;
                    result.Message = "传入参数有误";
                }
            }

            return(result);
        }
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public InvokeResult Insert(BsonDocument entity, BsonDocument instance, int userId)
        {
            InvokeResult result = new InvokeResult();


            if (entity == null || instance == null)
            {
                throw new ArgumentNullException();
            }


            if (HasExistObj(entity.Int("flowInstanceId"), entity.Int("grantUserId"), entity.Int("givenUserId")).Count() > 0)
            {
                result.Status  = Status.Failed;
                result.Message = "不能重复转办给同一个人";
                return(result);
            }
            //获取需要删除的列表 将status 设置为1,当“A转给B” “B再转给c”的时候需要将”A转给B“过滤
            var hitDisabledQuery = FindAll().Where(c => c.Int("givenUserId") == entity.Int("grantUserId") && c.Int("status") == 0).OrderByDescending(c => c.Date("createDate"));

            using (TransactionScope tran = new TransactionScope())
            {
                try
                {
                    //设置无效转办
                    if (hitDisabledQuery.Count() > 0)
                    {
                        var tempResult = dataOp.QuickUpdate("BusinessFlowTurnRight", hitDisabledQuery.ToList(), "status=1");
                        if (tempResult.Status != Status.Successful)
                        {
                            return(tempResult);
                        }
                    }

                    result = dataOp.Insert("BusinessFlowTurnRight", entity);

                    var          givenUserName = dataOp.FindOneByKeyVal("SysUser", "userId", entity.Text("givenUserId"));
                    BsonDocument flowTrace     = new BsonDocument();
                    flowTrace.Add("flowInstanceId", instance.Int("flowInstanceId"));
                    flowTrace.Add("traceType", 6);
                    flowTrace.Add("remark", entity.Text("remark"));
                    flowTrace.Add("preStepId", instance.Int("stepId"));
                    flowTrace.Add("result", string.Format("将操作权转办给了{0}", givenUserName != null ? givenUserName.Text("name") : string.Empty));
                    var traceResult = BusFlowTraceBll._(dataOp).Insert(flowTrace);
                    if (traceResult.Status == Status.Successful)
                    {
                        tran.Complete();
                    }
                    else
                    {
                        result.Status  = Status.Failed;
                        result.Message = "传入参数有误";
                    }
                }
                catch (NullReferenceException ex)
                {
                    result.Status  = Status.Failed;
                    result.Message = "传入参数有误";
                }
                catch (Exception ex)
                {
                    result.Status  = Status.Failed;
                    result.Message = "传入参数有误";
                }
            }

            return(result);
        }