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

19
submit/Handler111.ashx Normal file
View File

@@ -0,0 +1,19 @@
<%@ WebHandler Language="C#" Class="Handler111" %>
using System;
using System.Web;
public class Handler111 : IHttpHandler {
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/plain";
context.Response.Write("Hello World");
}
public bool IsReusable {
get {
return false;
}
}
}

View File

@@ -0,0 +1,231 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Runtime.Serialization.Json;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Web.Script.Serialization;
using System.Data;
public class JsonHelper
{
#region 序列化和反序列化
// 序列化
public static string JsonSerializer<T>(T t)
{
// 使用 DataContractJsonSerializer 将 T 对象序列化为内存流。
DataContractJsonSerializer jsonSerializer = new DataContractJsonSerializer(typeof(T));
MemoryStream ms = new MemoryStream();
// 使用 WriteObject 方法将 JSON 数据写入到流中。
jsonSerializer.WriteObject(ms, t);
// 流转字符串
string jsonString = Encoding.UTF8.GetString(ms.ToArray());
ms.Close();
//替换Json的Date字符串
string p = @"\\/Date\((\d+)\+\d+\)\\/";
MatchEvaluator matchEvaluator = new MatchEvaluator(ConvertJsonDateToDateString);
Regex reg = new Regex(p);
jsonString = reg.Replace(jsonString, matchEvaluator);
return jsonString;
}
public static T JsonDeserialize<T>(string jsonString)
{
//将"yyyy-MM-dd HH:mm:ss"格式的字符串转为"\/Date(1294499956278+0800)\/"格式
string p = @"\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}";
MatchEvaluator matchEvaluator = new MatchEvaluator(ConvertDateStringToJsonDate);
Regex reg = new Regex(p);
jsonString = reg.Replace(jsonString, matchEvaluator);
DataContractJsonSerializer jsonSerializer = new DataContractJsonSerializer(typeof(T));
// 字符串转流
MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(jsonString));
// 通过使用 DataContractJsonSerializer 的 ReadObject 方法,将 JSON 编码数据反序列化为T
T obj = (T)jsonSerializer.ReadObject(ms);
return obj;
}
public static string ConvertJsonDateToDateString(Match match)
{
string result = string.Empty;
DateTime dateTime = new DateTime(1970, 1, 1);
dateTime = dateTime.AddMilliseconds(long.Parse(match.Groups[1].Value));
dateTime = dateTime.ToLocalTime();
result = dateTime.ToString("yyyy-MM-dd HH:mm:ss");
return result;
}
private static string ConvertDateStringToJsonDate(Match m)
{
string result = string.Empty;
DateTime dt = DateTime.Parse(m.Groups[0].Value);
dt = dt.ToUniversalTime();
TimeSpan ts = dt - DateTime.Parse("1970-01-01");
result = string.Format("\\/Date({0}+0800)\\/", ts.TotalMilliseconds);
return result;
}
#endregion
// 对象转换为Json
public static string ObjectToJson(object obj)
{
JavaScriptSerializer js = new JavaScriptSerializer();
try
{
return js.Serialize(obj);
}
catch (Exception exception)
{
throw new Exception(exception.Message);
}
}
// 数据表转化为集合
public static List<Dictionary<string, object>> DataTableToList(DataTable dt)
{
List<Dictionary<string, object>> list = new List<Dictionary<string, object>>();
foreach (DataRow dataRow in dt.Rows)
{
Dictionary<string, object> dic = new Dictionary<string, object>();
foreach (DataColumn dc in dt.Columns)
{
dic.Add(dc.ColumnName, dataRow[dc.ColumnName]);
}
list.Add(dic);
}
return list;
}
// 表转换为Json
public static string DataTableToJson(DataTable dt)
{
return ObjectToJson(DataTableToList(dt));
}
/// <summary>
/// 将DataTable中的数据转换成JSON格式
/// </summary>
/// <param name="dt">数据源DataTable</param>
/// <param name="displayCount">是否输出数据总条数</param>
/// <param name="totalcount">JSON中显示的数据总条数</param>
/// <returns></returns>
public static string CreateJsonParameters(DataTable dt, bool displayCount, int totalcount)
{
StringBuilder JsonString = new StringBuilder();
//Exception Handling
if (dt != null)
{
JsonString.Append("{ ");
JsonString.Append("\"rows\":[ ");
for (int i = 0; i < dt.Rows.Count; i++)
{
JsonString.Append("{ ");
for (int j = 0; j < dt.Columns.Count; j++)
{
if (j < dt.Columns.Count - 1)
{
//if (dt.Rows[i][j] == DBNull.Value) continue;
if (dt.Columns[j].DataType == typeof(bool))
{
JsonString.Append("\"JSON_" + dt.Columns[j].ColumnName.ToLower() + "\":" +
dt.Rows[i][j].ToString().ToLower() + ",");
}
else if (dt.Columns[j].DataType == typeof(string))
{
JsonString.Append("\"JSON_" + dt.Columns[j].ColumnName.ToLower() + "\":" + "\"" +
dt.Rows[i][j].ToString().Replace("\"", "\\\"") + "\",");
}
else
{
JsonString.Append("\"JSON_" + dt.Columns[j].ColumnName.ToLower() + "\":" + "\"" + dt.Rows[i][j] + "\",");
}
}
else if (j == dt.Columns.Count - 1)
{
//if (dt.Rows[i][j] == DBNull.Value) continue;
if (dt.Columns[j].DataType == typeof(bool))
{
JsonString.Append("\"JSON_" + dt.Columns[j].ColumnName.ToLower() + "\":" +
dt.Rows[i][j].ToString().ToLower());
}
else if (dt.Columns[j].DataType == typeof(string))
{
JsonString.Append("\"JSON_" + dt.Columns[j].ColumnName.ToLower() + "\":" + "\"" +
dt.Rows[i][j].ToString().Replace("\"", "\\\"") + "\"");
}
else
{
JsonString.Append("\"JSON_" + dt.Columns[j].ColumnName.ToLower() + "\":" + "\"" + dt.Rows[i][j] + "\"");
}
}
}
/*end Of String*/
if (i == dt.Rows.Count - 1)
{
JsonString.Append("} ");
}
else
{
JsonString.Append("}, ");
}
}
JsonString.Append("]");
if (displayCount)
{
JsonString.Append(",");
JsonString.Append("\"total\":");
JsonString.Append(totalcount);
}
JsonString.Append("}");
return JsonString.ToString().Replace("\n", "");
}
else
{
return null;
}
}
StringBuilder result = new StringBuilder();
StringBuilder sb = new StringBuilder();
/// <summary>
/// 根据DataTable生成EasyUI Tree Json树结构
/// </summary>
/// <param name="tabel">数据源</param>
/// <param name="idCol">ID列</param>
/// <param name="txtCol">Text列</param>
/// <param name="url">节点Url</param>
/// <param name="rela">关系字段</param>
/// <param name="pId">父ID</param>
public string GetTreeJsonByTable(DataTable tabel, string idCol, string txtCol, string url, string rela, object pId)
{
result.Append(sb.ToString());
sb.Clear();
if (tabel.Rows.Count > 0)
{
sb.Append("[");
string filer = string.Format("{0}='{1}'", rela, pId);
DataRow[] rows = tabel.Select(filer);
if (rows.Length > 0)
{
foreach (DataRow row in rows)
{
sb.Append("{\"id\":\"" + row[idCol] + "\",\"text\":\"" + row[txtCol] + "\",\"attributes\":\"" + row[url] + "\",\"state\":\"open\"");
if (tabel.Select(string.Format("{0}='{1}'", rela, row[idCol])).Length > 0)
{
sb.Append(",\"children\":");
GetTreeJsonByTable(tabel, idCol, txtCol, url, rela, row[idCol]);
result.Append(sb.ToString());
sb.Clear();
}
result.Append(sb.ToString());
sb.Clear();
sb.Append("},");
}
sb = sb.Remove(sb.Length - 1, 1);
}
sb.Append("]");
result.Append(sb.ToString());
sb.Clear();
}
return result.ToString();
}
}

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);
}
}
}

267
submit/MESCommonBase01.ashx Normal file
View File

