Пример #1
0
 public IActionResult Ok(string msg = "")
 {
     apiResult = new LayuiData()
     {
         msg = msg
     };
     return(Json(apiResult));
 }
        public LayuiData GetRedisDBSettingList(int page, int limit)
        {
            var data     = _dbContext.Queryable <RedisDBSetting>().OrderBy(x => x.Code).ToList();
            int rowCount = data.Count;

            data = PageHelper.GetPageData <RedisDBSetting>(data, page, limit);
            return(LayuiData.CreateResult(rowCount, data));
        }
Пример #3
0
        public async Task <LayuiData> GetTaskList(string code = "", string name = "")
        {
            var items = string.IsNullOrEmpty(code) && string.IsNullOrEmpty(name)
               ? await _sqliteSql.Select <Tasks>().ToListAsync()
               : await _sqliteSql.Select <Tasks>().Where(o => o.Name.Contains(name) || o.Guid == int.Parse(code)
                                                         ).ToListAsync();

            return(LayuiData.CreateResult(items.Count, items));
        }
Пример #4
0
 /// <summary>
 /// 成功返回单个数据object
 /// </summary>
 /// <param name="data"></param>
 /// <param name="msg"></param>
 /// <returns></returns>
 public IActionResult Ok(object data, string msg = "", string code = "")
 {
     apiResult = new LayuiData()
     {
         msg  = msg,
         data = data,
         code = code
     };
     return(Json(apiResult, jsonSerializerSettings));
 }
Пример #5
0
 public IActionResult Error(string msg = "", string code = "")
 {
     apiResult = new LayuiData()
     {
         success = false,
         msg     = msg,
         code    = code
     };
     return(Json(apiResult));
 }
Пример #6
0
 public IActionResult Ok <T>(List <T> data, long count, string msg = "")
 {
     apiResult = new LayuiData()
     {
         data  = data,
         msg   = msg,
         count = count,
     };
     return(Json(apiResult, jsonSerializerSettings));
 }
Пример #7
0
 public IActionResult Ok <T>(List <T> data, string msg = "")
 {
     apiResult = new LayuiData()
     {
         data  = data,
         msg   = msg,
         count = data.LongCount(),
     };
     return(Json(apiResult));
 }
Пример #8
0
        public static LayuiData CreateErrorResult(string msg)
        {
            LayuiData layuiData = new LayuiData
            {
                Code  = "-1",
                Msg   = msg,
                Count = 0,
                Data  = null
            };

            return(layuiData);
        }
Пример #9
0
        public static LayuiData CreateResult(int count, object data)
        {
            LayuiData layuiData = new LayuiData
            {
                Code  = "0",
                Msg   = "",
                Count = count,
                Data  = data
            };

            return(layuiData);
        }
Пример #10
0
        public async Task <LayuiData> GetPublicDataAdaptersList(string guid)
        {
            string localPath = ApiUtils.GetLocalPath(_dbContext, guid, out string errorMessage);

            if (!string.IsNullOrEmpty(errorMessage))
            {
                return(LayuiData.CreateErrorResult(errorMessage));
            }

            using StreamReader reader = new StreamReader(localPath);
            string json = await reader.ReadToEndAsync();

            List <PublicDataAdapters> info = JsonConvert.DeserializeObject <List <PublicDataAdapters> >(json);

            ViewBag.Guid = guid;
            return(LayuiData.CreateResult(info.Count, info));
        }
Пример #11
0
        public static void Main(string[] args)
        {
            LayuiDataRepository userRepository = new LayuiDataRepository();
            LayuiData           layuiData      = new LayuiData();

            for (int i = 0; i < 100; i++)
            {
                layuiData.username   = "******" + i.ToString();
                layuiData.sex        = i % 2 == 0 ? "女" : "男";
                layuiData.city       = "城市-" + i.ToString();
                layuiData.sign       = "签名-" + i.ToString();
                layuiData.experience = 255;
                layuiData.logins     = 24;
                layuiData.wealth     = 83289381;
                layuiData.classify   = "作家";
                layuiData.score      = 55;
            }
        }
Пример #12
0
        public async Task <LayuiData> GetRedisDevList(int page, int limit, string redisaddr, int redisdb, string searchkey)
        {
            if (string.IsNullOrEmpty(redisaddr))
            {
                return(LayuiData.CreateResult(0, null));
            }
            #region 获取Redis的地址,连接实例
            string redisConn = await GetRedisDBAddr(redisaddr);

            RedisHelper redisHelper = new RedisHelper(redisConn);
            #endregion
            #region 根据地址查询键值对,如果redisdb为空就查询所有的(限制到1000条数据),如果searchkey为空也是如此
            List <RedisDataModel> redisDataModel = new List <RedisDataModel>();
            var data     = redisHelper.GetKeys(redisdb, searchkey ?? "*");;
            int rowCount = data.Count;
            data = PageHelper.GetPageData <RedisDataModel>(data, page, limit);
            #endregion
            return(LayuiData.CreateResult(rowCount, data));
        }
Пример #13
0
        public async Task <LayuiData> GetTasksDetailList(string guid = "")
        {
            var items = string.IsNullOrEmpty(guid)? await _sqliteSql.Select <TasksDetail>().ToListAsync(): await _sqliteSql.Select <TasksDetail>().Where(o => o.TaskCode == int.Parse(guid)).ToListAsync();

            var TaskDetailViewModelList = new List <TaskDetailViewModel>();

            foreach (var item in items)
            {
                TaskDetailViewModelList.Add(new TaskDetailViewModel {
                    ScriptCode = item.ScriptCode,
                    Guid       = item.Guid,
                    OrgCode    = item.OrgCode,
                    OrgName    = await _sqliteSql.Select <Organization>().Where(o => o.Guid == item.OrgCode).FirstAsync(o => o.Name),
                    TaskCode   = item.TaskCode,
                    TaskName   = await _sqliteSql.Select <Tasks>().Where(o => o.Guid == item.TaskCode).FirstAsync(o => o.Name),
                    ScriptName = await _sqliteSql.Select <Script>().Where(o => o.Guid == item.ScriptCode).FirstAsync(o => o.Name)
                });
            }
            return(LayuiData.CreateResult(TaskDetailViewModelList.Count, TaskDetailViewModelList));
        }
Пример #14
0
        public LayuiData GetServerList()
        {
            List <ServerInfo> data = _dbContext.SqlQueryable <ServerInfo>("select A.*,B.BusinessName from ServerInfo A left join BusinessCategory B on A.BusinessGuid = B.Guid").ToList();

            return(LayuiData.CreateResult(data.Count, data));
        }
Пример #15
0
        public LayuiData GetConfigList()
        {
            List <ConfigInfo> data = _dbContext.Queryable <ConfigInfo>().ToList();

            return(LayuiData.CreateResult(data.Count, data));
        }
Пример #16
0
        public LayuiData GetDataBaseList()
        {
            List <DataBaseInfo> data = _dbContext.Queryable <DataBaseInfo>().OrderBy(x => x.BusinessType).ToList();

            return(LayuiData.CreateResult(data.Count, data));
        }