Exemple #1
0
        public void GetCarDriverData(DataRow dataRow_0)
        {
            string contextData = this.protocolDrData_0.ContextData;

            try
            {
                int num = NumHelper.ConvertToInt(contextData.Substring(0, 2));
                if ((num != 1) && (num != 2))
                {
                    throw new Exception();
                }
                string   str2   = (num == 1) ? "插卡" : "拔卡";
                DateTime time   = DateTime.Parse(NumHelper.GetBCDDataTime(contextData.Substring(2, 12)));
                int      num2   = 0;
                string   str3   = "";
                int      length = 0;
                string   str4   = "";
                string   str5   = "";
                int      num4   = 0;
                string   str6   = "";
                DateTime time2  = Convert.ToDateTime("1970-01-01");
                string   format = "";
                if (num == 1)
                {
                    num2 = NumHelper.ConvertToInt(contextData.Substring(14, 2));
                    if ((num2 > 3) || (num2 < 0))
                    {
                        throw new Exception();
                    }
                    switch (num2)
                    {
                    case 0:
                        str3 = "IC卡读卡成功";
                        break;

                    case 1:
                        str3 = "读卡失败,原因为卡片密钥认证未通过";
                        break;

                    case 2:
                        str3 = "读卡失败,原因为卡片已被锁定";
                        break;

                    case 3:
                        str3 = "读卡失败,原因为卡内信息为空";
                        break;
                    }
                    if (num2 == 0)
                    {
                        length = NumHelper.ConvertToInt(contextData.Substring(0x10, 2)) * 2;
                        str4   = NumHelper.GetStringFromBase16ASCII(contextData.Substring(0x12, length));
                        str5   = NumHelper.GetStringFromBase16ASCII(contextData.Substring(0x12 + length, 40));
                        num4   = NumHelper.Convert16To10(contextData.Substring(0x3a + length, 2)) * 2;
                        str6   = NumHelper.GetStringFromBase16ASCII(contextData.Substring(60 + length, num4));
                        time2  = DateTime.Parse(NumHelper.GetBCDDate(contextData.Substring((60 + length) + num4, 8)));
                        format = "驾驶员姓名:{0},状态:{6},时间:{5},IC卡读取结果:{1},从业资格证:{2},发证机构名称:{3},证件有效期:{4}";
                        format = string.Format(format, new object[] { str4, str3, str5, str6, time2.ToString("yyyy-MM-dd"), time, str2 });
                    }
                    else
                    {
                        format = "驾驶员姓名:{0},状态:{3},时间:{2},IC卡读取结果:{1}";
                        format = string.Format(format, new object[] { str4, str3, time, str2 });
                    }
                    format = format.Replace("\0", "");
                }
                else
                {
                    format = "状态:{0},时间:{1}";
                    format = string.Format(format, str2, time);
                }
                dataRow_0["OrderName"] = "驾驶员身份信息应答";
                dataRow_0["Describe"]  = format;
                int    num5 = (dataRow_0["CarId"] == DBNull.Value) ? 0 : int.Parse(dataRow_0["CarId"].ToString());
                int    num6 = UpdataInsertDBInfor.UpdateDriverInfor(num5, num, time, num2, str4.Replace("\0", ""), str5.Replace("\0", ""), str6, time2);
                string str8 = "";
                if (num == 1)
                {
                    str8 = "驾驶员登陆成功";
                    if (num2 != 0)
                    {
                        str8 = "驾驶员登录失败," + str3;
                    }
                    else if (num6 == 0)
                    {
                        str8 = "驾驶员登录失败,原因为驾驶员身份信息无效";
                    }
                }
                else
                {
                    str8 = "驾驶员取卡成功";
                }
                IODeviceTextMsg msg = new IODeviceTextMsg {
                    InfoID  = 1,
                    Message = str8,
                    SimNum  = dataRow_0["SimNum"].ToString()
                };
                this.IODeviceAttachInfo.Add(msg);
            }
            catch (Exception)
            {
                int    startIndex = 0;
                int    num8       = NumHelper.Convert16To10(contextData.Substring(0, 2)) * 2;
                string str9       = NumHelper.GetStringFromBase16ASCII(contextData.Substring(2, num8));
                string str10      = NumHelper.GetStringFromBase16ASCII(contextData.Substring(2 + num8, 40));
                startIndex = (2 + num8) + 40;
                string str11 = NumHelper.GetStringFromBase16ASCII(contextData.Substring(startIndex, 80));
                startIndex += 80;
                int num9 = NumHelper.Convert16To10(contextData.Substring(startIndex, 2)) * 2;
                startIndex += 2;
                string str12 = NumHelper.GetStringFromBase16ASCII(contextData.Substring(startIndex, num9));
                string str13 = "驾驶员姓名:{0},驾驶员身份证编码:{1},从业资格证:{2},发证机构名称:{3}";
                str13 = string.Format(str13, new object[] { str9, str10, str11, str12 }).Replace("\0", "");
                dataRow_0["OrderName"] = "驾驶员身份信息应答";
                dataRow_0["Describe"]  = str13;
                int num10 = (dataRow_0["CarId"] == DBNull.Value) ? 0 : int.Parse(dataRow_0["CarId"].ToString());
                if (UpdataInsertDBInfor.UpdateDriverInfor(num10, str10.Replace("\0", ""), str11.Replace("\0", ""), str9.Replace("\0", ""), str12.Replace("\0", "")) == 0)
                {
                    IODeviceTextMsg msg3 = new IODeviceTextMsg {
                        InfoID  = 1,
                        Message = "驾驶员身份信息无效",
                        SimNum  = dataRow_0["SimNum"].ToString()
                    };
                    this.IODeviceAttachInfo.Add(msg3);
                }
            }
        }
