Example #1
0
        /// <summary>
        /// 导出文件附件
        /// </summary>
        /// <param name="wherestr">搜索条件</param>
        /// <returns>附件信息</returns>
        public ActionResult ExportFile(int pcode = 0, string name = "", string code = "")
        {
            try
            {
                string filename = HttpUtility.UrlEncode(string.Format("导出报表_组织机构管理_{0}.xlsx", DateTime.Now.ToString("yyyyMMddHHmmss")), Encoding.UTF8);
                string path     = System.Web.HttpContext.Current.Server.MapPath("~/tmp/");
                string where = "1=1";
                List <object> param = new List <object>();
                if (pcode > 0)
                {
                    where += " AND P_CODE=?";
                    param.Add(pcode);
                }
                if (string.IsNullOrWhiteSpace(name) == false)
                {
                    where += " AND NAME LIKE '%" + name.Replace('\'', ' ') + "%'";
                }
                if (string.IsNullOrWhiteSpace(code) == false)
                {
                    where += " AND DEPT_CODE=? ";
                    param.Add(code);
                }
                var dt = BF_DEPARTMENT.Instance.GetTableFields("NAME,DEPT_CODE,DEPT_LEVEL,P_CODE,DEPT_FLAG,REMARK,CREATE_TIME,UPDATE_TIME", where, param);
                if (dt == null)
                {
                    return(ShowAlert("导出数据到Excel出现错误:未查询出数据"));
                }
                dt.Columns.Remove("ID");
                dt.Columns["NAME"].Caption        = "部门名称";
                dt.Columns["DEPT_CODE"].Caption   = "部门编码";
                dt.Columns["DEPT_LEVEL"].Caption  = "部门层级";
                dt.Columns["P_CODE"].Caption      = "上级部门编码";
                dt.Columns["DEPT_FLAG"].Caption   = "部门标志";
                dt.Columns["REMARK"].Caption      = "部门说明";
                dt.Columns["CREATE_TIME"].Caption = "创建时间";
                dt.Columns["UPDATE_TIME"].Caption = "最后更新时间";

                Library.Export.ExcelFile export = new Library.Export.ExcelFile(path);
                string fullName = export.ToExcel(dt);
                if (string.IsNullOrWhiteSpace(fullName) == true)
                {
                    return(ShowAlert("未生成Excel文件"));
                }
                System.Web.HttpContext.Current.Response.Buffer = true;
                System.Web.HttpContext.Current.Response.Clear();//清除缓冲区所有内容
                System.Web.HttpContext.Current.Response.ContentType = "application/octet-stream";
                System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + filename);
                System.Web.HttpContext.Current.Response.WriteFile(fullName);
                System.Web.HttpContext.Current.Response.Flush();
                System.Web.HttpContext.Current.Response.End();
                //删除文件
                export.Delete(fullName);
            }
            catch (Exception ex)
            {
                BLog.Write(BLog.LogLevel.WARN, "导出默认报表[DB]到Excel出错:" + ex.ToString());
                return(ShowAlert("导出数据到Excel出现未知错误:" + ex.Message));
            }
            return(ShowAlert("导出成功"));
        }
Example #2
0
        /// <summary>
        /// 导出文件附件
        /// </summary>
        /// <param name="wherestr">搜索条件</param>
        /// <returns>附件信息</returns>
        public ActionResult ExportFile(int pid = 0, string name = "", string url = "")
        {
            try
            {
                string filename = HttpUtility.UrlEncode(string.Format("导出报表_菜单管理_{0}.xlsx", DateTime.Now.ToString("yyyyMMddHHmmss")), Encoding.UTF8);
                string path     = System.Web.HttpContext.Current.Server.MapPath("~/tmp/");
                string where = "1=1";
                List <object> param = new List <object>();
                if (pid > 0)
                {
                    where += " AND PID=?";
                    param.Add(pid);
                }
                if (string.IsNullOrWhiteSpace(name) == false)
                {
                    where += " AND NAME LIKE '%" + name.Replace('\'', ' ') + "%'";
                }
                if (string.IsNullOrWhiteSpace(url) == false)
                {
                    where += " AND URL LIKE '%" + url.Replace('\'', ' ') + "%'";
                }

                var dt = BF_MENU.Instance.GetTableFields("PID,NAME,URL,IS_ENABLE,IS_SHOW_NAV,CREATE_TIME,UPDATE_TIME", where, param);
                if (dt == null)
                {
                    return(ShowAlert("导出数据到Excel出现错误:未查询出数据"));
                }

                dt.Columns["PID"].Caption         = "上级菜单";
                dt.Columns["NAME"].Caption        = "菜单名称";
                dt.Columns["URL"].Caption         = "菜单URL地址";
                dt.Columns["IS_ENABLE"].Caption   = "启用状态";
                dt.Columns["IS_SHOW_NAV"].Caption = "导航显示";
                dt.Columns["CREATE_TIME"].Caption = "创建时间";
                dt.Columns["UPDATE_TIME"].Caption = "最后更新时间";


                Library.Export.ExcelFile export = new Library.Export.ExcelFile(path);
                string fullName = export.ToExcel(dt);
                if (string.IsNullOrWhiteSpace(fullName) == true)
                {
                    return(ShowAlert("未生成Excel文件"));
                }
                System.Web.HttpContext.Current.Response.Buffer = true;
                System.Web.HttpContext.Current.Response.Clear();//清除缓冲区所有内容
                System.Web.HttpContext.Current.Response.ContentType = "application/octet-stream";
                System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + filename);
                System.Web.HttpContext.Current.Response.WriteFile(fullName);
                System.Web.HttpContext.Current.Response.Flush();
                System.Web.HttpContext.Current.Response.End();
                //删除文件
                export.Delete(fullName);
            }
            catch (Exception ex)
            {
                BLog.Write(BLog.LogLevel.WARN, "导出默认报表[DB]到Excel出错:" + ex.ToString());
                return(ShowAlert("导出数据到Excel出现未知错误:" + ex.Message));
            }
            return(ShowAlert("导出成功!"));
        }
