當前位置:首頁 » 網頁前端 » webutil
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

webutil

發布時間: 2022-06-23 04:19:06

A. java.lang.IllegalArgumentException: Cannot format given Object as a Number

傳值是對象 不是數字 將傳送到參數轉化一下就好了

B. jquery跨域發送Post請求該怎麼處理

$.ajax({
url:'http://'+licenseServer+'/licenseManager/license/RegistInfo-addRegist?callback=?',
type:'get',
dataType:'jsonp',
data:{
param:paramObj
},
success:function(msg){
if(msg.success){
alert("授權申請已提交成功,請等待管理員審核!");
}
},
error:function(msg){
alert("授權申請提交失敗,請聯系技術服務!");
}
});

上面是前台頁面發出的請求

public void addRegist(){
try {
String callback = this.getRequest().getParameter("callback");
TRegistInfo regist = WebUtil.requestParam2Bean(getRequest(), TRegistInfo.class);
logger.info("callback="+callback);
logger.info(new GsonBuilder().setDateFormat("yyyy-MM-dd").create().toJson(regist));
regist.setScompanyname(new String(regist.getScompanyname().getBytes("ISO-8859-1"),"UTF-8"));
regist.setSlinkman(new String(regist.getSlinkman().getBytes("ISO-8859-1"),"UTF-8"));
regist.setSregistaddress(new String(regist.getSregistaddress().getBytes("ISO-8859-1"),"UTF-8"));
regist.setSremark(new String(regist.getSremark().getBytes("ISO-8859-1"),"UTF-8"));
regist.setDaddtime(new Date());
if(registInfoBiz.save(regist)){
this.writeResponse(callback+"({success:true})");
}else{
this.writeResponse(callback+"({success:false})");
}
} catch (Exception e) {
logger.error(e.toString());
}
}

這後台的代碼包含了業務,希望你能看的懂,關鍵還在於callback

C. int result = DbHelper.ExecuteNonQuery( );C#

sqlParameter是SqlCommand 的參數對象,用於從數據源中選擇對應的數據並將數據放在 DataSet 中

D. Oracle DevSuite 10 中如何將webutil.pll編譯成webutil.plx

在 操作系統環境下
frmcmp_batch MODULE_TYPE=LIBRARY mole=WEBUTIL.pll userid=apps/apps

E. 用iReport導出的txt文件中中文部分成了亂碼,這是什麼原因,如何解決

