Ejemplo n.º 1
0
        public unsafe int WriteNewCard(short com, int baud, ref string kmm, short kzt, string kh, string dqdm, string yhh, string tm, int ql, int csql, int ccsql, short cs, int ljgql, short bkcs, int ljyql, int bjql, int czsx, int tzed, string sqrq, string cssqrq, int oldprice, int newprice, string sxrq, string sxbj, int klx, string meterid)
        {
            int rs = -1;

            PLtCardReader pcr1 = new PLtCardReader()
            {
                dwDevType = 2,
                dwPort    = com + 1,
                dwBaud    = baud,
                dv_beep   = 0
            };
            PLtMeterStruct pms1 = new PLtMeterStruct()
            {
                WriteBack  = 0,
                Total      = 0,
                TotalMoney = 0,
                Remain     = 0,

                ChargingTimes            = 0,
                OverflowTimes            = 0,
                MagnetismInterferedTimes = 0,
                Valve       = 0,
                Battery     = 0,
                State1      = 0,                // 保留
                State2      = 0,
                State3      = 0,
                dwReserved  = 0,
                dblReserved = 0
            };

            PAdvancedSettingsStruct past = new PAdvancedSettingsStruct()
            {
                cbSize                 = 0,
                WarnAmount             = 10,
                WarnMoney              = 0,
                AllowedOverdraftAmount = 0,
                AllowedOverdraftMoney  = 0,
                ValveOffOnIdle         = 0,
                ValveOffOnLowPower     = 0,
                ValveOffOnWarning      = 0
            };

            PUserCard puc1 = new PUserCard()
            {
                cbSize         = 0,
                ChargingAmount = ql,
                BigMacType     = 0
            };

            puc1.ChargingTimes = cs;
            FillBytes(puc1.CardNO, kh);
            //写新卡前先清卡
            rs = RecycleUserCard(ref pcr1, ref puc1);
            Log.Debug("Lanbaoshi clear card end and rs is " + rs);
            rs = IssueUserCard(ref pcr1, ref puc1);
            Log.Debug("LanBaoshi WriteNewCard end and rs is " + rs);
            return(rs);
        }
Ejemplo n.º 2
0
        public unsafe int WriteNewCard(short com, int baud, ref string kmm, short kzt, string kh, string dqdm, string yhh, string tm, int ql, int csql, int ccsql, short cs, int ljgql, short bkcs, int ljyql, int bjql, int czsx, int tzed, string sqrq, string cssqrq, int oldprice, int newprice, string sxrq, string sxbj)
        {
            int rs = -1;

            try
            {
                PLtCardReader pcr1 = new PLtCardReader()
                {
                    dwDevType = 2,
                    dwPort    = com,
                    dwBaud    = baud,
                    dv_beep   = 0
                };
                PLtMeterStruct pms1 = new PLtMeterStruct()
                {
                    cbSize                   = 0,
                    WriteBack                = 0,
                    TotalAmount              = 0,
                    TotalMoney               = 0,
                    RemainAmount             = 0,
                    RemainMoney              = 0,
                    RechargeTimes            = 0,
                    OverflowTimes            = 0,
                    MagnetismInterferedTimes = 0,
                    Valve   = 0,
                    Battery = 0
                };

                PAdvancedSettingsStruct past = new PAdvancedSettingsStruct()
                {
                    cbSize                 = 0,
                    WarnAmount             = 10,
                    WarnMoney              = 0,
                    AllowedOverdraftAmount = 0,
                    AllowedOverdraftMoney  = 0,
                    ValveOffOnIdle         = 0,
                    ValveOffOnLowPower     = 0,
                    ValveOffOnWarning      = 0
                };

                PUserCard puc1 = new PUserCard()
                {
                    cbSize         = 0,
                    RechargeTimes  = cs,
                    RechargeAmount = ql * 10000,
                    RechargeMoney  = 0,
                    MecMeterType   = 1
                };
                FillBytes(puc1.CardNO, kh);
                FillBytes(puc1.UserNO, dqdm);
                //写卡之前先格式化卡
                Log.Debug("write card ql=" + ql + ",kagas=" + puc1.RechargeAmount);
                int pti = 0;
                rs = RecycleUserCard(ref pcr1, ref puc1, pti);
                Log.Debug("clear card rs=" + rs);
                Log.Debug("LanBaiShiGY WriteNewCard start"); String buf;
                String buf1;
                Log.Debug("发卡前读卡格式:");
                MingHua.GetSnapShot(com, baud, out buf);
                rs = IssueUserCard(ref pcr1, ref puc1, pti);
                Log.Debug("发卡后读卡格式:");
                MingHua.GetSnapShot(com, baud, out buf1);
                Log.Debug(buf);
                Log.Debug(buf1);
                Log.Debug("LanBaiShiGY WriteNewCard end, return:" + rs);
                if (rs == 0)
                {
                    Log.Debug("蓝宝石工业卡写新卡成功!");
                    return(0);
                }
                else
                {
                    Log.Debug("蓝宝石工业卡写新卡失败!");
                    return(-1);
                }
            }
            catch (Exception e)
            {
                Log.Debug("蓝宝石工业写新卡异常:" + e.Message + "--" + e.StackTrace);
            }
            return(rs);
        }