@@ -0,0 +1,267 @@
<%@ WebHandler Language="C#" Class="MESCommonBase01" %>
using System;
using System.Web;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using System.Web.Script.Serialization;
using System.Data;
//using BizDataAccess;
using System.Data.SqlClient;//<a href="uploadInvoiceScan.ashx">uploadInvoiceScan.ashx</a>
//using DbCallData;
using BasicData;
//using LitJson;
using DataLinkMesWork;
using System.Text.RegularExpressions;
public class MESCommonBase01 : IHttpHandler
{
public bool IsReusable
{
get
{
return false;
}
}
public void ProcessRequest(HttpContext context)
{
string connType = "01";
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(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(connType,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(connType,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(connType,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(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(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);
//if(DataLinkMesWork.DataLink.isBakup=="1")
//{
// DataLinkMesWork.DataLink.SqlWebCall_Bakup(type,jsonData,dataobj);
//}
break;
}
}
catch(Exception err)
{
context.Response.Write(responseText);
}
}
}

257
submit/MESCommonBase02.ashx Normal file
View File

@@ -0,0 +1,257 @@
<%@ WebHandler Language="C#" Class="MESCommonBase02" %>
using System;
using System.Web;
using System.IO;
using System.Web.Script.Serialization;
using BasicData;
using DataLinkMesWork;
public class MESCommonBase02 : IHttpHandler
{
public bool IsReusable
{
get
{
return false;
}
}
public void ProcessRequest(HttpContext context)
{
string connType = "01";
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(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(connType,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(connType,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(connType,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(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(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);
//if(DataLinkMesWork.DataLink.isBakup=="1")
//{
// DataLinkMesWork.DataLink.SqlWebCall_Bakup(type,jsonData,dataobj);
//}
break;
}
}
catch(Exception err)
{
context.Response.Write(responseText);
}
}
}

253
submit/MESCommonBase03.ashx Normal file
View File

@@ -0,0 +1,253 @@
<%@ WebHandler Language="C#" Class="MESCommonBase03" %>
using System;
using System.Web;
using System.IO;
using System.Web.Script.Serialization;
using BasicData;
using DataLinkMesWork;
public class MESCommonBase03 : IHttpHandler
{
public bool IsReusable
{
get
{
return false;
}
}
public void ProcessRequest(HttpContext context)
{
string connType = "03";
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(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(connType,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(connType,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(connType,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(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(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);
//if(DataLinkMesWork.DataLink.isBakup=="1")
//{
// DataLinkMesWork.DataLink.SqlWebCall_Bakup(type,jsonData,dataobj);
//}
break;
}
}
catch(Exception err)
{
context.Response.Write(responseText);
}
}
}

View File

@@ -0,0 +1,22 @@
<%@ WebHandler Language="C#" Class="MESCommonBase04" %>
using System.Web;
public class MESCommonBase04 : IHttpHandler
{
public bool IsReusable
{
get
{
return false;
}
}
public void ProcessRequest(HttpContext context)
{
string connType = "04";
//ProcessRequestHttpContext.ProcessRequestServer.ProcessRequestHttpContext(connType, context);
}
}

209
submit/MESCommonBase05.ashx Normal file
View File

@@ -0,0 +1,209 @@
<%@ 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);
// }
//}
}

254
submit/MESCommonBase06.ashx Normal file
View File

@@ -0,0 +1,254 @@
<%@ WebHandler Language="C#" Class="MESCommonBase06" %>
using System;
using System.Web;
using System.IO;
using System.Web.Script.Serialization;
using BasicData;
using DataLinkMesWork;
public class MESCommonBase06 : IHttpHandler
{
public bool IsReusable
{
get
{
return false;
}
}
public void ProcessRequest(HttpContext context)
{
string connType = "06";
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(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(connType,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(connType,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(connType,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(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(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);
//if(DataLinkMesWork.DataLink.isBakup=="1")
//{
// DataLinkMesWork.DataLink.SqlWebCall_Bakup(type,jsonData,dataobj);
//}
break;
}
}
catch(Exception err)
{
context.Response.Write(responseText);
}
}
}

254
submit/MESCommonBase07.ashx Normal file
View File

@@ -0,0 +1,254 @@
<%@ WebHandler Language="C#" Class="MESCommonBase07" %>
using System;
using System.Web;
using System.IO;
using System.Web.Script.Serialization;
using BasicData;
using DataLinkMesWork;
public class MESCommonBase07 : IHttpHandler
{
public bool IsReusable
{
get
{
return false;
}
}
public void ProcessRequest(HttpContext context)
{
string connType = "07";
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(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(connType,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(connType,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(connType,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(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(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);
//if(DataLinkMesWork.DataLink.isBakup=="1")
//{
// DataLinkMesWork.DataLink.SqlWebCall_Bakup(type,jsonData,dataobj);
//}
break;
}
}
catch(Exception err)
{
context.Response.Write(responseText);
} }
}

View File

@@ -0,0 +1,21 @@
<%@ WebHandler Language="C#" Class="MESCommonBase08" %>
using System.Web;
public class MESCommonBase08 : IHttpHandler
{
public bool IsReusable
{
get
{
return false;
}
}
public void ProcessRequest(HttpContext context)
{
string connType = "08";
//ProcessRequestHttpContext.ProcessRequestServer.ProcessRequestHttpContext(connType, context);
}
}

View File

@@ -0,0 +1,21 @@
<%@ WebHandler Language="C#" Class="MESCommonBase09" %>
using System.Web;
public class MESCommonBase09 : IHttpHandler
{
public bool IsReusable
{
get
{
return false;
}
}
public void ProcessRequest(HttpContext context)
{
string connType = "09";
//ProcessRequestHttpContext.ProcessRequestServer.ProcessRequestHttpContext(connType, context);
}
}

View File

@@ -0,0 +1,21 @@
<%@ WebHandler Language="C#" Class="MESCommonBase10" %>
using System.Web;
public class MESCommonBase10 : IHttpHandler
{
public bool IsReusable
{
get
{
return false;
}
}
public void ProcessRequest(HttpContext context)
{
string connType = "10";
//ProcessRequestHttpContext.ProcessRequestServer.ProcessRequestHttpContext(connType, context);
}
}

View File

@@ -0,0 +1,117 @@
<%@ WebHandler Language="C#" Class="DownloadHandler" %>
using System;
using System.Web;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Web.Script.Serialization;
using System.IO;
using System.Net;
using System.Web.Services;
using System.Text;
using BasicData;
using DataLinkMesWork;
using MESDownloadExcel;
public class DownloadHandler : IHttpHandler
{
/// <summary>
/// 00 标准DataTable
/// 01 计划工时模板
/// 02 外协加工任务单
/// 03 外购备料请款
/// 04 自家项目报表
/// 05 材料清单
/// </summary>
/// <param name="context"></param>
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "application/json";
var data = context.Request;
var stream = new StreamReader(data.InputStream).ReadToEnd();
//JsonData jsonData;
//string responseText = "NULL";
byte[] bytes = null;
string fileName = "test.xsl";
try
{
string InvoiceNum = HttpContext.Current.Request["param"];
JsonData jsonData = JsonMapper.ToObject(InvoiceNum);
DataLink.LogJsonData(jsonData);
MESDownloadExcel.ExcelWebCall.ExcelFile(jsonData,out bytes,out fileName);
fileName = fileName + ".xls";
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();
return;
}
catch (Exception ex)
{
return;
}
}
///// <summary>
///// Unicode编码(汉字转换为\uxxx)
///// </summary>
///// <param name="str"></param>
///// <returns></returns>
//public static string EnUnicode(string str)
//{
// StringBuilder strResult = new StringBuilder();
// if (!string.IsNullOrEmpty(str))
// {
// for (int i = 0; i < str.Length; i++)
// {
// strResult.Append("\\u");
// strResult.Append(((int)str[i]).ToString("x"));
// }
// }
// return strResult.ToString();
//}
///// <summary>
///// Unicode解码\uxxxx转换为汉字
///// </summary>
///// <param name="str"></param>
///// <returns></returns>
//public static string DeUnicode(string str)
//{
// //最直接的方法Regex.Unescape(str);
// Regex reg = new Regex(@"(?i)\\[uU]([0-9a-f]{4})");
// return reg.Replace(str, delegate(Match m) { return ((char)Convert.ToInt32(m.Groups[1].Value, 16)).ToString(); });
//}
// /// <summary>
///// Unicode解码
///// </summary>
///// <param name="str"></param>
///// <returns></returns>
//public static string DeUnicode(string str)
//{
// //最直接的方法Regex.Unescape(str);
// Regex reg = new Regex(@"(?i)\\[uU]([0-9a-f]{4})");
// return reg.Replace(str, delegate (Match m) { return ((char)Convert.ToInt32(m.Groups[1].Value, 16)).ToString(); });
//}
public bool IsReusable
{
get
{
return false;
}
}
}

View File

@@ -0,0 +1,117 @@
<%@ WebHandler Language="C#" Class="DownloadHandler" %>
using System;
using System.Web;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Web.Script.Serialization;
using System.IO;
using System.Net;
using System.Web.Services;
using System.Text;
using BasicData;
using DataLinkMesWork;
using MESDownloadExcel;
public class DownloadHandler : IHttpHandler
{
/// <summary>
/// 00 标准DataTable
/// 01 计划工时模板
/// 02 外协加工任务单
/// 03 外购备料请款
/// 04 自家项目报表
/// 05 材料清单
/// </summary>
/// <param name="context"></param>
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "application/json";
var data = context.Request;
var stream = new StreamReader(data.InputStream).ReadToEnd();
//JsonData jsonData;
//string responseText = "NULL";
byte[] bytes = null;
string fileName = "test.xsl";
try
{
string InvoiceNum = HttpContext.Current.Request["param"];
JsonData jsonData = JsonMapper.ToObject(InvoiceNum);
DataLink.LogJsonData(jsonData);
MESDownloadExcel.ExcelWebCallDemo.ExcelFile(jsonData,out bytes,out fileName);
fileName = fileName + ".xls";
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();
return;
}
catch (Exception ex)
{
return;
}
}
///// <summary>
///// Unicode编码(汉字转换为\uxxx)
///// </summary>
///// <param name="str"></param>
///// <returns></returns>
//public static string EnUnicode(string str)
//{
// StringBuilder strResult = new StringBuilder();
// if (!string.IsNullOrEmpty(str))
// {
// for (int i = 0; i < str.Length; i++)
// {
// strResult.Append("\\u");
// strResult.Append(((int)str[i]).ToString("x"));
// }
// }
// return strResult.ToString();
//}
///// <summary>
///// Unicode解码\uxxxx转换为汉字
///// </summary>
///// <param name="str"></param>
///// <returns></returns>
//public static string DeUnicode(string str)
//{
// //最直接的方法Regex.Unescape(str);
// Regex reg = new Regex(@"(?i)\\[uU]([0-9a-f]{4})");
// return reg.Replace(str, delegate(Match m) { return ((char)Convert.ToInt32(m.Groups[1].Value, 16)).ToString(); });
//}
// /// <summary>
///// Unicode解码
///// </summary>
///// <param name="str"></param>
///// <returns></returns>
//public static string DeUnicode(string str)
//{
// //最直接的方法Regex.Unescape(str);
// Regex reg = new Regex(@"(?i)\\[uU]([0-9a-f]{4})");
// return reg.Replace(str, delegate (Match m) { return ((char)Convert.ToInt32(m.Groups[1].Value, 16)).ToString(); });
//}
public bool IsReusable
{
get
{
return false;
}
}
}

View File

@@ -0,0 +1,52 @@
<%@ WebHandler Language="C#" Class="DownloadHandler" %>
using System;
using System.Web;
using System.Data;
using System.Collections.Generic;
using System.Linq;
//using BizDataAccess;
using System.IO;
using System.Net;
using System.Web.Services;
using System.Text;
public class DownloadHandler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
string filePath = "../webpage/part";
filePath = HttpContext.Current.Server.MapPath(filePath);
string id = HttpContext.Current.Request["id"];
filePath = filePath + "/" + id;
string name = HttpContext.Current.Request["name"];
try
{
System.IO.FileStream fs = new System.IO.FileStream(filePath, System.IO.FileMode.Open);
byte[] bytes = new byte[(int)fs.Length];
fs.Read(bytes, 0, bytes.Length);
fs.Close();
HttpContext.Current.Response.ContentType = "application/octet-stream";
//HttpContext.Current.Response.ContentType = getContentType(extension);
//通知浏览器下载文件而不是打开
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(name, System.Text.Encoding.UTF8));
HttpContext.Current.Response.BinaryWrite(bytes);
HttpContext.Current.Response.Flush();
HttpContext.Current.Response.End();
return;
}
catch (Exception ex)
{
return;
}
}
public bool IsReusable
{
get
{
return false;
}
}
}

View File

@@ -0,0 +1,76 @@
<%@ WebHandler Language="C#" Class="MESCommonBase" %>
using System;
using System.Web;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using System.Web.Script.Serialization;
using System.Data;
//using BizDataAccess;
using System.Data.SqlClient;
//using DbCallData;
//using BasicData;
using System.Net.Mail;
using System.Net.Mime;
using System.Timers;
using System.Xml;
using System.Net;
public class MESCommonBase : IHttpHandler
{
public bool IsReusable
{
get
{
return false;
}
}
public int message;
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
string Uid = HttpContext.Current.Request["Uid"];
string Key = HttpContext.Current.Request["Key"];
string smsMob = HttpContext.Current.Request["smsMob"];
string smsText = HttpContext.Current.Request["smsText"];
try
{
string url = "http://utf8.api.smschinese.cn/?Uid=" + Uid + "&Key=" + Key + "&smsMob=" + smsMob + "&smsText=" + smsText;
string relust = GetHtmlFromUrl(url);
context.Response.Write(Convert.ToInt16(relust));
}
catch (Exception ex)
{
return;
}
}
public string GetHtmlFromUrl(string url)
{
string strRet = null;
if(url==null || url.Trim().ToString()=="")
{
return strRet;
}
string targeturl = url.Trim().ToString();
try
{
HttpWebRequest hr = (HttpWebRequest)WebRequest.Create(targeturl);
hr.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";
hr.Method = "GET";
hr.Timeout = 30 * 60 * 1000;
WebResponse hs = hr.GetResponse();
Stream sr = hs.GetResponseStream();
StreamReader ser = new StreamReader(sr, Encoding.Default);
strRet = ser.ReadToEnd();
}
catch (Exception ex)
{
strRet = null;
}
return strRet;
}
}

157
submit/MESUpload.ashx Normal file
View File

@@ -0,0 +1,157 @@
<%@ WebHandler Language="C#" Class="UploadHandler" %>
using System;
using System.Web;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Net;
using System.Web.Services;
using System.Text;
using DataLinkMesWork;
using System.Data.SqlClient;
public class UploadHandler : IHttpHandler
{
private static string connectionString = System.Configuration.ConfigurationManager.AppSettings.GetValues("ConnectionString")[0].ToString();
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
string filePath = "../webpage/part";
filePath = HttpContext.Current.Server.MapPath(filePath);
string num = HttpContext.Current.Request["num"];
string tableName = HttpContext.Current.Request["tableName"];
string result = "";
bool isOK;
var stream = new StreamReader(context.Request.InputStream).ReadToEnd();
JsonData jsonData = JsonMapper.ToObject(stream);
//DataLink.LogJsonData(jsonData);
try
{
Guid guid = Guid.NewGuid();
string uid = guid.ToString().Replace("-", "").ToUpper();
HttpFileCollection files = context.Request.Files;
if (files.Count > 0)
{
for (int i = 0; i < files.Count; i++)
{
HttpPostedFile hpFile = files[0];
if (hpFile.ContentLength > 0)
{
string fileName = System.IO.Path.GetFileName(hpFile.FileName);
string suffix = fileName.Split(new Char[] { '.' })[1];
string name = fileName.Split(new Char[] { '.' })[0];
string sql = "insert into " + tableName + " (num, uid, name, suffix, 是否启用) values(" + num + ",'" + uid + "','" + name + "','" + suffix + "'," + '1' + ")";
isOK =DataLinkMesWork.DataLink.ExecuteNonQuery(sql);
//--业务代码 1
//-- 1 发货管理_附件
//-- 2 合同信息管理_履约保证金_履约保函
//-- 3 合同管理_文件路径
//-- 4 PDM_机床总图_文件列表
//-- 5 采购管理_采购发票_附件
//-- 6 车间采购管理_发票结算申请单
//-- 7 设备管理_设备监控_图片
//-- 8 车间生产管理_质检管理
//-- 9 人员管理_图片
//--10 tableName
//SET ANSI_NULLS ON
//GO
//SET QUOTED_IDENTIFIER ON
//GO
//ALTER PROCEDURE [dbo].[_文件存储_高精_增加]
// @业务代码 int,
// @文件标识 int,
// @文件名称 nvarchar(150),
// @文件后缀 nvarchar(50),
// @文件内容 varbinary(max)
// as
//SET NOCOUNT ON;
//INSERT INTO [dbo].[_文件存储_高精](业务代码,[文件标识],[文件名称],[文件后缀],[文件内容])
// VALUES(@业务代码,@文件标识,@文件名称,@文件后缀,@文件内容)
//isOK = SQLCommon.ExecuteNonQuery(sql, connectionString, out result);
//isOK = SQLCommon.ExecuteNonQuery(sql, connectionString, out result);
if (isOK)
{
try
{
filePath = filePath + "/" + uid + "." + suffix;
hpFile.SaveAs(filePath);
result = "[{ \"result\":\"1\"}]";
}
catch
{
}
}
else
{
result = "[{ \"result\":\"0\"}]";
}
try
{
//增加文件保存到数据库的功能
byte[]bytes = new byte[files[0].InputStream.Length];
files[0].InputStream.Read(bytes, 0, bytes.Length);
string procedureName = "_文件存储_高精_增加";
string errorMessage;
SqlParameter []thisParms = new SqlParameter[5];
thisParms[0] = new SqlParameter("@业务代码", 10);
thisParms[1] = new SqlParameter("@文件标识", uid);
thisParms[2] = new SqlParameter("@文件名称", name);
thisParms[3] = new SqlParameter("@文件后缀", suffix);
thisParms[4] = new SqlParameter("@文件内容", bytes);
DataLinkMesWork.DataLink.ExecuteStoredProcedure(procedureName, ref thisParms, out errorMessage);
if(DataLinkMesWork.DataLink.isBakup=="1")
{
DataLinkMesWork.DataLink.ExecuteNonQuery_Bakup(sql);
DataLinkMesWork.DataLink.ExecuteStoredProcedure_Bakup(procedureName, ref thisParms, out errorMessage);
}
}
catch
{
}
}
else
{
context.Response.Write(result);
}
}
}
}
catch (Exception ex)
{
result = "[{ \"result\":\"0\"}]";
}
context.Response.Write(result);
}
public bool IsReusable
{
get
{
return false;
}
}
}

103
submit/MESUploadFile.ashx Normal file
View File

@@ -0,0 +1,103 @@
<%@ WebHandler Language="C#" Class="UploadHandler" %>
using System;
using System.Web;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Net;
using System.Web.Services;
using System.Text;
using DataLinkMesWork;
using System.Data.SqlClient;
public class UploadHandler : IHttpHandler
{
private static string connectionString = System.Configuration.ConfigurationManager.AppSettings.GetValues("ConnectionString")[0].ToString();
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
string filePath = "../webpage/part";
filePath = HttpContext.Current.Server.MapPath(filePath);
string num = HttpContext.Current.Request["num"];
string tableName = HttpContext.Current.Request["tableName"];
string result = "";
bool isOK;
try
{
Guid guid = Guid.NewGuid();
string uid = guid.ToString().Replace("-", "").ToUpper();
HttpFileCollection files = context.Request.Files;
if (files.Count > 0)
{
for (int i = 0; i < files.Count; i++)
{
HttpPostedFile hpFile = files[0];
if (hpFile.ContentLength > 0)
{
string fileName = System.IO.Path.GetFileName(hpFile.FileName);
string suffix = fileName.Split(new Char[] { '.' })[1];
string name = fileName.Split(new Char[] { '.' })[0];
string sql = "insert into " + tableName + " (num, uid, name, suffix, 是否启用) values(" + num + ",'" + uid + "','" + name + "','" + suffix + "'," + '1' + ")";
isOK = DataLinkMesWork.DataLink.ExecuteNonQuery(sql);
//isOK = SQLCommon.ExecuteNonQuery(sql, connectionString, out result);
if (isOK)
{
filePath = filePath + "/" + uid + "." + suffix;
hpFile.SaveAs(filePath);
result = "[{ \"result\":\"1\"}]";
}
else
{
result = "[{ \"result\":\"0\"}]";
}
try
{
//增加文件保存到数据库的功能
byte[]bytes = new byte[files[0].InputStream.Length];
files[0].InputStream.Read(bytes, 0, bytes.Length);
string procedureName = "_文件存储_高精_增加";
string errorMessage;
SqlParameter []thisParms = new SqlParameter[5];
thisParms[0] = new SqlParameter("@业务代码", 10);
thisParms[1] = new SqlParameter("@文件标识", uid);
thisParms[2] = new SqlParameter("@文件名称", name);
thisParms[3] = new SqlParameter("@文件后缀", suffix);
thisParms[4] = new SqlParameter("@文件内容", bytes);
DataLinkMesWork.DataLink.ExecuteStoredProcedure(procedureName, ref thisParms, out errorMessage);
if(DataLinkMesWork.DataLink.isBakup=="1")
{
DataLinkMesWork.DataLink.ExecuteNonQuery_Bakup(sql);
}
}
catch
{
}
}
else
{
context.Response.Write(result);
}
}
}
}
catch (Exception ex)
{
result = "[{ \"result\":\"0\"}]";
}
context.Response.Write(result);
}
public bool IsReusable
{
get
{
return false;
}
}
}

52
submit/downloadFile.ashx Normal file
View File

@@ -0,0 +1,52 @@
<%@ WebHandler Language="C#" Class="DownloadHandler" %>
using System;
using System.Web;
using System.Data;
using System.Collections.Generic;
using System.Linq;
//using BizDataAccess;
using System.IO;
using System.Net;
using System.Web.Services;
using System.Text;
public class DownloadHandler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
string filePath = "../webpage/file";
filePath = HttpContext.Current.Server.MapPath(filePath);
string id = HttpContext.Current.Request["id"];
filePath = filePath + "/" + id;
string name = HttpContext.Current.Request["name"];
try
{
System.IO.FileStream fs = new System.IO.FileStream(filePath, System.IO.FileMode.Open);
byte[] bytes = new byte[(int)fs.Length];
fs.Read(bytes, 0, bytes.Length);
fs.Close();
HttpContext.Current.Response.ContentType = "application/octet-stream";
//HttpContext.Current.Response.ContentType = getContentType(extension);
//通知浏览器下载文件而不是打开
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(name, System.Text.Encoding.UTF8));
HttpContext.Current.Response.BinaryWrite(bytes);
HttpContext.Current.Response.Flush();
HttpContext.Current.Response.End();
return;
}
catch (Exception ex)
{
return;
}
}
public bool IsReusable
{
get
{
return false;
}
}
}

View File

@@ -0,0 +1,52 @@
<%@ WebHandler Language="C#" Class="DownloadHandler" %>
using System;
using System.Web;
using System.Data;
using System.Collections.Generic;
using System.Linq;
//using BizDataAccess;
using System.IO;
using System.Net;
using System.Web.Services;
using System.Text;
public class DownloadHandler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
string filePath = "../webpage/file";
filePath = HttpContext.Current.Server.MapPath(filePath);
string id = HttpContext.Current.Request["id"];
filePath = filePath + "/" + id;
string name = HttpContext.Current.Request["name"];
try
{
System.IO.FileStream fs = new System.IO.FileStream(filePath, System.IO.FileMode.Open);
byte[] bytes = new byte[(int)fs.Length];
fs.Read(bytes, 0, bytes.Length);
fs.Close();
HttpContext.Current.Response.ContentType = "application/octet-stream";
//HttpContext.Current.Response.ContentType = getContentType(extension);
//通知浏览器下载文件而不是打开
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(name, System.Text.Encoding.UTF8));
HttpContext.Current.Response.BinaryWrite(bytes);
HttpContext.Current.Response.Flush();
HttpContext.Current.Response.End();
return;
}
catch (Exception ex)
{
return;
}
}
public bool IsReusable
{
get
{
return false;
}
}
}

