<%@ 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 SystemFrameworks; 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/PDF"; filePath = HttpContext.Current.Server.MapPath(filePath); string filePath1 = "http://127.0.0.1:8100/webpage/PDF/"; string engineTypeValue1 = HttpContext.Current.Request["engineTypeValue1"]; string stationNumberValue = HttpContext.Current.Request["stationNumberValue"]; string engineTypeValue = HttpContext.Current.Request["engineTypeValue"]; string tableName = HttpContext.Current.Request["tableName"]; string result = ""; bool isOK; try { Guid guid = Guid.NewGuid(); string uid = guid.ToString().Replace("-", "").ToLower() 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); int index = fileName.LastIndexOf('.'); string name = fileName.Substring(0, index); string suffix = fileName.Substring(index + 1); string sql = "EXEC [电子看板_工位名称与产品型号工艺卡_保存] '"+stationNumberValue+"' , "+engineTypeValue1+" , '"+uid + ".pdf'"+" , '"+filePath1 + fileName + "'"; isOK = DataLinkMesWork.DataLink.ExecuteNonQuery(sql); if (isOK) { filePath = filePath + "/" + uid+"."+suffix; hpFile.SaveAs(filePath); result = "[{ \"result\":\"1\"}]"; } else { result = "[{ \"result\":\"0\"}]"; } } else { context.Response.Write(result); } } } } catch (Exception ex) { result = "[{ \"result\":\"0\"}]"; } context.Response.Write(result); } public bool IsReusable { get { return false; } } }