示例#1
0
        public unsafe int ReadGasCard(short com, int baud, ref string kh, ref int ql, ref decimal money, ref short cs, ref short bkcs, ref string dm)
        {
            PLtCardReader pcr1 = new PLtCardReader()
            {
                dwDevType = 2,
                dwPort    = com + 1,
                dwBaud    = baud,
                dv_beep   = 0
            };

            PUserCard puc1 = new PUserCard();

            int pti = 0;

            //string kh4 = new string((sbyte*)puc1.CardNO);
            //string dqdm4 = new string((sbyte*)puc1.UserNO)

            Log.Debug("LanBaoShi ReadGasCard Start");
            int rs = ReadUserCard(ref pcr1, ref puc1);

            Log.Debug("LanBaoShi ReadGasCard end and i is " + rs);
            cs = (short)puc1.ChargingTimes;
            ql = (int)puc1.ChargingAmount;
            dm = new string((sbyte *)puc1.UserNO);
            kh = new string((sbyte *)puc1.CardNO);
            return(rs);
        }
示例#2
0
        //格式化卡
        public int FormatGasCard(Int16 com,  //串口号,从0开始
                                 Int32 baud, //波特率
                                 string kmm, //卡密码,写卡后返回新密码
                                 string kh,  //卡号
                                 string dqdm)
        {
            PLtCardReader pcr1 = new PLtCardReader()
            {
                dwDevType = 2,
                dwPort    = com + 1,
                dwBaud    = baud,
                dv_beep   = 0
            };

            PUserCard puc1 = new PUserCard();
            int       pti  = 0;
            //string kh1 = new string((sbyte*)puc1.CardNO);
            //string dqdm1 = new string((sbyte*)puc1.UserNO);


            String buf;
            String buf1;

            Log.Debug("LanBaoShi Clear Card start");
            int rs = RecycleUserCard(ref pcr1, ref puc1);

            Log.Debug("LanBaoShi Clear Card end and i is " + rs);

            return(rs);
        }
示例#3
0
        //检测卡函数
        public unsafe int CheckGasCard(short com, int baud)
        {
            int rs = -1;

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

                PUserCard puc1 = new PUserCard();
                //string kh = new string((sbyte*)puc1.CardNO);
                //string dqdm = new string((sbyte*)puc1.UserNO);
                int istrue = 0;

                Log.Debug("LanBaoShi CheckGasCard start;端口号:" + pcr1.dwPort + "波特率:" + pcr1.dwBaud);

                rs = CheckLibrary(ref pcr1, ref puc1, ref istrue);

                //string kh = new string((sbyte*)puc1.CardNO);
                //string dqdm = new string((sbyte*)puc1.UserNO);
                Log.Debug("LanBaoShi CheckGasCard end,返回值return:" + rs + " istrue:" + istrue);

                //是蓝宝石卡
                if (istrue == 1)
                {
                    int pti = 0;
                    Log.Debug("LanBaoShi check ReadGasCard start。");

                    rs = ReadUserCard(ref pcr1, ref puc1, pti);

                    string kh   = new string((sbyte *)puc1.CardNO);
                    string dqdm = new string((sbyte *)puc1.UserNO);

                    Log.Debug("LanBaoShi check ReadGasCard end,返回值return:" + rs + "卡号:" + kh + "区域号:" + dqdm + "气量:" + puc1.RechargeAmount + "购气次数:" + puc1.RechargeTimes + "卡类型" + puc1.MecMeterType);

                    //是蓝宝石民用卡
                    if (puc1.MecMeterType == 0)
                    {
                        Log.Debug("此卡是蓝宝石民用卡!");
                        return(0);
                    }
                    Log.Debug("此卡不是蓝宝石民用卡!");
                    return(-1);
                }
                Log.Debug("此卡不是蓝宝石卡!");
                return(-1);
            }
            catch (Exception e)
            {
                Log.Debug("蓝宝石民用判卡异常:" + e.Message + "--" + e.StackTrace);
            }
            return(rs);
        }
示例#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 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);
        }
