Пример #1
0
        /// <summary>
        /// 加载流程定义
        /// </summary>
        /// <param name="p_prcID"></param>
        /// <returns></returns>
        internal static async Task <WfdPrc> GetPrcDef(long p_prcID)
        {
            WfdPrc def;

            if (!_prcDefs.TryGetValue(p_prcID, out def))
            {
                def = await AtCm.GetByID <WfdPrc>(p_prcID);

                _prcDefs[p_prcID] = def;
            }
            return(def);
        }
Пример #2
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);
        }
Пример #3
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("已自动签收!");
                }
            }
        }
Пример #4
0
        /// <summary>
        /// 获取验证码
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        async void OnGetCode(object sender, RoutedEventArgs e)
        {
            string phone = _tbPhone.Text.Trim();

            if (string.IsNullOrEmpty(phone))
            {
                _tbPhone.Focus(FocusState.Programmatic);
                return;
            }

            if (IsPhoneError())
            {
                return;
            }

            _btnCode.IsEnabled = false;
            string code = await AtCm.CreateVerificationCode(phone);

            _tbCode.Focus(FocusState.Programmatic);

            int sec   = 60;
            var timer = new DispatcherTimer();

            timer.Interval = TimeSpan.FromSeconds(1);
            timer.Tick    += (s, a) =>
            {
                sec--;
                if (sec <= 0)
                {
                    timer.Stop();
                    _btnCode.IsEnabled = true;
                    _btnCode.Content   = "获取验证码";
                }
                else
                {
                    _btnCode.Content = $"还剩{sec}秒";
                }
            };
            timer.Start();

            // 测试用
            DataPackage data = new DataPackage();

            data.SetText(code);
            Clipboard.SetContent(data);
        }
Пример #5
0
        /// <summary>
        /// 创建迁移实例
        /// </summary>
        /// <param name="p_tatvid">目标活动模板标识</param>
        /// <param name="p_tatviid">目标活动实例标识</param>
        /// <param name="p_date">创建时间</param>
        /// <param name="p_rollback">是否回退</param>
        /// <returns></returns>
        internal async Task <WfiTrs> CreateAtvTrs(long p_tatvid, long p_tatviid, DateTime p_date, bool p_rollback)
        {
            Dict dt = new Dict();

            dt["prcid"]      = PrcInst.PrcdID;
            dt["SrcAtvID"]   = AtvInst.AtvdID;
            dt["TgtAtvID"]   = p_tatvid;
            dt["IsRollback"] = p_rollback;
            long trsdid = await AtCm.GetScalar <long>("流程-迁移模板ID", dt);

            Throw.If(trsdid == 0, "未找到流程迁移模板");

            return(new WfiTrs(
                       ID: await AtCm.NewID(),
                       TrsdID: trsdid,
                       SrcAtviID: AtvInst.ID,
                       TgtAtviID: p_tatviid,
                       IsRollback: p_rollback,
                       Ctime: p_date));
        }
Пример #6
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);
        }
Пример #7
0
        /// <summary>
        /// 登录
        /// </summary>
        async void OnLogin()
        {
            string phone  = _tbPhone.Text.Trim();
            bool   isCode = _tbPwd.Visibility == Visibility.Collapsed;
            string txt    = isCode ? _tbCode.Text.Trim() : _tbPwd.Password;

            if (string.IsNullOrEmpty(phone))
            {
                _tbPhone.Focus(FocusState.Programmatic);
            }
            else if (IsPhoneError())
            {
            }
            else if (string.IsNullOrEmpty(txt))
            {
                if (isCode)
                {
                    _tbCode.Focus(FocusState.Programmatic);
                }
                else
                {
                    _tbPwd.Focus(FocusState.Programmatic);
                }
            }
            else
            {
                LoginPanel.Visibility = Visibility.Collapsed;
                InfoPanel.Visibility  = Visibility.Visible;
                try
                {
                    string      pwd = null;
                    LoginResult result;
                    if (isCode)
                    {
                        // 验证码登录
                        result = await AtCm.LoginByCode(phone, txt);

                        if (result.IsSuc)
                        {
                            pwd = result.Pwd;
                        }
                    }
                    else
                    {
                        // 密码登录
                        pwd    = Kit.GetMD5(txt);
                        result = await AtCm.LoginByPwd(phone, pwd);
                    }

                    if (!result.IsSuc)
                    {
                        LoginFailed(result.Error);
                        return;
                    }

                    // 保存以备自动登录
                    AtState.SaveCookie("LoginPhone", phone);
                    AtState.SaveCookie("LoginPwd", pwd);

                    Kit.InitUser(result);
                    var dlg = this.FindParentByType <Dlg>();
                    if (dlg != null)
                    {
                        // 中途登录后关闭对话框
                        dlg.Close();
                    }
                    else
                    {
                        // 正常登录后切换到主页
                        Startup.ShowHome();
                    }
                    // 接收服务器推送
                    Startup.RegisterSysPush();
                }
                catch
                {
                    LoginFailed("登录失败!");
                }
            }
        }