安裝就不用說了,但是要理解Ireport和JasperReport的關系十分重要,Ireport是設計報表的圖形界面,在Ireport里新建一個報表是以.jrxml的形式保存的,而最終要用到的是將.jrxml的文件編譯為.jsper的文件。.jasper文件就是JaserReport需要調用的報表模版,JasperReport的強大功能就在於它能將.jasper轉化為各種文件的格式,如xls,rtf,pdf等等最常用的文件格式。
要將.jsper文件應用在項目中,首先要做幾樣准備工作:
1.將安裝好的Ireport,找到它下面的lib目錄,再把jasperreports-1.3.0.jar這個包復制出來(這個包是JasperReport導出的關鍵),然後將這個包導入到需要應用的項目中,然後在eclipse中重新構建整個項目,這是最關鍵的第一步。
2.如果導出出現亂碼的問題,需要引入iText亞洲語言包,可以在 http://www.lowagie.com/iText/ 查看關於iText的相關信息,包括源代碼,文檔.
3.設計好報表,將報表編譯為.jsper文件,這些文件在iReport的安裝路徑下,很容易找到。
現在萬事俱備,只欠東風了。我在開始寫程序的的時候,在網上找了好些代碼,而導出的過程中用到的類 JRRtfExporter 的源代碼也踩過,並且發現了 http://www.koders.com 這個非常好的網站,這是開源項目的必備,在上面基本上很多類的源碼也能查到。
接著自己封裝了一個JasperReport類,而這個類可以實現導出各種格式的文件,代碼如下:
packagecommon.ireport;
importnet.sf.jasperreports.engine.*;
importnet.sf.jasperreports.engine.export.*;
importnet.sf.jasperreports.engine.export.JRRtfExporter;
importjava.util.List;
importjava.io.*;
import com.log.Logger;
/**
*IReport+JasperReport導出報表類介面
*<p>Title:導出報表類</p>
*<p>Description:</p>
*<p>Copyright:Copyright(c)2007</p>
*<font class=companyfont>
*CES
*</font>
*@author 野穀子
*@version 1.0.2007.02.14
*/
publicclassJasperReport{
privateLogger logger= newLogger("common.ireport.JasperReport");
/**CreatesanewinstanceofMyReport*/
publicJasperReport(){
}
/*
* 導出單個報表為rtf或word
* @param JasperPrint,OutputStream
* @ 頁面設置response.setContentType("application/msword");
* @ 頁面設置response.setHeader("Content-disposition","attachment;filename=fileName.doc");
* @ 頁面設置response.setContentLength(bytes.length);
*/
publicvoidexportReportToRTF(JasperPrint jasperPrint,OutputStreamout){
JRRtfExporter rtfExporter= newJRRtfExporter();
rtfExporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
rtfExporter.setParameter(JRExporterParameter.OUTPUT_STREAM, out);
try{
rtfExporter.exportReport();
logger.debug("Genertate the RTF report ok! :"+ out);
} catch(JRException e) {
e.printStackTrace();
logger.error("Generate the RTF report file ERROR!");
}
}
/*
* 導出多個報表為rtf或word
* @param List,OutputStream
* @ 頁面設置response.setContentType("application/msword");
* @ 頁面設置response.setHeader("Content-disposition","attachment;filename=fileName.doc");
* @ 頁面設置response.setContentLength(bytes.length);
*/
(List jasperPrints,OutputStream out){
JRRtfExporter rtfExporter= newJRRtfExporter();
rtfExporter.setParameter(JRExporterParameter.JASPER_PRINT_LIST, jasperPrints);
rtfExporter.setParameter(JRExporterParameter.OUTPUT_STREAM, out);
try{
rtfExporter.exportReport();
logger.debug("Genertate the mutiply RTF report ok! :"+ out);
} catch(JRException e) {
e.printStackTrace();
logger.error("Generate the mutiply RTF report file ERROR!");
}
}
/*
* 導出單個報表為PDF
* @param JasperPrint,OutputStream
* @ 頁面設置response.setContentType("application/pdf");
* @ 頁面設置response.setHeader("Content-disposition","attachment;filename=fileName.pdf");
* @ 頁面設置response.setContentLength(bytes.length);
*/
publicvoidexportReportToPDF(JasperPrint jasperPrint,OutputStreamout){
JRPdfExporter pdfExporter = newJRPdfExporter();
pdfExporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
pdfExporter.setParameter(JRExporterParameter.OUTPUT_STREAM, out);
try{
pdfExporter.exportReport();
logger.debug("Genertate the PDF report ok! :"+ out);
} catch(JRException e) {
e.printStackTrace();
logger.error("Generate the PDF report file ERROR!");
}
}
/*
* 導出單個報表為XLS
* @param JasperPrint,OutputStream
* @ 頁面設置response.setContentType("application/vnd.ms-excel");
* @ 頁面設置response.setHeader("Content-disposition","attachment;filename=fileName.xls");
* @ 頁面設置response.setContentLength(bytes.length);
*/
publicvoidexportReportToXLS(JasperPrint jasperPrint,OutputStreamout){
JRXlsExporter xlsExporter= newJRXlsExporter();
xlsExporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
xlsExporter.setParameter(JRExporterParameter.OUTPUT_STREAM, out);
xlsExporter.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.TRUE);
try{
xlsExporter.exportReport();
logger.debug("Genertate the XLS report ok! :"+ out);
} catch(JRException e) {
e.printStackTrace();
logger.error("Generate the XLS report file ERROR!");
}
}
/*
* 導出單個報表為HTML
* @param JasperPrint,OutputStream
* @ 頁面設置response.setContentType("text/html");
* @ 頁面設置response.setHeader("Content-disposition","attachment;filename=fileName.html");
* @ 頁面設置response.setContentLength(bytes.length);
*/
publicvoidexportReportToHTML(JasperPrint jasperPrint,OutputStreamout){
JRHtmlExporter htmlExporter = newJRHtmlExporter();
htmlExporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
htmlExporter.setParameter(JRExporterParameter.OUTPUT_STREAM, out);
htmlExporter.setParameter(JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN, Boolean.FALSE);
htmlExporter.setParameter(JRHtmlExporterParameter.IS_OUTPUT_IMAGES_TO_DIR, Boolean.FALSE);
try{
htmlExporter.exportReport();
logger.debug("Genertate the HTML report ok! :"+ out);
} catch(JRException e) {
e.printStackTrace();
logger.error("Generate the HTML report file ERROR!");
}
}
/*
* 導出單個報表為CSV
* @param JasperPrint,OutputStream
*/
publicvoidexportReportToCSV(JasperPrint jasperPrint,OutputStreamout){
JRCsvExporter csvExporter = newJRCsvExporter();
csvExporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
csvExporter.setParameter(JRExporterParameter.OUTPUT_STREAM, out);
try{
csvExporter.exportReport();
logger.debug("Genertate the CSV report ok! :"+ out);
} catch(JRException e) {
e.printStackTrace();
logger.error("Generate the CSV report file ERROR!");
}
}
/*
* 導出單個報表為TXT
* @param JasperPrint,OutputStream
* @ 頁面設置response.setContentType("text/html");
* @ 頁面設置response.setHeader("Content-disposition","attachment;filename=fileName.txt");
* @ 頁面設置response.setContentLength(bytes.length);
*/
publicvoidexportReportToTXT(JasperPrint jasperPrint,OutputStreamout){
JRTextExporter txtExporter = newJRTextExporter();
txtExporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
txtExporter.setParameter(JRExporterParameter.OUTPUT_STREAM, out);
txtExporter.setParameter(JRTextExporterParameter.CHARACTER_WIDTH, newInteger(80));
txtExporter.setParameter(JRTextExporterParameter.CHARACTER_HEIGHT, newInteger(25));
try{
txtExporter.exportReport();
logger.debug("Genertate the TXT report ok! :"+ out);
} catch(JRException e) {
e.printStackTrace();
logger.error("Generate the TXT report file ERROR!");
}
}
/*
* 導出單個報表為XML
* @param JasperPrint,OutputStream
*/
publicvoidexportReportToXML(JasperPrint jasperPrint,OutputStreamout){
try{
JasperExportManager.exportReportToXmlStream(jasperPrint, out);
logger.debug("Genertate the XML report ok! :"+ out);
} catch(JRException e) {
e.printStackTrace();
logger.error("Generate the XML report file ERROR!");
}
}
}
然後寫了一個Control類用於封裝.jasper文件,並獲取其對象,代碼如下:
packagecommon.ireport;
importnet.sf.jasperreports.engine.*;
importnet.sf.jasperreports.engine.export.*;
importnet.sf.jasperreports.engine.export.JRRtfExporter;
importnet.sf.jasperreports.engine.util.*;
importnet.sf.jasperreports.view.*;
importjava.util.*;
importjava.util.List;
importjava.sql.*;
importjava.io.*;
import java.net.URL;
/**
*導出報表控制類*<p>Title:導出報表控制類</p>
*<p>Description:</p>
*<p>Copyright:Copyright(c)2007</p>
*<font class=companyfont>
*CES
*</font>
*@author 野穀子
*@version 1.0.2007.02.14
*/
publicclassJsperReportControl {
privateLogger logger= newLogger("common.ireport.JsperReportControl");
privateQuery query= newQuery();
//定義報表模版路徑
privateString PREFIX="/ireportFile/";
//定義後綴名
privateString SUFFIX=".jasper";
publicJsperReportControl(){
}
/*
* 取得報表模版的對象
* 單個參數的情況
* @param 報表名稱:strFileName
* @param 參數名稱:strParamName
* @param 參數值:strParamValue
* @return JasperPrint
*/
publicJasperPrint getJsperPrint(String strFileName,String strParamName,String strParamValue) throwsSQLException{
JasperPrint jasperPrint = null;
String strJasper= this.getClassPath() + PREFIX + strFileName + SUFFIX ;
Map params = newHashMap();
params.put(strParamName,strParamValue);
//定義數據源連接對象
Connection conn = null;
query.createConnection(CommonManage.CONN);
conn = query.getConnection();
try{
//用JasperFillManager類導入.jasper文件,參數和數據源
jasperPrint = JasperFillManager.fillReport(strJasper, params, conn);
try{
if(conn==null){
conn.close();
}
}catch(SQLException sqle){
logger.error("關閉資料庫連接錯誤"+sqle);
}
}catch(Exception e){
logger.error("getJsperPrint(String strFileName,String strParamName,String strParamValue) Error"+e);
}
returnjasperPrint;
}
/**
*在類中取得當前文件所在的相對路徑與絕對路徑
*
*@return String
*/
publicStringgetClassPath(){
StringstrClassName=getClass().getName();
StringstrPackageName="";
StringstrURL= "";
if(getClass().getPackage()!=null)
{
strPackageName=getClass().getPackage().getName();
}
//System.out.println("ClassName:"+strClassName);
//System.out.println("PackageName:"+strPackageName);
StringstrClassFileName="";
if(!"".equals(strPackageName))
{
strClassFileName=strClassName.substring(strPackageName.length()+1,strClassName.length());
}
else
{
strClassFileName=strClassName;
}
//System.out.println("ClassFileName:"+strClassFileName);
String strTempName = strClassFileName+".class";
try
{
URLurl=null;
url=getClass().getResource(strClassFileName+".class");
strURL=url.toString();
System.out.println(strURL);
logger.info("strURL="+strURL);
}
catch(Exceptionex)
{
ex.printStackTrace();
}
//取.jasper文件的絕對路徑
strURL= strURL.substring("file:".length(),strURL.length()-strTempName.length());
System.out.println("strURL="+strURL);
returnstrURL;
}
}
期間在取絕對路徑時出現了問題,在本機測試可以通過,但放在伺服器上報錯,原因是本機是windows系統,而伺服器是linux系統,到現在我覺得最大的原因是getClass().getResource()這個方法在linux系統上取不到資源的位置而報錯。
最後就是所寫的 jsp 頁面了 , 代碼如下:
<%@ page import="java.util.Vector"%>
<%@ page import="java.io.*" %>
<%@ page import="java.io.OutputStream" %>
<%@ page import="java.util.List"%>
<%@ page import="net.sf.jasperreports.engine.*" %>
<%@ page import="common.ireport.JsperReportControl"%>
<%@ page import="common.ireport.JasperReport"%>
<%
String strMode = WebUtil.getParam(request,"mode").equals("")?"":WebUtil.getParam(request,"mode");
JsperReportControl jsperReportControl = newJsperReportControl();
JasperReport jasperReport = newJasperReport();
strFileName1 ="quanlitySupervise_page1";
strFileName2 ="quanlitySupervise_page2";
strFileName3 ="quanlitySupervise_page3";
strFileName4 ="quanlitySupervise_page4";
strFileName5 ="quanlitySupervise_page5";
strFileName6 ="quanlitySupervise_page6";
strFileName7 ="quanlitySupervise_page7";
strFileName8 ="quanlitySupervise_page8";
String strParamName="ID";
String strParamValue=strProjectID;
ByteArrayOutputStream baos = newByteArrayOutputStream();
String strQueryConditionTmp="projectName="+strProjectName;
QueryCtrl queryCtrl = newQueryCtrl();
String str="";
if(strMode.equals("out")){
JasperPrint jasperPrint1= jsperReportControl.getJsperPrint(strFileName1,strParamName,strParamValue);
JasperPrint jasperPrint2= jsperReportControl.getJsperPrint(strFileName2,strParamName,strParamValue);
JasperPrint jasperPrint3= jsperReportControl.getJsperPrint(strFileName3,strParamName,strParamValue);
JasperPrint jasperPrint4= jsperReportControl.getJsperPrint(strFileName4,strParamName,strParamValue);
JasperPrint jasperPrint5= jsperReportControl.getJsperPrint(strFileName5,strParamName,strParamValue);
JasperPrint jasperPrint6= jsperReportControl.getJsperPrint(strFileName6,strParamName,strParamValue);
JasperPrint jasperPrint7= jsperReportControl.getJsperPrint(strFileName7,strParamName,strParamValue);
JasperPrint jasperPrint8= jsperReportControl.getJsperPrint(strFileName8,strParamName,strParamValue);
List reportlist = (List)newjava.util.ArrayList();
reportlist.add(jasperPrint1);
reportlist.add(jasperPrint2);
reportlist.add(jasperPrint3);
reportlist.add(jasperPrint4);
reportlist.add(jasperPrint5);
reportlist.add(jasperPrint6);
reportlist.add(jasperPrint7);
reportlist.add(jasperPrint8);
//導出單頁測試用
//jasperReport.exportReportToRTF(jasperPrint1,baos);
//整合多頁導出
jasperReport.exportReportListToRTF(reportlist,baos);
byte[] bytes;
bytes = baos.toByteArray();
response.setContentType("application/ms_word");
String strDocName ="attachment;filename="+strProjectID+".doc";
response.setHeader("Content-disposition",strDocName);
response.setContentLength(bytes.length);
ServletOutputStream ouputStream = response.getOutputStream();
ouputStream.write(bytes, 0, bytes.length);
ouputStream.flush();
ouputStream.close();
}
}
%>
結尾:在本機測試通過了,但放於伺服器出現了錯誤: Can't connect to X11 window server using':0.0' as the value of the DISPLAY
而在 windows 系統中卻能正確運行,原因是程序調用了圖形界面的功能,而 windows 很好的支持圖形界面, linux 卻不能很好的支持,需要修改 linux 中的 DISPLAY 的變數:
下面有幾種方法:
1. 對於 tomcat 伺服器:找到腳本: catalina.sh ,
在 /usr/local/tomcat/bin/catalina.sh 中修改為
JAVA_OPTS="-Djava.awt.headless=true" 或者 CATALINA_OPTS="-Djava.awt.headless=true"
echo "Using CATALINA_BASE:$CATALINA_BASE"
echo "Using CATALINA_HOME:$CATALINA_HOME"
echo "Using CATALINA_TMPDIR:$CATALINA_TMPDIR"
echo "Using RUNJAVA:$_RUNJAVA"
echo "Using JAVA_OPTS:$JAVA_OPTS"
2 .對於伺服器中 oracle 自帶的 JSP server ,找到 jserv.properties 這個配置文件,在上面添加:
wrapper.env=DISPLAY=<SERVERNAME>:0
3 .或者用root身份執行一下xhost +命令,
第一種情況:DISPLAY在遠程資料庫中沒有正確定義,需要:
set DISPLAY=localComputer:0
export DISPLAY(取決於shell的不同而命令不同)
第二種情況:圖形界面的功能不能在遠程登陸的用戶中定義和使用,需要:
使用oracle用戶登錄xwindow:應用xhost +命令
哥們你看我說的對你有幫助嘛我就知道那麼多了