示例#5
0
        public unsafe int ReadGasCard(short com, int baud, ref string kh, ref int ql, ref decimal money, ref short cs, ref short bkcs, ref string dqdm)
        {
            int rs = -1;

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

                PUserCard puc1 = new PUserCard();

                int pti = 0;
                //string kh4 = new string((sbyte*)puc1.CardNO);
                //string dqdm4 = new string((sbyte*)puc1.UserNO);
                Log.Debug("LanBaoShi ReadGasCard start:端口号:" + pcr1.dwPort + "波特率:" + pcr1.dwBaud);
                rs = ReadUserCard(ref pcr1, ref puc1, pti);

                cs   = (short)puc1.RechargeTimes;
                ql   = (int)puc1.RechargeAmount / 10000;
                dqdm = new string((sbyte *)puc1.UserNO);
                kh   = new string((sbyte *)puc1.CardNO);

                Log.Debug("LanBaoShi ReadGasCard end,返回值return:" + rs + "卡号:" + kh + "区域号:" + dqdm + "气量:" + puc1.RechargeAmount + "购气次数:" + puc1.RechargeTimes + "卡类型" + puc1.MecMeterType);

                //string str = cardid.Substring(0, 2);
                //if (str != "??")
                //{
                //    kh = cardid;
                //}
                //else
                //{
                //    kh = cardid.Remove(0, 2);
                //}
                if (rs == 0)
                {
                    Log.Debug("蓝宝石读卡成功!");
                    return(0);
                }
                else
                {
                    Log.Debug("蓝宝石读卡失败!");
                    return(-1);
                }
            }
            catch (Exception e)
            {
                Log.Debug("蓝宝石读卡异常:" + e.Message + "--" + e.StackTrace);
            }
            return(rs);
        }
示例#6
0
        //格式化卡函数
        public unsafe int FormatGasCard(short com, int baud, string kmm, string kh, string dqdm)
        {
            int rs = -1;

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

                PUserCard puc1 = new PUserCard();
                int       pti  = 0;
                //string kh1 = new string((sbyte*)puc1.CardNO);
                //string dqdm1 = new string((sbyte*)puc1.UserNO);

                Log.Debug("LanBaoShi FormatGasCard start;端口号:" + pcr1.dwPort + "波特率:" + pcr1.dwBaud);

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

                //kh1 = new string((sbyte*)puc1.CardNO);
                //dqdm1 = new string((sbyte*)puc1.UserNO);
                Log.Debug("LanBaoShi FormatGasCard 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);
        }
示例#7
0
        public unsafe int ReadGasCard(short com, int baud, ref string kh, ref int ql, ref decimal money, ref short cs, ref short bkcs, ref string dqdm)
        {
            int rs = -1;

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

                PUserCard puc1 = new PUserCard();

                int pti = 0;
                Log.Debug("LanBaoShi ReadGasCard start");
                rs = ReadUserCard(ref pcr1, ref puc1, pti);
                Log.Debug("LanBaoShi ReadGasCard end,return:" + rs);
                cs   = (short)puc1.RechargeTimes;
                ql   = (int)puc1.RechargeAmount / 10000;
                dqdm = new string((sbyte *)puc1.UserNO);
                string cardid = new string((sbyte *)puc1.CardNO);
                string str    = cardid.Substring(0, 2);
                if (str != "??")
                {
                    kh = cardid;
                }
                else
                {
                    kh = cardid.Remove(0, 2);
                }
                if (rs == 0)
                {
                    Log.Debug("蓝宝石工业读卡成功!");
                    return(0);
                }
                else
                {
                    Log.Debug("蓝宝石工业读卡失败!");
                    return(-1);
                }
            }
            catch (Exception e)
            {
                Log.Debug("蓝宝石工业读卡异常:" + e.Message + "--" + e.StackTrace);
            }
            return(rs);
        }
示例#8
0
        public int CheckGasCard(short com, int baud)
        {
            int rs = -1;

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

                PUserCard puc1   = new PUserCard();
                int       istrue = 0;
                Log.Debug("LanBaoShiGY CheckGasCard start");
                rs = CheckLibrary(ref pcr1, ref puc1, ref istrue);
                Log.Debug("LanBaoShiGY CheckGasCard end,return:" + rs);
                if (1 == istrue)
                {
                    int pti = 0;
                    Log.Debug("LanBaoShiGY ReadGasCard start");
                    rs = ReadUserCard(ref pcr1, ref puc1, pti);
                    Log.Debug("LanBaoShiGY ReadGasCard end,return:" + rs);
                    if (puc1.MecMeterType == 1)
                    {
                        Log.Debug("此卡是蓝宝石工业卡!");
                        return(0);
                    }
                    Log.Debug("此卡不是蓝宝石工业卡!");
                    return(-1);
                }
                Log.Debug("此卡不是蓝宝石工业卡!");
                return(-1);
            }
            catch (Exception e)
            {
                Log.Debug("蓝宝石工业判卡异常:" + e.Message + "--" + e.StackTrace);
            }
            return(rs);
        }
