예제 #1
0
        async Task LoadWorkItem()
        {
            Dict dt = new Dict {
                { "itemid", _itemID }
            };

            PrcInst = await AtCm.First <WfiPrc>("流程-工作项的流程实例", dt);

            AtvInst = await AtCm.First <WfiAtv>("流程-工作项的活动实例", dt);

            WorkItem = await AtCm.GetByID <WfiItem>(_itemID);

            AtvDef = await AtCm.GetByID <WfdAtv>(AtvInst.AtvdID);
        }
예제 #2
0
        internal async Task Init()
        {
            // 根据流程实例id获取流程id 和 最后工作项id
            if (_prciID > 0)
            {
                var row = await AtCm.First("流程-最后工作项", new { prciID = _prciID });

                _prcID  = row.Long("prcID");
                _itemID = row.Long("itemID");
            }

            // 加载流程定义
            PrcDef = await GetPrcDef(_prcID);

            Throw.IfNullOrEmpty(PrcDef.FormType, "流程定义中未设置表单类型!");
            FormType = Type.GetType(PrcDef.FormType);
            Throw.IfNull(FormType, $"表单类型[{PrcDef.FormType}]不存在!");
            if (FormType.GetInterface("IWfForm") != typeof(IWfForm))
            {
                Throw.Msg("任务表单类型需要继承自WfForm!");
            }

            // 加载活动定义、流程实例、活动实例、工作项
            if (_itemID < 0)
            {
                await CreateWorkItem();
            }
            else
            {
                await LoadWorkItem();
            }

            // 自动签收
            if (_itemID > 0 &&
                Usage == WfFormUsage.Edit &&
                AtvDef.AutoAccept &&
                !WorkItem.IsAccept)
            {
                WorkItem.IsAccept   = true;
                WorkItem.AcceptTime = Kit.Now;
                if (await AtCm.Save(WorkItem))
                {
                    Kit.Msg("已自动签收!");
                }
            }
        }
예제 #3
0
        async Task CreateWorkItem()
        {
            AtvDef = await AtCm.First <WfdAtv>("流程-起始活动", new { prcid = _prcID });

            PrcInst = new WfiPrc(
                ID: await AtCm.NewID(),
                PrcdID: _prcID,
                Name: PrcDef.Name);

            AtvInst = new WfiAtv(
                ID: await AtCm.NewID(),
                PrciID: PrcInst.ID,
                AtvdID: AtvDef.ID,
                InstCount: 1);

            WorkItem = new WfiItem(
                ID: await AtCm.NewID(),
                AtviID: AtvInst.ID,
                AssignKind: WfiItemAssignKind.起始指派,
                IsAccept: true,
                Status: WfiItemStatus.活动,
                UserID: Kit.UserID,
                Sender: Kit.UserName);
        }