Download attendance photo.
Device number
Photo's name
The binary data of photo
The size of photo data
Return True if it is successful, or return False.
GetPhotoNamesByTime
/// <summary> /// Download the UserPhoto from the device(For TFT screen devices). /// </summary> /// <param name="phtoName">File Name of jpg image</param> /// <param name="Flag">When iFlag is 0, delete all attendance photo, when iFlag is 1, delete the photos between sTime and eTime </param> /// <param name="IP"> Ip of device </param> /// <param name="Port"> Port of Device </param> /// <param name="MachineNumber"> Device Number </param> /// <returns></returns> private Bitmap GetPhotoByName(string phtoName, int Flag, string IP = "10.0.0.44", int Port = 4370, int MachineNumber = 1) { //Create Standalone SDK class dynamicly. zkemkeeper.CZKEMClass axCZKEM1 = new zkemkeeper.CZKEMClass(); axCZKEM1.Connect_Net(IP, Port); int idwErrorCode = 0; Bitmap Pic = null; byte[] PhotoData = new byte[1024 * 60]; int phtoSize = 0; if (axCZKEM1.GetPhotoByName(MachineNumber, phtoName, out PhotoData[0], out phtoSize)) { using (MemoryStream msCamera = new MemoryStream(PhotoData, 0, phtoSize)) { using (Bitmap bt = new Bitmap(msCamera)) { if (bt != null) { FileStream fs = new FileStream(@"Photo\\" + phtoName + ".jpg", FileMode.OpenOrCreate); msCamera.WriteTo(fs); fs.Close(); Pic = new Bitmap(msCamera); } } } MessageBox.Show("GetPhotoByName,phtoName:" + phtoName.ToString() + "phtoSize:" + phtoSize.ToString(), "Success"); } else { axCZKEM1.GetLastError(ref idwErrorCode); MessageBox.Show("Operation failed,ErrorCode=" + idwErrorCode.ToString(), "Error"); } return Pic; }
''' <summary> ''' Download the UserPhoto from the device(For TFT screen devices). ''' </summary> ''' <param name="phtoName">File Name of jpg image</param> ''' <param name="Flag">When iFlag is 0, delete all attendance photo, when iFlag is 1, delete the photos between sTime and eTime </param> ''' <param name="IP"> Ip of device </param> ''' <param name="Port"> Port of Device </param> ''' <param name="MachineNumber"> Device Number </param> ''' <returns></returns> Private Function GetPhotoByName(phtoName As String, Flag As Integer, Optional IP As String = "10.0.0.44", Optional Port As Integer = 4370, Optional MachineNumber As Integer = 1) As Bitmap 'Create Standalone SDK class dynamicly. Dim axCZKEM1 As zkemkeeper.CZKEMClass = New zkemkeeper.CZKEMClass() axCZKEM1.Connect_Net(IP, Port) Dim idwErrorCode As Integer = 0 Dim Pic As Bitmap = Nothing Dim PhotoData(0 To 1024 * 60 - 1) As Byte Dim phtoSize As Integer = 0 If axCZKEM1.GetPhotoByName(MachineNumber, phtoName, PhotoData(0), phtoSize) Then Using msCamera As New MemoryStream(PhotoData, 0, phtoSize) Using bt As New Bitmap(msCamera) If bt IsNot Nothing Then Dim fs As New FileStream("Photo\\" & phtoName & ".jpg", FileMode.OpenOrCreate) msCamera.WriteTo(fs) fs.Close() Pic = New Bitmap(msCamera) End If End Using End Using MessageBox.Show("GetPhotoByName,phtoName:" & phtoName.ToString() & "phtoSize:" & phtoSize.ToString(), "Success") Else axCZKEM1.GetLastError(idwErrorCode) MessageBox.Show("Operation failed,ErrorCode=" & idwErrorCode.ToString(), "Error") End If Return Pic End Function