Ejemplo n.º 3
0
        public unsafe int WriteGasCard(short com, int baud, ref string kmm, string kh, string dqdm, int ql, int csql, int ccsql, short cs, int ljgql, int bjql, int czsx, int tzed, string sqrq, string cssqrq, int oldprice, int newprice, string sxrq, string sxbj)
        {
            int rs = -1;

            try
            {
                PLtCardReader pcr1 = new PLtCardReader()
                {
                    dwDevType = 2,
                    dwPort    = com,
                    dwBaud    = baud,
                    dv_beep   = 0
                };
                PLtMeterStruct pms1 = new PLtMeterStruct()
                {
                    cbSize                   = 0,
                    WriteBack                = 0,
                    TotalAmount              = 0,
                    TotalMoney               = 0,
                    RemainAmount             = 0,
                    RemainMoney              = 0,
                    RechargeTimes            = 0,
                    OverflowTimes            = 0,
                    MagnetismInterferedTimes = 0,
                    Valve   = 0,
                    Battery = 0
                };

                PAdvancedSettingsStruct past = new PAdvancedSettingsStruct()
                {
                    cbSize                 = 0,
                    WarnAmount             = 10,
                    WarnMoney              = 0,
                    AllowedOverdraftAmount = 0,
                    AllowedOverdraftMoney  = 0,
                    ValveOffOnIdle         = 0,
                    ValveOffOnLowPower     = 0,
                    ValveOffOnWarning      = 0
                };

                PUserCard puc1 = new PUserCard()
                {
                    cbSize        = 0,
                    RechargeTimes = cs,
                    RechargeMoney = 0,
                    MecMeterType  = 1
                };
                FillBytes(puc1.CardNO, kh);
                FillBytes(puc1.UserNO, dqdm);

                int pti = 0;
                if (ql != 0)
                {
                    puc1.RechargeAmount = ql * 10000;
                    String buf;
                    String buf1;
                    Log.Debug("购气前读卡格式:");
                    MingHua.GetSnapShot(com, baud, out buf);
                    rs = RechargeUserCard(ref pcr1, ref puc1, pti);
                    Log.Debug("购气后读卡格式:");
                    MingHua.GetSnapShot(com, baud, out buf1);
                    Log.Debug(buf);
                    Log.Debug(buf1);
                    if (rs == 0)
                    {
                        Log.Debug("蓝宝石工业购气成功!");
                        return(0);
                    }
                    else
                    {
                        Log.Debug("蓝宝石工业购气失败!");
                        return(-1);
                    }
                }
                else
                {
                    int rt  = ReadUserCard(ref pcr1, ref puc1, pti);
                    int gas = (int)puc1.RechargeAmount;
                    puc1.RechargeAmount = -gas;
                    String buf;
                    String buf1;
                    Log.Debug("退气前读卡格式:");
                    MingHua.GetSnapShot(com, baud, out buf);
                    rs = RechargeUserCard(ref pcr1, ref puc1, pti);
                    Log.Debug("退气后读卡格式:");
                    MingHua.GetSnapShot(com, baud, out buf1);
                    Log.Debug(buf);
                    Log.Debug(buf1);
                    if (rs == 0)
                    {
                        Log.Debug("蓝宝石工业冲正成功!");
                        return(0);
                    }
                    else
                    {
                        Log.Debug("蓝宝石工业冲正失败!");
                        return(-1);
                    }
                }
            }
            catch (Exception e)
            {
                Log.Debug("蓝宝石工业购气卡异常:" + e.Message + "--" + e.StackTrace);
            }
            return(rs);
        }
