Пример #1
0
        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()));
        }
Пример #2
0
        public static byte[] DistanceLose(List <CardInfo> cards)
        {
            StringBuilder sb       = new StringBuilder();
            int           dataType = 16777215;
            int           cardType = 1;
            int           index    = 23;

            foreach (CardInfo item in cards)
            {
                for (int i = 0; i < 2; i++)
                {
                    int typeBinary = Utility.GetIntegerSomeBit(cardType, i);
                    dataType = Utility.SetIntegeSomeBit(dataType, index - i, typeBinary == 1);
                }
                index -= 2;

                if (item.CardReportLoss == 0)
                {
                    item.CardReportLoss = 0;
                    item.Synchronous    = item.Synchronous == 0 ? 1 : 0;
                }
                int functionByte = 255;
                Utility.SetIntegeSomeBit(functionByte, 7, true);
                Utility.SetIntegeSomeBit(functionByte, 6, item.Synchronous == 1);

                sb.Append(item.CardNumber);
                sb.Append($"{functionByte:X2}");
                sb.Append($"{item.CardTime.AddMonths(1):yyMM}");
            }
            return(PortAgreement.WriteACard("797979", 0, $"{cards.Count:X2}{dataType:X6}{sb.ToString()}"));
        }
Пример #3
0
        public static byte[] SetDistanceData(LprCardDataParam param, ref int functionbyte)
        {
            int typebyte = SetCardTypeByte(param.CardTypeParam);

            functionbyte = SetCardFunctionByte(param.CardFunctioinParam);

            StringBuilder sb = new StringBuilder();

            sb.AppendFormat("{0:X2}", functionbyte);
            sb.AppendFormat("{0:X4}", param.Count);
            if (param.ViceCards != null && param.ViceCards.Count > 0)
            {
                foreach (LprCardViceCardParam item in param.ViceCards)
                {
                    sb.AppendFormat("{0:yyMMdd}", item.ViceCardTime);
                    sb.AppendFormat("{0:X4}", item.ViceCardPartition);
                    sb.Append(GetPlateNumber(item.PlateNumber));
                }
            }
            else
            {
                sb.Append("FFFFFFFFFFFFFFFFFFFFFFFFFF");
            }
            return(PortAgreement.GetDistanceContent(param.CardNumber, typebyte, 0, sb.ToString()));
        }
Пример #4
0
        public static byte[] SetDistanceData(string cardnumber, int count, DateTime time, int partition)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendFormat("{0:X4}", count);
            sb.AppendFormat("{0:yyMMdd}", time);
            sb.AppendFormat("{0:X4}", partition);
            return(PortAgreement.GetDistanceContent(cardnumber, 1, sb.ToString()));
        }
Пример #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="infos">挂失或解挂的卡片信息</param>
        /// <param name="state">挂失或解挂的状态 1 - 解挂 2 - 挂失</param>
        /// <returns></returns>
        public static byte[] PersonnelLoseOrRecovery(List <CardInfo> infos, int state)
        {
            StringBuilder sb = new StringBuilder();

            foreach (CardInfo item in infos)
            {
                sb.Append($"{item.CardNumber:X2}0{state}{item.CardTime:yyMM}");
            }
            return(PortAgreement.WriteACard("797979", 0, sb.ToString()));
        }
Пример #6
0
        public static byte[] Issue(CardInfo info)
        {
            int typeByte     = SetTypeByte(info);
            int functionByte = SetFunctionByte(info);

            StringBuilder sb = new StringBuilder($"{functionByte:X2}{info.CardCount:X4}");

            switch ((PortEnums.CardTypes)info.CardType)
            {
            case PortEnums.CardTypes.Card1:
                sb.Append($"{info.CardTime:yyMMdd}");
                sb.Append($"{info.CardPartition:X4}");
                break;

            case PortEnums.CardTypes.Card2:
                if (info.ViceCardInfos != null)
                {
                    foreach (CardInfo item in info.ViceCardInfos)
                    {
                        sb.Append($"{item.CardTime:yyMMdd}");
                        sb.Append($"{item.CardPartition:X4}");
                        sb.Append($"{item.CardCount:X4}");
                        sb.Append($"{item.CardNumber}");
                    }
                }
                else
                {
                    sb.Append("FFFFFFFFFFFFFFFFFFFFFFFFFF");
                }
                break;

            case PortEnums.CardTypes.Card3:
                if (info.ViceCardInfos != null)
                {
                    foreach (CardInfo item in info.ViceCardInfos)
                    {
                        sb.Append($"{item.CardTime:yyMmdd}");
                        sb.Append($"{item.CardPartition:X4}");
                        sb.Append($"{PlateNumberToHex(item.CardNumber)}");
                    }
                }
                else
                {
                    sb.Append("FFFFFFFFFFFFFFFFFFFFFFFFFF");
                }
                break;

            case PortEnums.CardTypes.Card4:
                sb = new StringBuilder($"{functionByte:X2}");
                break;
            }
            return(PortAgreement.WriteACard(info.CardNumber, typeByte, 0, $"{sb.ToString()}"));
        }
