public ActionResult ExportCompleteExample()
        {
            try
            {
                QuerySuite querySuite = new QuerySuite(this, "ExampleName desc");
                querySuite.Select("select a.*,b.userName,c.departmentName from GeneralExample a left join SysUser b on a.UserPicker=b.UserID left join SysDepartment c on a.OUPicker=c.DepartmentID");

                querySuite.AddParam("ExampleName", "like");
                querySuite.AddParam("PlainText", "=");
                querySuite.AddParam("DateTimePicker", ">=");

                DataSet ds = SqlHelper.Query(querySuite.ExportSql, querySuite.Params);

                string fileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, string.Format("export/{0:yyyyMMdd}/{1}.xlsx", DateTime.Now, Guid.NewGuid()));
                if (!Directory.Exists(Path.GetDirectoryName(fileName)))
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(fileName));
                }

                ExcelHelper.DataTableToExcel(ds.Tables[0], fileName, "导出Sheet");
                FileStream fs = new FileStream(fileName, FileMode.Open);
                return(File(fs, "application/vnd.ms-excel", "export.xlsx"));
            }
            catch (Exception ex)
            {
                LogHelper.SaveLog(ex);
                return(Json(new { Code = 1, Msg = "服务器异常,请联系管理员!" }));
            }
        }
예제 #2
0
        /// <summary>
        /// 获取项目信息数据
        /// </summary>
        /// <returns></returns>
        public JsonResult QueryTaskData()
        {
            try
            {
                QuerySuite querySuite = new QuerySuite(this, "CreateTime desc");
                querySuite.Select("select * from PmTask");

                querySuite.AddParam("TaskName", "like");

                DataSet ds = SqlHelper.Query(querySuite.QuerySql, querySuite.Params);
                return(Json(new { Code = 0, Total = ds.Tables[0].Rows[0][0], Data = QuerySuite.ToDictionary(ds.Tables[1]) }));
            }
            catch (Exception ex)
            {
                LogHelper.SaveLog(ex);
                return(Json(new { Code = 1, Msg = "服务器异常,请联系管理员!" }));
            }
        }
        /// <summary>
        /// 获取页面操作数据
        /// </summary>
        /// <returns></returns>
        public JsonResult QueryUserData(Guid?parentId)
        {
            try
            {
                QuerySuite querySuite = new QuerySuite(this, "orderNo asc");
                querySuite.Select("select * from SysUser");

                querySuite.AddParam(" and departmentId=@departmentId", new SqlParameter("departmentId", parentId));
                querySuite.AddParam("userName", "like");

                DataSet ds = SqlHelper.Query(querySuite.QuerySql, querySuite.Params);
                return(Json(new { Code = 0, Total = ds.Tables[0].Rows[0][0], Data = QuerySuite.ToDictionary(ds.Tables[1]) }));
            }
            catch (Exception ex)
            {
                LogHelper.SaveLog(ex);
                return(Json(new { Code = 1, Msg = "服务器异常,请联系管理员!" }));
            }
        }
        public ActionResult QueryCompleteExample()
        {
            try
            {
                QuerySuite querySuite = new QuerySuite(this, "exampleName desc");
                querySuite.Select("select a.*,b.userName,c.departmentName from GeneralExample a left join SysUser b on a.UserPicker=b.UserID left join SysDepartment c on a.OUPicker=c.DepartmentID");

                querySuite.AddParam("ExampleName", "like");
                querySuite.AddParam("PlainText", "=");
                querySuite.AddParam("DateTimePicker", ">=");

                DataSet ds = SqlHelper.Query(querySuite.QuerySql, querySuite.Params);

                return(Json(new { Code = 0, Total = ds.Tables[0].Rows[0][0], Data = QuerySuite.ToDictionary(ds.Tables[1]) }));
            }
            catch (Exception ex)
            {
                LogHelper.SaveLog(ex);
                return(Json(new { Code = 1, Msg = "服务器异常,请联系管理员!" }));
            }
        }
예제 #5
0
        public FileResult ExportCompleteExample()
        {
            try
            {
                QuerySuite querySuite = new QuerySuite(this, "ExampleName desc");
                querySuite.Select("select a.*,b.userName,c.departmentName from GeneralExample a left join SysUser b on a.UserPicker=b.UserID left join SysDepartment c on a.OUPicker=c.DepartmentID");

                querySuite.AddParam("ExampleName", "like");
                querySuite.AddParam("PlainText", "=");
                querySuite.AddParam("DateTimePicker", ">=");

                DataSet ds = SqlHelper.Query(querySuite.ExportSql, querySuite.Params);

                return(null);
            }
            catch (Exception ex)
            {
                LogHelper.SaveLog(ex);
                return(null);
            }
        }
        /// <summary>
        /// 根据父级id获取 部门数据
        /// </summary>
        /// <returns></returns>
        public JsonResult QueryDepartmentData()
        {
            try
            {
                QuerySuite querySuite = new QuerySuite(this, "createTime desc");

                querySuite.Select("select departmentId,departmentCode,departmentName,departmentFullName,createTime from SysDepartment");

                querySuite.AddParam("parentId", "=");
                querySuite.AddParam("departmentName", "like");
                querySuite.AddParam("departmentCode", "like");

                DataSet ds = SqlHelper.Query(querySuite.QuerySql, querySuite.Params);

                return(Json(new { Code = 0, Total = ds.Tables[0].Rows[0][0], Data = QuerySuite.ToDictionary(ds.Tables[1]) }));
            }
            catch (Exception ex)
            {
                LogHelper.SaveLog(ex);
                return(Json(new { Code = 1, Msg = "服务器异常,请联系管理员!" }));
            }
        }
        /// <summary>
        /// 获取日志数据
        /// </summary>
        /// <returns></returns>
        public JsonResult GetLogData()
        {
            try
            {
                QuerySuite querySuite = new QuerySuite(this, "createTime desc");
                querySuite.Select("select * from SysLog");

                querySuite.AddParam("userName", "like");
                querySuite.AddParam("departmentName", "like");
                querySuite.AddParam("title", "like");
                querySuite.AddParam("type", "like");
                querySuite.AddParam("description", "like");

                DataSet ds = SqlHelper.Query(querySuite.QuerySql, querySuite.Params);

                return(Json(new { Code = 0, Total = ds.Tables[0].Rows[0][0], Data = QuerySuite.ToDictionary(ds.Tables[1]) }));
            }
            catch (Exception ex)
            {
                LogHelper.SaveLog(ex);
                return(Json(new { Code = 1, Msg = "服务器异常,请联系管理员!" }));
            }
        }