public async Task <ModelMenuA3_FileDownload> GetA3DownloadFileByIdAsync(int DocId, int Id) { string sql = "SELECT TOP(1) file1name FROM Doc_MenuA3 WHERE doc_id='" + DocId + "' "; using (SqlConnection conn = new SqlConnection(ConnectionString)) { conn.Open(); using (SqlCommand command = new SqlCommand(sql, conn)) { SqlDataReader reader = await command.ExecuteReaderAsync(); if (reader.HasRows) { ModelMenuA3_FileDownload e = new ModelMenuA3_FileDownload(); while (await reader.ReadAsync()) { if (Id == 1) { e.filebase64 = ServerDirectorys.ReadFileToBase64(_IEnvironmentConfig.PathDocument, FolderDocument.menuA3, reader["file1name"].ToString()); e.filename = "เอกสารรายงานความก้าวหน้าโครงการ"; } } return(e); } } conn.Close(); } return(null); }
public async Task <ModelMenuD2_FileDownload> GetAllDownloadFileByFileNameAsync(string filename) { ModelMenuD2_FileDownload resp = new ModelMenuD2_FileDownload(); if (!string.IsNullOrEmpty(filename)) { resp.filename = filename; resp.filebase64 = ServerDirectorys.ReadFileToBase64(_IEnvironmentConfig.PathDocument, FolderDocument.menuA7, filename); return(resp); } else { return(null); } }