Exemplo n.º 1
0
        async void DelParams(Params p_par)
        {
            if (!await Kit.Confirm("确认要删除吗?"))
            {
                Kit.Msg("已取消删除!");
                return;
            }


            if (p_par.IsAdded)
            {
                _fv.Data = null;
                return;
            }

            int cnt = await AtCm.GetScalar <int>("参数-用户设置数", new { ParamID = p_par.ID });

            if (cnt > 0)
            {
                if (!await Kit.Confirm("该参数已存在用户设置,确认要删除吗?"))
                {
                    return;
                }
            }

            if (await AtCm.Delete(p_par))
            {
                LoadLast();
                _fv.Data = null;
                DeleteDataVer();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 是否激活后续活动
        /// </summary>
        /// <param name="p_atvSync">同步活动</param>
        /// <returns></returns>
        async Task <bool> IsActive(WfdAtv p_atvSync)
        {
            Dict dt = new Dict();

            dt["prciid"] = _info.PrcInst.ID;
            dt["atvdid"] = p_atvSync.ID;
            int cnt = await AtCm.GetScalar <int>("流程-同步活动实例数", dt);

            // 已产生同步实例
            if (cnt > 0)
            {
                return(false);
            }

            // 获得同步前所有活动
            dt             = new Dict();
            dt["TgtAtvID"] = p_atvSync.ID;
            var trss = await AtCm.Query <WfdTrs>("流程-活动前的迁移", dt);

            // 聚合方式
            // 全部
            if (p_atvSync.JoinKind == 0)
            {
                return(await GetAllFinish(trss));
            }

            // 任一
            if (p_atvSync.JoinKind == WfdAtvJoinKind.任一任务)
            {
                return(true);
            }

            // 即时
            return(await GetExistFinish(trss));
        }
Exemplo n.º 3
0
Arquivo: Menu.cs Projeto: Daoting/dt
        async Task OnDeleting()
        {
            if (IsGroup)
            {
                int count = await AtCm.GetScalar <int>("菜单-是否有子菜单", new { parentid = ID });

                Throw.If(count > 0, "含子菜单无法删除!");
            }
        }
Exemplo n.º 4
0
        async Task OnSaving()
        {
            Throw.IfNullOrEmpty(ID, "权限名称不可为空!");

            if ((IsAdded || Cells["id"].IsChanged) &&
                await AtCm.GetScalar <int>("权限-名称重复", new { id = ID }) > 0)
            {
                Throw.Msg("权限名称重复!");
            }
        }
Exemplo n.º 5
0
Arquivo: Role.cs Projeto: Daoting/dt
        async Task OnSaving()
        {
            Throw.IfNullOrEmpty(Name, "角色名称不可为空!");

            if ((IsAdded || Cells["name"].IsChanged) &&
                await AtCm.GetScalar <int>("角色-名称重复", new { name = Name }) > 0)
            {
                Throw.Msg("角色名称重复!");
            }
        }
Exemplo n.º 6
0
        public async void Show(long p_prciID, long p_prcID)
        {
            _prciID = p_prciID;

            // 查询流程模板id
            if (p_prcID <= 0)
            {
                p_prcID = await AtCm.GetScalar <long>("流程-实例id获取模板id", new { id = p_prciID });
            }

            var def = await WfFormInfo.GetPrcDef(p_prcID);

            if (string.IsNullOrEmpty(def.Diagram))
            {
                Kit.Warn("流程图模板内容为空!");
                return;
            }

            _sketch.ReadXml(def.Diagram);
            var atvs = await AtCm.Query("流程-活动实例状态", new { prciid = p_prciID });

            if (atvs.Count > 0)
            {
                foreach (var node in _sketch.Container.Children.OfType <SNode>())
                {
                    var dr = (from c in atvs
                              where c.Long("atvdid") == node.ID
                              select c).LastOrDefault();
                    if (dr != null)
                    {
                        switch (dr.Str("status"))
                        {
                        //活动
                        case "0":
                            node.BorderBrush = Res.醒目红色;
                            break;

                        //结束
                        case "1":
                            node.BorderBrush = Res.GreenBrush;
                            break;
                        }
                        node.Click += OnNodeClick;
                    }
                }
            }

            if (!Kit.IsPhoneUI)
            {
                Height = 700;
                Width  = 500;
            }
            Show();
        }
Exemplo n.º 7
0
        /// <summary>
        /// 判断当前活动是否完成,发送者是否为当前活动的最后一个发送者
        /// </summary>
        /// <returns></returns>
        public async Task <bool> IsFinished()
        {
            if (InstCount == 1)
            {
                return(true);
            }

            int count = await AtCm.GetScalar <int>("流程-工作项个数", new { atviid = ID });

            return((count + 1) >= InstCount);
        }
Exemplo n.º 8
0
        /// <summary>
        /// 获取活动的所有可执行用户
        /// </summary>
        /// <param name="p_atvid"></param>
        /// <returns></returns>
        async Task <Table> GetAtvUsers(long p_atvid)
        {
            Dict dt = new Dict {
                { "atvid", p_atvid }
            };

            if (await AtCm.GetScalar <int>("流程-是否活动授权任何人", dt) == 0)
            {
                return(await AtCm.Query("流程-活动的所有执行者", dt));
            }
            return(await AtCm.Query("流程-所有未过期用户"));
        }
Exemplo n.º 9
0
Arquivo: Params.cs Projeto: Daoting/dt
        async Task OnSaving()
        {
            Throw.IfNullOrEmpty(ID, "参数名不可为空!");

            if ((IsAdded || Cells["ID"].IsChanged) &&
                await AtCm.GetScalar <int>("参数-重复名称", new { id = ID }) > 0)
            {
                Throw.Msg("参数名重复!");
            }

            if (IsAdded)
            {
                Ctime = Mtime = Kit.Now;
            }
            else
            {
                Mtime = Kit.Now;
            }
        }
Exemplo n.º 10
0
        public async Task<bool> Delete(IEnumerable<Row> p_rows)
        {
            var ls = new List<Pubfile>();
            foreach (var row in p_rows)
            {
                if (row.Bool("IsFolder"))
                {
                    int cnt = await AtCm.GetScalar<int>("文件-子项个数", new { parentid = row.ID });
                    if (cnt > 0)
                    {
                        Kit.Warn($"[{row.Str("name")}]含有下级文件或文件夹,无法删除!");
                        return false;
                    }
                }

                ls.Add(new Pubfile(ID: row.ID));
            }
            return await AtCm.BatchDelete(ls);
        }
Exemplo n.º 11
0
Arquivo: Rpt.cs Projeto: Daoting/dt
        async Task OnSaving()
        {
            Throw.IfNullOrEmpty(Name, "报表名称不可为空!");

            if ((IsAdded || Cells["name"].IsChanged) &&
                await AtCm.GetScalar <int>("报表-重复名称", new { name = Name }) > 0)
            {
                Throw.Msg("报表名称重复!");
            }

            if (IsAdded)
            {
                Ctime = Mtime = Kit.Now;
            }
            else
            {
                Mtime = Kit.Now;
            }
        }
Exemplo n.º 12
0
        async Task <string> GetSender()
        {
            string sender = _info.WorkItem.Sender;

            if (_info.WorkItem.AssignKind == WfiItemAssignKind.回退)
            {
                Dict dt = new Dict();
                dt["prciid"] = _info.AtvInst.PrciID;
                dt["atvdid"] = _info.AtvInst.AtvdID;
                long id = await AtCm.GetScalar <long>("流程-最后已完成活动ID", dt);

                if (id != 0)
                {
                    dt           = new Dict();
                    dt["atviid"] = id;
                    sender       = await AtCm.GetScalar <string>("流程-活动发送者", dt);
                }
            }
            return(sender);
        }
Exemplo n.º 13
0
        /// <summary>
        /// 获得同步前的活动是否已经都完成
        /// </summary>
        /// <param name="p_trss"></param>
        /// <returns></returns>
        async Task <bool> GetAllFinish(Table <WfdTrs> p_trss)
        {
            bool finish = true;

            foreach (var trs in p_trss)
            {
                if (trs.SrcAtvID == _info.AtvDef.ID)
                {
                    continue;
                }

                var dt = new Dict();
                dt["atvdid"] = trs.SrcAtvID;
                dt["prciid"] = _info.PrcInst.ID;
                int cnt = await AtCm.GetScalar <int>("流程-活动结束的实例数", dt);

                if (cnt == 0)
                {
                    finish = false;
                    break;
                }
            }
            return(finish);
        }
Exemplo n.º 14
0
        async Task OnDeleting()
        {
            int cnt = await AtCm.GetScalar <int>("流程-流程实例数", new { PrcdID = ID });

            Throw.If(cnt > 0, "已有流程实例,禁止删除!");
        }
Exemplo n.º 15
0
        /// <summary>
        /// 执行发送
        /// </summary>
        /// <param name="p_manualSend">是否手动选择接收者</param>
        async void DoSend(bool p_manualSend)
        {
            #region 后续活动
            // 生成后续活动的活动实例、工作项、迁移实例,一个或多个
            var tblAtvs = Table <WfiAtv> .Create();

            var tblItems = Table <WfiItem> .Create();

            var tblTrs = Table <WfiTrs> .Create();

            DateTime time = Kit.Now;

            if (_info.NextRecvs.FinishedAtv != null &&
                (!p_manualSend || _info.NextRecvs.FinishedAtv.IsSelected))
            {
                // 完成
                _info.PrcInst.Status = WfiAtvStatus.结束;
                _info.PrcInst.Mtime  = time;
            }
            else
            {
                // 普通活动
                foreach (AtvRecv ar in _info.NextRecvs.Atvs)
                {
                    // 手动无选择时
                    if (p_manualSend &&
                        (ar.SelectedRecvs == null || ar.SelectedRecvs.Count == 0))
                    {
                        continue;
                    }

                    var atvInst = new WfiAtv(
                        ID: await AtCm.NewID(),
                        PrciID: _info.PrcInst.ID,
                        AtvdID: ar.Def.ID,
                        Status: WfiAtvStatus.活动,
                        Ctime: time,
                        Mtime: time);
                    tblAtvs.Add(atvInst);

                    if (p_manualSend)
                    {
                        // 手动发送,已选择项可能为用户或角色
                        atvInst.InstCount = ar.SelectedRecvs.Count;
                        foreach (var recvID in ar.SelectedRecvs)
                        {
                            var wi = await WfiItem.Create(atvInst.ID, time, ar.IsRole, recvID, ar.Note, false);

                            tblItems.Add(wi);
                        }
                    }
                    else
                    {
                        // 自动发送,按角色
                        atvInst.InstCount = ar.Recvs.Count;
                        foreach (var row in ar.Recvs)
                        {
                            var wi = await WfiItem.Create(atvInst.ID, time, ar.IsRole, row.ID, ar.Note, false);

                            tblItems.Add(wi);
                        }
                    }

                    // 增加迁移实例
                    var trs = await _info.CreateAtvTrs(ar.Def.ID, atvInst.ID, time, false);

                    tblTrs.Add(trs);
                }

                // 同步活动
                var syncAtv = _info.NextRecvs.SyncAtv;
                if (syncAtv != null &&
                    (!p_manualSend || (syncAtv.SelectedRecvs != null && syncAtv.SelectedRecvs.Count > 0)))
                {
                    // 同步实例
                    var syncInst = new WfiAtv(
                        ID: await AtCm.NewID(),
                        PrciID: _info.PrcInst.ID,
                        AtvdID: syncAtv.SyncDef.ID,
                        Status: WfiAtvStatus.步,
                        InstCount: 1,
                        Ctime: time,
                        Mtime: time);
                    tblAtvs.Add(syncInst);

                    // 同步工作项
                    WfiItem item = new WfiItem(
                        ID: await AtCm.NewID(),
                        AtviID: syncInst.ID,
                        AssignKind: WfiItemAssignKind.普通指派,
                        Status: WfiItemStatus.步,
                        IsAccept: false,
                        UserID: Kit.UserID,
                        Sender: Kit.UserName,
                        Stime: time,
                        Ctime: time,
                        Mtime: time,
                        Dispidx: await AtCm.NewSeq("sq_wfi_item"));
                    tblItems.Add(item);

                    // 同步迁移实例
                    Dict dt = new Dict();
                    dt["prcid"]      = _info.PrcInst.PrcdID;
                    dt["SrcAtvID"]   = _info.AtvInst.AtvdID;
                    dt["TgtAtvID"]   = syncAtv.SyncDef.ID;
                    dt["IsRollback"] = false;
                    long trsdid = await AtCm.GetScalar <long>("流程-迁移模板ID", dt);

                    var trs = new WfiTrs(
                        ID: await AtCm.NewID(),
                        TrsdID: trsdid,
                        SrcAtviID: _info.AtvInst.ID,
                        TgtAtviID: syncInst.ID,
                        IsRollback: false,
                        Ctime: time);
                    tblTrs.Add(trs);

                    // 同步活动的后续活动实例
                    var nextInst = new WfiAtv(
                        ID: await AtCm.NewID(),
                        PrciID: _info.PrcInst.ID,
                        AtvdID: syncAtv.Def.ID,
                        Status: WfiAtvStatus.活动,
                        Ctime: time,
                        Mtime: time);
                    tblAtvs.Add(nextInst);

                    if (p_manualSend)
                    {
                        // 手动发送,已选择项可能为用户或角色
                        nextInst.InstCount = syncAtv.SelectedRecvs.Count;
                        foreach (var recvID in syncAtv.SelectedRecvs)
                        {
                            var wi = await WfiItem.Create(nextInst.ID, time, syncAtv.IsRole, recvID, "", false);

                            tblItems.Add(wi);
                        }
                    }
                    else
                    {
                        // 自动发送,按角色
                        nextInst.InstCount = syncAtv.Recvs.Count;
                        foreach (var row in syncAtv.Recvs)
                        {
                            var wi = await WfiItem.Create(nextInst.ID, time, syncAtv.IsRole, row.ID, "", false);

                            tblItems.Add(wi);
                        }
                    }

                    // 增加迁移实例
                    dt               = new Dict();
                    dt["prcid"]      = _info.PrcInst.PrcdID;
                    dt["SrcAtvID"]   = syncAtv.SyncDef.ID;
                    dt["TgtAtvID"]   = syncAtv.Def.ID;
                    dt["IsRollback"] = false;
                    trsdid           = await AtCm.GetScalar <long>("流程-迁移模板ID", dt);

                    trs = new WfiTrs(
                        ID: await AtCm.NewID(),
                        TrsdID: trsdid,
                        SrcAtviID: syncInst.ID,
                        TgtAtviID: nextInst.ID,
                        IsRollback: false,
                        Ctime: time);
                    tblTrs.Add(trs);
                }
            }

            // 发送是否有效
            // 1. 只有'完成'时有效
            // 2. 至少含有一个活动实例时有效
            if (tblAtvs.Count == 0 && _info.PrcInst.Status != WfiAtvStatus.结束)
            {
                Kit.Msg("所有后续活动均无接收者,发送失败!");
                return;
            }
            #endregion

            #region 整理待保存数据
            List <object> data = new List <object>();
            if (_info.PrcInst.IsChanged)
            {
                data.Add(_info.PrcInst);
            }

            _info.AtvInst.Finished();
            data.Add(_info.AtvInst);

            _info.WorkItem.Finished();
            data.Add(_info.WorkItem);

            if (tblAtvs.Count > 0)
            {
                data.Add(tblAtvs);
                data.Add(tblItems);
                data.Add(tblTrs);
            }
            #endregion

            if (await AtCm.BatchSave(data, false))
            {
                Kit.Msg("发送成功!");
                _info.CloseWin();
                // 推送客户端提醒
            }
            else
            {
                // 避免保存失败后,再次点击发送时和保存表单一起被保存,造成状态错误!
                _info.PrcInst.RejectChanges();
                _info.AtvInst.RejectChanges();
                _info.WorkItem.RejectChanges();
                Kit.Warn("发送失败!");
            }
        }
Exemplo n.º 16
0
 public override Task <string> ReadTemplate()
 {
     return(AtCm.GetScalar <string>("报表-模板", new { id = _rpt.ID }));
 }
Exemplo n.º 17
0
        async Task Rollback()
        {
            // 活动执行者多于一人时,不允许进行回退
            if (_info.AtvInst.InstCount > 1)
            {
                Kit.Msg("该活动执行者多于一人,不允许回退!");
                return;
            }

            // 获得前一活动实例
            var pre = await _info.AtvInst.GetRollbackAtv();

            if (pre == null)
            {
                Kit.Msg("该活动不允许回退!");
                return;
            }

            if (!await Kit.Confirm("确认要回退吗?"))
            {
                return;
            }

            DateTime time       = Kit.Now;
            var      newAtvInst = new WfiAtv(
                ID: await AtCm.NewID(),
                PrciID: _info.PrcInst.ID,
                AtvdID: pre.AtvdID,
                Status: WfiAtvStatus.活动,
                InstCount: 1,
                Ctime: time,
                Mtime: time);

            // 创建迁移实例
            var newTrs = await _info.CreateAtvTrs(pre.AtvdID, newAtvInst.ID, time, true);

            // 当前活动完成状态
            _info.AtvInst.Finished();

            // 当前工作项置成完成状态
            _info.WorkItem.Finished();

            Dict dict = new Dict();

            dict["name"] = await GetSender();

            long userId = await AtCm.GetScalar <long>("流程-获取用户ID", dict);

            var newItem = await WfiItem.Create(newAtvInst.ID, time, false, userId, null, true);

            List <object> ls = new List <object>();

            if (_info.AtvInst.IsChanged)
            {
                ls.Add(_info.AtvInst);
            }
            ls.Add(_info.WorkItem);
            ls.Add(newAtvInst);
            ls.Add(newItem);
            ls.Add(newTrs);

            if (await AtCm.BatchSave(ls, false))
            {
                Kit.Msg("回退成功!");
                _info.CloseWin();
            }
            else
            {
                Kit.Msg("回退失败!");
            }
        }