Пример #1
0
 public object TestOption1([FromServices] JsonSerializeOptionHosting hosting)
 {
     hosting.Option.Converters.Add(new DateTimeJsonConverter("hh:mm"));
     return(new Entity {
         Date = DateTime.Now
     });
 }
Пример #2
0
        /// <summary>
        /// 根据查询条件获取机构。
        /// </summary>
        /// <param name="hosting">用来往 <see cref="JsonSerializeOption"/> 里加自定义的转换器。</param>
        /// <param name="id"></param>
        /// <param name="targetId"></param>
        /// <param name="currentId"></param>
        /// <param name="attribute"></param>
        /// <param name="state"></param>
        /// <param name="attType">附加的信息。</param>
        /// <param name="flag"></param>
        /// <returns></returns>
        public JsonResult DataDemand([FromServices] JsonSerializeOptionHosting hosting, int?id, int?targetId, int?currentId, OrgAttribute?attribute = null, StateFlags?state = null, ItemFlag?flag = null)
        {
            var converter = new DynamicTreeNodeJsonConverter <SysOrg>(s => s.Name, s => s.Code, s => s.AttributeName, s => s.State);

            hosting.Option.Converters.Add(converter);

            var list = adminService.GetOrgs(id, targetId, currentId, state, null, attribute);

            return(Json(id != null ? list : ItemFlagHelper.Insert(list, flag, s => new { id = 0, text = s.GetDescription() })));
        }
Пример #3
0
        /// <summary>
        /// 根据角色获取相应的机构。
        /// </summary>
        /// <param name="hosting"></param>
        /// <param name="roleId"></param>
        /// <returns></returns>
        public async Task <JsonResult> GetOrgsByRole([FromServices] JsonSerializeOptionHosting hosting, int?roleId)
        {
            if (roleId == null)
            {
                return(Json(new string[0]));
            }

            var converter = new DynamicTreeNodeJsonConverter <SysOrg>(s => s.Name, s => s.Permissible, s => s.FullName);

            hosting.Option.Converters.Add(converter);

            var list = await _adminService.GetOrgsByRoleAsync((int)roleId);

            return(Json(list));
        }
Пример #4
0
        /// <summary>
        /// 根据查询条件获取机构。
        /// </summary>
        /// <param name="hosting">用来往 <see cref="JsonSerializeOption"/> 里加自定义的转换器。</param>
        /// <param name="targetId"></param>
        /// <param name="attribute"></param>
        /// <param name="attType">附加的信息。</param>
        /// <param name="corpType">企业类别。</param>
        /// <param name="flag"></param>
        /// <returns></returns>
        public JsonResult Data([FromServices] JsonSerializeOptionHosting hosting, int?targetId, OrgAttribute?attribute = null, ItemFlag?flag = null)
        {
            var converter = new DynamicTreeNodeJsonConverter <SysOrg>(s => s.Name, s => s.Code, s => s.AttributeName, s => s.State);

            hosting.Option.Converters.Add(converter);

            var session = HttpContext.GetSession();

            var list = adminService.GetOrgs(session.UserID, null, attribute);

            if (targetId != null)
            {
                ExpandTarget(list, (int)targetId);
            }

            return(Json(ItemFlagHelper.Insert(list, flag, s => new { id = 0, text = s.GetDescription() })));
        }
Пример #5
0
        /// <summary>
        /// 根据查询条件获取模块。
        /// </summary>
        /// <param name="hosting">用来往 <see cref="JsonSerializeOption"/> 里加自定义的转换器。</param>
        /// <param name="id"></param>
        /// <param name="targetId"></param>
        /// <param name="currentId"></param>
        /// <param name="flag"></param>
        /// <returns></returns>
        public async Task <JsonResult> Data([FromServices] JsonSerializeOptionHosting hosting, int?id, int?targetId, int?currentId, ItemFlag?flag = null)
        {
            var converter = new DynamicTreeNodeJsonConverter <SysModule>(s => s.Name, s => s.Url, s => s.State);

            hosting.Option.Converters.Add(converter);

            var list = await adminService.GetModulesAsync(id, targetId, currentId, null);

            if (id != null)
            {
                return(Json(list));
            }
            else
            {
                return(Json(ItemFlagHelper.Insert(list, flag, s => new { id = 0, text = s.GetDescription() })));
            }
        }
Пример #6
0
 public JsonResult GetTime1([FromServices] JsonSerializeOptionHosting hosting)
 {
     hosting.Option.Converters.Add(new FullDateTimeJsonConverter());
     return(Json(DateTime.Now));
 }
Пример #7
0
 public JsonResult TestJsonSerializeOption([FromServices] JsonSerializeOptionHosting hosting)
 {
     throw new Exception("");
     hosting.Option.Converters.Add(new FullDateTimeJsonConverter());
     return(Json(DateTime.Now));
 }
Пример #8
0
 public JsonResult TestOption1([FromServices] JsonSerializeOptionHosting hosting)
 {
     return(Json(new Entity {
         Date = DateTime.Now
     }));
 }