Example #3
0
        /// <summary>
        /// 导出文件附件
        /// </summary>
        /// <param name="wherestr">搜索条件</param>
        /// <returns>附件信息</returns>
        public ActionResult ExportFile(string name = "", string ip = "", int type = 0)
        {
            try
            {
                string filename = HttpUtility.UrlEncode(string.Format("导出报表_数据库管理_{0}.xlsx", DateTime.Now.ToString("yyyyMMddHHmmss")), Encoding.UTF8);
                string path     = System.Web.HttpContext.Current.Server.MapPath("~/tmp/");
                string where = "1=1";
                if (string.IsNullOrWhiteSpace(name) == false)
                {
                    where += " AND NAME LIKE '%" + name.Replace('\'', ' ') + "%'";
                }
                if (string.IsNullOrWhiteSpace(ip) == false)
                {
                    where += " AND IP LIKE '%" + ip.Replace('\'', ' ') + "%'";
                }
                if (type > 0)
                {
                    where += " AND DB_TYPE=" + type;
                }

                var dt = BF_DATABASE.Instance.GetTableFields("NAME,DB_TYPE,IP,PORT,USER_NAME,DB_NAME,REMARK,UPDATE_TIME", where);
                if (dt == null)
                {
                    return(ShowAlert("导出数据到Excel出现错误:未查询出数据"));
                }

                dt.Columns["NAME"].Caption        = "数据库名称";
                dt.Columns["DB_TYPE"].Caption     = "数据库类型";
                dt.Columns["IP"].Caption          = "IP地址";
                dt.Columns["PORT"].Caption        = "端口号";
                dt.Columns["USER_NAME"].Caption   = "用户名";
                dt.Columns["DB_NAME"].Caption     = "实例名";
                dt.Columns["REMARK"].Caption      = "备注";
                dt.Columns["UPDATE_TIME"].Caption = "最后更新时间";


                Library.Export.ExcelFile export = new Library.Export.ExcelFile(path);
                string fullName = export.ToExcel(dt);
                if (string.IsNullOrWhiteSpace(fullName) == true)
                {
                    return(ShowAlert("未生成Excel文件"));
                }
                System.Web.HttpContext.Current.Response.Buffer = true;
                System.Web.HttpContext.Current.Response.Clear();//清除缓冲区所有内容
                System.Web.HttpContext.Current.Response.ContentType = "application/octet-stream";
                System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + filename);
                System.Web.HttpContext.Current.Response.WriteFile(fullName);
                System.Web.HttpContext.Current.Response.Flush();
                System.Web.HttpContext.Current.Response.End();
                //删除文件
                export.Delete(fullName);
            }
            catch (Exception ex)
            {
                BLog.Write(BLog.LogLevel.WARN, "导出默认报表[DB]到Excel出错:" + ex.ToString());
                return(ShowAlert("导出数据到Excel出现未知错误:" + ex.Message));
            }
            return(ShowAlert("导出成功"));
        }