Ejemplo n.º 4
0
        public unsafe int WriteNewCard(short com, int baud, ref string kmm, short kzt, string kh, string dqdm, string yhh, string tm, int ql, int csql, int ccsql, short cs, int ljgql, short bkcs, int ljyql, int bjql, int czsx, int tzed, string sqrq, string cssqrq, int oldprice, int newprice, string sxrq, string sxbj)
        {
            int rs = -1;

            PLtCardReader pcr1 = new PLtCardReader()
            {
                dwDevType = 2,
                dwPort = com+1,
                dwBaud = baud,
                dv_beep = 0
            };
            PLtMeterStruct pms1 = new PLtMeterStruct()
            {

                WriteBack = 0,
                Total = 0,
                TotalMoney = 0,
                Remain = 0,

                ChargingTimes = 0,
                OverflowTimes = 0,
                MagnetismInterferedTimes = 0,
                Valve = 0,
                Battery = 0,
                State1 = 0,			// 保留
                State2 = 0,
                State3 = 0,
                dwReserved = 0,
                dblReserved = 0
            };

            PAdvancedSettingsStruct past = new PAdvancedSettingsStruct()
            {
                cbSize = 0,
                WarnAmount = 10,
                WarnMoney = 0,
                AllowedOverdraftAmount = 0,
                AllowedOverdraftMoney = 0,
                ValveOffOnIdle = 0,
                ValveOffOnLowPower = 0,
                ValveOffOnWarning = 0
            };

            PUserCard puc1 = new PUserCard()
            {
                cbSize = 0,
                ChargingAmount = ql,
                BigMacType = 0
            };
            puc1.ChargingTimes = cs;
            FillBytes(puc1.CardNO, kh);
          //写新卡前先清卡
            rs = RecycleUserCard(ref pcr1, ref puc1);
            Log.Debug("Lanbaoshi clear card end and rs is " + rs);
             rs = IssueUserCard(ref pcr1, ref puc1);
            Log.Debug("LanBaoshi WriteNewCard end and rs is " + rs);
            return rs;

        }
Ejemplo n.º 5
0
        public unsafe int WriteGasCard(short com, int baud, ref string kmm, string kh, string dqdm, int ql, int csql, int ccsql, short cs, int ljgql, int bjql, int czsx, int tzed, string sqrq, string cssqrq, int oldprice, int newprice, string sxrq, string sxbj)
        {
            int rs = -1;

            PLtCardReader pcr1 = new PLtCardReader()
            {
                dwDevType = 2,
                dwPort = com+1,
                dwBaud = baud,
                dv_beep = 0
            };
            PLtMeterStruct pms1 = new PLtMeterStruct()
            {

                WriteBack = 0,
                Total = 0,
                TotalMoney = 0,
                Remain = 0,

                ChargingTimes = 0,
                OverflowTimes = 0,
                MagnetismInterferedTimes = 0,
                Valve = 0,
                Battery = 0,
                State1 = 0,			// 保留
                State2 = 0,
                State3 = 0,
                dwReserved = 0,
                dblReserved = 0
            };

            PAdvancedSettingsStruct past = new PAdvancedSettingsStruct()
            {
                cbSize = 0,
                WarnAmount = 10,
                WarnMoney = 0,
                AllowedOverdraftAmount = 0,
                AllowedOverdraftMoney = 0,
                ValveOffOnIdle = 0,
                ValveOffOnLowPower = 0,
                ValveOffOnWarning = 0
            };

            PUserCard puc1 = new PUserCard()
            {
                cbSize = 0,
                ChargingTimes = cs, 
                BigMacType = 0
            };
            //给卡号、用户号赋值
            FillBytes(puc1.CardNO, kh);
            //    FillBytes(puc1.UserNO, dqdm);
            //正常购气
            //气量

            Log.Debug("lanBaoshi writegascard start  and  cs  is"+cs+" + and ql is "+ql);
            if (ql > 0)
            {
                puc1.ChargingAmount = ql;
                rs = ChargeUserCard(ref pcr1, ref puc1);
            }
            else {

                puc1.ChargingAmount = ql;
                rs = ChargeUserCard(ref pcr1, ref puc1);
            }
            Log.Debug("LANBaoshi writegascard end and i is " + rs);
            return rs;
        }