View File

@@ -0,0 +1,164 @@
<%@ WebHandler Language="C#" Class="excel" %>
using System;
using System.Web;
using SystemFramework;
using WriteExcel;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using DataLinkMesWork;
public class excel : IHttpHandler {
HttpContext contextMesWebFun;
public void ProcessRequest (HttpContext context) {
string ss;
DataLinkMesWork.DataLink.InitSystem(out ss);
//if (!InitSystemReg(out resultReg))
//{
// return resultReg;
//}
contextMesWebFun = context; ;
context.Response.ContentType = "text/plain";
string type = contextMesWebFun.Request["type"];
string responseText = "";
byte[] bytes=null;
switch (type)
{
//扫描信息
case "Excel_NewArrivalList":
bytes= Excel_NewArrivalList();
HttpContext.Current.Response.ContentType = "application/ms-excel";
//通知浏览器下载文件而不是打开
HttpContext.Current.Response.AddHeader("Content-Disposition", "filename="+ HttpUtility.UrlEncode("OutsourcingMaterialsSearch.xls", 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;
}
}
/// <summary>
/// 外购模板
/// </summary>
/// <returns></returns>
public byte[] Excel_NewArrivalList()
{
string value = null;
byte[] bytes=null;
try
{
System.Data.DataTable dt = null;
string folename = HttpContext.Current.Request["folename"];
string rec1 = HttpContext.Current.Request["rec1"];
string rec2 = HttpContext.Current.Request["rec2"];
string rec3 = HttpContext.Current.Request["rec3"];
string rec4 = HttpContext.Current.Request["rec4"];
List<string> str = new List<string>();
str.Add(rec1);
str.Add(rec2);
str.Add(rec3);
str.Add(rec4);
Hashtable ht=null;
pushHtDt1(str,out ht);
string sql = HttpContext.Current.Request["sql"];
Excel_NewArrivalList_SQL( out dt);
WriteExcel. Form1 frm = new Form1();
bytes = frm.demo1(folename, ht, dt);
}
catch (Exception err)
{
}
return bytes;
}
// 将固定参数传入哈希表
private void pushHtDt1(List<string> str ,out Hashtable htDt1)
{
htDt1 = new Hashtable();
for (int i = 0; i < str.Count; i++)
{
htDt1.Add(i, str[i].ToString());
}
}
static public void Excel_NewArrivalList_SQL(out DataTable dt)
{
ParamData[] paramData = new ParamData[1];
paramData[0].name = "到货单流水号";
paramData[0].value = "39";
string procedureName = "备料管理_到货单明细查询";
SqlParameter[] thisParms = new SqlParameter[1];
thisParms[0] = new System.Data.SqlClient.SqlParameter("@到货单流水号", "39");
SqlCmd.ExecuteStoredProcedure(procedureName, ref paramData, out dt);
}
//public static bool ExecuteStoredProcedure(string procedureName, ref SqlParameter[] sqlParameters, out DataTable dt)
//{
// string errorMessage;
// DataSet ds;
// ExecuteStoredProcedure(procedureName, "server=192.168.1.140;database=ERPTOOL_GJ;uid=sa;pwd=126.com;Connection Reset=FALSE;Max Pool Size = 1000", ref sqlParameters,out ds, out errorMessage);
// try
// {
// dt = ds.Tables[0];
// return true;
// }
// catch
// {
// dt = null;
// return false;
// }
//}
//public static bool ExecuteStoredProcedure(string procedureName, string connectionString, ref SqlParameter[] sqlParameters, out DataSet ds, out string errorMessage)
//{
// bool result = false;
// errorMessage = "";
// ds = new DataSet();
// using (SqlConnection conn = new SqlConnection(connectionString))
// {
// try
// {
// conn.Open();
// using (SqlDataAdapter dsCommand = new SqlDataAdapter())
// {
// dsCommand.SelectCommand = new SqlCommand(procedureName, conn);
// dsCommand.SelectCommand.CommandType = CommandType.StoredProcedure;
// for (int i = 0; i < sqlParameters.Length; i++)
// {
// dsCommand.SelectCommand.Parameters.Add(sqlParameters[i]);
// }
// dsCommand.Fill(ds);
// }
// result = true;
// }
// catch (Exception e)
// {
// errorMessage = e.ToString();
// //TestConnection();
// ApplicationLog.WriteLog(e, "\r\nExecuteStoredProcedure\r\n存储过程\r\n" + procedureName + "\r\n连接字符串\r\n" + connectionString);
// }
// finally
// {
// if (conn.State == ConnectionState.Open)
// conn.Close();
// }
// }
// return result;
//}
public bool IsReusable {
get {
return false;
}
}
}

164
submit/excel.ashx.exclude Normal file
View File

@@ -0,0 +1,164 @@
<%@ WebHandler Language="C#" Class="excel" %>
using System;
using System.Web;
using SystemFramework;
using WriteExcel;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using DataLinkMesWork;
public class excel : IHttpHandler {
HttpContext contextMesWebFun;
public void ProcessRequest (HttpContext context) {
string ss;
DataLinkMesWork.DataLink.InitSystem(out ss);
//if (!InitSystemReg(out resultReg))
//{
// return resultReg;
//}
contextMesWebFun = context; ;
context.Response.ContentType = "text/plain";
string type = contextMesWebFun.Request["type"];
string responseText = "";
byte[] bytes=null;
switch (type)
{
//扫描信息
case "Excel_NewArrivalList":
bytes= Excel_NewArrivalList();
HttpContext.Current.Response.ContentType = "application/ms-excel";
//通知浏览器下载文件而不是打开
HttpContext.Current.Response.AddHeader("Content-Disposition", "filename="+ HttpUtility.UrlEncode("OutsourcingMaterialsSearch.xls", 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;
}
}
/// <summary>
/// 外购模板
/// </summary>
/// <returns></returns>
public byte[] Excel_NewArrivalList()
{
string value = null;
byte[] bytes=null;
try
{
System.Data.DataTable dt = null;
string folename = HttpContext.Current.Request["folename"];
string rec1 = HttpContext.Current.Request["rec1"];
string rec2 = HttpContext.Current.Request["rec2"];
string rec3 = HttpContext.Current.Request["rec3"];
string rec4 = HttpContext.Current.Request["rec4"];
List<string> str = new List<string>();
str.Add(rec1);
str.Add(rec2);
str.Add(rec3);
str.Add(rec4);
Hashtable ht=null;
pushHtDt1(str,out ht);
string sql = HttpContext.Current.Request["sql"];
Excel_NewArrivalList_SQL( out dt);
WriteExcel. Form1 frm = new Form1();
bytes = frm.demo1(folename, ht, dt);
}
catch (Exception err)
{
}
return bytes;
}
// 将固定参数传入哈希表
private void pushHtDt1(List<string> str ,out Hashtable htDt1)
{
htDt1 = new Hashtable();
for (int i = 0; i < str.Count; i++)
{
htDt1.Add(i, str[i].ToString());
}
}
static public void Excel_NewArrivalList_SQL(out DataTable dt)
{
ParamData[] paramData = new ParamData[1];
paramData[0].name = "到货单流水号";
paramData[0].value = "39";
string procedureName = "备料管理_到货单明细查询";
SqlParameter[] thisParms = new SqlParameter[1];
thisParms[0] = new System.Data.SqlClient.SqlParameter("@到货单流水号", "39");
SqlCmd.ExecuteStoredProcedure(procedureName, ref paramData, out dt);
}
//public static bool ExecuteStoredProcedure(string procedureName, ref SqlParameter[] sqlParameters, out DataTable dt)
//{
// string errorMessage;
// DataSet ds;
// ExecuteStoredProcedure(procedureName, "server=192.168.1.140;database=ERPTOOL_GJ;uid=sa;pwd=126.com;Connection Reset=FALSE;Max Pool Size = 1000", ref sqlParameters,out ds, out errorMessage);
// try
// {
// dt = ds.Tables[0];
// return true;
// }
// catch
// {
// dt = null;
// return false;
// }
//}
//public static bool ExecuteStoredProcedure(string procedureName, string connectionString, ref SqlParameter[] sqlParameters, out DataSet ds, out string errorMessage)
//{
// bool result = false;
// errorMessage = "";
// ds = new DataSet();
// using (SqlConnection conn = new SqlConnection(connectionString))
// {
// try
// {
// conn.Open();
// using (SqlDataAdapter dsCommand = new SqlDataAdapter())
// {
// dsCommand.SelectCommand = new SqlCommand(procedureName, conn);
// dsCommand.SelectCommand.CommandType = CommandType.StoredProcedure;
// for (int i = 0; i < sqlParameters.Length; i++)
// {
// dsCommand.SelectCommand.Parameters.Add(sqlParameters[i]);
// }
// dsCommand.Fill(ds);
// }
// result = true;
// }
// catch (Exception e)
// {
// errorMessage = e.ToString();
// //TestConnection();
// ApplicationLog.WriteLog(e, "\r\nExecuteStoredProcedure\r\n存储过程\r\n" + procedureName + "\r\n连接字符串\r\n" + connectionString);
// }
// finally
// {
// if (conn.State == ConnectionState.Open)
// conn.Close();
// }
// }
// return result;
//}
public bool IsReusable {
get {
return false;
}
}
}

View File

@@ -0,0 +1,322 @@
<%@ WebHandler Language="C#" Class="MESCommonBase" %>
using System;
using System.Web;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using System.Web.Script.Serialization;
using System.Data;
using BizDataAccess;
using System.Data.SqlClient;
using DbCallData;
using BasicData;
public class MESCommonBase : IHttpHandler
{
public bool IsReusable
{
get
{
return false;
}
}
private static string connectionString = System.Configuration.ConfigurationManager.AppSettings.GetValues("ConnectionString")[0].ToString();
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "application/json";
var data = context.Request;
var stream = new StreamReader(data.InputStream).ReadToEnd();
var dataobj = new JavaScriptSerializer().Deserialize<jsonobj>(stream);
string responseText = "NULL";
try
{
responseText = DbCallData.DbCom.DbCall(dataobj);
context.Response.Write(responseText);
}
catch
{
context.Response.Write(responseText);
}
}
//有参数 没有返回值
//public static bool ExecuteStoredProcedure(string procedureName, string connectionString, ref SqlParameter[] sqlParameters, out string errorMessage)
//有参数 有返回值
//public static bool ExecuteStoredProcedure(string procedureName, string connectionString, ref SqlParameter[] sqlParameters, out DataSet ds, out string errorMessage)
//无参数 有返回值
//public static bool ExecuteStoredProcedure(string procedureName, string connectionString, out DataTable dt, out string errorMessage)
//public static bool ExecuteStoredProcedure(string procedureName, string connectionString, out DataSet ds, out string errorMessage)
/// <summary>
/// 执行存储过程
/// </summary>
/// <param name="json"></param>
/// <returns></returns>
//private string ExePROCEDURE(jsonobj json)
//{
// string result = "";
// DataSet ds = null;
// try
// {
// if (json.HasReturn)//执行有返回值的存储过程
// {
// if (json.Param == "" || json.Param == null)//执行没有参数的存储过程
// {
// SQLCommon.ExecuteStoredProcedure(json.Name, connectionString, out ds, out result);
// }
// else//执行有参数的存储过程
// {
// string[] parmas;
// SqlParameter[] thisParms;
// try
// {
// parmas = json.Param.Split('|');
// thisParms = new SqlParameter[parmas.Length];
// for (int i = 0; i < parmas.Length; i++)
// {
// string[] pp = parmas[i].Split('&');
// object inputValue=null;
// if(pp.Length==3)
// {
// switch (pp[2])
// {
// case "Int":
// inputValue = Convert.ToInt32( pp[1]);
// break;
// case "String":
// inputValue = pp[2];
// break;
// case "Boolean":
// inputValue = Convert.ToBoolean( pp[1]);
// break;
// case "DateTime":
// inputValue = Convert.ToDateTime( pp[1]);
// break;
// default:
// inputValue = pp[1];
// break;
// }
// thisParms[i] = new SqlParameter(pp[0], inputValue);
// }
// else if(pp.Length==2)
// {
// thisParms[i] = new SqlParameter(pp[0], pp[1]);
// }
// }
// }
// catch (Exception)
// {
// return result = "参数有误,请检查参数的格式是否正确";
// }
// SQLCommon.ExecuteStoredProcedure(json.Name, connectionString, ref thisParms, out ds, out result);
// }
// }
// else//执行没有返回值的存储过程
// {
// if (json.Param == "" || json.Param == null)//执行没有参数的存储过程
// {
// SQLCommon.ExecuteStoredProcedure(json.Name, connectionString, out ds, out result);
// }
// else//执行有参数的存储过程
// {
// string[] parmas;
// SqlParameter[] thisParms;
// try
// {
// parmas = json.Param.Split('|');
// thisParms = new SqlParameter[parmas.Length];
// for (int i = 0; i < parmas.Length; i++)
// {
// string[] pp = parmas[i].Split('&');
// thisParms[i] = new SqlParameter(pp[0], pp[1]);
// }
// }catch (Exception)
// {
// return result = "参数有误,请检查参数的格式是否正确";
// }
// SQLCommon.ExecuteStoredProcedure(json.Name, connectionString, ref thisParms, out result);
// }
// }
// if (ds != null && ds.Tables.Count > 0)
// {
// result = JsonHelper.DataTableToJson(ds.Tables[0]);
// }
// }
// catch (Exception ex)
// {
// result = ex.Message;
// }
// return result;
//}
/// <summary>
/// 执行存储过程 无返回值
/// </summary>
/// <param name="json"></param>
/// <returns></returns>
//private string ExePROCEDURE2(jsonobj json)
//{
// string result = "";
// DataSet ds = null;
// try
// {
// if (json.HasReturn)//执行有返回值的存储过程
// {
// if (json.Param == "" || json.Param == null)//执行没有参数的存储过程
// {
// SQLCommon.ExecuteStoredProcedure(json.Name, connectionString, out ds, out result);
// }
// else//执行有参数的存储过程
// {
// string[] parmas;
// SqlParameter[] thisParms;
// try
// {
// parmas = json.Param.Split('|');
// thisParms = new SqlParameter[parmas.Length];
// for (int i = 0; i < parmas.Length; i++)
// {
// string[] pp = parmas[i].Split('&');
// object inputValue=null;
// if(pp.Length==3)
// {
// switch (pp[2])
// {
// case "Int":
// inputValue = Convert.ToInt32( pp[1]);
// break;
// case "String":
// inputValue = pp[2];
// break;
// case "Boolean":
// inputValue = Convert.ToBoolean( pp[1]);
// break;
// case "DateTime":
// inputValue = Convert.ToDateTime( pp[1]);
// break;
// default:
// inputValue = pp[1];
// break;
// }
// thisParms[i] = new SqlParameter(pp[0], inputValue);
// }
// else if(pp.Length==2)
// {
// thisParms[i] = new SqlParameter(pp[0], pp[1]);
// }
// }
// }
// catch (Exception)
// {
// return result = "参数有误,请检查参数的格式是否正确";
// }
// SQLCommon.ExecuteStoredProcedure(json.Name, connectionString, ref thisParms, out ds, out result);
// }
// }
// else//执行没有返回值的存储过程
// {
// if (json.Param == "" || json.Param == null)//执行没有参数的存储过程
// {
// SQLCommon.ExecuteStoredProcedure(json.Name, connectionString, out ds, out result);
// }
// else//执行有参数的存储过程
// {
// string[] parmas;
// SqlParameter[] thisParms;
// try
// {
// parmas = json.Param.Split('|');
// thisParms = new SqlParameter[parmas.Length];
// for (int i = 0; i < parmas.Length; i++)
// {
// string[] pp = parmas[i].Split('&');
// thisParms[i] = new SqlParameter(pp[0], pp[1]);
// }
// }catch (Exception)
// {
// return result = "参数有误,请检查参数的格式是否正确";
// }
// SQLCommon.ExecuteStoredProcedure(json.Name, connectionString, ref thisParms, out result);
// }
// }
// if (ds != null && ds.Tables.Count > 0)
// {
// result = JsonHelper.DataTableToJson(ds.Tables[0]);
// }
// }
// catch (Exception ex)
// {
// result = ex.Message;
// }
// return result;
//}
/// <summary>
/// 执行SQL语句
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
//private string ExeSQL(jsonobj obj)
//{
// string result = "";
// try
// {
// if (obj.HasReturn)//执行有返回值的sql
// {
// if (obj.Param == "")//执行没有参数的存储过程
// {
// //SQLCommon.ExecuteDataset();
// }
// else//执行有参数的存储过程
// {
// }
// }
// else//执行没有返回值的sql
// {
// if (obj.Param == "")//执行没有参数的存储过程
// {
// //SQLCommon.ExecuteStoredProcedure(obj.Name, connectionString, out ds, out result);
// }
// else//执行有参数的存储过程
// {
// }
// }
// }
// catch (Exception ex)
// {
// result = ex.Message;
// }
// return result;
//}
//[Serializable]
//class jsonobj
//{
// public string Type;
// public string Name;
// public string Param;
// public bool HasReturn;
//}
}

122
submit/upload2.ashx Normal file
View File

@@ -0,0 +1,122 @@
<%@ WebHandler Language="C#" Class="UploadHandler" %>
using System;
using System.Web;
using System.Data;
using System.Collections.Generic;
using System.Linq;
//using BizDataAccess;
using System.IO;
using System.Net;
using System.Web.Services;
using System.Text;
using DataLinkMesWork;
using System.Data.SqlClient;
public class UploadHandler : IHttpHandler
{
private static string connectionString = System.Configuration.ConfigurationManager.AppSettings.GetValues("ConnectionString")[0].ToString();
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
string filePath = "../webpage/img";
filePath = HttpContext.Current.Server.MapPath(filePath);
string InvoiceNum = HttpContext.Current.Request["InvoiceNum"];
string result = "";
if(InvoiceNum == "null" || InvoiceNum == "" || InvoiceNum == "undefined")
{
result = "[{ \"result\":\"0\"}]";
context.Response.Write(result);
}
bool isOK;
try
{
Guid guid = Guid.NewGuid();
string uid = guid.ToString().Replace("-", "").ToUpper();
HttpFileCollection files = context.Request.Files;
if (files.Count > 0)
{
for (int i = 0; i < files.Count; i++)
{
HttpPostedFile hpFile = files[0];
if (hpFile.ContentLength > 0)
{
string fileName = System.IO.Path.GetFileName(hpFile.FileName);
string suffix = fileName.Split(new Char[] { '.' })[1];
string Name = fileName.Split(new Char[] { '.' })[0];
string sql = "insert into 发货管理_附件 values(" + InvoiceNum + ",'" + uid + '.' + suffix + "','" + '1' + "')";
isOK = DataLinkMesWork.DataLink.ExecuteNonQuery(sql);
//--业务代码 1
//-- 1 发货管理_附件
//-- 2 合同信息管理_履约保证金_履约保函
//-- 3 合同管理_文件路径
//-- 4 PDM_机床总图_文件列表
//-- 5 采购管理_采购发票_附件
//-- 6 车间采购管理_发票结算申请单
//-- 7 设备管理_设备监控_图片
//-- 8 车间生产管理_质检管理
//-- 9 人员管理_图片
//--10 tableName
if (isOK)
{
filePath = filePath + "/" + uid + "." + suffix;
hpFile.SaveAs(filePath);
result = "[{ \"result\":\"1\"}]";
}
else
{
result = "[{ \"result\":\"0\"}]";
}
try
{
//增加文件保存到数据库的功能
byte[]bytes = new byte[files[0].InputStream.Length];
files[0].InputStream.Read(bytes, 0, bytes.Length);
string procedureName = "_文件存储_高精_增加";
string errorMessage;
SqlParameter []thisParms = new SqlParameter[5];
thisParms[0] = new SqlParameter("@业务代码", 1);
thisParms[1] = new SqlParameter("@文件标识", uid);
thisParms[2] = new SqlParameter("@文件名称", Name);
thisParms[3] = new SqlParameter("@文件后缀", suffix);
thisParms[4] = new SqlParameter("@文件内容", bytes);
DataLinkMesWork.DataLink.ExecuteStoredProcedure(procedureName, ref thisParms, out errorMessage);
if(DataLinkMesWork.DataLink.isBakup=="1")
{
DataLinkMesWork.DataLink.ExecuteNonQuery_Bakup(sql);
DataLinkMesWork.DataLink.ExecuteStoredProcedure_Bakup(procedureName, ref thisParms, out errorMessage);
}
}
catch
{
}
}
else
{
context.Response.Write(result);
}
}
}
}
catch (Exception ex)
{
result = "[{ \"result\":\"0\"}]";
}
context.Response.Write(result);
}
public bool IsReusable
{
get
{
return false;
}
}
}

127
submit/upload3.ashx Normal file
View File

@@ -0,0 +1,127 @@
<%@ WebHandler Language="C#" Class="UploadHandler" %>
using System;
using System.Web;
using System.Data;
using System.Collections.Generic;
using System.Linq;
//using BizDataAccess;
using System.IO;
using System.Net;
using System.Web.Services;
using System.Text;
using DataLinkMesWork;
using System.Data.SqlClient;
public class UploadHandler : IHttpHandler
{
private static string connectionString = System.Configuration.ConfigurationManager.AppSettings.GetValues("ConnectionString")[0].ToString();
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
string filePath = "../webpage/img";
filePath = HttpContext.Current.Server.MapPath(filePath);
string ProjectId = HttpContext.Current.Request["ProjectId"];
string result = "";
if(ProjectId == "null" || ProjectId == "" || ProjectId == "undefined")
{
result = "[{ \"result\":\"0\"}]";
context.Response.Write(result);
}
bool isOK;
try
{
Guid guid = Guid.NewGuid();
string uid = guid.ToString().Replace("-", "").ToUpper();
HttpFileCollection files = context.Request.Files;
if (files.Count > 0)
{
for (int i = 0; i < files.Count; i++)
{
HttpPostedFile hpFile = files[0];
if (hpFile.ContentLength > 0)
{
string fileName = System.IO.Path.GetFileName(hpFile.FileName);
string suffix = fileName.Split(new Char[] { '.' })[1];
string Name = fileName.Split(new Char[] { '.' })[0];
string sql = "insert into 合同信息管理_履约保证金_履约保函 values(" + ProjectId + ",'" + uid + '.' + suffix + "','" + '1' + "')";
isOK = DataLinkMesWork.DataLink.ExecuteNonQuery(sql);
//--业务代码 1
//-- 1 发货管理_附件
//-- 2 合同信息管理_履约保证金_履约保函
//-- 3 合同管理_文件路径
//-- 4 PDM_机床总图_文件列表
//-- 5 采购管理_采购发票_附件
//-- 6 车间采购管理_发票结算申请单
//-- 7 设备管理_设备监控_图片
//-- 8 车间生产管理_质检管理
//-- 9 人员管理_图片
//--10 tableName
if (isOK)
{
filePath = filePath + "/" + uid + "." + suffix;
hpFile.SaveAs(filePath);
result = "[{ \"result\":\"1\"}]";
}
else
{
result = "[{ \"result\":\"0\"}]";
}
try
{
//增加文件保存到数据库的功能
byte[]bytes = new byte[files[0].InputStream.Length];
files[0].InputStream.Read(bytes, 0, bytes.Length);
string procedureName = "_文件存储_高精_增加";
string errorMessage;
SqlParameter []thisParms = new SqlParameter[5];
thisParms[0] = new SqlParameter("@业务代码", 2);
thisParms[1] = new SqlParameter("@文件标识", uid);
thisParms[2] = new SqlParameter("@文件名称", Name);
thisParms[3] = new SqlParameter("@文件后缀", suffix);
thisParms[4] = new SqlParameter("@文件内容", bytes);
DataLinkMesWork.DataLink.ExecuteStoredProcedure(procedureName, ref thisParms, out errorMessage);
if(DataLinkMesWork.DataLink.isBakup=="1")
{
DataLinkMesWork.DataLink.ExecuteNonQuery_Bakup(sql);
DataLinkMesWork.DataLink.ExecuteStoredProcedure_Bakup(procedureName, ref thisParms, out errorMessage);
}
}
catch
{
}
}
else
{
context.Response.Write(result);
}
}
}
}
catch (Exception ex)
{
result = "[{ \"result\":\"0\"}]";
}
context.Response.Write(result);
}
public bool IsReusable
{
get
{
return false;
}
}
}

117
submit/uploadFile.ashx Normal file
View File

@@ -0,0 +1,117 @@
<%@ WebHandler Language="C#" Class="UploadHandler" %>
using System;
using System.Web;
using System.Data;
using System.Collections.Generic;
using System.Linq;
//using BizDataAccess;
using System.IO;
using System.Net;
using System.Web.Services;
using System.Text;
using DataLinkMesWork;
using System.Data.SqlClient;
public class UploadHandler : IHttpHandler
{
private static string connectionString = System.Configuration.ConfigurationManager.AppSettings.GetValues("ConnectionString")[0].ToString();
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
string filePath = "../webpage/file";
filePath = HttpContext.Current.Server.MapPath(filePath);
string ProjectNum = HttpContext.Current.Request["ProjectNum"];
string result = "";
bool isOK;
try
{
Guid guid = Guid.NewGuid();
string uid = guid.ToString().Replace("-", "").ToUpper();
HttpFileCollection files = context.Request.Files;
if (files.Count > 0)
{
for (int i = 0; i < files.Count; i++)
{
HttpPostedFile hpFile = files[0];
if (hpFile.ContentLength > 0)
{
string fileName = System.IO.Path.GetFileName(hpFile.FileName);
string suffix = fileName.Split(new Char[] { '.' })[1];
string Name = fileName.Split(new Char[] { '.' })[0];
string sql = "insert into 合同管理_文件路径 values(" + ProjectNum + ",'" + uid + "','" + Name + "','" + suffix + "'," + '1' + ")";
isOK = DataLinkMesWork.DataLink.ExecuteNonQuery(sql);
//--业务代码 1
//-- 1 发货管理_附件
//-- 2 合同信息管理_履约保证金_履约保函
//-- 3 合同管理_文件路径
//-- 4 PDM_机床总图_文件列表
//-- 5 采购管理_采购发票_附件
//-- 6 车间采购管理_发票结算申请单
//-- 7 设备管理_设备监控_图片
//-- 8 车间生产管理_质检管理
//-- 9 人员管理_图片
//--10 tableName
if (isOK)
{
filePath = filePath + "/" + uid + "." + suffix;
hpFile.SaveAs(filePath);
result = "[{ \"result\":\"1\"}]";
}
else
{
result = "[{ \"result\":\"0\"}]";
}
try
{
//增加文件保存到数据库的功能
byte[]bytes = new byte[files[0].InputStream.Length];
files[0].InputStream.Read(bytes, 0, bytes.Length);
string procedureName = "_文件存储_高精_增加";
string errorMessage;
SqlParameter []thisParms = new SqlParameter[5];
thisParms[0] = new SqlParameter("@业务代码", 3);
thisParms[1] = new SqlParameter("@文件标识", uid);
thisParms[2] = new SqlParameter("@文件名称", Name);
thisParms[3] = new SqlParameter("@文件后缀", suffix);
thisParms[4] = new SqlParameter("@文件内容", bytes);
DataLinkMesWork.DataLink.ExecuteStoredProcedure(procedureName, ref thisParms, out errorMessage);
if(DataLinkMesWork.DataLink.isBakup=="1")
{
DataLinkMesWork.DataLink.ExecuteNonQuery_Bakup(sql);
DataLinkMesWork.DataLink.ExecuteStoredProcedure_Bakup(procedureName, ref thisParms, out errorMessage);
}
}
catch
{
}
}
else
{
context.Response.Write(result);
}
}
}
}
catch (Exception ex)
{
result = "[{ \"result\":\"0\"}]";
}
context.Response.Write(result);
}
public bool IsReusable
{
get
{
return false;
}
}
}

