<%@ Page Language="C#" %>
<%@ Import namespace="System" %>
<%@ Import namespace="System.Data" %>
<%@ Import namespace="System.IO" %>
<%@ Import namespace="System.Threading" %>
<script language="C#" runat="server">
static String [] arrField = {"kmdm", "kmmc", "jd", "qcye", "jfe", "dfe"};
static String [] arrField_PID = {"id", "kmmc", "jd", "qcye", "jfe", "dfe"};
static String [] arrData = {
"101 现金 1 392093.12 223399.1 98300",
"102 银行存款 1",
"10201 招商银行 1 339888.23 200000",
"10202 工商银行 1",
"1020201 工商银行垭口支行 1 209000 200000",
"1020202 工商银行柳沿支行 1 1000 20000.23",
"141 长期投资 1",
"14101 乡村基地项目 1 482025.06",
"14102 合作社项目 1 100000.00 20220",
"201 短期借款 2",
"20101 农经站 2 80000.00 39300",
"20105 员工借款 2",
"2010501 农经部 2",
"201050101 章军 2 100 2000",
"201050102 盛科 2 3092.02 2000",
"201050103 高俊杰 2",
"2010502 维修部 2",
"201050201 张思亮 2 30000 30000",
"201050202 陈倩倩 2 200 100",
"2010503 综合部 2",
"541 管理费用 3",
"54101 干部报酬 3 451660.00",
"54102 办公费 3 12255.30"
};
public void Page_Load(Object sender, EventArgs e) {
Response.ContentType = "text/xml";
String url = HttpContext.Current.Request.Url.OriginalString;
int i = url.IndexOf('?');
if(i > 0) url = url.Substring(0, i);
String format = Request.Params["format"];
String kmdm = Request.Params["kmdm"];
int leftLen = (kmdm == null) ? 0 : kmdm.Length;
if(leftLen>0) Thread.Sleep(500); //故意延缓0.5秒响应
Response.Write("<records>");
int rows = arrData.Length;
for(i=0; i<rows; i++) {
String [] arr = arrData[i].Split('\t');
if(leftLen == 0) {
if(arr[0].Length != 3) continue;
}
else {
if(arr[0].Length != leftLen+2) continue;
if(!arr[0].StartsWith(kmdm)) continue;
}
//main: 3种format
if(format == "byid") {
Response.Write("<record>");
for(int j=0; j<6; j++) {
if(j >= arr.Length) break;
Response.Write("<" +arrField[j]+ ">" +arr[j]+ "</" +arrField[j]+ ">");
}
Response.Write("</record>");
}
else if(format == "bypid") {
Response.Write("<record ");
for(int j=0; j<6; j++) {
if(j >= arr.Length) break;
Response.Write(arrField_PID[j]+ "='" +arr[j]+ "' ");
}
if(leftLen > 0) Response.Write("pid='" +kmdm+ "'");
Response.Write("/>");
}
else if(format == "bydata") {
Response.Write("<record ");
for(int j=0; j<6; j++) {
if(j >= arr.Length) break;
Response.Write(arrField[j]+ "='" +arr[j]+ "' ");
}
if(i < rows-1) {
String ID = arr[0];
arr = arrData[i+1].Split('\t');
if(arr[0].StartsWith(ID)) {
String s = "LazyLoad='" +url + "?format=bydata&kmdm=" + ID + "'";
Response.Write(s);
}
}
Response.Write("/>");
}
}
Response.Write("</records>");
Response.End();
}
</script>