public HttpResponseMessage Search() { bal = new T_Planing_Action_AfterAppliedCoatingBAL(); ResposeType response = new ResposeType(); HttpResponseMessage mapMessage = null; T_Planing_Action_AfterAppliedCoatingDTO dto = null; List <T_Planing_Action_AfterAppliedCoatingDTO> objList = null; response.statusCode = false; try { var context = HttpContext.Current; dto = ConvertX.GetReqeustForm <T_Planing_Action_AfterAppliedCoatingDTO>(); objList = bal.FindByObjList(dto); foreach (T_Planing_Action_AfterAppliedCoatingDTO mainDTO in objList) { //Find detail and push to main object in list T_Planing_Action_AfterAppliedCoatingDTO detailDTO = new T_Planing_Action_AfterAppliedCoatingDTO(); detailDTO.PID = mainDTO.PID; detailDTO = bal.FindByPK(detailDTO); mainDTO.UploadFileList = detailDTO.UploadFileList; mainDTO.DryFilmThicknessList = detailDTO.DryFilmThicknessList; if (!ObjUtil.isEmpty(mainDTO.UploadFileList)) { foreach (T_Planing_File file in mainDTO.UploadFileList) { file.HtmlFile = System.Web.VirtualPathUtility.ToAbsolute(planPath + "/" + file.PID + "/" + file.UploadType + "/" + file.FileName); string fullPath = context.Server.MapPath(planPath) + @"\" + file.PID + @"\" + file.UploadType + @"\" + file.FileName; file.Base64File = Utility.convertFileToBase64(fullPath); } } } response.statusCode = true; response.data = objList; } catch (Exception ex) { logger.error("Search error:" + ex.ToString()); response.statusText = ex.ToString(); } mapMessage = Request.CreateResponse(HttpStatusCode.OK, response); return(mapMessage); }
public HttpResponseMessage View() { bal = new T_Planing_Action_AfterAppliedCoatingBAL(); ResposeType response = new ResposeType(); HttpResponseMessage mapMessage = null; T_Planing_Action_AfterAppliedCoatingDTO dto = null; response.statusCode = false; try { var context = HttpContext.Current; dto = ConvertX.GetReqeustForm <T_Planing_Action_AfterAppliedCoatingDTO>(); dto = bal.FindByPK(dto); if (dto != null && dto.UploadFileList != null) { foreach (var uploadFile in dto.UploadFileList) { uploadFile.HtmlFile = System.Web.VirtualPathUtility.ToAbsolute(planPath + "/" + dto.PID + "/" + uploadFile.UploadType + "/" + uploadFile.FileName); string fullPath = context.Server.MapPath(planPath) + @"\" + uploadFile.PID + @"\" + uploadFile.UploadType + @"\" + uploadFile.FileName; uploadFile.Base64File = Utility.convertFileToBase64(fullPath); } } response.statusCode = true; response.data = dto; } catch (Exception ex) { logger.error("View error:" + ex.ToString()); response.statusText = ex.ToString(); } mapMessage = Request.CreateResponse(HttpStatusCode.OK, response); return(mapMessage); }