View File

@@ -0,0 +1,119 @@
<%@ WebHandler Language="C#" Class="UploadHandler" %>
using System;
using System.Web;
using System.Data;
using System.Collections.Generic;
using System.Linq;
//using BizDataAccess;
using System.IO;
using System.Net;
using System.Web.Services;
using System.Text;
using DataLinkMesWork;
using System.Data.SqlClient;
public class UploadHandler : IHttpHandler
{
private static string connectionString = System.Configuration.ConfigurationManager.AppSettings.GetValues("ConnectionString")[0].ToString();
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
string filePath = "../webpage/file";
filePath = HttpContext.Current.Server.MapPath(filePath);
string MachineNum = HttpContext.Current.Request["MachineNum"];
string result = "";
bool isOK;
try
{
Guid guid = Guid.NewGuid();
string uid = guid.ToString().Replace("-", "").ToUpper();
HttpFileCollection files = context.Request.Files;
if (files.Count > 0)
{
for (int i = 0; i < files.Count; i++)
{
HttpPostedFile hpFile = files[0];
if (hpFile.ContentLength > 0)
{
string fileName = System.IO.Path.GetFileName(hpFile.FileName);
string suffix = fileName.Split(new Char[] { '.' })[1];
string Name = fileName.Split(new Char[] { '.' })[0];
string sql = "insert into PDM_机床总图_文件列表 values(" + MachineNum + ",'" + uid + "','" + Name + "','" + suffix + "'," + '1' + ")";
isOK = DataLinkMesWork.DataLink.ExecuteNonQuery(sql);
//--业务代码 1
//-- 1 发货管理_附件
//-- 2 合同信息管理_履约保证金_履约保函
//-- 3 合同管理_文件路径
//-- 4 PDM_机床总图_文件列表
//-- 5 采购管理_采购发票_附件
//-- 6 车间采购管理_发票结算申请单
//-- 7 设备管理_设备监控_图片
//-- 8 车间生产管理_质检管理
//-- 9 人员管理_图片
//--10 tableName
if (isOK)
{
filePath = filePath + "/" + uid + "." + suffix;
hpFile.SaveAs(filePath);
result = "[{ \"result\":\"1\"}]";
}
else
{
result = "[{ \"result\":\"0\"}]";
}
try
{
//增加文件保存到数据库的功能
byte[]bytes = new byte[files[0].InputStream.Length];
files[0].InputStream.Read(bytes, 0, bytes.Length);
string procedureName = "_文件存储_高精_增加";
string errorMessage;
SqlParameter []thisParms = new SqlParameter[5];
thisParms[0] = new SqlParameter("@业务代码", 4);
thisParms[1] = new SqlParameter("@文件标识", uid);
thisParms[2] = new SqlParameter("@文件名称", Name);
thisParms[3] = new SqlParameter("@文件后缀", suffix);
thisParms[4] = new SqlParameter("@文件内容", bytes);
DataLinkMesWork.DataLink.ExecuteStoredProcedure(procedureName, ref thisParms, out errorMessage);
if(DataLinkMesWork.DataLink.isBakup=="1")
{
DataLinkMesWork.DataLink.ExecuteNonQuery_Bakup(sql);
DataLinkMesWork.DataLink.ExecuteStoredProcedure_Bakup(procedureName, ref thisParms, out errorMessage);
}
}
catch
{
}
}
else
{
context.Response.Write(result);
}
}
}
}
catch (Exception ex)
{
result = "[{ \"result\":\"0\"}]";
}
context.Response.Write(result);
}
public bool IsReusable
{
get
{
return false;
}
}
}