F. easyui 的datagrid請求的時候發送4次請求,是這么回事呢

var grid = $("#dg");
grid.datagrid({
border:false,
fit:true,
idField:"id",
url:'activity/find',
pagination:true,
rownumbers:true,
singleSelect:true,
columns:[[
{field:'id',title:'ID',width:100},
{field:'title',title:'標題',width:300},
{field:'hotline',title:'熱線',width:60},
{field:'status',title:'狀態',width:60,formatter:function(v){
if(v == "1")
return "進行中";
else if(v == "2")
return "已結束";
}},
{field:'order_num',title:'顯示順序',width:60},
{field:'start_time',title:'開始時間',width:100},
{field:'end_time',title:'結束時間',width:100},
{field:'created_time',title:'創建時間', formatter:WebUtil.easyui.formatter.millisecond},
{field:'updated_time',title:'更新時間', formatter:WebUtil.easyui.formatter.millisecond}
]],
toolbar:[{
iconCls:"icon-reload",
text:"刷新",
handler:function(){
grid.datagrid('reload');
}
}, "-", {
iconCls:"icon-add",
text:"添加",
handler:function(){}
},{
iconCls:"icon-edit",
text:"修改",
handler:function(){}
},{
iconCls:"icon-remove",
text:"刪除",
handler:function(){}
}]
});

