init: 山西治金技师学院MES管理系统首次入库

This commit is contained in:
XingCheng3
2026-06-08 17:03:11 +08:00
commit 084a2b9d95
82 changed files with 92088 additions and 0 deletions

278
submit/MESCommonBase.ashx Normal file
View File

@@ -0,0 +1,278 @@
<%@ WebHandler Language = "C#" Class="MESCommonBase" %>
using System;
using System.Web;
using Newtonsoft.Json;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using System.Web.Script.Serialization;
using System.Data;
using BasicData;
using DataLinkMesWork;
public class MESCommonBase : IHttpHandler
{
public bool IsReusable
{
get
{
return false;
}
}
public void ProcessRequest(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 3001:
try
{
responseText = DataLinkMesWork.DbCallType1003_SqlCmd.SqlExec(dataobj.Param, jsonData);
}
catch (Exception err){}
context.Response.Write(responseText);
break;
case 2001:
//DataLink.LogJsonData(jsonData);
MESDownloadExcel.ExcelWebCall.ExcelFile(jsonData,out bytes,out fileName,ref 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(jsonData);
MESDownloadExcel.ExcelWebCall.ExcelFilePdf(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 2003:// 合成excel图片下载
string[] dataimg;
if(context.Request.Form.Keys.Count>0)
{
dataimg = data.Form.GetValues(0);
MESDownloadExcel.ExcelWebCall.ExcelFile(jsonData,out bytes,out fileName,ref dataimg[0]);
if (bytes == null) return;
fileName = fileName + "."+dataimg[0];
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(jsonData, out bytes, out fileName, out suffix);
//}
}
break;
case 2004:
//DataLink.LogJsonData(jsonData);
DataLinkMesWork.DataLink.ExePROCEDURE_Type2004(jsonData, out bytes, out fileName, out fileExtension);
//MESDownloadExcel.ExcelWebCall.ExcelFile(jsonData,out bytes,out fileName,ref 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.Substring(fileName.LastIndexOf(".")+1);
name = fileName.Substring(0,fileName.LastIndexOf("."));
responseText = DataLinkMesWork.DataLink.ExePROCEDURE_Type15(jsonData, name, suffix, bytes);
context.Response.Write(responseText);
//if(DataLinkMesWork.DataLink.isBakup=="1")
//{
// DataLinkMesWork.DataLink.ExePROCEDURE_Type15_Bakup(jsonData, name, suffix, bytes);
//}
}
else
{
fileName = "";
bytes = new byte[1];
suffix = "";
name = "";
responseText = DataLinkMesWork.DataLink.ExePROCEDURE_Type15(jsonData, name, suffix, bytes);
context.Response.Write(responseText);
//if(DataLinkMesWork.DataLink.isBakup=="1")
//{
// DataLinkMesWork.DataLink.ExePROCEDURE_Type15_Bakup(jsonData, name, suffix, bytes);
//}
}
break;
case 16://上传文件
DataLink.LogJsonData(jsonData);
DataLinkMesWork.DataLink.ExePROCEDURE_Type16(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(jsonData, out bytes, out fileName, out suffix);
//}
break;
case 4000:
string userIP;
HttpRequest Request = HttpContext.Current.Request;
// 如果使用代理获取真实IP
if (context.Request.ServerVariables["HTTP_X_FORWARDED_FOR"] != "")
userIP = context.Request.ServerVariables["REMOTE_ADDR"];
else
userIP = context.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (userIP == null || userIP == "")
userIP = context.Request.UserHostAddress;
context.Response.Write(userIP);
break;
default:
//DataLink.LogJsonData(jsonData);
responseText = DataLinkMesWork.DataLink.SqlWebCall(type,jsonData,dataobj);
context.Response.Write(responseText);
//if(DataLinkMesWork.DataLink.isBakup=="1")
//{
// DataLinkMesWork.DataLink.SqlWebCall_Bakup(type,jsonData,dataobj);
//}
break;
}
}
catch(Exception err)
{
context.Response.Write(responseText);
}
}
}