View File

@@ -0,0 +1,165 @@
<%@ WebHandler Language="C#" Class="UploadHandler" %>
using System;
using System.Web;
using System.Data;
using System.Collections.Generic;
using System.Linq;
//using BizDataAccess;
using System.IO;
using System.Net;
using System.Web.Services;
using System.Text;
using System.Data.SqlClient;
using DataLinkMesWork;
public class UploadHandler : IHttpHandler
{
private static string connectionString = System.Configuration.ConfigurationManager.AppSettings.GetValues("ConnectionString")[0].ToString();
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
string filePath = "../webpage/file";
filePath = HttpContext.Current.Server.MapPath(filePath);
string invoiceNum = HttpContext.Current.Request["invoiceNum"];
string money = HttpContext.Current.Request["money"];
string supplierValue = HttpContext.Current.Request["supplierValue"];
string paid = HttpContext.Current.Request["paid"];
string unpaid = HttpContext.Current.Request["unpaid"];
string tax = HttpContext.Current.Request["tax"];
string isCost = HttpContext.Current.Request["isCost"];
string remark = HttpContext.Current.Request["remark"];
int applyOrderNum = 0; // 发票结算申请单流水号
string result = "";
bool isOK1;
bool isOK2;
try
{
Guid guid = Guid.NewGuid();
string uid = guid.ToString().Replace("-", "").ToUpper();
HttpFileCollection files = context.Request.Files;
if (files.Count > 0)
{
for (int i = 0; i < files.Count; i++)
{
HttpPostedFile hpFile = files[0];
if (hpFile.ContentLength > 0)
{
string fileName = System.IO.Path.GetFileName(hpFile.FileName);
string suffix = fileName.Split(new Char[] { '.' })[1];
string Name = fileName.Split(new Char[] { '.' })[0];
string procedureName = "采购管理_发票结算申请单_增加数据";
string errorMessage;
SqlParameter[] thisParms = new SqlParameter[9];
thisParms[0] = new SqlParameter("@发票结算申请单流水号", applyOrderNum);
thisParms[1] = new SqlParameter("@发票号", invoiceNum);
thisParms[2] = new SqlParameter("@发票金额", money);
thisParms[3] = new SqlParameter("@供应商流水号", supplierValue);
thisParms[4] = new SqlParameter("@已付款项", paid);
thisParms[5] = new SqlParameter("@尚欠金额", unpaid);
thisParms[6] = new SqlParameter("@税额", tax);
thisParms[7] = new SqlParameter("@是否费用类", isCost);
thisParms[8] = new SqlParameter("@备注", remark);
thisParms[0].Direction = ParameterDirection.Output;
isOK1 = DataLinkMesWork.DataLink.ExecuteStoredProcedure(procedureName, ref thisParms, out errorMessage);
applyOrderNum = Convert.ToInt32(thisParms[0].Value);
//--业务代码 1
//-- 1 发货管理_附件
//-- 2 合同信息管理_履约保证金_履约保函
//-- 3 合同管理_文件路径
//-- 4 PDM_机床总图_文件列表
//-- 5 采购管理_采购发票_附件
//-- 6 车间采购管理_发票结算申请单
//-- 7 设备管理_设备监控_图片
//-- 8 车间生产管理_质检管理
//-- 9 人员管理_图片
//--10 tableName
if (isOK1)
{
string sql2 = "insert into 采购管理_采购发票_附件 values(" + applyOrderNum + ",'" + uid + "','" + Name + "','" + suffix + "'," + '1' + ")";
isOK2 = DataLinkMesWork.DataLink.ExecuteNonQuery(sql2);
if (isOK2)
{
filePath = filePath + "/" + uid + "." + suffix;
hpFile.SaveAs(filePath);
result = "[{ \"result\":\"1\"}]";
}
else
{
result = "[{ \"result\":\"0\"}]";
}
}
else
{
result = "[{ \"result\":\"0\"}]";
}
try
{
//增加文件保存到数据库的功能
byte[]bytes = new byte[files[0].InputStream.Length];
files[0].InputStream.Read(bytes, 0, bytes.Length);
string procedureName1 = "_文件存储_高精_增加";
string errorMessage1;
SqlParameter []thisParms1 = new SqlParameter[5];
thisParms1[0] = new SqlParameter("@业务代码", 5);
thisParms1[1] = new SqlParameter("@文件标识", uid);
thisParms1[2] = new SqlParameter("@文件名称", Name);
thisParms1[3] = new SqlParameter("@文件后缀", suffix);
thisParms1[4] = new SqlParameter("@文件内容", bytes);
DataLinkMesWork.DataLink.ExecuteStoredProcedure(procedureName1, ref thisParms1, out errorMessage1);
if(DataLinkMesWork.DataLink.isBakup=="1")
{
isOK1 = DataLinkMesWork.DataLink.ExecuteStoredProcedure_Bakup(procedureName, ref thisParms, out errorMessage);
applyOrderNum = Convert.ToInt32(thisParms[0].Value);
if (isOK1)
{
DataLinkMesWork.DataLink.ExecuteStoredProcedure_Bakup(procedureName1, ref thisParms1, out errorMessage1);
string sql2 = "insert into 采购管理_采购发票_附件 values(" + applyOrderNum + ",'" + uid + "','" + Name + "','" + suffix + "'," + '1' + ")";
isOK2 = DataLinkMesWork.DataLink.ExecuteNonQuery_Bakup(sql2);
}
else
{
//result = "[{ \"result\":\"0\"}]";
}
}
}
catch
{
}
}
else
{
context.Response.Write(result);
}
}
}
}
catch (Exception ex)
{
result = "[{ \"result\":\"0\"}]";
}
context.Response.Write(result);
}
public bool IsReusable
{
get
{
return false;
}
}
}

