Esempio n. 1
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            List <Role> list = null;

            ControlHelper.ThreadRunExt(AppHelper.MainForm, () =>
            {
                var succ = true;
                var msg  = "";
                try
                {
                    ResponseModel responseModel = new ResponseModel();
                    RbacApi rbac  = new RbacApi();
                    responseModel = rbac.GetRoles();



                    if (responseModel.Code == 1)
                    {
                        if (responseModel.DataCount > 0)
                        {
                            list = JsonConvert.DeserializeObject <List <Role> >(responseModel?.Data?.ToString());
                            ControlHelper.ThreadInvokerControl(AppHelper.MainForm, () =>
                            {
                                if (list != null)
                                {
                                    CGridHelper.ClearGrid(dgv);
                                    CGridHelper.FillGrid <Role>(dgv, list);
                                }
                            });
                        }
                        else
                        {
                            succ = false;
                            msg  = "查询数据为空!";
                        }
                    }
                    else
                    {
                        succ = false;
                        msg  = responseModel?.Message;
                    }
                }
                catch (Exception ex)
                {
                    succ = false;
                    msg  = ex.Message;
                }
                if (!succ)
                {
                    ControlHelper.ThreadInvokerControl(AppHelper.MainForm, () =>
                    {
                        FrmTips.ShowTips(AppHelper.MainForm, msg, 2000, true, ContentAlignment.MiddleCenter, null, TipsSizeMode.Medium, new Size(300, 100), TipsState.Error);
                    });
                }
            }, null, AppHelper.MainForm, true, "正在查询……", 200);
        }
Esempio n. 2
0
        private void Init()
        {
            RbacApi rbac     = new RbacApi();
            var     response = rbac.GetRoles();

            if (response.Code == 1 && response.DataCount > 0)
            {
                List <Role> roles = JsonConvert.DeserializeObject <List <Role> >(response.Data?.ToString());
                tvMenus.Nodes.Clear();
                tvMenus.CheckBoxes = true;
                foreach (var item in roles)
                {
                    TreeNode rootNode = new TreeNode(item.RoleName);
                    rootNode.Name = item.Id.ToString();
                    tvMenus.Nodes.Add(rootNode);
                    tvMenus.ExpandAll();
                }
            }
        }