Example #4
0
        /// <summary>
        /// 样表
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns></returns>
        private ActionResult ImportDownload(BF_IMPORT.Entity entity)
        {
            try
            {
                List <string>            commentList = new List <string>();
                DataTable                dt          = BF_IMPORT.GetSampleTable(entity, out commentList);
                string                   filename    = HttpUtility.UrlEncode(string.Format("{0}_{1}.xlsx", entity.NAME, DateTime.Now.ToString("yyyyMMddHHmmss")), Encoding.UTF8);
                string                   path        = System.Web.HttpContext.Current.Server.MapPath("~/tmp/");
                Library.Export.ExcelFile export      = new Library.Export.ExcelFile(path);
                string                   fullName    = export.ToExcel(dt);
                if (string.IsNullOrWhiteSpace(fullName) == true || System.IO.File.Exists(fullName) == false)
                {
                    return(ShowAlert("未生成Excel文件"));
                }

                IWorkbook workBook;
                using (FileStream fs = System.IO.File.OpenRead(fullName))
                {
                    workBook = new XSSFWorkbook(fs);
                    ISheet sheet = workBook.GetSheetAt(0);
                    IRow   row   = sheet.GetRow(0);

                    XSSFDrawing patriarch = (XSSFDrawing)sheet.CreateDrawingPatriarch();
                    for (int c = 0; c < row.Cells.Count; c++)
                    {
                        if (string.IsNullOrWhiteSpace(commentList[c]) == false)
                        {
                            IComment comment = patriarch.CreateCellComment(new XSSFClientAnchor(0, 50, 0, 50, c, 0, c + 3, 5));
                            comment.Author           = "编辑提示";
                            comment.String           = new XSSFRichTextString("【编辑提示】\r\n" + commentList[c]);
                            row.Cells[c].CellComment = comment;
                        }
                    }
                }

                //重写文件
                using (FileStream fs = System.IO.File.Create(fullName))
                {
                    workBook.Write(fs);
                    fs.Close();
                }

                System.Web.HttpContext.Current.Response.Buffer = true;
                System.Web.HttpContext.Current.Response.Clear();//清除缓冲区所有内容
                System.Web.HttpContext.Current.Response.ContentType = "application/octet-stream";
                System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + filename);
                System.Web.HttpContext.Current.Response.WriteFile(fullName);
                System.Web.HttpContext.Current.Response.Flush();
                System.Web.HttpContext.Current.Response.End();
                //删除文件
                export.Delete(fullName);
            }
            catch (Exception ex)
            {
                ShowAlert("生成样表出错:" + ex.Message);
            }
            return(View());
        }
Example #5
0
        /// <summary>
        /// 导出文件附件
        /// </summary>
        /// <param name="wherestr">搜索条件</param>
        /// <returns>附件信息</returns>
        public ActionResult ExportFile(string content = "")
        {
            try
            {
                string filename = HttpUtility.UrlEncode(string.Format("导出报表_操作日志_{0}.xlsx", DateTime.Now.ToString("yyyyMMddHHmmss")), Encoding.UTF8);
                string path     = System.Web.HttpContext.Current.Server.MapPath("~/tmp/");

                List <object> param = new List <object>();
                #region 添加参数
                string where = "1=1";

                if (string.IsNullOrWhiteSpace(content) == false)
                {
                    where += " and content LIKE '%" + content.Replace('\'', ' ') + "%'";
                }
                #endregion

                var dt = BLL.FW.BF_OP_LOG.Instance.GetTableFields("LOG_TIME,LOG_LEVEL,IS_SUCCESS,SRC_IP,SRC_PORT,USER_NAME,CONTROLLER,ACTION,REQ_URL,CONTENT,DETAIL", where, param);
                if (dt == null)
                {
                    return(ShowAlert("导出数据到Excel出现错误:未查询出数据"));
                }
                dt.Columns["LOG_TIME"].Caption   = "日志时间";
                dt.Columns["LOG_LEVEL"].Caption  = "等级";
                dt.Columns["IS_SUCCESS"].Caption = "成功";
                dt.Columns["SRC_IP"].Caption     = "源IP";
                dt.Columns["SRC_PORT"].Caption   = "源端口";
                dt.Columns["USER_NAME"].Caption  = "登录名";
                dt.Columns["CONTROLLER"].Caption = "控制器名称";
                dt.Columns["ACTION"].Caption     = "ACTION名称";
                dt.Columns["REQ_URL"].Caption    = "请求URL地址";
                dt.Columns["CONTENT"].Caption    = "请求内容";
                dt.Columns["DETAIL"].Caption     = "源IP";

                Library.Export.ExcelFile export = new Library.Export.ExcelFile(path);
                string fullName = export.ToExcel(dt);
                if (string.IsNullOrWhiteSpace(fullName) == true)
                {
                    return(ShowAlert("未生成Excel文件"));
                }
                System.Web.HttpContext.Current.Response.Buffer = true;
                System.Web.HttpContext.Current.Response.Clear();//清除缓冲区所有内容
                System.Web.HttpContext.Current.Response.ContentType = "application/octet-stream";
                System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + filename);
                System.Web.HttpContext.Current.Response.WriteFile(fullName);
                System.Web.HttpContext.Current.Response.Flush();
                System.Web.HttpContext.Current.Response.End();
                //删除文件
                export.Delete(fullName);
            }
            catch (Exception ex)
            {
                BLog.Write(BLog.LogLevel.WARN, "导出默认报表[DB]到Excel出错:" + ex.ToString());
                return(ShowAlert("导出数据到Excel出现未知错误:" + ex.Message));
            }
            return(ShowAlert("导出成功"));
        }