View File

@@ -0,0 +1,183 @@
<%@ WebHandler Language="C#" Class="UploadHandler" %>
using System;
using System.Web;
using System.Data;
using System.Collections.Generic;
using System.Linq;
//using BizDataAccess;
using System.IO;
using System.Net;
using System.Web.Services;
using System.Text;
using System.Data.SqlClient;
using DataLinkMesWork;
public class UploadHandler : IHttpHandler
{
private static string connectionString = System.Configuration.ConfigurationManager.AppSettings.GetValues("ConnectionString")[0].ToString();
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
string filePath = "../webpage/file";
filePath = HttpContext.Current.Server.MapPath(filePath);
string invoiceNum = HttpContext.Current.Request["invoiceNum"];
string money = HttpContext.Current.Request["money"];
string supplierValue = HttpContext.Current.Request["supplierValue"];
string paid = HttpContext.Current.Request["paid"];
string unpaid = HttpContext.Current.Request["unpaid"];
string tax = HttpContext.Current.Request["tax"];
string isCost = HttpContext.Current.Request["isCost"];
string remark = HttpContext.Current.Request["remark"];
int applyOrderNum = 0; // 发票结算申请单流水号
string result = "";
bool isOK1;
bool isOK2;
try
{
Guid guid = Guid.NewGuid();
string uid = guid.ToString().Replace("-", "").ToUpper();
HttpFileCollection files = context.Request.Files;
if (files.Count > 0)
{
for (int i = 0; i < files.Count; i++)
{
HttpPostedFile hpFile = files[0];
if (hpFile.ContentLength > 0)
{
string fileName = System.IO.Path.GetFileName(hpFile.FileName);
string suffix = fileName.Split(new Char[] { '.' })[1];
string Name = fileName.Split(new Char[] { '.' })[0];
string procedureName = "车间采购管理_发票结算申请单_增加数据";
string errorMessage;
SqlParameter[] thisParms = new SqlParameter[9];
thisParms[0] = new SqlParameter("@发票结算申请单流水号", applyOrderNum);
thisParms[1] = new SqlParameter("@发票号", invoiceNum);
thisParms[2] = new SqlParameter("@发票金额", money);
thisParms[3] = new SqlParameter("@供应商流水号", supplierValue);
thisParms[4] = new SqlParameter("@已付款项", paid);
thisParms[5] = new SqlParameter("@尚欠金额", unpaid);
thisParms[6] = new SqlParameter("@税额", tax);
thisParms[7] = new SqlParameter("@是否费用类", isCost);
thisParms[8] = new SqlParameter("@备注", remark);
thisParms[0].Direction = ParameterDirection.Output;
isOK1 = SQLCommon.ExecuteStoredProcedure(procedureName, connectionString, ref thisParms, out errorMessage);
applyOrderNum = Convert.ToInt32(thisParms[0].Value);
//--业务代码 1
//-- 1 发货管理_附件
//-- 2 合同信息管理_履约保证金_履约保函
//-- 3 合同管理_文件路径
//-- 4 PDM_机床总图_文件列表
//-- 5 采购管理_采购发票_附件
//-- 6 车间采购管理_发票结算申请单
//-- 7 设备管理_设备监控_图片
//-- 8 车间生产管理_质检管理
//-- 9 人员管理_图片
//--10 tableName
if (isOK1)
{
string sql2 = "insert into 车间采购管理_采购发票_附件 values(" + applyOrderNum + ",'" + uid + "','" + Name + "','" + suffix + "'," + '1' + ")";
isOK2 = SQLCommon.ExecuteNonQuery(sql2, connectionString, out result);
if (isOK2)
{
filePath = filePath + "/" + uid + "." + suffix;
hpFile.SaveAs(filePath);
result = "[{ \"result\":\"1\"}]";
}
else
{
result = "[{ \"result\":\"0\"}]";
}
}
else
{
result = "[{ \"result\":\"0\"}]";
}
try
{
//增加文件保存到数据库的功能
byte[]bytes = new byte[files[0].InputStream.Length];
files[0].InputStream.Read(bytes, 0, bytes.Length);
string procedureName1 = "_文件存储_高精_增加";
string errorMessage1;
SqlParameter []thisParms1 = new SqlParameter[5];
thisParms1[0] = new SqlParameter("@业务代码", 6);
thisParms1[1] = new SqlParameter("@文件标识", uid);
thisParms1[2] = new SqlParameter("@文件名称", Name);
thisParms1[3] = new SqlParameter("@文件后缀", suffix);
thisParms1[4] = new SqlParameter("@文件内容", bytes);
DataLinkMesWork.DataLink.ExecuteStoredProcedure(procedureName1, ref thisParms1, out errorMessage1);
if(DataLinkMesWork.DataLink.isBakup=="1")
{
isOK1 = DataLinkMesWork.DataLink.ExecuteStoredProcedure_Bakup(procedureName, ref thisParms, out errorMessage);
applyOrderNum = Convert.ToInt32(thisParms[0].Value);
DataLinkMesWork.DataLink.ExecuteStoredProcedure_Bakup(procedureName1, ref thisParms1, out errorMessage1);
if (isOK1)
{
string sql2 = "insert into 车间采购管理_采购发票_附件 values(" + applyOrderNum + ",'" + uid + "','" + Name + "','" + suffix + "'," + '1' + ")";
isOK2 = DataLinkMesWork.DataLink.ExecuteNonQuery_Bakup(sql2);
if (isOK2)
{
//filePath = filePath + "/" + uid + "." + suffix;
//hpFile.SaveAs(filePath);
//result = "[{ \"result\":\"1\"}]";
}
else
{
//result = "[{ \"result\":\"0\"}]";
}
}
else
{
//result = "[{ \"result\":\"0\"}]";
}
}
}
catch
{
}
}
else
{
context.Response.Write(result);
}
}
}
}
catch (Exception ex)
{
result = "[{ \"result\":\"0\"}]";
}
context.Response.Write(result);
}
public bool IsReusable
{
get
{
return false;
}
}
}