Ejemplo n.º 6
0
        public unsafe int WriteNewCard(short com, int baud, ref string kmm, short kzt, string kh, string dqdm, string yhh, string tm, int ql, int csql, int ccsql, short cs, int ljgql, short bkcs, int ljyql, int bjql, int czsx, int tzed, string sqrq, string cssqrq, int oldprice, int newprice, string sxrq, string sxbj)
        {
            int rs = -1;
            try
            {
                PLtCardReader pcr1 = new PLtCardReader()
                {
                    dwDevType = 2,
                    dwPort = com,
                    dwBaud = baud,
                    dv_beep = 0
                };
                PLtMeterStruct pms1 = new PLtMeterStruct()
                {
                    cbSize = 0,
                    WriteBack = 0,
                    TotalAmount = 0,
                    TotalMoney = 0,
                    RemainAmount = 0,
                    RemainMoney = 0,
                    RechargeTimes = 0,
                    OverflowTimes = 0,
                    MagnetismInterferedTimes = 0,
                    Valve = 0,
                    Battery = 0
                };

                PAdvancedSettingsStruct past = new PAdvancedSettingsStruct()
                {
                    cbSize = 0,
                    WarnAmount = 10,
                    WarnMoney = 0,
                    AllowedOverdraftAmount = 0,
                    AllowedOverdraftMoney = 0,
                    ValveOffOnIdle = 0,
                    ValveOffOnLowPower = 0,
                    ValveOffOnWarning = 0
                };

                PUserCard puc1 = new PUserCard()
                {
                    cbSize = 0,
//                    RechargeTimes = cs,
                    RechargeAmount = ql * 10000,
                    RechargeMoney = 0,
                    MecMeterType = 0
                };

                //发卡购气
                if(kzt == 0)
                {
                    //次数一定是1
                    puc1.RechargeTimes = 1;
                }
                //换表补气
                else
                {
                    puc1.RechargeTimes = cs;
                }

                FillBytes(puc1.CardNO, kh);
                FillBytes(puc1.UserNO, dqdm);
                
                //写卡之前先格式化卡
                Log.Debug("write card 清卡 start");
                
                int pti = 0;
                rs = RecycleUserCard(ref pcr1, ref puc1, pti);
                
                Log.Debug("write card 清卡 end: rs=" + rs);

                Log.Debug("LanBaiShi WriteNewCard start:卡号:" + kh + "区域号:" + dqdm + "气量:" + puc1.RechargeAmount + "购气次数:" + puc1.RechargeTimes + "卡类型" + puc1.MecMeterType);

                String buf;
                String buf1;
                Log.Debug("发卡前读卡格式:");
                MingHua.GetSnapShot(com, baud, out buf);
                rs = IssueUserCard(ref pcr1, ref puc1, pti);
                Log.Debug("发卡后后读卡格式:");
                MingHua.GetSnapShot(com, baud, out buf1);
                Log.Debug(buf);
                Log.Debug(buf1);

                Log.Debug("LanBaiShi WriteNewCard end, return:" + rs);
                
                if (rs == 0)
                {
                    Log.Debug("蓝宝石卡写新卡成功!");
                    return 0;
                }
                else
                {
                    Log.Debug("蓝宝石卡写新卡失败!");
                    return -1;
                }
            }
            catch (Exception e)
            {
                Log.Debug("蓝宝石写新卡卡异常:" + e.Message + "--" + e.StackTrace);
            }
            return rs;
        }
