/**************************************************************************************************************************** * FunctionName:SetTmp10ToFp10 * Parameters In:Size,PIN,FingerID,Valid,Template * Parameters Out:DataBuf * Return Value:void * Device Used:template.fp10.1 coming from devices using 10.0 arithmetic * Function:To convert the independent parameters to bytes arrays DataBuf according to the class Template * Explanation:he length of the finger templates is variable * Auther:Darcy * Date:Oct.23, 2009 *****************************************************************************************************************************/ public void SetTmp10ToFp10(out byte[] DataBuf, int Size, int PIN, int FingerID, int Valid, string Template) { DataBuf = new byte[Size]; byte[] TemplateBuf = new byte[Size - 6]; Tmp10Header tmp10 = new Tmp10Header(); tmp10.Size = (ushort)Size; tmp10.PIN = (ushort)PIN; tmp10.FingerID = (byte)FingerID; tmp10.Valid = (byte)Valid; Array.Copy(Raw.RawSerialize(tmp10), DataBuf, 6); Template = Template.Replace(" ", ""); if (Template.Length <= 0) { Template = ""; } byte[] TemplateBytes = new byte[Template.Length / 2]; for (int i = 0; i < Template.Length; i += 2) { if (!byte.TryParse(Template.Substring(i, 2), NumberStyles.HexNumber, null, out TemplateBytes[i / 2])) { TemplateBytes[i / 2] = 0; } } string TemplateFromHex = ASCIIEncoding.Default.GetString(TemplateBytes); TemplateBuf = System.Text.Encoding.Default.GetBytes(TemplateFromHex); Array.Copy(TemplateBuf, 0, DataBuf, 6, TemplateFromHex.Length); }
/**************************************************************************************************************************** * FunctionName:SetSSRUserInfoToDat * Parameters In:PIN,Privilege,Password,Name,Card,Group,TimeZones(string),PIN2(string) * Parameters Out:DataBuf * Return Value:void * Device Used:user.dat in TFT screen Device * Function:To convert the independent parameters to bytes arrays DataBuf according to the class SSR_User * Auther:Darcy * Date:Oct.23, 2009 *****************************************************************************************************************************/ public void SetSSRUserInfoToDat(out byte[] DataBuf, int PIN, int Privilege, string Password, string Name, int Card, int Group, string TimeZones, string PIN2) { DataBuf = new byte[72]; byte[] PasswordBuf = new byte[8]; byte[] NameBuf = new byte[24]; byte[] CardBuf = new byte[4]; byte[] TimeZonesBuf = new byte[8]; byte[] PIN2Buf = new byte[24]; SSR_User ssruser = new SSR_User(); ssruser.PIN = (ushort)PIN; ssruser.Privilege = (byte)Privilege; PasswordBuf = System.Text.Encoding.Default.GetBytes(Password); Array.Copy(PasswordBuf, ssruser.Password, 8); NameBuf = System.Text.Encoding.Default.GetBytes(Name); Array.Copy(NameBuf, ssruser.Name, 24); CardBuf = BitConverter.GetBytes(Card); Array.Copy(CardBuf, ssruser.Card, 4); ssruser.Group = (byte)Group; TimeZonesBuf = System.Text.Encoding.Default.GetBytes(TimeZones); ssruser.TimeZones[0] = (ushort)TimeZonesBuf[0]; //whether to use timezones or not (0 stands for yes,1 stands for defining by yourself) ssruser.TimeZones[1] = (ushort)TimeZonesBuf[1]; //(if you use the timezones)timezoune1 ssruser.TimeZones[2] = (ushort)TimeZonesBuf[2]; //timezone2 ssruser.TimeZones[3] = (ushort)TimeZonesBuf[3]; //timezone3 PIN2Buf = System.Text.Encoding.Default.GetBytes(PIN2); Array.Copy(PIN2Buf, ssruser.PIN2, 24); Array.Copy(Raw.RawSerialize(ssruser), DataBuf, 72); }
/**************************************************************************************************************************** * FunctionName: SetFaceToDat * Parameters In:Size,PIN,FaceID,Valid,Reserve,ActiveTime,VfCount,Face * Parameters Out:DataBuf * Return Value:void * Device Used:devices supporting faces registering * Function:To convert the independent parameters to bytes arrays DataBuf according to the class Template * Auther:Darcy * Date:Oct.23, 2009 *****************************************************************************************************************************/ public void SetFaceToDat(out byte[] DataBuf, int Size, int PIN, int FaceID, int Valid, int Reserve, int ActiveTime, int VfCount, string Face) { DataBuf = new byte[2576]; byte[] FaceBuf = new byte[2560]; FaceTmp face = new FaceTmp(); face.Size = (ushort)Size; face.PIN = (ushort)PIN; face.FaceID = (byte)FaceID; face.Valid = (byte)Valid; face.Reserve = (ushort)Reserve; face.ActiveTime = (uint)ActiveTime; face.VfCount = (uint)VfCount; Face = Face.Replace(" ", ""); if (Face.Length <= 0) { Face = ""; } byte[] FaceBytes = new byte[Face.Length / 2]; for (int i = 0; i < Face.Length; i += 2) { if (!byte.TryParse(Face.Substring(i, 2), NumberStyles.HexNumber, null, out FaceBytes[i / 2])) { FaceBytes[i / 2] = 0; } } string FaceFromHex = ASCIIEncoding.Default.GetString(FaceBytes); FaceBuf = System.Text.Encoding.Default.GetBytes(FaceFromHex); Array.Copy(FaceBuf, face.Face, FaceFromHex.Length); Array.Copy(Raw.RawSerialize(face), DataBuf, 2576); }