Example #6
0
        /// <summary>
        /// 导出文件附件
        /// </summary>
        /// <param name="wherestr">搜索条件</param>
        /// <returns>附件信息</returns>
        public ActionResult ExportFile(string name = "")
        {
            try
            {
                string filename = HttpUtility.UrlEncode(string.Format("导出报表_图形报表_{0}.xlsx", DateTime.Now.ToString("yyyyMMddHHmmss")), Encoding.UTF8);
                string path     = System.Web.HttpContext.Current.Server.MapPath("~/tmp/");

                #region 添加参数
                string        orderByField = "CR.ID";
                string        orderByType  = "DESC";
                List <object> param        = new List <object>();
                string where = "1=1";
                if (string.IsNullOrWhiteSpace(name) == false)
                {
                    where += " and CR.NAME LIKE '%" + name.Replace('\'', ' ') + "%'";
                }
                #endregion
                int       count = 0;
                DataTable dt    = BF_CHART_REPORT.Instance.GetDataTable(0, 0, ref count, name, orderByField, orderByType);
                if (dt == null)
                {
                    return(ShowAlert("导出数据到Excel出现错误:未查询出数据"));
                }
                dt.Columns.Remove("ID");
                dt.Columns["NAME"].Caption        = "名称";
                dt.Columns["DBNAME"].Caption      = "数据库名称";
                dt.Columns["CHART_TYPE"].Caption  = "类别";
                dt.Columns["SHOWEXPORT"].Caption  = "导出";
                dt.Columns["SHOWDEBUG"].Caption   = "调试";
                dt.Columns["SQL_CODE"].Caption    = "SQL";
                dt.Columns["IS_ENABLE"].Caption   = "启用";
                dt.Columns["UPDATE_TIME"].Caption = "更新时间";

                Library.Export.ExcelFile export = new Library.Export.ExcelFile(path);
                string fullName = export.ToExcel(dt);
                if (string.IsNullOrWhiteSpace(fullName) == true)
                {
                    return(ShowAlert("未生成Excel文件"));
                }
                System.Web.HttpContext.Current.Response.Buffer = true;
                System.Web.HttpContext.Current.Response.Clear();//清除缓冲区所有内容
                System.Web.HttpContext.Current.Response.ContentType = "application/octet-stream";
                System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + filename);
                System.Web.HttpContext.Current.Response.WriteFile(fullName);
                System.Web.HttpContext.Current.Response.Flush();
                System.Web.HttpContext.Current.Response.End();
                //删除文件
                export.Delete(fullName);
            }
            catch (Exception ex)
            {
                BLog.Write(BLog.LogLevel.WARN, "导出默认报表[DB]到Excel出错:" + ex.ToString());
                return(ShowAlert("导出数据到Excel出现未知错误:" + ex.Message));
            }
            return(ShowAlert("导出成功"));
        }