Ejemplo n.º 7
0
        public unsafe int WriteGasCard(short com, int baud, ref string kmm, string kh, string dqdm, int ql, int csql, int ccsql, short cs, int ljgql, int bjql, int czsx, int tzed, string sqrq, string cssqrq, int oldprice, int newprice, string sxrq, string sxbj)
        {
            int rs = -1;
            try
            {
                PLtCardReader pcr1 = new PLtCardReader()
                {
                    dwDevType = 2,
                    dwPort = com,
                    dwBaud = baud,
                    dv_beep = 0
                };

                PLtMeterStruct pms1 = new PLtMeterStruct()
                {
                    cbSize = 0,
                    WriteBack = 0,
                    TotalAmount = 0,
                    TotalMoney = 0,
                    RemainAmount = 0,
                    RemainMoney = 0,
                    RechargeTimes = 0,
                    OverflowTimes = 0,
                    MagnetismInterferedTimes = 0,
                    Valve = 0,
                    Battery = 0
                };

                PAdvancedSettingsStruct past = new PAdvancedSettingsStruct()
                {
                    cbSize = 0,
                    WarnAmount = 10,
                    WarnMoney = 0,
                    AllowedOverdraftAmount = 0,
                    AllowedOverdraftMoney = 0,
                    ValveOffOnIdle = 0,
                    ValveOffOnLowPower = 0,
                    ValveOffOnWarning = 0
                };

                PUserCard puc1 = new PUserCard()
                {
                    cbSize = 0,
                    RechargeTimes = cs,
                    RechargeMoney = 0,
                    MecMeterType = 0
                };

                //给卡号、用户号赋值
                FillBytes(puc1.CardNO, kh);
                FillBytes(puc1.UserNO, dqdm);

                int pti = 0;

                //正常购气
                if (ql != 0)
                {
                    //气量
                    puc1.RechargeAmount = ql * 10000;
                    string kh2 = new string((sbyte*)puc1.CardNO);
                    string dqdm2 = new string((sbyte*)puc1.UserNO);

                    Log.Debug("LanBaoShi WriteGasCard start:卡号:" + kh2 + "区域号:" + dqdm2 + "气量:" + puc1.RechargeAmount + "购气次数:" + puc1.RechargeTimes + "卡类型" + puc1.MecMeterType);

                    String buf;
                    String buf1;
                    Log.Debug("购气前读卡格式:");
                    MingHua.GetSnapShot(com, baud, out buf);
                    rs = RechargeUserCard(ref pcr1, ref puc1, pti);
                    Log.Debug("购气后读卡格式:");
                    MingHua.GetSnapShot(com, baud, out buf1);
                    Log.Debug(buf);
                    Log.Debug(buf1);

                    //kh2 = new string((sbyte*)puc1.CardNO);
                    //dqdm2 = new string((sbyte*)puc1.UserNO);
                    Log.Debug("LanBaoShi WriteGasCard start:返回值return:" + rs + "卡号:" + kh2 + "区域号:" + dqdm2 + "气量:" + puc1.RechargeAmount + "购气次数:" + puc1.RechargeTimes + "卡类型" + puc1.MecMeterType);
                    if (rs == 0)
                    {
                        Log.Debug("蓝宝石购气成功!");
                        return 0;
                    }
                    else
                    {
                        Log.Debug("蓝宝石购气失败!");
                        return -1;
                    }
                }
                //退气
                else
                {
                    //读取卡上气量
                    int rt = ReadUserCard(ref pcr1, ref puc1, pti);
                    string kh2 = new string((sbyte*)puc1.CardNO);
                    string dqdm2 = new string((sbyte*)puc1.UserNO);

                    Log.Debug("LanBaoShi 退气 ReadUserCard end:返回值:" + rt + "区域号:" + dqdm2 + "气量:" + puc1.RechargeAmount + "购气次数:" + puc1.RechargeTimes + "卡类型" + puc1.MecMeterType);

                    //退气时读卡失败
                    if (rt != 0)
                    {
                        return -1;
                    }

                    int gas = (int)puc1.RechargeAmount;

                    puc1.RechargeAmount = -gas;

                    Log.Debug("LanBaoShi 退气 WriteGasCard start:卡号:" + kh2 + "区域号:" + dqdm2 + "气量:" + puc1.RechargeAmount + "购气次数:" + puc1.RechargeTimes + "卡类型" + puc1.MecMeterType);

                    String buf;
                    String buf1;
                    Log.Debug("退气前读卡格式:");
                    MingHua.GetSnapShot(com, baud, out buf);
                    rs = RechargeUserCard(ref pcr1, ref puc1, pti);
                    Log.Debug("退气后读卡格式:");
                    MingHua.GetSnapShot(com, baud, out buf1);
                    Log.Debug(buf);
                    Log.Debug(buf1);
                    //kh2 = new string((sbyte*)puc1.CardNO);
                    //dqdm2 = new string((sbyte*)puc1.UserNO);
                    Log.Debug("LanBaoShi 退气 WriteGasCard end:返回值return:" + rs + "卡号:" + kh2 + "区域号:" + dqdm2 + "气量:" + puc1.RechargeAmount + "购气次数:" + puc1.RechargeTimes + "卡类型" + puc1.MecMeterType);
                    if (rs == 0)
                    {
                        Log.Debug("蓝宝石冲正成功!");
                        return 0;
                    }
                    else
                    {
                        Log.Debug("蓝宝石冲正失败!");
                        return -1;
                    }
                }
            }
            catch (Exception e)
            {
                Log.Debug("蓝宝石写卡异常:" + e.Message + "--" + e.StackTrace);
            }
            return rs;
        }