示例#9
0
        //格式化卡函数
        public int FormatGasCard(short com, int baud, string kmm, string kh, string dqdm)
        {
            int rs = -1;

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

                PUserCard puc1 = new PUserCard();
                int       pti  = 0;
                Log.Debug("LanBaoShi FormatGasCard start");
                rs = RecycleUserCard(ref pcr1, ref puc1, pti);
                Log.Debug("LanBaoShi FormatGasCard 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);
        }
示例#10
0
       public unsafe  int CheckGasCard(

             Int16 com,          //串口号,从0开始
             Int32 baud          //波特率
             ){

                 int rs = -1;
            try
            {
                PLtCardReader pcr1 = new PLtCardReader()
                {
                    dwDevType = 2,
                    dwPort = com+1,
                    dwBaud = baud,
                    dv_beep = 0
                };

                PUserCard puc1 = new PUserCard();
                //string kh = new string((sbyte*)puc1.CardNO);
                //string dqdm = new string((sbyte*)puc1.UserNO);
                int istrue = 0;
                
                Log.Debug("LanBaoShi CheckGasCard start;端口号:" + pcr1.dwPort + "波特率:" + pcr1.dwBaud);
                
                rs = CheckLibrary(ref pcr1, ref puc1, ref istrue);
                
                //string kh = new string((sbyte*)puc1.CardNO);
                //string dqdm = new string((sbyte*)puc1.UserNO);
                Log.Debug("LanBaoShi CheckGasCard end,返回值return:" + rs + " istrue:" + istrue);
                
                //是蓝宝石卡
                if (istrue == 1)
                {
                    int pti = 0;
                    Log.Debug("LanBaoShi check ReadGasCard start。");
                    
               //     rs = ReadUserCard(ref pcr1, ref puc1, pti);
                    
              
                    rs = ReadUserCard(ref pcr1, ref puc1);
                    string kh = new string((sbyte*)puc1.CardNO);
                    string dqdm = new string((sbyte*)puc1.UserNO);
                    Log.Debug("LanBaoShi check ReadGasCard end,返回值return:" + rs + "卡号:" + kh + "区域号:" + dqdm + "气量:" + puc1.ChargingAmount + "购气次数:" + puc1.ChargingTimes + "卡类型" + puc1.BigMacType);
                    if (kh.Substring(0, 4).Equals("0000") | kh.Substring(0, 4).Equals("8000") | kh.Substring(0, 4).Equals("0200"))
                    {
                        //是蓝宝石民用卡
                        if (puc1.BigMacType == 0)
                        {
                            Log.Debug("此卡是蓝宝石民用卡!");
                            return 0;
                        }
                        Log.Debug("此卡不是蓝宝石民用卡!");
                        return -1;
                    }
                    else {
                        Log.Debug("此卡不是蓝宝石卡");
                        return -1;
                    }
                }
                Log.Debug("此卡不是蓝宝石卡!");
                return -1;
            }
            catch (Exception e)
            {
                Log.Debug("蓝宝石民用判卡异常:" + e.Message + "--" + e.StackTrace);
            }
            return rs;
        
       }
示例#11
0
        //格式化卡
        public int FormatGasCard(Int16 com,          //串口号,从0开始
           Int32 baud,         //波特率
           string kmm,         //卡密码,写卡后返回新密码
           string kh,          //卡号
           string dqdm)
        {
            PLtCardReader pcr1 = new PLtCardReader()
            {
                dwDevType = 2,
                dwPort = com+1,
                dwBaud = baud,
                dv_beep = 0
            };

            PUserCard puc1 = new PUserCard();
            int pti = 0;
            //string kh1 = new string((sbyte*)puc1.CardNO);
            //string dqdm1 = new string((sbyte*)puc1.UserNO);


            String buf;
            String buf1;
            Log.Debug("LanBaoShi Clear Card start");
            int rs = RecycleUserCard(ref pcr1, ref puc1);
            Log.Debug("LanBaoShi Clear Card end and i is "+rs);
          
            return rs;
        }
示例#12
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;
        }
