/**************************************************************************************************************************** * 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: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); }