Card.LanBaoShiGY.WriteGasCard C# (CSharp) Метод

WriteGasCard() публичный Метод

public WriteGasCard ( short com, int baud, 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
com short
baud int
kmm string
kh string
dqdm string
ql int
csql int
ccsql int
cs short
ljgql int
bjql int
czsx int
tzed int
sqrq string
cssqrq string
oldprice int
newprice int
sxrq string
sxbj string
Результат int
        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;
        }