示例#13
0
        public unsafe int ReadGasCard(short com, int baud, ref string kh, ref int ql, ref decimal money, ref short cs, ref short bkcs, ref string dqdm)
        {
            int rs = -1;
            try
            {
                PLtCardReader pcr1 = new PLtCardReader()
                {
                    dwDevType = 2,
                    dwPort = com,
                    dwBaud = baud,
                    dv_beep = 0
                };

                PUserCard puc1 = new PUserCard();

                int pti = 0;
                //string kh4 = new string((sbyte*)puc1.CardNO);
                //string dqdm4 = new string((sbyte*)puc1.UserNO);
                Log.Debug("LanBaoShi ReadGasCard start:端口号:" + pcr1.dwPort + "波特率:" + pcr1.dwBaud);
                rs = ReadUserCard(ref pcr1, ref puc1, pti);
                
                cs = (short)puc1.RechargeTimes;
                ql = (int)puc1.RechargeAmount / 10000;
                dqdm = new string((sbyte*)puc1.UserNO);
                kh = new string((sbyte*)puc1.CardNO);
                
                Log.Debug("LanBaoShi ReadGasCard end,返回值return:" + rs + "卡号:" + kh + "区域号:" + dqdm + "气量:" + puc1.RechargeAmount + "购气次数:" + puc1.RechargeTimes + "卡类型" + puc1.MecMeterType);
                
                //string str = cardid.Substring(0, 2);
                //if (str != "??")
                //{
                //    kh = cardid;
                //}
                //else
                //{
                //    kh = cardid.Remove(0, 2);
                //}
                if (rs == 0)
                {
                    Log.Debug("蓝宝石读卡成功!");
                    return 0;
                }
                else
                {
                    Log.Debug("蓝宝石读卡失败!");
                    return -1;
                }
            }
            catch (Exception e)
            {
                Log.Debug("蓝宝石读卡异常:" + e.Message + "--" + e.StackTrace);
            }
            return rs;
        }
示例#14
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;
        }
示例#15
0
 public static extern int ChargeUserCard(ref PLtCardReader pcr, ref PUserCard puc);
示例#16
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;
        }
示例#17
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;

        }
示例#18
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);
        }
示例#19
0
        public unsafe int ReadGasCard(short com, int baud, ref string kh, ref int ql, ref decimal money, ref short cs, ref short bkcs, ref string dqdm)
        {
            int rs = -1;
            try
            {
                PLtCardReader pcr1 = new PLtCardReader()
                {
                    dwDevType = 2,
                    dwPort = com,
                    dwBaud = baud,
                    dv_beep = 0
                };

                PUserCard puc1 = new PUserCard();

                int pti = 0;
                Log.Debug("LanBaoShi ReadGasCard start");
                rs = ReadUserCard(ref pcr1, ref puc1, pti);
                Log.Debug("LanBaoShi ReadGasCard end,return:" + rs);
                cs = (short)puc1.RechargeTimes;
                ql = (int)puc1.RechargeAmount / 10000;
                dqdm = new string((sbyte*)puc1.UserNO);
                string cardid = new string((sbyte*)puc1.CardNO);
                string str = cardid.Substring(0, 2);
                if (str != "??")
                {
                    kh = cardid;
                }
                else
                {
                    kh = cardid.Remove(0, 2);
                }
                if (rs == 0)
                {
                    Log.Debug("蓝宝石工业读卡成功!");
                    return 0;
                }
                else
                {
                    Log.Debug("蓝宝石工业读卡失败!");
                    return -1;
                }
            }
            catch (Exception e)
            {
                Log.Debug("蓝宝石工业读卡异常:" + e.Message + "--" + e.StackTrace);
            }
            return rs;
        }