Example #7
0
        /// <summary>
        /// 导出文件附件
        /// </summary>
        /// <param name="wherestr">搜索条件</param>
        /// <returns>附件信息</returns>
        public ActionResult ExportFile(int pid = 0, string name = "")
        {
            try
            {
                string filename = HttpUtility.UrlEncode(string.Format("导出报表_脚本类型_{0}.xlsx", DateTime.Now.ToString("yyyyMMddHHmmss")), Encoding.UTF8);
                string path     = System.Web.HttpContext.Current.Server.MapPath("~/tmp/");
                string where = "1=1";
                List <object> param = new List <object>();
                if (pid > 0)
                {
                    where += " AND PID=?";
                    param.Add(pid);
                }
                if (string.IsNullOrWhiteSpace(name) == false)
                {
                    where += " AND NAME LIKE '%" + name.Replace('\'', ' ') + "%'";
                }
                int count = 0;
                var dt    = BF_ST_TYPE.Instance.GetDataTable(0, 0, ref count, pid, name, "st.ID", "asc");
                if (dt == null)
                {
                    return(ShowAlert("导出数据到Excel出现错误:未查询出数据"));
                }
                dt.Columns["NAME"].Caption        = "类型名称";
                dt.Columns["PNAME"].Caption       = "上层类型";
                dt.Columns["REMARK"].Caption      = "备注";
                dt.Columns["CREATENAME"].Caption  = "创建者";
                dt.Columns["CREATE_TIME"].Caption = "创建时间";
                dt.Columns["UPDATENAME"].Caption  = "最后更新者";
                dt.Columns["UPDATE_TIME"].Caption = "最后更新时间";

                Library.Export.ExcelFile export = new Library.Export.ExcelFile(path);
                string fullName = export.ToExcel(dt);
                if (string.IsNullOrWhiteSpace(fullName) == true)
                {
                    return(ShowAlert("未生成Excel文件"));
                }
                System.Web.HttpContext.Current.Response.Buffer = true;
                System.Web.HttpContext.Current.Response.Clear();//清除缓冲区所有内容
                System.Web.HttpContext.Current.Response.ContentType = "application/octet-stream";
                System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + filename);
                System.Web.HttpContext.Current.Response.WriteFile(fullName);
                System.Web.HttpContext.Current.Response.Flush();
                System.Web.HttpContext.Current.Response.End();
                //删除文件
                export.Delete(fullName);
            }
            catch (Exception ex)
            {
                BLog.Write(BLog.LogLevel.WARN, "导出默认报表[DB]到Excel出错:" + ex.ToString());
                return(ShowAlert("导出数据到Excel出现未知错误:" + ex.Message));
            }
            return(ShowAlert("导出成功"));
        }
Example #8
0
        /// <summary>
        /// 导出文件附件
        /// </summary>
        /// <param name="wherestr">搜索条件</param>
        /// <returns>附件信息</returns>
        public ActionResult ExportFile(string enName = "", string cnName = "")
        {
            try
            {
                string filename = HttpUtility.UrlEncode(string.Format("导出报表_字段显示配置_{0}.xlsx", DateTime.Now.ToString("yyyyMMddHHmmss")), Encoding.UTF8);
                string path     = System.Web.HttpContext.Current.Server.MapPath("~/tmp/");
                string where = "1=1";
                if (string.IsNullOrWhiteSpace(enName) == false)
                {
                    where += " AND EN_NAME LIKE '%" + enName.Replace('\'', ' ') + "%'";
                }
                if (string.IsNullOrWhiteSpace(cnName) == false)
                {
                    where += " AND CN_NAME LIKE '%" + cnName.Replace('\'', ' ') + "%'";
                }

                var dt = BF_FIELD.Instance.GetTableFields("EN_NAME,CN_NAME,FIELD_DATA_TYPE,IS_REQUISITE,IS_SHOW,SHOW_WIDTH", where);
                if (dt == null)
                {
                    return(ShowAlert("导出数据到Excel出现错误:未查询出数据"));
                }
                dt.Columns["EN_NAME"].Caption         = "字段英文名";
                dt.Columns["CN_NAME"].Caption         = "字段中文名";
                dt.Columns["FIELD_DATA_TYPE"].Caption = "IP字段类型";
                dt.Columns["IS_REQUISITE"].Caption    = "是否必须";
                dt.Columns["IS_SHOW"].Caption         = "是否显示";
                dt.Columns["SHOW_WIDTH"].Caption      = "显示宽度";

                Library.Export.ExcelFile export = new Library.Export.ExcelFile(path);
                string fullName = export.ToExcel(dt);
                if (string.IsNullOrWhiteSpace(fullName) == true)
                {
                    return(ShowAlert("未生成Excel文件"));
                }
                System.Web.HttpContext.Current.Response.Buffer = true;
                System.Web.HttpContext.Current.Response.Clear();//清除缓冲区所有内容
                System.Web.HttpContext.Current.Response.ContentType = "application/octet-stream";
                System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + filename);
                System.Web.HttpContext.Current.Response.WriteFile(fullName);
                System.Web.HttpContext.Current.Response.Flush();
                System.Web.HttpContext.Current.Response.End();
                //删除文件
                export.Delete(fullName);
            }
            catch (Exception ex)
            {
                BLog.Write(BLog.LogLevel.WARN, "导出默认报表[DB]到Excel出错:" + ex.ToString());
                return(ShowAlert("导出数据到Excel出现未知错误:" + ex.Message));
            }
            return(ShowAlert("导出成功"));
        }