Ejemplo n.º 8
0
        public unsafe int WriteGasCard(short com, int baud, ref string kmm, string kh, string dqdm, int ql, int csql, int ccsql, short cs, int ljgql, int bjql, int czsx, int tzed, string sqrq, string cssqrq, int oldprice, int newprice, string sxrq, string sxbj)
        {
            int rs = -1;

            try
            {
                PLtCardReader pcr1 = new PLtCardReader()
                {
                    dwDevType = 2,
                    dwPort    = com,
                    dwBaud    = baud,
                    dv_beep   = 0
                };

                PLtMeterStruct pms1 = new PLtMeterStruct()
                {
                    cbSize                   = 0,
                    WriteBack                = 0,
                    TotalAmount              = 0,
                    TotalMoney               = 0,
                    RemainAmount             = 0,
                    RemainMoney              = 0,
                    RechargeTimes            = 0,
                    OverflowTimes            = 0,
                    MagnetismInterferedTimes = 0,
                    Valve   = 0,
                    Battery = 0
                };

                PAdvancedSettingsStruct past = new PAdvancedSettingsStruct()
                {
                    cbSize                 = 0,
                    WarnAmount             = 10,
                    WarnMoney              = 0,
                    AllowedOverdraftAmount = 0,
                    AllowedOverdraftMoney  = 0,
                    ValveOffOnIdle         = 0,
                    ValveOffOnLowPower     = 0,
                    ValveOffOnWarning      = 0
                };

                PUserCard puc1 = new PUserCard()
                {
                    cbSize        = 0,
                    RechargeTimes = cs,
                    RechargeMoney = 0,
                    MecMeterType  = 0
                };

                //给卡号、用户号赋值
                FillBytes(puc1.CardNO, kh);
                FillBytes(puc1.UserNO, dqdm);

                int pti = 0;

                //正常购气
                if (ql != 0)
                {
                    //气量
                    puc1.RechargeAmount = ql * 10000;
                    string kh2   = new string((sbyte *)puc1.CardNO);
                    string dqdm2 = new string((sbyte *)puc1.UserNO);

                    Log.Debug("LanBaoShi WriteGasCard start:卡号:" + kh2 + "区域号:" + dqdm2 + "气量:" + puc1.RechargeAmount + "购气次数:" + puc1.RechargeTimes + "卡类型" + puc1.MecMeterType);

                    String buf;
                    String buf1;
                    Log.Debug("购气前读卡格式:");
                    MingHua.GetSnapShot(com, baud, out buf);
                    rs = RechargeUserCard(ref pcr1, ref puc1, pti);
                    Log.Debug("购气后读卡格式:");
                    MingHua.GetSnapShot(com, baud, out buf1);
                    Log.Debug(buf);
                    Log.Debug(buf1);

                    //kh2 = new string((sbyte*)puc1.CardNO);
                    //dqdm2 = new string((sbyte*)puc1.UserNO);
                    Log.Debug("LanBaoShi WriteGasCard start:返回值return:" + rs + "卡号:" + kh2 + "区域号:" + dqdm2 + "气量:" + puc1.RechargeAmount + "购气次数:" + puc1.RechargeTimes + "卡类型" + puc1.MecMeterType);
                    if (rs == 0)
                    {
                        Log.Debug("蓝宝石购气成功!");
                        return(0);
                    }
                    else
                    {
                        Log.Debug("蓝宝石购气失败!");
                        return(-1);
                    }
                }
                //退气
                else
                {
                    //读取卡上气量
                    int    rt    = ReadUserCard(ref pcr1, ref puc1, pti);
                    string kh2   = new string((sbyte *)puc1.CardNO);
                    string dqdm2 = new string((sbyte *)puc1.UserNO);

                    Log.Debug("LanBaoShi 退气 ReadUserCard end:返回值:" + rt + "区域号:" + dqdm2 + "气量:" + puc1.RechargeAmount + "购气次数:" + puc1.RechargeTimes + "卡类型" + puc1.MecMeterType);

                    //退气时读卡失败
                    if (rt != 0)
                    {
                        return(-1);
                    }

                    int gas = (int)puc1.RechargeAmount;

                    puc1.RechargeAmount = -gas;

                    Log.Debug("LanBaoShi 退气 WriteGasCard start:卡号:" + kh2 + "区域号:" + dqdm2 + "气量:" + puc1.RechargeAmount + "购气次数:" + puc1.RechargeTimes + "卡类型" + puc1.MecMeterType);

                    String buf;
                    String buf1;
                    Log.Debug("退气前读卡格式:");
                    MingHua.GetSnapShot(com, baud, out buf);
                    rs = RechargeUserCard(ref pcr1, ref puc1, pti);
                    Log.Debug("退气后读卡格式:");
                    MingHua.GetSnapShot(com, baud, out buf1);
                    Log.Debug(buf);
                    Log.Debug(buf1);
                    //kh2 = new string((sbyte*)puc1.CardNO);
                    //dqdm2 = new string((sbyte*)puc1.UserNO);
                    Log.Debug("LanBaoShi 退气 WriteGasCard end:返回值return:" + rs + "卡号:" + kh2 + "区域号:" + dqdm2 + "气量:" + puc1.RechargeAmount + "购气次数:" + puc1.RechargeTimes + "卡类型" + puc1.MecMeterType);
                    if (rs == 0)
                    {
                        Log.Debug("蓝宝石冲正成功!");
                        return(0);
                    }
                    else
                    {
                        Log.Debug("蓝宝石冲正失败!");
                        return(-1);
                    }
                }
            }
            catch (Exception e)
            {
                Log.Debug("蓝宝石写卡异常:" + e.Message + "--" + e.StackTrace);
            }
            return(rs);
        }
