Two times in the development of the download time attendance photos

Source: Internet
Author: User

Attendance machine is m880, need to set up in the attendance machine to save time and attendance photos.

Only functions to download attendance records in the SDK development documentation

Readgenerallogdata

Ssr_getgenerallogdata

Both mates can read the punch-card record.

The document does not have a function to download the absence photo, and you view photo in the code hint. Found the following three functions

Public virtual bool Getphotonamesbytime (int dwmachinenumber, int. Iflag, String stime, String etime, out string Allphotonam e);

Public virtual bool Getphotocount (int dwmachinenumber, out int count, int iflag);

Public virtual bool Getphotobyname (int dwmachinenumber, String photoname, out byte photodata, out int photolength);

The function can be guessed by name.

Getphotonamesbytime read the list of photos in the attendance machine, the photo naming rules are time + attendance number, multiple names separated by ' \ t '.

Getphotobyname download photos by name.

But when called in the code below, the error code-2 is returned.

byte Photodata; int 0 //////photo name needs to be added ". jpg" Axczkem1.getphotobyname (imachinenumber,"20150910063045"  ". jpg"out   photolength)

After the sale of the control, no one. Only on their own.

Using Wireshark analysis of computer and attendance machine communication, found that the time machine has been correctly returned to the photo data, photo data is binary data.

The parameters of the Getphotobyname function are out photodata, which should save the photo data.

The problem is that photodata is of type Byte, and the binary data of the photo should be the byte[] type. Calling a function causes the data to be written to the memory illegally.

Thought of an unconventional solution.

unsafe{byte[] Photodata =New byte[1024x768*Ten]; intPhotolength =0; Try{if(Axczkem1.getphotobyname (Imachinenumber, Arr[j]. Trim () +". jpg", outphotodata[0], outphotolength)) {if(Photolength <photodata.length) {byte[] tmp =New byte[Photolength];        Array.copy (Photodata, TMP, photolength); System.IO.File.WriteAllBytes ("d:\\photos\\20150910063045.jpg", TMP); }         }       }     Catch(Exception ex) {}}

Finally set in the properties of the project: Allow unsafe code.

Two times in the development of the download time attendance photos

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.