Example #9
0
        /// <summary>
        /// 导出文件附件
        /// </summary>
        /// <param name="wherestr">搜索条件</param>
        /// <returns>附件信息</returns>
        public ActionResult ExportFile(string message = "", int TaskId = 0)
        {
            try
            {
                string filename = HttpUtility.UrlEncode(string.Format("导出报表_任务日志_{0}.xlsx", DateTime.Now.ToString("yyyyMMddHHmmss")), Encoding.UTF8);
                string path     = System.Web.HttpContext.Current.Server.MapPath("~/tmp/");

                List <object> param = new List <object>();
                #region 添加参数
                string where = "TASK_ID=?";
                param.Add(TaskId);

                if (string.IsNullOrWhiteSpace(message) == false)
                {
                    where += " and message LIKE '%" + message.Replace('\'', ' ') + "%'";
                }
                #endregion

                var dt = BLL.FW.BF_ST_TASK_LOG.Instance.GetTableFields("LOG_TIME,LOG_LEVEL,MESSAGE", where, param);
                if (dt == null)
                {
                    return(ShowAlert("导出数据到Excel出现错误:未查询出数据"));
                }
                dt.Columns["LOG_TIME"].Caption  = "日志时间";
                dt.Columns["LOG_LEVEL"].Caption = "等级";
                dt.Columns["MESSAGE"].Caption   = "日志内容";

                Library.Export.ExcelFile export = new Library.Export.ExcelFile(path);
                string fullName = export.ToExcel(dt);
                if (string.IsNullOrWhiteSpace(fullName) == true)
                {
                    return(ShowAlert("未生成Excel文件"));
                }
                System.Web.HttpContext.Current.Response.Buffer = true;
                System.Web.HttpContext.Current.Response.Clear();//清除缓冲区所有内容
                System.Web.HttpContext.Current.Response.ContentType = "application/octet-stream";
                System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + filename);
                System.Web.HttpContext.Current.Response.WriteFile(fullName);
                System.Web.HttpContext.Current.Response.Flush();
                System.Web.HttpContext.Current.Response.End();
                //删除文件
                export.Delete(fullName);
            }
            catch (Exception ex)
            {
                BLog.Write(BLog.LogLevel.WARN, "导出默认报表[DB]到Excel出错:" + ex.ToString());
                return(ShowAlert("导出数据到Excel出现未知错误:" + ex.Message));
            }
            return(ShowAlert("导出成功"));
        }
Example #10
0
        /// <summary>
        /// 导出文件附件
        /// </summary>
        /// <param name="wherestr">搜索条件</param>
        /// <returns>附件信息</returns>
        public ActionResult ExportFile(string daterange = "", string flowName = "", string nodeName = "", string param = "", string statusId = "", string successId = "")
        {
            try
            {
                string filename = HttpUtility.UrlEncode(string.Format("导出报表_脚本任务_{0}.xlsx", DateTime.Now.ToString("yyyyMMddHHmmss")), Encoding.UTF8);
                string path     = System.Web.HttpContext.Current.Server.MapPath("~/tmp/");

                int count = 0;
                var dt    = BF_ST_TASK.Instance.GetDataTable(0, 0, ref count, daterange, flowName, nodeName, param, statusId, successId);
                if (dt == null)
                {
                    return(ShowAlert("导出数据到Excel出现错误:未查询出数据"));
                }
                dt.Columns.Remove("ID");
                dt.Columns["FLOWNAME"].Caption       = "流程名称";
                dt.Columns["NODENAME"].Caption       = "节点名称";
                dt.Columns["IS_MANUAL"].Caption      = "手动启动";
                dt.Columns["REFERENCE_DATE"].Caption = "基准日期";
                dt.Columns["RETRY_TIMES"].Caption    = "重试次数";
                dt.Columns["RUN_STATUS"].Caption     = "运行状态";
                dt.Columns["IS_SUCCESS"].Caption     = "是否成功";
                dt.Columns["START_TIME"].Caption     = "开始时间";
                dt.Columns["FINISH_TIME"].Caption    = "结束时间";
                dt.Columns["CREATE_TIME"].Caption    = "创建时间";
                dt.Columns["REMARK"].Caption         = "备注";

                Library.Export.ExcelFile export = new Library.Export.ExcelFile(path);
                string fullName = export.ToExcel(dt);
                if (string.IsNullOrWhiteSpace(fullName) == true)
                {
                    return(ShowAlert("未生成Excel文件"));
                }
                System.Web.HttpContext.Current.Response.Buffer = true;
                System.Web.HttpContext.Current.Response.Clear();//清除缓冲区所有内容
                System.Web.HttpContext.Current.Response.ContentType = "application/octet-stream";
                System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + filename);
                System.Web.HttpContext.Current.Response.WriteFile(fullName);
                System.Web.HttpContext.Current.Response.Flush();
                System.Web.HttpContext.Current.Response.End();
                //删除文件
                export.Delete(fullName);
            }
            catch (Exception ex)
            {
                BLog.Write(BLog.LogLevel.WARN, "导出默认报表[DB]到Excel出错:" + ex.ToString());
                return(ShowAlert("导出数据到Excel出现未知错误:" + ex.Message));
            }
            return(ShowAlert("导出成功"));
        }
