DAL/生产管理/模具管理/ClsSc_MouldDotCheckBill.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
WebAPI/Controllers/SBGL/Sb_EquipDotCheckBillController.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
WebAPI/Controllers/SBGL/Sb_EquipMaintainBillController.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
WebAPI/Controllers/Sc_MouldRepairInBillListController.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
DAL/Éú²ú¹ÜÀí/Ä£¾ß¹ÜÀí/ClsSc_MouldDotCheckBill.cs
@@ -140,7 +140,7 @@ //ä¿ååæ§å¶========================================= string HBillNote = ""; DataSet ds = oCn.RunProcReturn("Exec h_p_Sb_MouldDotCheckBill_BeforeSaveCtrl " + omodel.HInterID.ToString() + ", '" + omodel.HBillNo + "','" + HBillNote + "',1,1 ", "h_p_Sb_MouldDotCheckBill_BeforeSaveCtrl"); DataSet ds = oCn.RunProcReturn("Exec h_p_Sc_MouldDotCheckBill_BeforeSaveCtrl " + omodel.HInterID.ToString() + ", '" + omodel.HBillNo + "','" + HBillNote + "',1,1 ", "h_p_Sc_MouldDotCheckBill_BeforeSaveCtrl"); if (ds == null) { sReturn = "ä¿ååå¤æå¤±è´¥ï¼"; @@ -190,7 +190,7 @@ } //ç¹æ£å®æï¼ååå¨å ·ç¹æ£è®¡ååå表æ¯å¦ç¹æ£æ è®° oCn.RunProc("exec h_p_Sb_MouldDotCheck_AfterSaveCtrl " + omodel.HMouldDotCheckPlanInterID + "," + omodel.HMouldDotCheckPlanEntryID); oCn.RunProc("exec h_p_Sc_MouldDotCheck_AfterSaveCtrl " + omodel.HMouldDotCheckPlanInterID + "," + omodel.HMouldDotCheckPlanEntryID); ////é ä»¶é¡¹ç® //foreach (Model.ClsSc_MouldDotCheckBillSub_Item oSub in DetailCol) WebAPI/Controllers/SBGL/Sb_EquipDotCheckBillController.cs
@@ -4,8 +4,11 @@ using System; using System.Collections.Generic; using System.Data; using System.IO; using System.Web; using System.Web.Http; using WebAPI.Models; namespace WebAPI.Controllers { public class Sb_EquipDotCheckBillController : ApiController @@ -17,6 +20,7 @@ public DAL.ClsSb_EquipDotCheckBill BillNew = new DAL.ClsSb_EquipDotCheckBill(); //对åºåæ®ç±» public DAL.ClsSb_EquipDotCheckBill BillOld = new DAL.ClsSb_EquipDotCheckBill(); //对åºåæ®ç±» Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter(); //è·åç³»ç»åæ° string fileip = System.Configuration.ConfigurationManager.AppSettings["FileIP"]; #region 设å¤ç¹æ£è®°å½è¡¨ @@ -847,5 +851,185 @@ } } #endregion #region 设å¤ç¹æ£è®°å½æç §ä¸ä¼ [Route("Sb_EquipDotCheckBill/UploadFile")] [HttpPost] public object UploadFile() { string HBillNo = HttpContext.Current.Request.Params["HBillNo"]; //åæ®å· string HRemark = HttpContext.Current.Request.Params["HRemark"]; //夿³¨ string HUserName = HttpContext.Current.Request.Params["HUserName"]; //å建人 HttpPostedFile files = HttpContext.Current.Request.Files["file"]; string path = HttpContext.Current.Server.MapPath("~/../Files/EquipFolder/" + HBillNo); //string path = @"D:\\Files\\"+ HBillNo; dynamic dyResult = UpLoadFile(files, path, HBillNo, HRemark, HUserName); if (dyResult != null && dyResult.result == 1) { objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "ä¸ä¼ æåï¼"; objJsonResult.data = null; return objJsonResult; } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = dyResult.returnval; objJsonResult.data = null; return objJsonResult; } } public dynamic UpLoadFile(HttpPostedFile files, string path, string HBillNo, string HRemark, string HUserName) { dynamic Result_Ob = new { result = 1, returnval = "ä¸ä¼ æåï¼" }; string filePath = Path.GetFullPath(files.FileName);//æä»¶ä¸ä¼ è·¯å¾ string fileExtension = Path.GetExtension(files.FileName);// æä»¶æ©å±å string filename = files.FileName;//æä»¶å string fileSavePath = path;// ä¸ä¼ ä¿åè·¯å¾ int filesize = files.ContentLength;//è·åä¸ä¼ æä»¶ç大å°åä½ä¸ºåèbyte int Maxsize = 40000 * 1024;//å®ä¹ä¸ä¼ æä»¶çæå¤§ç©ºé´å¤§å°ä¸º40M try { if (files == null || files.ContentLength <= 0) { Result_Ob = new { result = 0, returnval = "æä»¶ä¸è½ä¸ºç©º!" }; return Result_Ob; } if (filesize >= Maxsize) { Result_Ob = new { result = 0, returnval = "ä¸ä¼ æä»¶è¶ è¿40Mï¼ä¸è½ä¸ä¼ ï¼" }; return Result_Ob; } string fileurl = Path.Combine(fileSavePath, filename); if (Directory.Exists(fileurl) == true) //妿åå¨éåæä»¶å°±æç¤º { Result_Ob = new { result = 0, returnval = "åå¨ååæä»¶ï¼" }; return Result_Ob; } //å 餿°æ®è¡¨æ°æ® ds = oCN.RunProcReturn("delete from MES_AccessoriesList where HSourceBillNo ='" + HBillNo + "' and HFileName='" + filename + "'", "MES_AccessoriesList"); if (Directory.Exists(path)) { File.Delete(fileurl); //å 餿宿件 files.SaveAs(fileurl); string StrPath = "/files/EquipFolder/" + HBillNo + "/" + filename; if (File.Exists(fileurl)) { //è¿éå¯ä»¥æ§è¡ä¸äºå ¶å®çæä½ï¼æ¯å¦æ´æ°æ°æ®åº //åå ¥æ°æ®è¡¨ oCN.RunProc("Insert into MES_AccessoriesList (HFileName,HFilePath,HFilePath_Cus,HFileType" + ",HLoadMan,HLoadDate,HRemark,HVerNum,HFileSize" + ",HFileClsID,HSourceBillNo" + ") values('" + filename.ToString() + "','" + StrPath.ToString() + "','" + filePath.ToString() + "','" + fileExtension.ToString() + "'" + ",'" + HUserName + "',getdate(),'" + HRemark + "','V1','" + filesize + "','" + 0 + "','" + HBillNo + "') "); } else { Result_Ob = new { result = 0, returnval = "ä¸ä¼ å¤±è´¥ï¼æ¤æä»¶ä¸ºæ¶ææä»¶" }; } } else { Directory.CreateDirectory(fileSavePath); //æ·»å æä»¶å¤¹ files.SaveAs(fileurl); string StrPath = "/files/EquipFolder/" + HBillNo + "/" + filename; if (File.Exists(fileurl)) { //è¿éå¯ä»¥æ§è¡ä¸äºå ¶å®çæä½ï¼æ¯å¦æ´æ°æ°æ®åº //åå ¥æ°æ®è¡¨ oCN.RunProc("Insert into MES_AccessoriesList (HFileName,HFilePath,HFilePath_Cus,HFileType" + ",HLoadMan,HLoadDate,HRemark,HVerNum,HFileSize" + ",HFileClsID,HSourceBillNo" + ") values('" + filename.ToString() + "','" + StrPath.ToString() + "','" + filePath.ToString() + "','" + fileExtension.ToString() + "'" + ",'" + HUserName + "',getdate(),'" + HRemark + "','V1','" + filesize + "','" + 0 + "','" + HBillNo + "') "); } else { Result_Ob = new { result = 0, returnval = "ä¸ä¼ å¤±è´¥ï¼æ¤æä»¶ä¸ºæ¶ææä»¶" }; } } } catch (Exception e) { Result_Ob = new { result = 0, returnval = e.Message }; } return Result_Ob; } /// <summary> /// æ ¹æ®åæ®å·æ¥æ¾ä¸ä¼ æä»¶å表 /// </summary> /// <param name="sWhere"></param> /// <returns></returns> [Route("Sb_EquipDotCheckBill/Filelist")] [HttpGet] public object Filelist(string HBillNo) { var url = fileip + "/files/EquipFolder/" + HBillNo + "/"; //@"C:\\files\\" try { ds = oCN.RunProcReturn("select *,'" + url + "'+CAST(HFileName as varchar(200))as url from MES_AccessoriesList where HSourceBillNo='" + HBillNo + "'", "MES_AccessoriesList"); objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "Sucessï¼"; objJsonResult.data = ds.Tables[0]; return objJsonResult; } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "Exceptionï¼" + e.ToString(); objJsonResult.data = null; return objJsonResult; } } /// <summary> /// æ ¹æ®ID,åæ®å·,æä»¶å å 餿件 /// </summary> /// <param name="sWhere"></param> /// <returns></returns> [Route("Sb_EquipDotCheckBill/DeleteFilelist")] [HttpGet] public object DeleteFilelist(string HItemID, string HSourceBillNo, string HFileName) { try { oCN.RunProc("delete from MES_AccessoriesList where HItemID =" + HItemID); string fileurl = Path.Combine(HttpContext.Current.Server.MapPath("~/../Files/EquipFolder/" + HSourceBillNo), HFileName); File.Delete(fileurl); //å 餿宿件 objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "å 餿åï¼"; objJsonResult.data = null; return objJsonResult; } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "Exceptionï¼" + e.ToString(); objJsonResult.data = null; return objJsonResult; } } #endregion } } WebAPI/Controllers/SBGL/Sb_EquipMaintainBillController.cs
@@ -4,6 +4,8 @@ using System; using System.Collections.Generic; using System.Data; using System.IO; using System.Web; using System.Web.Http; using WebAPI.Models; namespace WebAPI.Controllers @@ -18,6 +20,7 @@ public DAL.ClsSb_EquipDotCheckBill BillNew = new DAL.ClsSb_EquipDotCheckBill(); //对åºåæ®ç±» public DAL.ClsSb_EquipDotCheckBill BillOld = new DAL.ClsSb_EquipDotCheckBill(); //对åºåæ®ç±» public DAL.ClsSb_EquipMaintainBill BillOld2 = new DAL.ClsSb_EquipMaintainBill(); //设å¤ä¿å »è®°å½å string fileip = System.Configuration.ConfigurationManager.AppSettings["FileIP"]; #region 设å¤ä¿å »è®¡å表 @@ -999,5 +1002,185 @@ } } #endregion #region 设å¤ä¿å »è®°å½æç §ä¸ä¼ [Route("Sb_EquipMaintainBill/UploadFile")] [HttpPost] public object UploadFile() { string HBillNo = HttpContext.Current.Request.Params["HBillNo"]; //åæ®å· string HRemark = HttpContext.Current.Request.Params["HRemark"]; //夿³¨ string HUserName = HttpContext.Current.Request.Params["HUserName"]; //å建人 HttpPostedFile files = HttpContext.Current.Request.Files["file"]; string path = HttpContext.Current.Server.MapPath("~/../Files/EquipFolder/" + HBillNo); //string path = @"D:\\Files\\"+ HBillNo; dynamic dyResult = UpLoadFile(files, path, HBillNo, HRemark, HUserName); if (dyResult != null && dyResult.result == 1) { objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "ä¸ä¼ æåï¼"; objJsonResult.data = null; return objJsonResult; } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = dyResult.returnval; objJsonResult.data = null; return objJsonResult; } } public dynamic UpLoadFile(HttpPostedFile files, string path, string HBillNo, string HRemark, string HUserName) { dynamic Result_Ob = new { result = 1, returnval = "ä¸ä¼ æåï¼" }; string filePath = Path.GetFullPath(files.FileName);//æä»¶ä¸ä¼ è·¯å¾ string fileExtension = Path.GetExtension(files.FileName);// æä»¶æ©å±å string filename = files.FileName;//æä»¶å string fileSavePath = path;// ä¸ä¼ ä¿åè·¯å¾ int filesize = files.ContentLength;//è·åä¸ä¼ æä»¶ç大å°åä½ä¸ºåèbyte int Maxsize = 40000 * 1024;//å®ä¹ä¸ä¼ æä»¶çæå¤§ç©ºé´å¤§å°ä¸º40M try { if (files == null || files.ContentLength <= 0) { Result_Ob = new { result = 0, returnval = "æä»¶ä¸è½ä¸ºç©º!" }; return Result_Ob; } if (filesize >= Maxsize) { Result_Ob = new { result = 0, returnval = "ä¸ä¼ æä»¶è¶ è¿40Mï¼ä¸è½ä¸ä¼ ï¼" }; return Result_Ob; } string fileurl = Path.Combine(fileSavePath, filename); if (Directory.Exists(fileurl) == true) //妿åå¨éåæä»¶å°±æç¤º { Result_Ob = new { result = 0, returnval = "åå¨ååæä»¶ï¼" }; return Result_Ob; } //å 餿°æ®è¡¨æ°æ® ds = oCN.RunProcReturn("delete from MES_AccessoriesList where HSourceBillNo ='" + HBillNo + "' and HFileName='" + filename + "'", "MES_AccessoriesList"); if (Directory.Exists(path)) { File.Delete(fileurl); //å 餿宿件 files.SaveAs(fileurl); string StrPath = "/files/EquipFolder/" + HBillNo + "/" + filename; if (File.Exists(fileurl)) { //è¿éå¯ä»¥æ§è¡ä¸äºå ¶å®çæä½ï¼æ¯å¦æ´æ°æ°æ®åº //åå ¥æ°æ®è¡¨ oCN.RunProc("Insert into MES_AccessoriesList (HFileName,HFilePath,HFilePath_Cus,HFileType" + ",HLoadMan,HLoadDate,HRemark,HVerNum,HFileSize" + ",HFileClsID,HSourceBillNo" + ") values('" + filename.ToString() + "','" + StrPath.ToString() + "','" + filePath.ToString() + "','" + fileExtension.ToString() + "'" + ",'" + HUserName + "',getdate(),'" + HRemark + "','V1','" + filesize + "','" + 0 + "','" + HBillNo + "') "); } else { Result_Ob = new { result = 0, returnval = "ä¸ä¼ å¤±è´¥ï¼æ¤æä»¶ä¸ºæ¶ææä»¶" }; } } else { Directory.CreateDirectory(fileSavePath); //æ·»å æä»¶å¤¹ files.SaveAs(fileurl); string StrPath = "/files/EquipFolder/" + HBillNo + "/" + filename; if (File.Exists(fileurl)) { //è¿éå¯ä»¥æ§è¡ä¸äºå ¶å®çæä½ï¼æ¯å¦æ´æ°æ°æ®åº //åå ¥æ°æ®è¡¨ oCN.RunProc("Insert into MES_AccessoriesList (HFileName,HFilePath,HFilePath_Cus,HFileType" + ",HLoadMan,HLoadDate,HRemark,HVerNum,HFileSize" + ",HFileClsID,HSourceBillNo" + ") values('" + filename.ToString() + "','" + StrPath.ToString() + "','" + filePath.ToString() + "','" + fileExtension.ToString() + "'" + ",'" + HUserName + "',getdate(),'" + HRemark + "','V1','" + filesize + "','" + 0 + "','" + HBillNo + "') "); } else { Result_Ob = new { result = 0, returnval = "ä¸ä¼ å¤±è´¥ï¼æ¤æä»¶ä¸ºæ¶ææä»¶" }; } } } catch (Exception e) { Result_Ob = new { result = 0, returnval = e.Message }; } return Result_Ob; } /// <summary> /// æ ¹æ®åæ®å·æ¥æ¾ä¸ä¼ æä»¶å表 /// </summary> /// <param name="sWhere"></param> /// <returns></returns> [Route("Sb_EquipMaintainBill/Filelist")] [HttpGet] public object Filelist(string HBillNo) { var url = fileip + "/files/EquipFolder/" + HBillNo + "/"; //@"C:\\files\\" try { ds = oCN.RunProcReturn("select *,'" + url + "'+CAST(HFileName as varchar(200))as url from MES_AccessoriesList where HSourceBillNo='" + HBillNo + "'", "MES_AccessoriesList"); objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "Sucessï¼"; objJsonResult.data = ds.Tables[0]; return objJsonResult; } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "Exceptionï¼" + e.ToString(); objJsonResult.data = null; return objJsonResult; } } /// <summary> /// æ ¹æ®ID,åæ®å·,æä»¶å å 餿件 /// </summary> /// <param name="sWhere"></param> /// <returns></returns> [Route("Sb_EquipMaintainBill/DeleteFilelist")] [HttpGet] public object DeleteFilelist(string HItemID, string HSourceBillNo, string HFileName) { try { oCN.RunProc("delete from MES_AccessoriesList where HItemID =" + HItemID); string fileurl = Path.Combine(HttpContext.Current.Server.MapPath("~/../Files/EquipFolder/" + HSourceBillNo), HFileName); File.Delete(fileurl); //å 餿宿件 objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "å 餿åï¼"; objJsonResult.data = null; return objJsonResult; } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "Exceptionï¼" + e.ToString(); objJsonResult.data = null; return objJsonResult; } } #endregion } } WebAPI/Controllers/Sc_MouldRepairInBillListController.cs
@@ -4,6 +4,8 @@ using System; using System.Collections.Generic; using System.Data; using System.IO; using System.Web; using System.Web.Http; using ViewAPI; using WebAPI.Models; @@ -26,6 +28,7 @@ public DAL.ClsSc_MouldScrapInBill BillNew0 = new DAL.ClsSc_MouldScrapInBill(); //æ¨¡å ·æ¥åºå ¥åºå¯¹åºåæ®ç±» public DAL.ClsSc_MouldScrapInBill BillOld0 = new DAL.ClsSc_MouldScrapInBill(); //æ¨¡å ·æ¥åºå ¥åºå¯¹åºåæ®ç±» string fileip = System.Configuration.ConfigurationManager.AppSettings["FileIP"]; /// <summary> @@ -10233,5 +10236,366 @@ return objJsonResult; } #endregion #region å¨å ·ç¹æ£è®°å½æç §ä¸ä¼ [Route("Sc_MouldDotCheckBill/UploadFile")] [HttpPost] public object UploadFile() { string HBillNo = HttpContext.Current.Request.Params["HBillNo"]; //åæ®å· string HRemark = HttpContext.Current.Request.Params["HRemark"]; //夿³¨ string HUserName = HttpContext.Current.Request.Params["HUserName"]; //å建人 HttpPostedFile files = HttpContext.Current.Request.Files["file"]; string path = HttpContext.Current.Server.MapPath("~/../Files/MouldFolder/" + HBillNo); //string path = @"D:\\Files\\"+ HBillNo; dynamic dyResult = UpLoadFile(files, path, HBillNo, HRemark, HUserName); if (dyResult != null && dyResult.result == 1) { objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "ä¸ä¼ æåï¼"; objJsonResult.data = null; return objJsonResult; } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = dyResult.returnval; objJsonResult.data = null; return objJsonResult; } } public dynamic UpLoadFile(HttpPostedFile files, string path, string HBillNo, string HRemark, string HUserName) { dynamic Result_Ob = new { result = 1, returnval = "ä¸ä¼ æåï¼" }; string filePath = Path.GetFullPath(files.FileName);//æä»¶ä¸ä¼ è·¯å¾ string fileExtension = Path.GetExtension(files.FileName);// æä»¶æ©å±å string filename = files.FileName;//æä»¶å string fileSavePath = path;// ä¸ä¼ ä¿åè·¯å¾ int filesize = files.ContentLength;//è·åä¸ä¼ æä»¶ç大å°åä½ä¸ºåèbyte int Maxsize = 40000 * 1024;//å®ä¹ä¸ä¼ æä»¶çæå¤§ç©ºé´å¤§å°ä¸º40M try { if (files == null || files.ContentLength <= 0) { Result_Ob = new { result = 0, returnval = "æä»¶ä¸è½ä¸ºç©º!" }; return Result_Ob; } if (filesize >= Maxsize) { Result_Ob = new { result = 0, returnval = "ä¸ä¼ æä»¶è¶ è¿40Mï¼ä¸è½ä¸ä¼ ï¼" }; return Result_Ob; } string fileurl = Path.Combine(fileSavePath, filename); if (Directory.Exists(fileurl) == true) //妿åå¨éåæä»¶å°±æç¤º { Result_Ob = new { result = 0, returnval = "åå¨ååæä»¶ï¼" }; return Result_Ob; } //å 餿°æ®è¡¨æ°æ® ds = oCN.RunProcReturn("delete from MES_AccessoriesList where HSourceBillNo ='" + HBillNo + "' and HFileName='" + filename + "'", "MES_AccessoriesList"); if (Directory.Exists(path)) { File.Delete(fileurl); //å 餿宿件 files.SaveAs(fileurl); string StrPath = "/files/MouldFolder/" + HBillNo + "/" + filename; if (File.Exists(fileurl)) { //è¿éå¯ä»¥æ§è¡ä¸äºå ¶å®çæä½ï¼æ¯å¦æ´æ°æ°æ®åº //åå ¥æ°æ®è¡¨ oCN.RunProc("Insert into MES_AccessoriesList (HFileName,HFilePath,HFilePath_Cus,HFileType" + ",HLoadMan,HLoadDate,HRemark,HVerNum,HFileSize" + ",HFileClsID,HSourceBillNo" + ") values('" + filename.ToString() + "','" + StrPath.ToString() + "','" + filePath.ToString() + "','" + fileExtension.ToString() + "'" + ",'" + HUserName + "',getdate(),'" + HRemark + "','V1','" + filesize + "','" + 0 + "','" + HBillNo + "') "); } else { Result_Ob = new { result = 0, returnval = "ä¸ä¼ å¤±è´¥ï¼æ¤æä»¶ä¸ºæ¶ææä»¶" }; } } else { Directory.CreateDirectory(fileSavePath); //æ·»å æä»¶å¤¹ files.SaveAs(fileurl); string StrPath = "/files/MouldFolder/" + HBillNo + "/" + filename; if (File.Exists(fileurl)) { //è¿éå¯ä»¥æ§è¡ä¸äºå ¶å®çæä½ï¼æ¯å¦æ´æ°æ°æ®åº //åå ¥æ°æ®è¡¨ oCN.RunProc("Insert into MES_AccessoriesList (HFileName,HFilePath,HFilePath_Cus,HFileType" + ",HLoadMan,HLoadDate,HRemark,HVerNum,HFileSize" + ",HFileClsID,HSourceBillNo" + ") values('" + filename.ToString() + "','" + StrPath.ToString() + "','" + filePath.ToString() + "','" + fileExtension.ToString() + "'" + ",'" + HUserName + "',getdate(),'" + HRemark + "','V1','" + filesize + "','" + 0 + "','" + HBillNo + "') "); } else { Result_Ob = new { result = 0, returnval = "ä¸ä¼ å¤±è´¥ï¼æ¤æä»¶ä¸ºæ¶ææä»¶" }; } } } catch (Exception e) { Result_Ob = new { result = 0, returnval = e.Message }; } return Result_Ob; } /// <summary> /// æ ¹æ®åæ®å·æ¥æ¾ä¸ä¼ æä»¶å表 /// </summary> /// <param name="sWhere"></param> /// <returns></returns> [Route("Sc_MouldDotCheckBill/Filelist")] [HttpGet] public object Filelist(string HBillNo) { var url = fileip + "/files/MouldFolder/" + HBillNo + "/"; //@"C:\\files\\" try { ds = oCN.RunProcReturn("select *,'" + url + "'+CAST(HFileName as varchar(200))as url from MES_AccessoriesList where HSourceBillNo='" + HBillNo + "'", "MES_AccessoriesList"); objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "Sucessï¼"; objJsonResult.data = ds.Tables[0]; return objJsonResult; } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "Exceptionï¼" + e.ToString(); objJsonResult.data = null; return objJsonResult; } } /// <summary> /// æ ¹æ®ID,åæ®å·,æä»¶å å 餿件 /// </summary> /// <param name="sWhere"></param> /// <returns></returns> [Route("Sc_MouldDotCheckBill/DeleteFilelist")] [HttpGet] public object DeleteFilelist(string HItemID, string HSourceBillNo, string HFileName) { try { oCN.RunProc("delete from MES_AccessoriesList where HItemID =" + HItemID); string fileurl = Path.Combine(HttpContext.Current.Server.MapPath("~/../Files/MouldFolder/" + HSourceBillNo), HFileName); File.Delete(fileurl); //å 餿宿件 objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "å 餿åï¼"; objJsonResult.data = null; return objJsonResult; } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "Exceptionï¼" + e.ToString(); objJsonResult.data = null; return objJsonResult; } } #endregion #region å¨å ·ä¿å »è®°å½æç §ä¸ä¼ [Route("Sc_MouldMaintainBill/UploadFile")] [HttpPost] public object UploadFile_Maintain() { string HBillNo = HttpContext.Current.Request.Params["HBillNo"]; //åæ®å· string HRemark = HttpContext.Current.Request.Params["HRemark"]; //夿³¨ string HUserName = HttpContext.Current.Request.Params["HUserName"]; //å建人 HttpPostedFile files = HttpContext.Current.Request.Files["file"]; string path = HttpContext.Current.Server.MapPath("~/../Files/MouldFolder/" + HBillNo); //string path = @"D:\\Files\\"+ HBillNo; dynamic dyResult = UpLoadFile_Maintain(files, path, HBillNo, HRemark, HUserName); if (dyResult != null && dyResult.result == 1) { objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "ä¸ä¼ æåï¼"; objJsonResult.data = null; return objJsonResult; } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = dyResult.returnval; objJsonResult.data = null; return objJsonResult; } } public dynamic UpLoadFile_Maintain(HttpPostedFile files, string path, string HBillNo, string HRemark, string HUserName) { dynamic Result_Ob = new { result = 1, returnval = "ä¸ä¼ æåï¼" }; string filePath = Path.GetFullPath(files.FileName);//æä»¶ä¸ä¼ è·¯å¾ string fileExtension = Path.GetExtension(files.FileName);// æä»¶æ©å±å string filename = files.FileName;//æä»¶å string fileSavePath = path;// ä¸ä¼ ä¿åè·¯å¾ int filesize = files.ContentLength;//è·åä¸ä¼ æä»¶ç大å°åä½ä¸ºåèbyte int Maxsize = 40000 * 1024;//å®ä¹ä¸ä¼ æä»¶çæå¤§ç©ºé´å¤§å°ä¸º40M try { if (files == null || files.ContentLength <= 0) { Result_Ob = new { result = 0, returnval = "æä»¶ä¸è½ä¸ºç©º!" }; return Result_Ob; } if (filesize >= Maxsize) { Result_Ob = new { result = 0, returnval = "ä¸ä¼ æä»¶è¶ è¿40Mï¼ä¸è½ä¸ä¼ ï¼" }; return Result_Ob; } string fileurl = Path.Combine(fileSavePath, filename); if (Directory.Exists(fileurl) == true) //妿åå¨éåæä»¶å°±æç¤º { Result_Ob = new { result = 0, returnval = "åå¨ååæä»¶ï¼" }; return Result_Ob; } //å 餿°æ®è¡¨æ°æ® ds = oCN.RunProcReturn("delete from MES_AccessoriesList where HSourceBillNo ='" + HBillNo + "' and HFileName='" + filename + "'", "MES_AccessoriesList"); if (Directory.Exists(path)) { File.Delete(fileurl); //å 餿宿件 files.SaveAs(fileurl); string StrPath = "/files/MouldFolder/" + HBillNo + "/" + filename; if (File.Exists(fileurl)) { //è¿éå¯ä»¥æ§è¡ä¸äºå ¶å®çæä½ï¼æ¯å¦æ´æ°æ°æ®åº //åå ¥æ°æ®è¡¨ oCN.RunProc("Insert into MES_AccessoriesList (HFileName,HFilePath,HFilePath_Cus,HFileType" + ",HLoadMan,HLoadDate,HRemark,HVerNum,HFileSize" + ",HFileClsID,HSourceBillNo" + ") values('" + filename.ToString() + "','" + StrPath.ToString() + "','" + filePath.ToString() + "','" + fileExtension.ToString() + "'" + ",'" + HUserName + "',getdate(),'" + HRemark + "','V1','" + filesize + "','" + 0 + "','" + HBillNo + "') "); } else { Result_Ob = new { result = 0, returnval = "ä¸ä¼ å¤±è´¥ï¼æ¤æä»¶ä¸ºæ¶ææä»¶" }; } } else { Directory.CreateDirectory(fileSavePath); //æ·»å æä»¶å¤¹ files.SaveAs(fileurl); string StrPath = "/files/MouldFolder/" + HBillNo + "/" + filename; if (File.Exists(fileurl)) { //è¿éå¯ä»¥æ§è¡ä¸äºå ¶å®çæä½ï¼æ¯å¦æ´æ°æ°æ®åº //åå ¥æ°æ®è¡¨ oCN.RunProc("Insert into MES_AccessoriesList (HFileName,HFilePath,HFilePath_Cus,HFileType" + ",HLoadMan,HLoadDate,HRemark,HVerNum,HFileSize" + ",HFileClsID,HSourceBillNo" + ") values('" + filename.ToString() + "','" + StrPath.ToString() + "','" + filePath.ToString() + "','" + fileExtension.ToString() + "'" + ",'" + HUserName + "',getdate(),'" + HRemark + "','V1','" + filesize + "','" + 0 + "','" + HBillNo + "') "); } else { Result_Ob = new { result = 0, returnval = "ä¸ä¼ å¤±è´¥ï¼æ¤æä»¶ä¸ºæ¶ææä»¶" }; } } } catch (Exception e) { Result_Ob = new { result = 0, returnval = e.Message }; } return Result_Ob; } /// <summary> /// æ ¹æ®åæ®å·æ¥æ¾ä¸ä¼ æä»¶å表 /// </summary> /// <param name="sWhere"></param> /// <returns></returns> [Route("Sc_MouldMaintainBill/Filelist")] [HttpGet] public object Filelist_Maintain(string HBillNo) { var url = fileip + "/files/MouldFolder/" + HBillNo + "/"; //@"C:\\files\\" try { ds = oCN.RunProcReturn("select *,'" + url + "'+CAST(HFileName as varchar(200))as url from MES_AccessoriesList where HSourceBillNo='" + HBillNo + "'", "MES_AccessoriesList"); objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "Sucessï¼"; objJsonResult.data = ds.Tables[0]; return objJsonResult; } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "Exceptionï¼" + e.ToString(); objJsonResult.data = null; return objJsonResult; } } /// <summary> /// æ ¹æ®ID,åæ®å·,æä»¶å å 餿件 /// </summary> /// <param name="sWhere"></param> /// <returns></returns> [Route("Sc_MouldMaintainBill/DeleteFilelist")] [HttpGet] public object DeleteFilelist_Maintain(string HItemID, string HSourceBillNo, string HFileName) { try { oCN.RunProc("delete from MES_AccessoriesList where HItemID =" + HItemID); string fileurl = Path.Combine(HttpContext.Current.Server.MapPath("~/../Files/MouldFolder/" + HSourceBillNo), HFileName); File.Delete(fileurl); //å 餿宿件 objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "å 餿åï¼"; objJsonResult.data = null; return objJsonResult; } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "Exceptionï¼" + e.ToString(); objJsonResult.data = null; return objJsonResult; } } #endregion } }