Example #1
0
        /// <summary>
        /// 获取文件列表
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public void getFileList(HttpContext context)
        {
            string   pageNo   = HttpContext.Current.Request["pageNo"];
            string   pageSize = HttpContext.Current.Request["pageSize"];
            string   fileType = HttpContext.Current.Request["fileType"];
            string   userId   = HttpContext.Current.Session["userID"].ToString();
            sceneBll bll      = new sceneBll();

            try
            {
                List <Model.file> list = bll.GetFileList(int.Parse(pageNo), int.Parse(pageSize), int.Parse(fileType), userId);
                StringBuilder     lstr = new StringBuilder();
                foreach (Model.file m in list)
                {
                    lstr.Append(@"{
                            'id': '" + m.Fileid + @"',
                            'name': '" + m.fileUserName + @"',
                            'extName': '" + m.extName + @"',
                            'fileType': '" + m.fileType + @"',
                            'bizType': '101',
                            'path': '" + m.path + @"',
                            'tmbPath': '" + m.path + @"',
                            'createTime': '" + m.addtime + @"',
                            'createUser': '******',
                            'sort': '0',
                            'size': '26',
                            'status': '1'
                        },");
                }
                //count总数
                string msg = @"{
                    'success': true, 
                    'code': '200', 
                    'msg': 'success', 
                    'obj': null, 
                    'map': {
                        'count': '" + bll.GetFileCount(userId, int.Parse(fileType)).ToString() + @"',
                        'pageNo': '" + pageNo + @"', 
                        'pageSize': '" + pageSize + @"'
                    }, 
                    'list': [
                        " + lstr.ToString().Trim(',') + @" 
                    ]
    }";
                context.Response.Write(MentStr(msg));
            }
            catch (Exception ex)
            {
                string msg = @"{
                    'success': false,
                    'code': '403',
                    'msg': '获取文件失败',
                    'obj': null,
                    'map': null,
                    'list': null
                }";
                context.Response.Write(MentStr(msg));
            }
        }