📄 reportmanager.java
字号:
/*
* Created on 2004/1/27
*/
package com.leeman.wkexs.common;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import com.leeman.common.resource.ConfigManager;
import com.leeman.common.util.Formatter;
import com.leeman.wkexs.web.base.BaseConstants;
/**
* @author hong
*/
public class ReportManager {
private int paraNum;
private String langID;
private String reportPath;
private String selection;
private String[] fieldName;
private String[] fieldValue;
private String url="";
private String[] subRptName;
private String[] subSelection;
private String showReport;
private String exportFileName;
private String showReportASPFileName = "/ShowReport.asp";
private String getLangID(HttpServletRequest req)
{
HttpSession session = req.getSession(true);
String langID =(String)session.getAttribute(BaseConstants.SESSION_LANG_ID);
return (langID!= null?langID:"");
}
public void Set_Data(HttpServletRequest req, String ReportPath, String Selection, int ParaNum, String[] FieldName, String[] FieldValue)
{
reportPath = ReportPath;
selection = Selection;
paraNum = ParaNum;
fieldName = FieldName;
fieldValue = FieldValue;
langID = getLangID(req);
}
public void Set_Data(HttpServletRequest req, String ReportPath, String Selection, int ParaNum, String[] FieldName, String[] FieldValue,
String[] SubReportName, String[] SubSelection)
{
reportPath = ReportPath;
selection = Selection;
paraNum = ParaNum;
fieldName = FieldName;
fieldValue = FieldValue;
if (SubReportName != null)
{
subRptName = SubReportName;
subSelection = SubSelection;
}
langID = getLangID(req);
}
public void Set_Data(HttpServletRequest req, String ReportPath, String Selection, int ParaNum, String[] FieldName, String[] FieldValue, String Url)
{
reportPath = ReportPath;
selection = Selection;
paraNum = ParaNum;
fieldName = FieldName;
fieldValue = FieldValue;
url = Url;
langID = getLangID(req);
}
public void Set_Data(HttpServletRequest req, String ReportPath, String Selection, int ParaNum, String[] FieldName, String[] FieldValue,
String[] SubReportName, String[] SubSelection, String Url)
{
reportPath = ReportPath;
selection = Selection;
paraNum = ParaNum;
fieldName = FieldName;
fieldValue = FieldValue;
url = Url;
if (SubReportName != null)
{
subRptName = SubReportName;
subSelection = SubSelection;
}
langID = getLangID(req);
}
public void Set_Data(HttpServletRequest req, String ReportPath, String Selection, int ParaNum, String[] FieldName, String[] FieldValue, String ShowReport, String exportName)
{
reportPath = ReportPath;
selection = Selection;
paraNum = ParaNum;
fieldName = FieldName;
fieldValue = FieldValue;
showReport = ShowReport;
exportFileName = exportName;
langID = getLangID(req);
}
public String Gen_Report() throws Exception
{
String message = "";
if (langID.equalsIgnoreCase(BaseConstants.LANG_ENGLISH))
{
message = "<font face='arial' size='2'>Loading report, please wait ...</font>";
}
else if (langID.equalsIgnoreCase(BaseConstants.LANG_TRADITIONAL_CHINESE ))
{
message = "<font face='新細明體'>正在產生報表,請稍候‧‧‧</font>";
}
else if (langID.equalsIgnoreCase(BaseConstants.LANG_SIMPLIFIED_CHINESE))
{
message = "<font face='Simsun'>正在产生报表,请稍候···</font>";
}
String reportHost = ConfigManager.getConfig("REPORT_HOST");
String uid = ConfigManager.getConfig("DB_USER");
String pwd = ConfigManager.getConfig("DB_PASSWORD");
String dbServer = ConfigManager.getConfig("REPORT_ODBC_DSN");
String reportWebPath = ConfigManager.getConfig("REPORT_WEB_PATH");
String dbName = "";
String appPath = "http://" + reportHost + reportWebPath + showReportASPFileName;
//Generate the content of the submit form
String input ="";
input += "\"";
input += "<html>";
input += "<head>";
input += "<META HTTP-EQUIV=\\\"Content-Type\\\" content=\\\"text/html; charset=utf-8\\\">";
input += "</head>";
input += "<body onLoad='javascript:form1.submit();'>";
input += "<P>" + message + "</P>";
input += "<form name='form1' method='post' action='" + appPath + "'>";
input += ("<input type='hidden' name='DbServer' value='" + dbServer + "' size='100'>");
input += ("<input type='hidden' name='DbName' value='" + dbName + "' size='100'>");
input += ("<input type='hidden' name='Uid' value='" + uid + "' size='100'>");
input += ("<input type='hidden' name='Pwd' value='" + pwd + "' size='100'>");
input += ("<input type='hidden' name='ReportName' value='" + Formatter.replaceAll(reportPath, "\\", "\\\\") + "' size='200'>");
input += ("<input type='hidden' name='Password' value='" + "CRYSTAL" + "' size='100'>");
input += ("<input type='hidden' name='StrSelection' value='" + (selection==null?"":selection) + "' size='500'>");
input += ("<input type='hidden' name='ParaNum' value='" + paraNum + "' size='100'>");
input += ("<input type='hidden' name='showViewer' value='" + showReport + "' size='100'>");
input += ("<input type='hidden' name='exportFileName' value='" + exportFileName + "' size='100'>");
//input para into the form
for(int i=0; i< paraNum; i++)
{
input += ("<input type='hidden' name='txhFieldName" + (i+1) + "' value='" + fieldName[i] + "' size='100'>");
input += ("<input type='hidden' name='txhFieldValue" + (i+1) + "' value='" + fieldValue[i] + "' size='100'>");
}
//input sub-report
if (subRptName != null)
{
input += ("<input type='hidden' name='SubRptNum' value='" + subRptName.length + "' size='100'>");
for(int n=0; n< subRptName.length; n++)
{
input += ("<input type='hidden' name='SubRptName" + (n+1) + "' value='" + subRptName[n] + "' size='100'>");
input += ("<input type='hidden' name='SubSelection" + (n+1) + "' value='" + subSelection[n] + "' size='500'>");
}
}
input += ("<input type='hidden' name='Url' value='" + url + "' size='100'>");
input += "</form>";
input += "</body>";
input += "</html>";
input += "\"";
//Debug
//System.out.println(input);
return input;
}
public String Delete_Report(String exportFileName) throws Exception
{
String reportHost = ConfigManager.getConfig("REPORT_HOST");
String reportWebPath = ConfigManager.getConfig("REPORT_WEB_PATH");
String appPath = "http://"+ reportHost + reportWebPath + "/RemoveExport.asp";
//Generate the content of the submit form
String input ="";
input += "\"";
input += "<html>";
input += "<head>";
input += "<META HTTP-EQUIV=\\\"Content-Type\\\" content=\\\"text/html; charset=utf-8\\\">";
input += "</head>";
input += "<body onLoad='javascript:form1.submit();'>";
input += "<P>deleting report ...</P>";
input += "<form name='form1' method='post' action='" + appPath + "'>";
input += ("<input type='hidden' name='exportFileName' value='" + exportFileName + "' size='100'>");
input += "</form>";
input += "</body>";
input += "</html>";
input += "\"";
System.out.println(input);
return input;
}
public String selectionConvert(String selection)
{
return selection;//.replace("\"", "\\\"");
}
public String getPrintCommand() throws Exception{
StringBuffer cmd = new StringBuffer();
cmd.append("<script language=\"javascript\">\n");
cmd.append("var myWin = window.open( '', 'Report1', 'height=600,width=800,resizable=yes,toolbar=no,menubar=no,left=0,top=0');\n");
cmd.append("myWin.close();\n");
cmd.append("myWin = window.open( '', 'Report1','height=600,width=800,resizable=yes,toolbar=no,menubar=no,left=0,top=0');\n");
cmd.append("myWin.document.write(" + Gen_Report() + ");\n");
cmd.append("myWin.location.reload();\n");
cmd.append("</script>");
return cmd.toString();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -