public ActionResult AddPermission([DataSourceRequest] DataSourceRequest request, PermissionModel permission)
        {
            try
            {
                if (permission != null)
                {
                    permission.ParentID = 0;
                    permission.Layer = 1;
                    permission.CreateTime = DateTime.Now;

                    this.systemPermissionService = new SystemPermissionService();

                    var sysPermission = DataTransfer.Transfer<System_Permission>(permission, typeof(PermissionModel));
                    sysPermission.ID = this.systemPermissionService.AddPermission(sysPermission);

                    if (sysPermission.ID > 0)
                    {
                        return this.Json(new[] { sysPermission }.ToDataSourceResult(request, this.ModelState));
                    }
                }
            }
            catch (Exception exception)
            {
                throw new Exception(exception.Message, exception);
            }

            return this.View();
        }
        public ActionResult RemovePermission(int id)
        {
            try
            {
                this.systemPermissionService = new SystemPermissionService();
                this.systemPermissionService.RemovePermissionByID(id);

                return this.RedirectToAction("Index");
            }
            catch (Exception exception)
            {
                throw new Exception(exception.Message, exception);
            }
        }
        /// <summary>
        /// 查询子权限选择项列表
        /// </summary>
        /// <param name="permissionID">
        /// The permission ID.
        /// </param>
        /// <returns>
        /// 子权限选择项列表
        /// </returns>
        public ActionResult QuerySubPermissionSelectListItems(int permissionID)
        {
            this.systemPermissionService = new SystemPermissionService();

            int pageCount;
            int totalCount;

            var paging = new Paging("[System_Permission]", null, "ID", string.Format("ParentID = {0}", permissionID), 1, 1000);

            var list = this.systemPermissionService.Query(paging, out pageCount, out totalCount);
            return list != null ? this.Json(list, JsonRequestBehavior.AllowGet) : this.Json(null);
        }
        /// <summary>
        /// The query select list.
        /// </summary>
        /// <param name="id">
        /// The id.
        /// </param>
        /// <returns>
        /// The <see cref="ActionResult"/>.
        /// </returns>
        public ActionResult QueryPermissionTreeViewItems(int? id)
        {
            if (id == null)
            {
                id = 0;
            }

            this.systemPermissionService = new SystemPermissionService();

            int pageCount;
            int totalCount;

            var paging = new Paging("[System_Permission]", null, "ID", string.Format("ParentID = {0}", id), 1, 1000);

            var list = this.systemPermissionService.Query(paging, out pageCount, out totalCount);
            if (list == null)
            {
                return this.Json(null);
            }

            var modelList = new List<dynamic>();
            foreach (var systemPermission in list)
            {
                modelList.Add(new { id = systemPermission.ID, Name = systemPermission.Name, hasChildren = this.systemPermissionService.HasChildren(systemPermission.ID) });
            }

            return this.Json(modelList, JsonRequestBehavior.AllowGet);
        }
        /// <summary>
        /// 查询子权限列表
        /// </summary>
        /// <param name="request">
        /// 数据源请求信息对象
        /// </param>
        /// <param name="permissionID">
        /// 上级权限编号
        /// </param>
        /// <returns>
        /// 执行方法结果
        /// </returns>
        public ActionResult QueryPermissionByID([DataSourceRequest] DataSourceRequest request, int permissionID)
        {
            this.systemPermissionService = new SystemPermissionService();

            int pageCount;
            int totalCount;

            var paging = new Paging("[System_Permission]", null, "ID", string.Format("ParentID = {0}", permissionID), request.Page, request.PageSize);

            var list = this.systemPermissionService.Query(paging, out pageCount, out totalCount);

            if (request.Page <= 0)
            {
                request.Page = 1;
            }

            if (list == null)
            {
                return this.View();
            }

            var permissionModels = new List<PermissionModel>();

            foreach (var systemPermission in list)
            {
                permissionModels.Add(DataTransfer.Transfer<PermissionModel>(systemPermission, typeof(System_Permission)));
            }

            var result = new DataSourceResult { Data = permissionModels, Total = totalCount };
            return this.Json(result, JsonRequestBehavior.AllowGet);
        }
        public ActionResult ModifyPermission([DataSourceRequest] DataSourceRequest request, PermissionModel permission)
        {
            if (permission == null || !this.ModelState.IsValid)
            {
                return this.Json(new[] { permission }.ToDataSourceResult(request, this.ModelState));
            }

            try
            {
                this.systemPermissionService = new SystemPermissionService();

                var systemPermission = DataTransfer.Transfer<System_Permission>(permission, typeof(PermissionModel));
                this.systemPermissionService.ModifyPermission(systemPermission);
            }
            catch (Exception exception)
            {
                throw new Exception(exception.Message, exception);
            }

            return this.Json(new[] { permission }.ToDataSourceResult(request, this.ModelState));
        }