Пример #7
0
        public static byte[] SetDistanceData(SingleCardDataParam param, ref int functionbyte)
        {
            int typebyte = SetCardTypeByte(param.CardTypeParam);

            functionbyte = SetCardFunctionByte(param.CardFunctioinParam);

            StringBuilder sb = new StringBuilder();

            sb.AppendFormat("{0:X2}", functionbyte);
            sb.AppendFormat("{0:X4}", param.Count);
            sb.AppendFormat("{0:yyMMdd}", param.NewTime);
            sb.AppendFormat("{0:X4}", param.Partition);
            return(PortAgreement.GetDistanceContent(param.CardNumber, typebyte, 0, sb.ToString()));
        }
Пример #8
0
        public static byte[] Issue(CardInfo info, int datatype, string customdata)
        {
            int           typeByte = 2;
            StringBuilder sb       = new StringBuilder();

            if (datatype == 1)
            {
                sb.Append($"{info.CardTime:yyMMdd}");
                sb.Append($"{info.CardPartition:X4}");
            }
            else
            {
                sb.Append(customdata);
            }
            return(PortAgreement.WriteACard(info.CardNumber, typeByte, 0, sb.ToString()));
        }
Пример #9
0
        public static byte[] CombinationLoss(List <LossParameter> lossparams)
        {
            int           index    = 0;
            int           losstype = 87381;
            StringBuilder sb       = new StringBuilder();

            foreach (LossParameter item in lossparams)
            {
                losstype = BinaryHelper.SetIntegeSomeBit(losstype, index, true);
                index   += 2;
                sb.Append(item.CardNumber);
                sb.AppendFormat("{0:X2}", SetFunctionParameeter(item.Function));
                sb.AppendFormat("{0:yyMM}", item.Time.AddDays(1));
            }
            string content = string.Format("{0:X2}{1:X6}{2}", lossparams.Count, losstype, sb.ToString());

            return(PortAgreement.GetLossContent("797979", content));
        }
Пример #10
0
        public static byte[] SetDistanceData(string cardnumber, int count, List <LprCardViceCardParam> param)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendFormat("{0:X4}", count);
            if (param != null && param.Count > 0)
            {
                foreach (LprCardViceCardParam item in param)
                {
                    sb.AppendFormat("{0:yyMMdd}", item.ViceCardTime);
                    sb.AppendFormat("{0:X4}", item.ViceCardPartition);
                    sb.Append(GetPlateNumber(item.PlateNumber));
                }
            }
            else
            {
                sb.Append("FFFFFFFFFFFFFFFFFFFFFFFFFF");
            }
            return(PortAgreement.GetDistanceContent(cardnumber, 1, sb.ToString()));
        }
Пример #11
0
        public static byte[] SetLossCard(LossCardDataParam[] param)
        {
            StringBuilder sb       = new StringBuilder();
            int           datatype = 16777215;
            int           cardtype = 1;
            int           index    = 23;

            foreach (LossCardDataParam item in param)
            {
                cardtype = item.CardType != CardTypes.ViceCard ? 2 : 1;
                for (int i = 0; i < 2; i++)
                {
                    int typebinary = BinaryHelper.GetIntegerSomeBit(cardtype, i);
                    datatype = BinaryHelper.SetIntegeSomeBit(datatype, index - i, typebinary != 0);
                }
                index -= 2;
                sb.Append(item.CardNumber);
                sb.AppendFormat("{0:X2}", BinaryHelper.SetIntegeSomeBit(item.Functionbyte, 7, true));
                sb.AppendFormat("{0:yyMM}", item.CardTime.AddMonths(1));
            }
            return(PortAgreement.GetDistanceContent("797979", 0, string.Format("{0:X2}{1:X6}{2}", param.Length, datatype, sb.ToString())));
        }
Пример #12
0
        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()));
        }