package com.hyrt.zibo.oa.service;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import java.util.Map;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.ByteArrayBuffer;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.util.Log;
import android.widget.Toast;
import com.hyrt.zibo.oa.tools.AlertDialogFactory;
import com.hyrt.zibo.oa.tools.DialogCallback;
import com.hyrt.zibo.oa.tools.MyTools;
import com.hyrt.zibo.oa.tools.PageBean;
import com.hyrt.zibo.oa.tools.XmlUtil;
import com.hyrt.zibo.oa.ui.BaseDetailActivity;
import com.hyrt.zibo.oa.ui.MainChoice;
/**
*
*@author: liangguofeng
*@create: 2011-6-30
*@project: zibooaandorid
*@describe: 基础服务Service
**/
public class CommonService extends BaseService {
private final String DEBUG_TAG = "CommonService";
private Activity act;
private Map<String, String> params;
private int type;
private String requestType;
private String requestList;
private String[][] args;
public CommonService(Activity currentActivity, Map<String, String> params, int type) {
this.act = currentActivity;
handler = getMsgHandler(currentActivity);
this.params = params;
this.type = type;
}
public void execute() {
new Thread() {
public void doStart() {
if (progressDialog == null || !progressDialog.isShowing()) {
progressDialog = ProgressDialog.show(act, noticeTitle, noticeMsg);
} else {
progressDialog.dismiss();
}
this.start();
}
public void run() {
try {
currentThread = currentThread();
PageBean pageBean = getPageBean();
pageBean.setModeId(type);
switch (type) {
case 101:
requestType = "zbgs";
requestList = "zbgs002";
args = new String[][] { { "PAGENO", pageBean.getPageNo() + "" },
{ "PAGESIZE", pageBean.getPageSize() + "" }, { "ENTREGNO", params.get("ENTREGNO") },
{ "ENTNAME", params.get("ENTNAME") }, { "LEREP", params.get("LEREP") },
{ "LOCALADM", params.get("LOCALADM") } };
break;
case 102:
requestType = "zbgs";
requestList = "zbgs004";
args = new String[][] { { "SUBID", params.get("SUBID") } };
break;
case 104:
requestType = "zbgs";
requestList = "zbgs007";
args = new String[][] { { "AnCheInfoID", params.get("AnCheInfoID") } };
break;
case 105:
requestType = "zbgs";
requestList = "zbgs009";
args = new String[][] { { "MARNO", params.get("MARNO") } };
break;
case 106:
requestType = "zbgs";
requestList = "zbgs011";
args = new String[][] { { "ENTID", params.get("ENTID") } };
break;
case 201:
requestType = "zbgsjg";
requestList = "zbgsjg001";
args = new String[][] { { "PAGENO", pageBean.getPageNo() + "" },
{ "PAGESIZE", pageBean.getPageSize() + "" }, { "ENTREGNO", params.get("ENTREGNO") },
{ "ENTNAME", params.get("ENTNAME") }, { "LEREP", params.get("LEREP") },
{ "LOCALADM", params.get("LOCALADM") } };
break;
case 402:
requestType = "zbgsydzf";
requestList = "zbgsydzf006";
args = new String[][] { { "PAGENO", pageBean.getPageNo() + "" },
{ "PAGESIZE", pageBean.getPageSize() + "" },
{ "INVOLVEDNUMB", params.get("INVOLVEDNUMB") },
{ "INVOLVEDNAME", params.get("INVOLVEDNAME") },
{ "QUERYTYPE", params.get("QUERYTYPE") } };
break;
case 403:
requestType = "zbgsydzf";
requestList = "zbgsydzf002";
args = new String[][] { { "PAGENO", pageBean.getPageNo() + "" },
{ "PAGESIZE", pageBean.getPageSize() + "" }, { "FILLNO", params.get("FILLNO") },
{ "INVPT", params.get("INVPT") }, { "CASENAME", params.get("CASENAME") },
{ "QUERYTYPE", params.get("QUERYTYPE") } };
break;
case 501:
requestType = "zbgsydbg";
requestList = "zbgsydbg001";
args = new String[][] { { "PAGENO", pageBean.getPageNo() + "" },
{ "PAGESIZE", pageBean.getPageSize() + "" },
{"NAME",params.get("NAME")},{ "DATE", params.get("DATE") },
{ "CURUSERNAME", params.get("CURUSERNAME") } };
break;
case 502:
requestType = "zbgsydbg";
requestList = "zbgsydbg003";
args = new String[][] {
{ "PAGENO", pageBean.getPageNo() + "" },
{ "PAGESIZE", pageBean.getPageSize() + "" },
{ "NAME", params.get("NAME") },
{ "DATE", params.get("DATE") },
{"CURUSERNAME", params.get("CURUSERNAME")}
};
break;
case 503:
requestType = "zbgsydbg";
requestList = "zbgsydbg005";
args = new String[][] { { "PAGENO", pageBean.getPageNo() + "" },
{ "PAGESIZE", pageBean.getPageSize() + "" },
{"NAME",params.get("NAME")},
{ "VALUENUMBER", params.get("VALUENUMBER") },
{ "CURUSERNAME", params.get("CURUSERNAME") } };
break;
case 505:
requestType = "zbgsydbg";
requestList = "zbgsydbg007";
args = new String[][] { { "PAGENO", pageBean.getPageNo() + "" },
{ "PAGESIZE", pageBean.getPageSize() + "" },{ "QUERYTYPE", params.get("QUERYTYPE")},
{ "TITLE", params.get("TITLE") }, { "OWNER", params.get("OWNER") }};
break;
case 703:
requestType = "zbgs12315";
requestList = "zbgs12315001";
args = new String[][] { { "PAGENO", pageBean.getPageNo() + "" },
{ "PAGESIZE", pageBean.getPageSize() + "" }, { "DJBM", params.get("DJBM") },
{ "QUERYTYPE", params.get("QUERYTYPE") },
{ "NAME", params.get("NAME") }, { "INVOPT", params.get("INVOPT") },
{ "INFOTYPE", params.get("INFOTYPE") } };
break;
case 8021:
requestType = "zbgs12315";
requestList = "zbgs12315003";
args = new String[][] { { "PAGENO", pageBean.getPageNo() + "" },
{ "PAGESIZE", pageBean.getPageSize() + "" }, { "LICNO", params.get("LICNO") },
{ "ENTNAME", params.get("ENTNAME") }, { "QUERYTYPE", params.get("QUERYTYPE") } };
break;
case 901:
requestType = "zbgsydzf";
requestList = "zbgsydzf004";
args = new String[][] { { "PAGENO", pageBean.getPageNo() + "" },
{ "PAGESIZE", pageBean.getPageSize() + "" }, { "DM", params.get("DM") },
{ "MS", params.get("MS") },
{"QUERYTYPE",params.get("QUERYTYPE")}};
break;
}
pageBean.setArgs(args);
String rs = XmlUtil.writerXml(args);
Log.i(DEBUG_TAG, "+++++++++++++++++Request : " + rs);
rs = agent.mwpiAgent(requestType, rs, requestList, "");
Log.i(DEBUG_TAG, "+++++++++++++++++Response : " + rs);
XmlUtil.getListParserXML(rs, pageBean, type);
toListActivity(act, pageBean);
flag = false;
if (progressDialog != null && progressDialog.isShowing()) {
progressDialog.dismiss();
}
} catch (Exception e) {
// 异常处理
sendExceptionMsg();
}
}
}.doStart();
// 超时检查
addTask(progressDialog, handler);
}
/**
* 检查登录用户名和密码是否正确
*/
public void checkLogin() {
new Thread() {
public void doStart() {
if (progressDialog == null || !progressDialog.isShowing()) {