112
submit/uploadOP.ashx Normal file
View File

@@ -0,0 +1,112 @@
<%@ WebHandler Language="C#" Class="UploadHandler" %>
using System;
using System.Web;
using System.Data;
using System.Collections.Generic;
using System.Linq;
//using BizDataAccess;
using System.IO;
using System.Net;
using System.Web.Services;
using System.Text;
using System.Data.SqlClient;
using DataLinkMesWork;
public class UploadHandler : IHttpHandler
{
private static string connectionString = System.Configuration.ConfigurationManager.AppSettings.GetValues("ConnectionString")[0].ToString();
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
string filePath = "../webpage/file";
filePath = HttpContext.Current.Server.MapPath(filePath);
string Num = HttpContext.Current.Request["num"];
string result = "";
bool isOK1;
try
{
Guid guid = Guid.NewGuid();
string uid = guid.ToString().Replace("-", "").ToUpper();
HttpFileCollection files = context.Request.Files;
HttpPostedFile hpFile = files[0];
string fileName = System.IO.Path.GetFileName(hpFile.FileName);
string suffix = fileName.Split(new Char[] { '.' })[1];
string Name = fileName.Split(new Char[] { '.' })[0];
string sql2 = "insert into 设备管理_设备监控_图片 values('" + Num + "','" + uid + "','" + Name + "','" + suffix + "'," + '1' + ")";
isOK1 = SQLCommon.ExecuteNonQuery(sql2, connectionString, out result);
if (isOK1)
{
filePath = filePath + "/" + uid + "." + suffix;
hpFile.SaveAs(filePath);
result = "[{ \"result\":\"1\"}]";
}
else
{
result = "[{ \"result\":\"0\"}]";
}
try
{
//增加文件保存到数据库的功能
byte[]bytes = new byte[files[0].InputStream.Length];
files[0].InputStream.Read(bytes, 0, bytes.Length);
string procedureName = "_文件存储_高精_增加";
string errorMessage;
SqlParameter []thisParms = new SqlParameter[5];
thisParms[0] = new SqlParameter("@业务代码", 7);
thisParms[1] = new SqlParameter("@文件标识", uid);
thisParms[2] = new SqlParameter("@文件名称", Name);
thisParms[3] = new SqlParameter("@文件后缀", suffix);
thisParms[4] = new SqlParameter("@文件内容", bytes);
DataLinkMesWork.DataLink.ExecuteStoredProcedure(procedureName, ref thisParms, out errorMessage);
//--业务代码 1
//-- 1 发货管理_附件
//-- 2 合同信息管理_履约保证金_履约保函
//-- 3 合同管理_文件路径
//-- 4 PDM_机床总图_文件列表
//-- 5 采购管理_采购发票_附件
//-- 6 车间采购管理_发票结算申请单
//-- 7 设备管理_设备监控_图片
//-- 8 车间生产管理_质检管理
//-- 9 人员管理_图片
//--10 tableName
if(DataLinkMesWork.DataLink.isBakup=="1")
{
DataLinkMesWork.DataLink.ExecuteStoredProcedure_Bakup(procedureName, ref thisParms, out errorMessage);
DataLinkMesWork.DataLink.ExecuteNonQuery_Bakup(sql2);
}
}
catch
{
}
}
catch (Exception ex)
{
result = "[{ \"result\":\"0\"}]";
}
context.Response.Write(result);
}
public bool IsReusable
{
get
{
return false;
}
}
}

