Exemplo n.º 1
0
        public DataTable GetDepartmentALL()
        {
            Connection            con        = new Connection();
            var                   department = JsonConvert.DeserializeObject <List <Model.Question> >(con.Json(path));
            List <Model.Question> dt         = (from c in department select c).ToList();

            return(ConvertToDataTable.ToDataTable(dt));
        }
Exemplo n.º 2
0
        public DataTable GetDepartmentnameFromDepartmentID(int departmentID)
        {
            Connection            con        = new Connection();
            var                   department = JsonConvert.DeserializeObject <List <Model.Question> >(con.Json(path));
            List <Model.Question> dt         = (from c in department where c.DepartmentID == departmentID select c).ToList();

            return(ConvertToDataTable.ToDataTable(dt));
        }
Exemplo n.º 3
0
        public JsonResult RenderToExcel(int code, DateTime startdt, DateTime enddt, string queryname, string content, string filename)
        {
            Response resp = new Response();
            Log      log  = LogFactory.GetLogger("RenderToExcel");

            #region
            try
            {
                int totalnum;
                if (code == 1) //是报文记录
                {
                    List <TelegramLog> lst = new CWTelegramLog().FindPageList(0, 0, startdt, enddt, queryname, content, out totalnum);
                    if (lst.Count > 0)
                    {
                        List <TelegramLog> filterLst = new List <TelegramLog>();
                        if (totalnum > 1000)
                        {
                            filterLst = lst.Skip(0).Take(1000).ToList();
                        }
                        else
                        {
                            filterLst.AddRange(lst);
                        }
                        DataTable dt   = ConvertToDataTable.ToDataTable <TelegramLog>(filterLst);
                        string    path = ExcelUtility.Instance.RenderDataTableToExcel(dt, "报文日志报表", filename, 12);
                        resp.Code    = 1;
                        resp.Message = "数据导出成功,记录数- " + filterLst.Count + " ,文件路径- " + path;
                    }
                    else
                    {
                        resp.Message = "没有记录要导出.";
                    }
                }
                else if (code == 2) //是操作记录
                {
                    List <OperateLog> lst = new CWOperateRecordLog().FindPageList(0, 0, startdt, enddt, queryname, content, out totalnum);
                    if (lst.Count > 0)
                    {
                        List <OperateLog> filterLst = new List <OperateLog>();
                        if (totalnum > 1000)
                        {
                            filterLst = lst.Skip(0).Take(1000).ToList();
                        }
                        else
                        {
                            filterLst.AddRange(lst);
                        }

                        DataTable dt   = ConvertToDataTable.ToDataTable <OperateLog>(filterLst);
                        string    path = ExcelUtility.Instance.RenderDataTableToExcel(dt, "操作日志报表", filename, 4);
                        resp.Code    = 1;
                        resp.Message = "数据导出成功,记录数- " + filterLst.Count + " ,文件路径- " + path;
                    }
                    else
                    {
                        resp.Message = "没有记录要导出.";
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error("报表,导出到EXCEL异常:" + ex.ToString());
                resp.Message = "数据导出失败,请联供应商!";
            }
            #endregion
            return(Json(resp, JsonRequestBehavior.AllowGet));
        }