|
|
@ -131,6 +131,32 @@ namespace AMESCoreStudio.Web.Controllers |
|
|
|
return Json(new Table() { count = 0, data = null }); |
|
|
|
} |
|
|
|
|
|
|
|
[ResponseCache(Duration = 0)] |
|
|
|
[HttpGet] |
|
|
|
public async Task<IActionResult> GetNgRepairBlob(int id) |
|
|
|
{ |
|
|
|
var result = await _repApi.GetNgRepairBlob(id); |
|
|
|
|
|
|
|
if (result.Count > 0) |
|
|
|
{ |
|
|
|
return Json(new Table() { code = 0, msg = "", data = result, count = result.Count }); |
|
|
|
} |
|
|
|
|
|
|
|
return Json(new Table() { count = 0, data = null }); |
|
|
|
} |
|
|
|
|
|
|
|
public IActionResult REP001B(string id) |
|
|
|
{ |
|
|
|
ViewBag.ImageUrl = $"\\REPImage\\" + id; |
|
|
|
return View(); |
|
|
|
} |
|
|
|
|
|
|
|
public async Task<IActionResult> REP001D(string id) |
|
|
|
{ |
|
|
|
var result = await _repApi.DeleteNgRepairBlob(id); |
|
|
|
return Json(new Result() { success = true, msg = "" }); |
|
|
|
} |
|
|
|
|
|
|
|
public async Task<IActionResult> REP001R(int id) |
|
|
|
{ |
|
|
|
await GetRMAReasonList(); |
|
|
@ -167,30 +193,30 @@ namespace AMESCoreStudio.Web.Controllers |
|
|
|
{ |
|
|
|
model.ngRepairBlob = result5[0]; |
|
|
|
|
|
|
|
if (result5[0].ImageName1 != "" && result5[0].ImageName1 != null) |
|
|
|
{ |
|
|
|
ViewBag.Image1Url = $"\\REPImage\\" + result5[0].ImageName1; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
ViewBag.Image1Url = $"\\REPImage\\" + "noimage.jfif"; |
|
|
|
} |
|
|
|
if (result5[0].ImageName2 != "" && result5[0].ImageName2 != null) |
|
|
|
{ |
|
|
|
ViewBag.Image2Url = $"\\REPImage\\" + result5[0].ImageName2; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
ViewBag.Image2Url = $"\\REPImage\\" + "noimage.jfif"; |
|
|
|
} |
|
|
|
if (result5[0].ImageName3 != "" && result5[0].ImageName3 != null) |
|
|
|
{ |
|
|
|
ViewBag.Image3Url = $"\\REPImage\\" + result5[0].ImageName3; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
ViewBag.Image3Url = $"\\REPImage\\" + "noimage.jfif"; |
|
|
|
} |
|
|
|
//if (result5[0].ImageName1 != "" && result5[0].ImageName1 != null)
|
|
|
|
//{
|
|
|
|
// ViewBag.Image1Url = $"\\REPImage\\" + result5[0].ImageName1;
|
|
|
|
//}
|
|
|
|
//else
|
|
|
|
//{
|
|
|
|
// ViewBag.Image1Url = $"\\REPImage\\" + "noimage.jfif";
|
|
|
|
//}
|
|
|
|
//if (result5[0].ImageName2 != "" && result5[0].ImageName2 != null)
|
|
|
|
//{
|
|
|
|
// ViewBag.Image2Url = $"\\REPImage\\" + result5[0].ImageName2;
|
|
|
|
//}
|
|
|
|
//else
|
|
|
|
//{
|
|
|
|
// ViewBag.Image2Url = $"\\REPImage\\" + "noimage.jfif";
|
|
|
|
//}
|
|
|
|
//if (result5[0].ImageName3 != "" && result5[0].ImageName3 != null)
|
|
|
|
//{
|
|
|
|
// ViewBag.Image3Url = $"\\REPImage\\" + result5[0].ImageName3;
|
|
|
|
//}
|
|
|
|
//else
|
|
|
|
//{
|
|
|
|
// ViewBag.Image3Url = $"\\REPImage\\" + "noimage.jfif";
|
|
|
|
//}
|
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
@ -212,7 +238,7 @@ namespace AMESCoreStudio.Web.Controllers |
|
|
|
|
|
|
|
//頁面提交,id=0 添加,id>0 修改
|
|
|
|
[HttpPost] |
|
|
|
public async Task<IActionResult> REP001RSaveAsync(REP001ViewModel model, IFormFile formFile1, IFormFile formFile2, IFormFile formFile3) |
|
|
|
public async Task<IActionResult> REP001RSaveAsync(REP001ViewModel model, IFormFile formFile) |
|
|
|
{ |
|
|
|
IResultModel result; |
|
|
|
var userID = ""; |
|
|
@ -229,79 +255,25 @@ namespace AMESCoreStudio.Web.Controllers |
|
|
|
model.ngComponent.ReplyDate = System.DateTime.Now; |
|
|
|
model.ngComponent.Status = 1; |
|
|
|
|
|
|
|
string FileName1 = string.Empty; |
|
|
|
string NewName1 = string.Empty; |
|
|
|
string FilePath1 = string.Empty; |
|
|
|
|
|
|
|
string FileName2 = string.Empty; |
|
|
|
string NewName2 = string.Empty; |
|
|
|
string FilePath2 = string.Empty; |
|
|
|
|
|
|
|
string FileName3 = string.Empty; |
|
|
|
string NewName3 = string.Empty; |
|
|
|
string FilePath3 = string.Empty; |
|
|
|
|
|
|
|
if (formFile1 != null) |
|
|
|
{ |
|
|
|
if (formFile1.Length > 0) |
|
|
|
{ |
|
|
|
//取得使用者上傳檔案的原始檔名
|
|
|
|
FileName1 = Path.GetFileName(formFile1.FileName); |
|
|
|
//取原始檔名中的副檔名
|
|
|
|
var fileExt = Path.GetExtension(FileName1); |
|
|
|
//為避免使用者上傳的檔案名稱發生重複,重新給一個亂數名稱
|
|
|
|
NewName1 = Path.GetRandomFileName() + fileExt; |
|
|
|
//指定要寫入的路徑、檔名和副檔名
|
|
|
|
FilePath1 = $"\\REPImage\\";//本機目錄
|
|
|
|
using (var stream = new FileStream(_env.WebRootPath + FilePath1 + NewName1, FileMode.Create)) |
|
|
|
{ |
|
|
|
await formFile1.CopyToAsync(stream); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
ModelState.AddModelError("error", "請選擇要上傳檔案"); |
|
|
|
} |
|
|
|
|
|
|
|
if (formFile2 != null) |
|
|
|
{ |
|
|
|
if (formFile2.Length > 0) |
|
|
|
{ |
|
|
|
//取得使用者上傳檔案的原始檔名
|
|
|
|
FileName2 = Path.GetFileName(formFile2.FileName); |
|
|
|
//取原始檔名中的副檔名
|
|
|
|
var fileExt = Path.GetExtension(FileName2); |
|
|
|
//為避免使用者上傳的檔案名稱發生重複,重新給一個亂數名稱
|
|
|
|
NewName2 = Path.GetRandomFileName() + fileExt; |
|
|
|
//指定要寫入的路徑、檔名和副檔名
|
|
|
|
FilePath2 = $"\\REPImage\\";//本機目錄
|
|
|
|
using (var stream = new FileStream(_env.WebRootPath + FilePath2 + NewName2, FileMode.Create)) |
|
|
|
{ |
|
|
|
await formFile2.CopyToAsync(stream); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
ModelState.AddModelError("error", "請選擇要上傳檔案"); |
|
|
|
} |
|
|
|
string FileName = string.Empty; |
|
|
|
string NewName = string.Empty; |
|
|
|
string FilePath = string.Empty; |
|
|
|
|
|
|
|
if (formFile3 != null) |
|
|
|
if (formFile != null) |
|
|
|
{ |
|
|
|
if (formFile3.Length > 0) |
|
|
|
if (formFile.Length > 0) |
|
|
|
{ |
|
|
|
//取得使用者上傳檔案的原始檔名
|
|
|
|
FileName3 = Path.GetFileName(formFile3.FileName); |
|
|
|
FileName = Path.GetFileName(formFile.FileName); |
|
|
|
//取原始檔名中的副檔名
|
|
|
|
var fileExt = Path.GetExtension(FileName3); |
|
|
|
var fileExt = Path.GetExtension(FileName); |
|
|
|
//為避免使用者上傳的檔案名稱發生重複,重新給一個亂數名稱
|
|
|
|
NewName3 = Path.GetRandomFileName() + fileExt; |
|
|
|
NewName = Path.GetRandomFileName() + fileExt; |
|
|
|
//指定要寫入的路徑、檔名和副檔名
|
|
|
|
FilePath3 = $"\\REPImage\\";//本機目錄
|
|
|
|
using (var stream = new FileStream(_env.WebRootPath + FilePath3 + NewName3, FileMode.Create)) |
|
|
|
FilePath = $"\\REPImage\\";//本機目錄
|
|
|
|
using (var stream = new FileStream(_env.WebRootPath + FilePath + NewName, FileMode.Create)) |
|
|
|
{ |
|
|
|
await formFile3.CopyToAsync(stream); |
|
|
|
await formFile.CopyToAsync(stream); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -339,7 +311,7 @@ namespace AMESCoreStudio.Web.Controllers |
|
|
|
model.ngRepair.ComponentID = model.ngComponent.ComponentID; |
|
|
|
result = await _repApi.PostNgRepair(JsonConvert.SerializeObject(model.ngRepair)); |
|
|
|
} |
|
|
|
if (NewName1 == string.Empty && NewName2 == string.Empty && NewName3 == string.Empty) |
|
|
|
if (NewName == string.Empty) |
|
|
|
{ } |
|
|
|
else |
|
|
|
{ |
|
|
@ -357,18 +329,14 @@ namespace AMESCoreStudio.Web.Controllers |
|
|
|
if (model.ngRepairBlob == null) |
|
|
|
{ |
|
|
|
NgRepairBlob ng_repair_blob = new NgRepairBlob(); |
|
|
|
ng_repair_blob.ImageName1 = NewName1; |
|
|
|
ng_repair_blob.ImageName2 = NewName2; |
|
|
|
ng_repair_blob.ImageName3 = NewName3; |
|
|
|
ng_repair_blob.ImageName = NewName; |
|
|
|
ng_repair_blob.RepairID = repairID; |
|
|
|
|
|
|
|
model.ngRepairBlob = ng_repair_blob; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
model.ngRepairBlob.ImageName1 = NewName1; |
|
|
|
model.ngRepairBlob.ImageName2 = NewName2; |
|
|
|
model.ngRepairBlob.ImageName2 = NewName3; |
|
|
|
model.ngRepairBlob.ImageName = NewName; |
|
|
|
model.ngRepairBlob.RepairID = repairID; |
|
|
|
} |
|
|
|
|
|
|
|