示例#20
0
        public unsafe int CheckGasCard(

            Int16 com,           //串口号,从0开始
            Int32 baud           //波特率
            )
        {
            int rs = -1;

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

                PUserCard puc1 = new PUserCard();
                //string kh = new string((sbyte*)puc1.CardNO);
                //string dqdm = new string((sbyte*)puc1.UserNO);
                int istrue = 0;

                Log.Debug("LanBaoShi CheckGasCard start;端口号:" + pcr1.dwPort + "波特率:" + pcr1.dwBaud);

                rs = CheckLibrary(ref pcr1, ref puc1, ref istrue);

                //string kh = new string((sbyte*)puc1.CardNO);
                //string dqdm = new string((sbyte*)puc1.UserNO);
                Log.Debug("LanBaoShi CheckGasCard end,返回值return:" + rs + " istrue:" + istrue);

                //是蓝宝石卡
                if (istrue == 1)
                {
                    int pti = 0;
                    Log.Debug("LanBaoShi check ReadGasCard start。");

                    //     rs = ReadUserCard(ref pcr1, ref puc1, pti);


                    rs = ReadUserCard(ref pcr1, ref puc1);
                    string kh   = new string((sbyte *)puc1.CardNO);
                    string dqdm = new string((sbyte *)puc1.UserNO);
                    Log.Debug("LanBaoShi check ReadGasCard end,返回值return:" + rs + "卡号:" + kh + "区域号:" + dqdm + "气量:" + puc1.ChargingAmount + "购气次数:" + puc1.ChargingTimes + "卡类型" + puc1.BigMacType);
                    if (kh.Substring(0, 4).Equals("0000") | kh.Substring(0, 4).Equals("8000") | kh.Substring(0, 4).Equals("0200"))
                    {
                        //是蓝宝石民用卡
                        if (puc1.BigMacType == 0)
                        {
                            Log.Debug("此卡是蓝宝石民用卡!");
                            return(0);
                        }
                        Log.Debug("此卡不是蓝宝石民用卡!");
                        return(-1);
                    }
                    else
                    {
                        Log.Debug("此卡不是蓝宝石卡");
                        return(-1);
                    }
                }
                Log.Debug("此卡不是蓝宝石卡!");
                return(-1);
            }
            catch (Exception e)
            {
                Log.Debug("蓝宝石民用判卡异常:" + e.Message + "--" + e.StackTrace);
            }
            return(rs);
        }
示例#21
0
        public unsafe int ReadGasCard(short com, int baud, ref string kh, ref int ql, ref decimal money, ref short cs, ref short bkcs,ref string dm)
       {
           PLtCardReader pcr1 = new PLtCardReader()
            {
                dwDevType = 2,
                dwPort = com+1,
                dwBaud = baud,
                dv_beep = 0
            };

            PUserCard puc1 = new PUserCard();

            int pti = 0;
            //string kh4 = new string((sbyte*)puc1.CardNO);
            //string dqdm4 = new string((sbyte*)puc1.UserNO)

            Log.Debug("LanBaoShi ReadGasCard Start");
          int  rs = ReadUserCard(ref pcr1, ref puc1);
              Log.Debug("LanBaoShi ReadGasCard end and i is "+rs);
             cs = (short)puc1.ChargingTimes;
             ql = (int)puc1.ChargingAmount;
             dm = new string((sbyte*)puc1.UserNO);
             kh = new string((sbyte*)puc1.CardNO);
            return rs;
}
示例#22
0
 public static extern int CheckLibrary(ref PLtCardReader pcr, ref PUserCard puc, ref int IsTrue);
示例#23
0
 public static extern int CheckLibrary(ref PLtCardReader pcr, ref PUserCard puc, ref int IsTrue);
示例#24
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);
        }
示例#25
0
 public static extern int ChargeUserCard(ref PLtCardReader pcr, ref PUserCard puc);
示例#26
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);
        }
示例#27
0
 public static extern int RecycleUserCard(ref PLtCardReader pcr, ref PUserCard puc);