Ejemplo n.º 9
0
        public unsafe int WriteGasCard(short com, int baud, ref string kmm, string kh, string dqdm, int ql, int csql, int ccsql, short cs, int ljgql, int bjql, int czsx, int tzed, string sqrq, string cssqrq, int oldprice, int newprice, string sxrq, string sxbj)
        {
            int rs = -1;

            PLtCardReader pcr1 = new PLtCardReader()
            {
                dwDevType = 2,
                dwPort    = com + 1,
                dwBaud    = baud,
                dv_beep   = 0
            };
            PLtMeterStruct pms1 = new PLtMeterStruct()
            {
                WriteBack  = 0,
                Total      = 0,
                TotalMoney = 0,
                Remain     = 0,

                ChargingTimes            = 0,
                OverflowTimes            = 0,
                MagnetismInterferedTimes = 0,
                Valve       = 0,
                Battery     = 0,
                State1      = 0,                // 保留
                State2      = 0,
                State3      = 0,
                dwReserved  = 0,
                dblReserved = 0
            };

            PAdvancedSettingsStruct past = new PAdvancedSettingsStruct()
            {
                cbSize                 = 0,
                WarnAmount             = 10,
                WarnMoney              = 0,
                AllowedOverdraftAmount = 0,
                AllowedOverdraftMoney  = 0,
                ValveOffOnIdle         = 0,
                ValveOffOnLowPower     = 0,
                ValveOffOnWarning      = 0
            };

            PUserCard puc1 = new PUserCard()
            {
                cbSize        = 0,
                ChargingTimes = cs,
                BigMacType    = 0
            };

            //给卡号、用户号赋值
            FillBytes(puc1.CardNO, kh);
            //    FillBytes(puc1.UserNO, dqdm);
            //正常购气
            //气量

            Log.Debug("lanBaoshi writegascard start  and  cs  is" + cs + " + and ql is " + ql);
            if (ql > 0)
            {
                puc1.ChargingAmount = ql;
                rs = ChargeUserCard(ref pcr1, ref puc1);
            }
            else
            {
                puc1.ChargingAmount = ql;
                rs = ChargeUserCard(ref pcr1, ref puc1);
            }
            Log.Debug("LANBaoshi writegascard end and i is " + rs);
            return(rs);
        }