148
submit/uploadPDA.ashx Normal file
View File

@@ -0,0 +1,148 @@
<%@ WebHandler Language="C#" Class="UploadHandler" %>
using System;
using System.Web;
using System.Data;
using System.Collections.Generic;
using System.Linq;
//using BizDataAccess;
using System.IO;
using System.Net;
using System.Web.Services;
using System.Text;
using System.Data.SqlClient;
using DataLinkMesWork;
public class UploadHandler : IHttpHandler
{
private static string connectionString = System.Configuration.ConfigurationManager.AppSettings.GetValues("ConnectionString")[0].ToString();
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
string filePath = "../webpage/file";
filePath = HttpContext.Current.Server.MapPath(filePath);
string number = HttpContext.Current.Request["number"];
string number1 = HttpContext.Current.Request["number1"];
string reasonsForNonconformity = HttpContext.Current.Request["reasonsForNonconformity"];
string disqualificationTreatment = HttpContext.Current.Request["disqualificationTreatment"];
string remark = HttpContext.Current.Request["remark"];
string num = HttpContext.Current.Request["num"];
string type = HttpContext.Current.Request["type"];
int qualifiedNum = 2; // 发票结算申请单流水号
string result = "";
bool isOK;
try
{
Guid guid = Guid.NewGuid();
string uid = guid.ToString().Replace("-", "").ToUpper();
HttpFileCollection files = context.Request.Files;
if (files.Count > 0)
{
for (int i = 0; i < files.Count; i++)
{
HttpPostedFile hpFile = files[0];
if (hpFile.ContentLength > 0)
{
string fileName = System.IO.Path.GetFileName(hpFile.FileName);
string suffix = fileName.Split(new Char[] { '.' })[1];
string Name = fileName.Split(new Char[] { '.' })[0];
string procedureName = "车间生产管理_质检管理_不合格处理";
string errorMessage;
SqlParameter[] thisParms = new SqlParameter[12];
thisParms[0] = new SqlParameter("@零部件流水号", num);
thisParms[1] = new SqlParameter("@质检类型代码", type);
thisParms[2] = new SqlParameter("@数量", number);
thisParms[3] = new SqlParameter("@不合格数量", number1);
thisParms[4] = new SqlParameter("@是否合格", qualifiedNum);
thisParms[5] = new SqlParameter("@不合格原因", reasonsForNonconformity);
thisParms[6] = new SqlParameter("@不合格处理", disqualificationTreatment);
thisParms[7] = new SqlParameter("@备注", remark);
thisParms[8] = new SqlParameter("@文件标识", uid);
thisParms[9] = new SqlParameter("@文件名称", Name);
thisParms[10] = new SqlParameter("@文件后缀", suffix);
thisParms[11] = new SqlParameter("@是否启用", 1);
isOK = DataLinkMesWork.DataLink.ExecuteStoredProcedure(procedureName, ref thisParms, out errorMessage);
try
{
if (isOK)
{
filePath = filePath + "/" + uid + "." + suffix;
hpFile.SaveAs(filePath);
result = "[{ \"result\":\"1\"}]";
}
else
{
result = "[{ \"result\":\"0\"}]";
}
try
{
//增加文件保存到数据库的功能
byte[]bytes = new byte[files[0].InputStream.Length];
files[0].InputStream.Read(bytes, 0, bytes.Length);
string procedureName1 = "_文件存储_高精_增加";
string errorMessage1;
SqlParameter []thisParms1 = new SqlParameter[5];
thisParms1[0] = new SqlParameter("@业务代码", 8);
thisParms1[1] = new SqlParameter("@文件标识", uid);
thisParms1[2] = new SqlParameter("@文件名称", Name);
thisParms1[3] = new SqlParameter("@文件后缀", suffix);
thisParms1[4] = new SqlParameter("@文件内容", bytes);
DataLinkMesWork.DataLink.ExecuteStoredProcedure(procedureName1, ref thisParms1, out errorMessage1);
//--业务代码 1
//-- 1 发货管理_附件
//-- 2 合同信息管理_履约保证金_履约保函
//-- 3 合同管理_文件路径
//-- 4 PDM_机床总图_文件列表
//-- 5 采购管理_采购发票_附件
//-- 6 车间采购管理_发票结算申请单
//-- 7 设备管理_设备监控_图片
//-- 8 车间生产管理_质检管理
//-- 9 人员管理_图片
//--10 tableName
if(DataLinkMesWork.DataLink.isBakup=="1")
{
DataLinkMesWork.DataLink.ExecuteStoredProcedure_Bakup(procedureName1, ref thisParms1, out errorMessage1);
DataLinkMesWork.DataLink.ExecuteStoredProcedure_Bakup(procedureName, ref thisParms, out errorMessage);
}
}
catch
{
}
}
catch
{
}
}
else
{
context.Response.Write(result);
}
}
}
}
catch (Exception ex)
{
result = "[{ \"result\":\"0\"}]";
}
context.Response.Write(result);
}
public bool IsReusable
{
get
{
return false;
}
}
}

119
submit/uploadPerson.ashx Normal file
View File

@@ -0,0 +1,119 @@
<%@ WebHandler Language="C#" Class="UploadHandler" %>
using System;
using System.Web;
using System.Data;
using System.Collections.Generic;
using System.Linq;
//using BizDataAccess;
using System.IO;
using System.Net;
using System.Web.Services;
using System.Text;
using System.Data.SqlClient;
using DataLinkMesWork;
public class UploadHandler : IHttpHandler
{
private static string connectionString = System.Configuration.ConfigurationManager.AppSettings.GetValues("ConnectionString")[0].ToString();
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
string filePath = "../webpage/file";
filePath = HttpContext.Current.Server.MapPath(filePath);
string Num = HttpContext.Current.Request["num"];
string result = "";
bool isOK1;
try
{
Guid guid = Guid.NewGuid();
string uid = guid.ToString().Replace("-", "").ToUpper();
HttpFileCollection files = context.Request.Files;
HttpPostedFile hpFile = files[0];
string fileName = System.IO.Path.GetFileName(hpFile.FileName);
string suffix = fileName.Split(new Char[] { '.' })[1];
string Name = fileName.Split(new Char[] { '.' })[0];
string sql2 = "insert into 人员管理_图片 values(" + Num + ",'" + uid + "','" + Name + "','" + suffix + "'," + '1' + ")";
isOK1 = DataLinkMesWork.DataLink.ExecuteNonQuery(sql2);
try
{
//--业务代码 1
//-- 1 发货管理_附件
//-- 2 合同信息管理_履约保证金_履约保函
//-- 3 合同管理_文件路径
//-- 4 PDM_机床总图_文件列表
//-- 5 采购管理_采购发票_附件
//-- 6 车间采购管理_发票结算申请单
//-- 7 设备管理_设备监控_图片
//-- 8 车间生产管理_质检管理
//-- 9 人员管理_图片
//--10 tableName
if (isOK1)
{
filePath = filePath + "/" + uid + "." + suffix;
hpFile.SaveAs(filePath);
result = "[{ \"result\":\"1\"}]";
}
else
{
result = "[{ \"result\":\"0\"}]";
}
try
{
//增加文件保存到数据库的功能
byte[]bytes = new byte[files[0].InputStream.Length];
files[0].InputStream.Read(bytes, 0, bytes.Length);
string procedureName = "_文件存储_高精_增加";
string errorMessage;
SqlParameter []thisParms = new SqlParameter[5];
thisParms[0] = new SqlParameter("@业务代码", 9);
thisParms[1] = new SqlParameter("@文件标识", uid);
thisParms[2] = new SqlParameter("@文件名称", Name);
thisParms[3] = new SqlParameter("@文件后缀", suffix);
thisParms[4] = new SqlParameter("@文件内容", bytes);
DataLinkMesWork.DataLink.ExecuteStoredProcedure(procedureName, ref thisParms, out errorMessage);
if(DataLinkMesWork.DataLink.isBakup=="1")
{
DataLinkMesWork.DataLink.ExecuteStoredProcedure_Bakup(procedureName, ref thisParms, out errorMessage);
DataLinkMesWork.DataLink.ExecuteNonQuery_Bakup(sql2);
}
}
catch
{
}
}
catch
{
}
}
catch (Exception ex)
{
result = "[{ \"result\":\"0\"}]";
}
context.Response.Write(result);
}
public bool IsReusable
{
get
{
return false;
}
}
}

13
submit/web.config Normal file
View File

@@ -0,0 +1,13 @@
<?xml version="1.0"?>
<configuration>
<system.webServer>
<directoryBrowse enabled="true"/>
</system.webServer>
<system.web>
<compilation>
<assemblies>
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</assemblies>
</compilation>
</system.web>
</configuration>