public JsonResult InsertExceldata() { var result = new ModelJsonResult <ModelInsertExcelData>(); var modelInsertExcel = new ModelInsertExcelData(); try { string inYear = Request["year"]; HttpFileCollectionBase files = Request.Files; if (files == null || 0.Equals(files.Count)) { result.SetError("No File Data To Load"); return(Json(result)); } var fb = files[0]; if (fb == null || fb.InputStream == null) { result.SetError("No File Data To Load"); return(Json(result)); } string exttension = System.IO.Path.GetExtension(fb.FileName); if (!(new string[] { ".xls", ".xlsx" }).Contains(exttension)) { result.SetError("File Type Not In xls or xlsx"); return(Json(result)); } insertExcelRiskManagementData( pFileStream: fb.InputStream, pStrUploadBy: User.Identity.Name, pIntYear: inYear.GetInt(), pModelResult: modelInsertExcel ); result.SetResultValue(modelInsertExcel); return(Json(result)); } catch (Exception ex) { result.SetException(ex); return(Json(result)); } }
public JsonResult IsDuplicateExcelData() { var result = new ModelJsonResult <bool>(); string inYear = Request["year"]; HttpFileCollectionBase files = Request.Files; if (files == null || 0.Equals(files.Count)) { result.SetError("No File Data To Load"); return(Json(result)); } var fb = files[0]; if (fb == null || fb.InputStream == null) { result.SetError("No File Data To Load"); return(Json(result)); } string exttension = System.IO.Path.GetExtension(fb.FileName); if (!(new string[] { ".xls", ".xlsx" }).Contains(exttension)) { result.SetError("File Type Not In xls or xlsx"); return(Json(result)); } var dto = new DTO.DtoRisk(); bool isDuplicate = false; var listRiskManagement = dto.ReadExcelRiskManagementImport( pStreamExcel: fb.InputStream, pIntYear: inYear.GetInt(), pStrUploadBy: User.Identity.Name ); isDuplicate = dto.GetListRiskManagementImportDuplicate(listRiskManagement).Any(); result.SetResultValue(isDuplicate); return(Json(result)); }