Example #11
0
        /// <summary>
        /// 导出文件附件
        /// </summary>
        /// <param name="wherestr">搜索条件</param>
        /// <returns>附件信息</returns>
        public ActionResult ExportFile(string name = "")
        {
            try
            {
                string filename = HttpUtility.UrlEncode(string.Format("导出报表_数据外导配置_{0}.xlsx", DateTime.Now.ToString("yyyyMMddHHmmss")), Encoding.UTF8);
                string path     = System.Web.HttpContext.Current.Server.MapPath("~/tmp/");
                string where = "1=1";
                if (string.IsNullOrWhiteSpace(name) == false)
                {
                    where += " AND NAME LIKE '%" + name.Replace('\'', ' ') + "%'";
                }

                var dt = BF_IMPORT.Instance.GetTable(where);
                if (dt == null)
                {
                    return(ShowAlert("导出数据到Excel出现错误:未查询出数据"));
                }

                Library.Export.ExcelFile export = new Library.Export.ExcelFile(path);
                string fullName = export.ToExcel(dt);
                if (string.IsNullOrWhiteSpace(fullName) == true)
                {
                    return(ShowAlert("未生成Excel文件"));
                }
                System.Web.HttpContext.Current.Response.Buffer = true;
                System.Web.HttpContext.Current.Response.Clear();//清除缓冲区所有内容
                System.Web.HttpContext.Current.Response.ContentType = "application/octet-stream";
                System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + filename);
                System.Web.HttpContext.Current.Response.WriteFile(fullName);
                System.Web.HttpContext.Current.Response.Flush();
                System.Web.HttpContext.Current.Response.End();
                //删除文件
                export.Delete(fullName);
            }
            catch (Exception ex)
            {
                BLog.Write(BLog.LogLevel.WARN, "导出默认报表[DB]到Excel出错:" + ex.ToString());
                return(ShowAlert("导出数据到Excel出现未知错误:" + ex.Message));
            }
            return(ShowAlert("导出成功"));
        }
Example #12
0
        /// <summary>
        /// 导出文件附件
        /// </summary>
        /// <param name="wherestr">搜索条件</param>
        /// <returns>附件信息</returns>
        public ActionResult ExportFile(string name = "", int runState = -1, int isEnable = -1, int lastTaskIs = -1, int self = 0)
        {
            try
            {
                string filename = HttpUtility.UrlEncode(string.Format("导出报表_脚本任务_{0}.xlsx", DateTime.Now.ToString("yyyyMMddHHmmss")), System.Text.Encoding.UTF8);
                string path     = System.Web.HttpContext.Current.Server.MapPath("~/tmp/");

                string where = "1=1";
                List <object> param = new List <object>();

                #region 添加参数
                if (!string.IsNullOrWhiteSpace(name))
                {
                    where += " AND NAME LIKE '%" + name.Replace('\'', ' ') + "%'";
                }
                if (runState > -1)
                {
                    where += " AND RUN_STATUS = " + runState;
                }
                if (isEnable > -1)
                {
                    where += " AND IS_ENABLE = " + isEnable;
                }
                if (lastTaskIs > -1)
                {
                    where += " AND LAST_TASK_IS =" + lastTaskIs;
                }
                if (self > 0)
                {
                    where += " AND CREATE_UID = " + SystemSession.UserID;
                }

                #endregion
                var dt = BLL.FW.BF_ST_FLOW.Instance.GetTableFields("ID,NAME,TYPE_ID,CRON,RETRY_TIMES,IS_ENABLE,RUN_STATUS,LAST_TASK_IS,LAST_TASK_ID", where, param);
                if (dt == null)
                {
                    return(ShowAlert("导出数据到Excel出现错误:未查询出数据"));
                }
                dt.Columns.Remove("ID");
                dt.Columns["NAME"].Caption         = "脚本流名称";
                dt.Columns["TYPE_ID"].Caption      = "脚本流类型";
                dt.Columns["CRON"].Caption         = "时间表达式";
                dt.Columns["RETRY_TIMES"].Caption  = "失败重试次数";
                dt.Columns["IS_ENABLE"].Caption    = "是否启用";
                dt.Columns["RUN_STATUS"].Caption   = "运行状态";
                dt.Columns["LAST_TASK_IS"].Caption = "最新任务是否成功";
                dt.Columns["LAST_TASK_ID"].Caption = "最新任务ID";

                Library.Export.ExcelFile export = new Library.Export.ExcelFile(path);
                string fullName = export.ToExcel(dt);
                if (string.IsNullOrWhiteSpace(fullName) == true)
                {
                    return(ShowAlert("未生成Excel文件"));
                }
                System.Web.HttpContext.Current.Response.Buffer = true;
                System.Web.HttpContext.Current.Response.Clear();//清除缓冲区所有内容
                System.Web.HttpContext.Current.Response.ContentType = "application/octet-stream";
                System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + filename);
                System.Web.HttpContext.Current.Response.WriteFile(fullName);
                System.Web.HttpContext.Current.Response.Flush();
                System.Web.HttpContext.Current.Response.End();
                //删除文件
                export.Delete(fullName);
            }
            catch (Exception ex)
            {
                BLog.Write(BLog.LogLevel.WARN, "导出默认报表[DB]到Excel出错:" + ex.ToString());
                return(ShowAlert("导出数据到Excel出现未知错误:" + ex.Message));
            }
            return(ShowAlert("导出成功"));
        }
