コード例 #1
0
        public static void DynamicCreate(IClientSessionHandle session, FlowDynamicPostParam param)
        {
            param.Creator.Validate();
            if (param.Operators is null || param.Operators.Count == 0)
            {
                throw new Exception("next operators can not be empty");
            }
            //
            var flowDef = _flowDefs.Find(session, x => x.Id == param.FlowDef).SingleOrDefault() ?? throw new Exception("flowDef is null");

            if (flowDef.ApproveType != ApproveType.Danymic)
            {
                throw new Exception("flowDef approve must be dynamic");
            }
            //
            var obj = new Flow
            {
                Id            = param.BusinessKeyId,
                Business      = flowDef.BusinessType,
                BusinessKeyId = param.BusinessKeyId,
                DealStatus    = false,
                Status        = new FlowStatus(),
                CommonInfo    = new FlowCommonInfo
                {
                    Title   = param.Title,
                    FlowDef = new FlowDefReference
                    {
                        Rid         = flowDef.Id,
                        Name        = flowDef.Name,
                        ApproveType = flowDef.ApproveType
                    },
                    Creator = param.Creator
                },
                BusinessContents = param.BusinessContents,
                School           = param.School
            };

            obj.BuildText();
            obj.Process = new FlowProcess
            {
                Operators    = new List <FlowReferenceItem>(),
                OperatorsNow = param.Operators,
                StepNow      = 1,
                Steps        = new List <FlowStep> {
                }
            };
            _ = _flows.ReplaceOne(session, x => x.Id == obj.Id, obj, new ReplaceOptions {
                IsUpsert = true
            });
        }