示例#28
0
        //检测卡函数
        public unsafe int CheckGasCard(short com, int baud)
        {
            int rs = -1;
            try
            {
                PLtCardReader pcr1 = new PLtCardReader()
                {
                    dwDevType = 2,
                    dwPort = com,
                    dwBaud = baud,
                    dv_beep = 0
                };

                PUserCard puc1 = new PUserCard();
                //string kh = new string((sbyte*)puc1.CardNO);
                //string dqdm = new string((sbyte*)puc1.UserNO);
                int istrue = 0;
                
                Log.Debug("LanBaoShi CheckGasCard start;端口号:" + pcr1.dwPort + "波特率:" + pcr1.dwBaud);
                
                rs = CheckLibrary(ref pcr1, ref puc1, ref istrue);
                
                //string kh = new string((sbyte*)puc1.CardNO);
                //string dqdm = new string((sbyte*)puc1.UserNO);
                Log.Debug("LanBaoShi CheckGasCard end,返回值return:" + rs + " istrue:" + istrue);
                
                //是蓝宝石卡
                if (istrue == 1)
                {
                    int pti = 0;
                    Log.Debug("LanBaoShi check ReadGasCard start。");
                    
                    rs = ReadUserCard(ref pcr1, ref puc1, pti);
                    
                    string kh = new string((sbyte*)puc1.CardNO);
                    string dqdm = new string((sbyte*)puc1.UserNO);
                    
                    Log.Debug("LanBaoShi check ReadGasCard end,返回值return:" + rs + "卡号:" + kh + "区域号:" + dqdm + "气量:" + puc1.RechargeAmount + "购气次数:" + puc1.RechargeTimes + "卡类型" + puc1.MecMeterType);
                    
                    //是蓝宝石民用卡
                    if (puc1.MecMeterType == 0)
                    {
                        Log.Debug("此卡是蓝宝石民用卡!");
                        return 0;
                    }
                    Log.Debug("此卡不是蓝宝石民用卡!");
                    return -1;
                }
                Log.Debug("此卡不是蓝宝石卡!");
                return -1;
            }
            catch (Exception e)
            {
                Log.Debug("蓝宝石民用判卡异常:" + e.Message + "--" + e.StackTrace);
            }
            return rs;
        }
示例#29
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);
        }
示例#30
0
        //格式化卡函数
        public unsafe int FormatGasCard(short com, int baud, string kmm, string kh, string dqdm)
        {
            int rs = -1;
            try
            {
                PLtCardReader pcr1 = new PLtCardReader()
                {
                    dwDevType = 2,
                    dwPort = com,
                    dwBaud = baud,
                    dv_beep = 0
                };

                PUserCard puc1 = new PUserCard();
                int pti = 0;
                //string kh1 = new string((sbyte*)puc1.CardNO);
                //string dqdm1 = new string((sbyte*)puc1.UserNO);

                Log.Debug("LanBaoShi FormatGasCard start;端口号:" + pcr1.dwPort + "波特率:" + pcr1.dwBaud);

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

                //kh1 = new string((sbyte*)puc1.CardNO);
                //dqdm1 = new string((sbyte*)puc1.UserNO);
                Log.Debug("LanBaoShi FormatGasCard 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;
        }
示例#31
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;
        }
示例#32
0
 public static extern int RechargeUserCard(ref PLtCardReader pcr, ref PUserCard puc, int pti);
示例#33
0
 public static extern int RecycleUserCard(ref PLtCardReader pcr, ref PUserCard puc, int pti);
示例#34
0
        public int CheckGasCard(short com, int baud)
        {
            int rs = -1;
            try 
            {
                PLtCardReader pcr1 = new PLtCardReader()
                {
                    dwDevType = 2,
                    dwPort = com,
                    dwBaud = baud,
                    dv_beep = 0
                };

                PUserCard puc1 = new PUserCard();
                int istrue = 0;
                Log.Debug("LanBaoShiGY CheckGasCard start");
                rs = CheckLibrary(ref pcr1, ref puc1, ref istrue);
                Log.Debug("LanBaoShiGY CheckGasCard end,return:" + rs);
                if (1 == istrue)
                {
                    int pti = 0;
                    Log.Debug("LanBaoShiGY ReadGasCard start");
                    rs = ReadUserCard(ref pcr1, ref puc1, pti);
                    Log.Debug("LanBaoShiGY ReadGasCard end,return:" + rs);
                    if (puc1.MecMeterType == 1)
                    {
                        Log.Debug("此卡是蓝宝石工业卡!");
                        return 0;
                    }
                    Log.Debug("此卡不是蓝宝石工业卡!");
                    return -1;
                }
                Log.Debug("此卡不是蓝宝石工业卡!");
                return -1;
            }
            catch(Exception e)
            {
                Log.Debug("蓝宝石工业判卡异常:" + e.Message + "--" + e.StackTrace);
            }
            return rs;
        }