Example #13
0
        /// <summary>
        /// 导出文件附件
        /// </summary>
        /// <param name="wherestr">搜索条件</param>
        /// <returns>附件信息</returns>
        public ActionResult ExportFile(string name = "", string typeId = "", string dbId = "", int self = 0)
        {
            try
            {
                string filename = HttpUtility.UrlEncode(string.Format("导出报表_脚本任务_{0}.xlsx", DateTime.Now.ToString("yyyyMMddHHmmss")), Encoding.UTF8);
                string path     = System.Web.HttpContext.Current.Server.MapPath("~/tmp/");

                string where = "1=1";
                List <object> param = new List <object>();
                #region 添加参数
                if (string.IsNullOrWhiteSpace(name) == false)
                {
                    where += " AND NAME LIKE '%" + name.Replace('\'', ' ') + "%'";
                }

                if (string.IsNullOrWhiteSpace(typeId) == false)
                {
                    where += " AND TYPE_ID = ?";
                    param.Add(typeId);
                }
                if (string.IsNullOrWhiteSpace(dbId) == false)
                {
                    where += " AND DB_ID = ?";
                    param.Add(dbId);
                }
                #endregion
                int count = 0;
                var dt    = BF_ST_NODE.Instance.GetDataTable(0, 0, ref count, name, typeId, dbId, self);
                if (dt == null)
                {
                    return(ShowAlert("导出数据到Excel出现错误:未查询出数据"));
                }
                dt.Columns.Remove("ID");
                dt.Columns.Remove("LAST_TASK_ID");
                dt.Columns["NAME"].Caption         = "任务名称";
                dt.Columns["TYPENAME"].Caption     = "类型";
                dt.Columns["TASKNAME"].Caption     = "最新任务";
                dt.Columns["DBNAME"].Caption       = "数据库名称";
                dt.Columns["RUN_STATUS"].Caption   = "运行状态";
                dt.Columns["LAST_TASK_IS"].Caption = "是否成功";
                dt.Columns["LAST_TASK_ST"].Caption = "开始时间";
                dt.Columns["LAST_TASK_FT"].Caption = "结束时间";
                dt.Columns["CREATE_NAME"].Caption  = "创建者";
                dt.Columns["CREATE_TIME"].Caption  = "创建时间";
                dt.Columns["UPDATE_TIME"].Caption  = "更新时间";
                dt.Columns["UPDATE_NAME"].Caption  = "更新者";

                Library.Export.ExcelFile export = new Library.Export.ExcelFile(path);
                string fullName = export.ToExcel(dt);
                if (string.IsNullOrWhiteSpace(fullName) == true)
                {
                    return(ShowAlert("未生成Excel文件"));
                }
                System.Web.HttpContext.Current.Response.Buffer = true;
                System.Web.HttpContext.Current.Response.Clear();//清除缓冲区所有内容
                System.Web.HttpContext.Current.Response.ContentType = "application/octet-stream";
                System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + filename);
                System.Web.HttpContext.Current.Response.WriteFile(fullName);
                System.Web.HttpContext.Current.Response.Flush();
                System.Web.HttpContext.Current.Response.End();
                //删除文件
                export.Delete(fullName);
            }
            catch (Exception ex)
            {
                BLog.Write(BLog.LogLevel.WARN, "导出默认报表[DB]到Excel出错:" + ex.ToString());
                return(ShowAlert("导出数据到Excel出现未知错误:" + ex.Message));
            }
            return(ShowAlert("导出成功"));
        }