private static int SetTypeParameter(DistanceParameterContent parameter, object obj) { int type = 0; if (parameter.Type != null) { type = 1; if (parameter.Function != null || obj != null) { type = 2; } type = BinaryHelper.SetIntegeSomeBit(type, 7, parameter.Type.Value.Lock != 0); if (parameter.Type.Value.Distance > 0) { type = BinaryHelper.SetIntegeSomeBit(type, 6, true); for (int i = 0; i < 2; i++) { int distancebinary = BinaryHelper.GetIntegerSomeBit(parameter.Type.Value.Distance - 1, i); type = BinaryHelper.SetIntegeSomeBit(type, 5 - i, distancebinary != 0); } } else { type = BinaryHelper.SetIntegeSomeBit(type, 6, false); } } return(type); }
public static byte[] CombinationDistanceCard(DistanceParameterContent parameter, List <PlateCardData> data) { int start = 0; int type = SetTypeParameter(parameter, data); int function = SetFunctionParameeter(parameter.Function.Value); StringBuilder sb = new StringBuilder(); if (function != -1) { sb.AppendFormat("{0:X2}", function); } else { start = 1; } sb.AppendFormat("{0:X4}", parameter.Count); if (data != null) { if (data.Count > 0) { foreach (PlateCardData item in data) { sb.AppendFormat("{0:yyMMdd}", item.Time); sb.AppendFormat("{0:X4}", item.Partition); sb.Append(GetLprNumber(item.Plate)); } } else { sb.Append("FFFFFFFFFFFFFFFFFFFFFFFFFF"); } } return(PortAgreement.GetDistanceContent(parameter.CardNumber, type, start, sb.ToString())); }
public static byte[] CombinationDistanceCard(DistanceParameterContent parameter, SingleCardData?data) { int start = 0; int type = SetTypeParameter(parameter, data); int function = SetFunctionParameeter(parameter.Function.Value); StringBuilder sb = new StringBuilder(); if (function != -1) { sb.AppendFormat("{0:X2}", function); } else { start = 1; } sb.AppendFormat("{0:X4}", parameter.Count); if (data != null) { sb.AppendFormat("{0:yyMMdd}", data.Value.Time); sb.AppendFormat("{0:X4}", data.Value.Partition); } return(PortAgreement.GetDistanceContent(parameter.CardNumber, type, start, sb.ToString())); }