Exemple #2
0
        public void GetCarDriverData(DataRow dataRow_0)
        {
            string contextData = this.protocolDrData_0.ContextData;
            try
            {
                int num = NumHelper.ConvertToInt(contextData.Substring(0, 2));
                if ((num != 1) && (num != 2))
                {
                    throw new Exception();
                }
                string str2 = (num == 1) ? "插卡" : "拔卡";
                DateTime time = DateTime.Parse(NumHelper.GetBCDDataTime(contextData.Substring(2, 12)));
                int num2 = 0;
                string str3 = "";
                int length = 0;
                string str4 = "";
                string str5 = "";
                int num4 = 0;
                string str6 = "";
                DateTime time2 = Convert.ToDateTime("1970-01-01");
                string format = "";
                if (num == 1)
                {
                    num2 = NumHelper.ConvertToInt(contextData.Substring(14, 2));
                    if ((num2 > 3) || (num2 < 0))
                    {
                        throw new Exception();
                    }
                    switch (num2)
                    {
                        case 0:
                            str3 = "IC卡读卡成功";
                            break;

                        case 1:
                            str3 = "读卡失败,原因为卡片密钥认证未通过";
                            break;

                        case 2:
                            str3 = "读卡失败,原因为卡片已被锁定";
                            break;

                        case 3:
                            str3 = "读卡失败,原因为卡内信息为空";
                            break;
                    }
                    if (num2 == 0)
                    {
                        length = NumHelper.ConvertToInt(contextData.Substring(0x10, 2)) * 2;
                        str4 = NumHelper.GetStringFromBase16ASCII(contextData.Substring(0x12, length));
                        str5 = NumHelper.GetStringFromBase16ASCII(contextData.Substring(0x12 + length, 40));
                        num4 = NumHelper.Convert16To10(contextData.Substring(0x3a + length, 2)) * 2;
                        str6 = NumHelper.GetStringFromBase16ASCII(contextData.Substring(60 + length, num4));
                        time2 = DateTime.Parse(NumHelper.GetBCDDate(contextData.Substring((60 + length) + num4, 8)));
                        format = "驾驶员姓名:{0},状态:{6},时间:{5},IC卡读取结果:{1},从业资格证:{2},发证机构名称:{3},证件有效期:{4}";
                        format = string.Format(format, new object[] { str4, str3, str5, str6, time2.ToString("yyyy-MM-dd"), time, str2 });
                    }
                    else
                    {
                        format = "驾驶员姓名:{0},状态:{3},时间:{2},IC卡读取结果:{1}";
                        format = string.Format(format, new object[] { str4, str3, time, str2 });
                    }
                    format = format.Replace("\0", "");
                }
                else
                {
                    format = "状态:{0},时间:{1}";
                    format = string.Format(format, str2, time);
                }
                dataRow_0["OrderName"] = "驾驶员身份信息应答";
                dataRow_0["Describe"] = format;
                int num5 = (dataRow_0["CarId"] == DBNull.Value) ? 0 : int.Parse(dataRow_0["CarId"].ToString());
                int num6 = UpdataInsertDBInfor.UpdateDriverInfor(num5, num, time, num2, str4.Replace("\0", ""), str5.Replace("\0", ""), str6, time2);
                string str8 = "";
                if (num == 1)
                {
                    str8 = "驾驶员登陆成功";
                    if (num2 != 0)
                    {
                        str8 = "驾驶员登录失败," + str3;
                    }
                    else if (num6 == 0)
                    {
                        str8 = "驾驶员登录失败,原因为驾驶员身份信息无效";
                    }
                }
                else
                {
                    str8 = "驾驶员取卡成功";
                }
                IODeviceTextMsg msg = new IODeviceTextMsg {
                    InfoID = 1,
                    Message = str8,
                    SimNum = dataRow_0["SimNum"].ToString()
                };
                this.IODeviceAttachInfo.Add(msg);
            }
            catch (Exception)
            {
                int startIndex = 0;
                int num8 = NumHelper.Convert16To10(contextData.Substring(0, 2)) * 2;
                string str9 = NumHelper.GetStringFromBase16ASCII(contextData.Substring(2, num8));
                string str10 = NumHelper.GetStringFromBase16ASCII(contextData.Substring(2 + num8, 40));
                startIndex = (2 + num8) + 40;
                string str11 = NumHelper.GetStringFromBase16ASCII(contextData.Substring(startIndex, 80));
                startIndex += 80;
                int num9 = NumHelper.Convert16To10(contextData.Substring(startIndex, 2)) * 2;
                startIndex += 2;
                string str12 = NumHelper.GetStringFromBase16ASCII(contextData.Substring(startIndex, num9));
                string str13 = "驾驶员姓名:{0},驾驶员身份证编码:{1},从业资格证:{2},发证机构名称:{3}";
                str13 = string.Format(str13, new object[] { str9, str10, str11, str12 }).Replace("\0", "");
                dataRow_0["OrderName"] = "驾驶员身份信息应答";
                dataRow_0["Describe"] = str13;
                int num10 = (dataRow_0["CarId"] == DBNull.Value) ? 0 : int.Parse(dataRow_0["CarId"].ToString());
                if (UpdataInsertDBInfor.UpdateDriverInfor(num10, str10.Replace("\0", ""), str11.Replace("\0", ""), str9.Replace("\0", ""), str12.Replace("\0", "")) == 0)
                {
                    IODeviceTextMsg msg3 = new IODeviceTextMsg {
                        InfoID = 1,
                        Message = "驾驶员身份信息无效",
                        SimNum = dataRow_0["SimNum"].ToString()
                    };
                    this.IODeviceAttachInfo.Add(msg3);
                }
            }
        }