Ejemplo n.º 10
0
        public unsafe int WriteGasCard(short com, int baud, ref string kmm, string kh, string dqdm, int ql, int csql, int ccsql, short cs, int ljgql, int bjql, int czsx, int tzed, string sqrq, string cssqrq, int oldprice, int newprice, string sxrq, string sxbj)
        {
            int rs = -1;
            try
            {
                PLtCardReader pcr1 = new PLtCardReader()
                {
                    dwDevType = 2,
                    dwPort = com,
                    dwBaud = baud,
                    dv_beep = 0
                };
                PLtMeterStruct pms1 = new PLtMeterStruct()
                {
                    cbSize = 0,
                    WriteBack = 0,
                    TotalAmount = 0,
                    TotalMoney = 0,
                    RemainAmount = 0,
                    RemainMoney = 0,
                    RechargeTimes = 0,
                    OverflowTimes = 0,
                    MagnetismInterferedTimes = 0,
                    Valve = 0,
                    Battery = 0
                };

                PAdvancedSettingsStruct past = new PAdvancedSettingsStruct()
                {
                    cbSize = 0,
                    WarnAmount = 10,
                    WarnMoney = 0,
                    AllowedOverdraftAmount = 0,
                    AllowedOverdraftMoney = 0,
                    ValveOffOnIdle = 0,
                    ValveOffOnLowPower = 0,
                    ValveOffOnWarning = 0
                };

                PUserCard puc1 = new PUserCard()
                {
                    cbSize = 0,
                    RechargeTimes = cs,
                    RechargeMoney = 0,
                    MecMeterType = 1
                };
                FillBytes(puc1.CardNO, kh);
                FillBytes(puc1.UserNO, dqdm);

                int pti = 0;
                if (ql != 0)
                {
                    puc1.RechargeAmount = ql * 10000;
                    String buf;
                    String buf1;
                    Log.Debug("购气前读卡格式:");
                    MingHua.GetSnapShot(com, baud, out buf);
                    rs = RechargeUserCard(ref pcr1, ref puc1, pti);
                    Log.Debug("购气后读卡格式:");
                    MingHua.GetSnapShot(com, baud, out buf1);
                    Log.Debug(buf);
                    Log.Debug(buf1);
                    if (rs == 0)
                    {
                        Log.Debug("蓝宝石工业购气成功!");
                        return 0;
                    }
                    else
                    {
                        Log.Debug("蓝宝石工业购气失败!");
                        return -1;
                    }
                }
                else
                {
                    int rt = ReadUserCard(ref pcr1, ref puc1, pti);
                    int gas = (int)puc1.RechargeAmount;
                    puc1.RechargeAmount = -gas;
                    String buf;
                    String buf1;
                    Log.Debug("退气前读卡格式:");
                    MingHua.GetSnapShot(com, baud, out buf);
                    rs = RechargeUserCard(ref pcr1, ref puc1, pti);
                    Log.Debug("退气后读卡格式:");
                    MingHua.GetSnapShot(com, baud, out buf1);
                    Log.Debug(buf);
                    Log.Debug(buf1);
                    if (rs == 0)
                    {
                        Log.Debug("蓝宝石工业冲正成功!");
                        return 0;
                    }
                    else
                    {
                        Log.Debug("蓝宝石工业冲正失败!");
                        return -1;
                    }
                }
            }
            catch (Exception e)
            {
                Log.Debug("蓝宝石工业购气卡异常:" + e.Message + "--" + e.StackTrace);
            }
            return rs;
        }