public string Get_Jmjm1_Attach_List(DownLoadImg request) { string Result = null; jan = new List <JobNoAttachName>(); string strPath = ""; string DocumentPath = ""; try { using (var db = DbConnectionFactory.OpenDbConnection()) { //string strSQL = "Select Top 1 BackupPath From Saco1"; string strSQL = "Select DocumentPath From Saco1 "; List <Saco1> saco1 = db.Select <Saco1>(strSQL); if (saco1.Count > 0) { DocumentPath = saco1[0].DocumentPath; } } //strPath = DocumentPath + "\\csbk1\\" + request.BookingNo; // GetAllDirList(strPath); if (request.TableName == "Aemp1") { strPath = DocumentPath + "\\" + request.TableName + "\\" + request.Key + "\\" + "signature.png"; /*20160518 download file path for signature.png*/ } else { strPath = DocumentPath + "\\" + request.TableName + "\\" + request.Key + "\\" + "signature.png"; /*20160518 download file path for signature.png*/ } if (File.Exists(strPath)) { using (FileStream fsRead = new FileStream(strPath, FileMode.Open)) { int fsLen = (int)fsRead.Length; /*20160518 To convert imgage ask Base64 */ Image img = Image.FromStream(fsRead); MemoryStream ms = new MemoryStream(); byte[] imagedata = null; img.Save(ms, System.Drawing.Imaging.ImageFormat.Png); imagedata = ms.GetBuffer(); Result = Convert.ToBase64String(imagedata); } } else { Result = null; } } catch { throw; } return(Result); }
public List <Tobk1> Get_Jmjm1_Doc_List(DownLoadImg request) { List <Tobk1> Result = null; try { using (var db = DbConnectionFactory.OpenDbConnection()) { string strSQL = "SELECT Top 1 JobNo " + "FROM Tobk1 Where JobNo='" + request.JobNo + "' And IsNull(StatusCode,'')<>'DEL'"; Result = db.Select <Tobk1>(strSQL); } } catch { throw; } return(Result); }
public string Get_Jmjm1_Attach_List(DownLoadImg request) { string Result = null; jan = new List <JobNoAttachName>(); string strPath = ""; string DocumentPath = ""; try { using (var db = DbConnectionFactory.OpenDbConnection()) { string strSQL = "Select Top 1 DocumentPath From Saco1"; List <Saco1> saco1 = db.Select <Saco1>(strSQL); if (saco1.Count > 0) { DocumentPath = saco1[0].DocumentPath; } } //strPath = DocumentPath + "\\Tobk1\\" + request.JobNo; // GetAllDirList(strPath); // DocumentPath = "E:\\Sysfreight"; strPath = DocumentPath + "\\Tobk1\\" + request.JobNo + "\\" + "signature.png"; //strPath = DocumentPath + "\\Tobk1\\" + request.JobNo; using (FileStream fsRead = new FileStream(strPath, FileMode.Open)) { int fsLen = (int)fsRead.Length; Image img = Image.FromStream(fsRead); //BinaryFormatter binFormatter = new BinaryFormatter(); //MemoryStream memStream = new MemoryStream(); //binFormatter.Serialize(memStream, img); //byte[] bytes = memStream.GetBuffer(); //string base64 = Convert.ToBase64String(bytes); //Result = base64; MemoryStream ms = new MemoryStream(); byte[] imagedata = null; img.Save(ms, System.Drawing.Imaging.ImageFormat.Png); imagedata = ms.GetBuffer(); Result = Convert.ToBase64String(imagedata); } } catch { throw; } return(Result); }