照這個邏輯寫,同時注意是否其他載入代碼裡面調用了datagrid載入。

G. 怎麼獲取springmvc的參數

問題條理不太清晰
看著很費勁
太長了
回答問題:
前三個參數,具有指定含義的,你的意思是想省略,但又要用到,最好隱藏起來
理論上來說這三個參數可以聲明在類中方法體外,哪些方法需要再進行調用
但實際上這樣線程不安全,多個不同的請求調用同一個,多線程會出問題
所以一般來說都是需要定義在方法形參中

H. C#中UDP地址十進制轉二進制演算法

剛好我前一陣前了一個簡單的協議框架。我也是對二進制、十進制、16進制這些來回轉換很頭疼。當時我是寫一個工具類專門負責各種轉換。下面把這個類的代碼貼出來。


///<summary>
///協議工具
///</summary>
publicclassProtocolUtil
{

///<summary>
///從一個緩沖區復制數據到另一個緩沖區
///</summary>
///<paramname="input">需要復制數據的緩沖區</param>
///<paramname="output">保存結果的緩沖區</param>
///<returns></returns>
publicstaticintCopyBuffer(byte[]input,byte[]output)
{
//if(input.Length<output.Length)
//{
//returnfalse;
//}
intCounter=0;
for(inti=0;i<input.Length&&i<output.Length;i++)
{
output[i]=input[i];
Counter++;
}
returnCounter;

}


///<summary>
///埠轉換成位元組
///</summary>
///<paramname="port"></param>
///<returns></returns>
publicstaticstringPort2Hix(intport)
{
stringResult=port.ToString("X4");
returnResult;
}


///<summary>
///從位元組當中獲取整數,高位在前,可用於埠號、長度
///</summary>
///<remarks>
///注意16進制和10進制的換算。
///byte[]{30,22}對應的是7702
///但是16進制的是3022,對應的是12322
///</remarks>
///<paramname="inputBytes"></param>
///<paramname="start"></param>
///<paramname="size"></param>
///<returns></returns>
publicstaticintGetInt(byte[]inputBytes,intstart,intsize)
{
if(start>=0&&start<inputBytes.Length&&start+size-1<inputBytes.Length)
{
intResult=0;
intk=0;
for(inti=size;i>0;i--)
{
intm=inputBytes[start+i-1];
intn=m*(int)Math.Pow(256f,k);

Result+=n;
k++;
}
returnResult;
}

return0;
}

publicstaticbyte[]StringArr2Buffer(string[]strArr)
{
byte[]Arr1=newbyte[strArr.Length];

for(inti=0;i<strArr.Length;i++)
{
Arr1[i]=String2Byte(strArr[i]);

x.Say(i+":十六進制顯示"+strArr[i]+"byte顯示"+Arr1[i]+"二進制顯示:"+OneZeroString(Arr1[i]));
}
returnArr1;

}

///<summary>
///十六進制的字元串FFEE形式轉換為二進制
///</summary>
///<paramname="s"></param>
///<returns></returns>
publicstaticbyte[]X2String2Bytes(strings)
{
intLen=0;
if(s.Length%2==0)
{
Len=s.Length/2;
}
else
{
Len=s.Length/2+1;
}

byte[]Arr1=newbyte[Len];

for(inti=0;i<Len;i++)
{
stringMM=s.Substring(i*2,2);
Arr1[i]=String2Byte(MM);

x.Say(i+":十六進制顯示"+MM+"byte顯示"+Arr1[i]+"二進制顯示:"+OneZeroString(Arr1[i]));
}
returnArr1;
}


///<summary>
///二進制的01形式轉換成字元串形式,結果就是01110110
///</summary>
///<paramname="input"></param>
///<returns></returns>
(byteinput)
{
returnConvert.ToString(input,2);
}

publicstaticstringByte2String(byteinput)
{

returninput.ToString("X2");
}

publicstaticbyteString2Byte(stringinput)
{
//把字元串認為是16進制數據,轉換成byte
returnbyte.Parse(input,System.Globalization.NumberStyles.HexNumber);

}


}


