Esempio n. 1
0
        //public string GetGuid()
        //{
        //    return _context.Guid.ToString();
        //}

        /// <summary>
        /// 会报错
        /// </summary>
        /// <returns></returns>
        public string GetGuidAsync()
        {
            Task <string> task = new Task <string>(() =>
            {
                DBContext context = DBContextFactory.GetDBContext();
                return(context.Guid.ToString());
            });

            task.Start();
            return(task.Result);
        }
Esempio n. 2
0
        public BaseController()
        {
            this.Entity = DBContextFactory.GetDBContext();
            //取得当前管理员
            var ManageClientDataModel = ClientHook.GetModel();

            if (ManageClientDataModel != null)
            {
                int ManageID = int.Parse(ManageClientDataModel.ID);
                this.CurrentManage = this.Entity.M_Manage.Where(o => o.ID == ManageID).FirstOrDefault();
            }

            //授权
            if (this.CurrentManage != null)
            {
                if (!CurrentManage.RoleIDs.IsNullOrEmpty())
                {
                    var   RoleIDsStr = CurrentManage.RoleIDs.Split(',');
                    int[] RoleIDs    = Array.ConvertAll <string, int>(RoleIDsStr, delegate(string s) { return(int.Parse(s)); });
                    if (RoleIDs.Length > 0)
                    {
                        var M_RoleList = Entity.M_Role.Where(o => RoleIDs.Contains(o.ID)).ToList();
                        if (M_RoleList.Count > 0)
                        {
                            var   MenuIDsList    = M_RoleList.Select(o => o.MenuIDs).ToList();
                            var   MenuIDsListStr = string.Join(",", MenuIDsList);
                            var   MenuIDsStr     = MenuIDsListStr.Split(',');
                            int[] MenuIDs        = Array.ConvertAll <string, int>(MenuIDsStr, delegate(string s) { return(int.Parse(s)); });
                            MenuTree = Entity.M_Menu.Where(o => MenuIDs.Contains(o.ID)).ToList();
                        }
                    }
                }
            }
            MenuTree = Entity.M_Menu.ToList();

            this.ViewBag.Entity   = Entity;
            this.ViewBag.MenuTree = MenuTree;
        }