209 lines
8.5 KiB
Plaintext
209 lines
8.5 KiB
Plaintext
<%@ WebHandler Language="C#" Class="MESCommonBase05" %>
|
|
|
|
using System.Web;
|
|
|
|
public class MESCommonBase05 : IHttpHandler
|
|
{
|
|
|
|
public bool IsReusable
|
|
{
|
|
get
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
public void ProcessRequest(HttpContext context)
|
|
{
|
|
string connType = "05";
|
|
//ProcessRequestHttpContext.ProcessRequestServer.ProcessRequestHttpContext(connType, context);
|
|
}
|
|
|
|
//public void ProcessRequestHttpContext(string connType,HttpContext context)
|
|
//{
|
|
// context.Response.ContentType = "application/json";
|
|
// var data = context.Request;
|
|
// var stream = new StreamReader(data.InputStream).ReadToEnd();
|
|
// string InvoiceNum;
|
|
// //JsonData jsonData;
|
|
// string responseText = "NULL";
|
|
// byte[] bytes = null;
|
|
// string fileName = "test.xsl";
|
|
|
|
// try
|
|
// {
|
|
// JsonData jsonData=null;
|
|
// try
|
|
// {
|
|
// jsonData = JsonMapper.ToObject(stream);
|
|
|
|
// }
|
|
// catch(Exception err)
|
|
// { }
|
|
// int type=0;
|
|
// try
|
|
// {
|
|
// if(jsonData!=null)
|
|
// {
|
|
// if(jsonData.ContainsKey("Type"))
|
|
// {
|
|
// type = Int32.Parse( jsonData["Type"].ToString());
|
|
// }else if(jsonData.ContainsKey("type"))
|
|
// {
|
|
// type = Int32.Parse( jsonData["type"].ToString());
|
|
// }
|
|
// }
|
|
// }
|
|
// catch
|
|
// {
|
|
|
|
// }
|
|
// jsonobj dataobj=null;
|
|
// try
|
|
// {
|
|
// dataobj = new JavaScriptSerializer().Deserialize<jsonobj>(stream);
|
|
// if(dataobj!=null)
|
|
// {
|
|
// type = Int32.Parse(dataobj.Type);
|
|
// }
|
|
|
|
// }
|
|
// catch(Exception err)
|
|
// {
|
|
// dataobj = null;
|
|
// }
|
|
|
|
// if(dataobj==null)
|
|
// {
|
|
// try
|
|
// {
|
|
// InvoiceNum = HttpContext.Current.Request["param"];
|
|
// if(InvoiceNum!=null)
|
|
// {
|
|
// jsonData = JsonMapper.ToObject(InvoiceNum);
|
|
// if(jsonData.ContainsKey("Type"))
|
|
// {
|
|
// type = Int32.Parse( jsonData["Type"].ToString());
|
|
// }else if(jsonData.ContainsKey("type"))
|
|
// {
|
|
// type = Int32.Parse( jsonData["type"].ToString());
|
|
// }
|
|
// }
|
|
// }
|
|
// catch
|
|
// {
|
|
// jsonData = null;
|
|
// }
|
|
|
|
// }
|
|
// string fileExtension;
|
|
// HttpFileCollection files;
|
|
// string suffix;
|
|
// string name;
|
|
// switch(type)
|
|
// {
|
|
// case 2001:
|
|
|
|
// DataLink.LogJsonData(connType,jsonData);
|
|
|
|
// MESDownloadExcel.ExcelWebCall.ExcelFile(connType,jsonData,out bytes,out fileName,out fileExtension);
|
|
// fileName = fileName + "."+fileExtension;
|
|
|
|
// HttpContext.Current.Response.ContentType = "application/octet-stream";
|
|
// //HttpContext.Current.Response.ContentType = getContentType(extension);
|
|
// //通知浏览器下载文件而不是打开
|
|
// HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
|
|
// HttpContext.Current.Response.AddHeader("Access-Control-Expose-Headers", "Content-Disposition");
|
|
// HttpContext.Current.Response.BinaryWrite(bytes);
|
|
// HttpContext.Current.Response.Flush();
|
|
// HttpContext.Current.Response.End();
|
|
// break;
|
|
// case 2002:
|
|
// DataLink.LogJsonData(connType,jsonData);
|
|
|
|
// MESDownloadExcel.ExcelWebCall.ExcelFilePdf(connType,jsonData,out bytes,out fileName,out fileExtension);
|
|
// fileName = fileName + "."+fileExtension;
|
|
|
|
// HttpContext.Current.Response.ContentType = "application/octet-stream";
|
|
// //HttpContext.Current.Response.ContentType = getContentType(extension);
|
|
// //通知浏览器下载文件而不是打开
|
|
// HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
|
|
// HttpContext.Current.Response.AddHeader("Access-Control-Expose-Headers", "Content-Disposition");
|
|
// HttpContext.Current.Response.BinaryWrite(bytes);
|
|
// HttpContext.Current.Response.Flush();
|
|
// HttpContext.Current.Response.End();
|
|
|
|
// break;
|
|
// case 15://上传文件
|
|
// files = context.Request.Files;
|
|
// if (files.Count > 0)
|
|
// {
|
|
|
|
// fileName = files[0].FileName;
|
|
// bytes = new byte[files[0].InputStream.Length];
|
|
// files[0].InputStream.Read(bytes, 0, bytes.Length);
|
|
// suffix = fileName.Split(new Char[] { '.' })[1];
|
|
// name = fileName.Split(new Char[] { '.' })[0];
|
|
// DataLinkMesWork.DataLink.ExePROCEDURE_Type15(connType,jsonData, name, suffix, bytes);
|
|
// if(DataLinkMesWork.DataLink.isBakup=="1")
|
|
// {
|
|
// DataLinkMesWork.DataLink.ExePROCEDURE_Type15_Bakup(connType,jsonData, name, suffix, bytes);
|
|
// }
|
|
// }
|
|
// else
|
|
// {
|
|
// fileName = "";
|
|
// bytes = new byte[1];
|
|
// suffix = "";
|
|
// name = "";
|
|
// DataLinkMesWork.DataLink.ExePROCEDURE_Type15(connType,jsonData, name, suffix, bytes);
|
|
// if(DataLinkMesWork.DataLink.isBakup=="1")
|
|
// {
|
|
// DataLinkMesWork.DataLink.ExePROCEDURE_Type15_Bakup(connType,jsonData, name, suffix, bytes);
|
|
// }
|
|
// }
|
|
|
|
// break;
|
|
// case 16://上传文件
|
|
// DataLink.LogJsonData(jsonData);
|
|
// DataLinkMesWork.DataLink.ExePROCEDURE_Type16(connType,jsonData, out bytes, out fileName, out suffix);
|
|
// if (bytes == null) return;
|
|
// fileName = fileName + "."+suffix;
|
|
|
|
// HttpContext.Current.Response.ContentType = "application/octet-stream";
|
|
// //HttpContext.Current.Response.ContentType = getContentType(extension);
|
|
// //通知浏览器下载文件而不是打开
|
|
// HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
|
|
// HttpContext.Current.Response.AddHeader("Access-Control-Expose-Headers", "Content-Disposition");
|
|
// HttpContext.Current.Response.BinaryWrite(bytes);
|
|
// HttpContext.Current.Response.Flush();
|
|
// HttpContext.Current.Response.End();
|
|
// if(DataLinkMesWork.DataLink.isBakup=="1")
|
|
// {
|
|
// DataLinkMesWork.DataLink.ExePROCEDURE_Type16_Bakup(connType,jsonData, out bytes, out fileName, out suffix);
|
|
// }
|
|
// break;
|
|
// default:
|
|
|
|
// DataLink.LogJsonData(jsonData);
|
|
|
|
// responseText = DataLinkMesWork.DataLink.SqlWebCall(connType,type,jsonData,dataobj);//.SqlWebCall(stream);
|
|
|
|
// context.Response.Write(responseText);
|
|
// string isBakup= DataLinkMesWork.DataLink.GetIsBakupByConnType(connType);
|
|
// if(isBakup=="1")
|
|
// {
|
|
// DataLinkMesWork.DataLink.SqlWebCall_Bakup(connType,type,jsonData,dataobj);
|
|
// }
|
|
// break;
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
// catch(Exception err)
|
|
// {
|
|
// context.Response.Write(responseText);
|
|
// }
|
|
//}
|
|
|
|
} |