代碼當中用到了另一個類x,這個是用來在調試的時候輸出信息的。代碼如下。

usingSystem;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Text;
usingSystem.Diagnostics;


namespaceXP
{
///<summary>
///調試的時候,用來跟蹤過程和反應信息類
///</summary>
publicclassx
{
publicstaticvoidSay(stringmsg)
{
if(EnableDebug)
{
Trace.WriteLine(msg);
}
}

publicstaticvoidTimerLog(stringlog)
{
log+="[當前時間:"+DateTime.Now.ToString("yyyyMMddhh:mm:ss.ffff")+"]";
Say(log);
}
///<summary>是否允許開啟Debug模式</summary>
///<remarks>
///通過配置文件開啟Debug模式以後可以在網站運行時提供一些額外的調試信息,輔助診斷問題。
///</remarks>
publicstaticboolEnableDebug
{
get
{
#ifDEBUG
boolResult=true;
if(Result)
returntrue;
#endif
//stringEnableDebugConfig=SA.WebUtil.Common.Config.ConfigReader.CreateInstance().GetConfigItem("EnableDebug");
////stringEnableDebugConfig="1";
//if(String.IsNullOrEmpty(EnableDebugConfig))
//{
//returnfalse;
//}
//if("1"==EnableDebugConfig||"true"==EnableDebugConfig.ToLower())
//returntrue;
returnfalse;
}

}

}
}