Beispiel #1
0
        //写购气卡
        public WriteRet WriteGasCard(
            string factory, //厂家
            string kmm,     //卡密码,写卡后返回新密码
            string kh,      //卡号
            string dqdm,    //地区代码,从气表管理里取
            Int32 ql,       //气量
            Int32 csql,     //上次购气量,有些表需要传
            Int32 ccsql,    //上上次购气量,有些表需要传
            Int16 cs,       //购气次数
            Int32 ljgql,    //当前表累计购气量
            Int32 bjql,     //报警气量
            Int32 czsx,     //充值上限,可以在气表管理中设置
            Int32 tzed,     //透支额度,可以在气表管理中设置
            string sqrq,    //售气日期,格式为YYYYMMDD
            string cssqrq,  //上次售气日期,格式为YYYYMMDD
            Int32 oldprice, //旧单价,价格管理中取
            Int32 newprice, //新单价,价格管理中取
            string sxrq,    //生效日期,价格管理中取
            string sxbj,    //生效标记,0不生效,1生效,价格管理中取
            string result
            )
        {
            Log.Debug("WriteGasCard(string factory, string kmm, string kh, string dqdm, Int32 ql, Int32 csql, Int32 ccsql, " +
                      " Int16 cs, Int32 ljgql, Int32 bjql, Int32 czsx, Int32 tzed,  string sqrq, string cssqrq, " +
                      " Int32 oldprice, Int32 newprice, string sxrq, string sxbj)="
                      + factory + "," + kmm + "," + kh + "," + dqdm + "," + ql + "," + csql + ","
                      + ccsql + "," + cs + "," + ljgql + "," + bjql + "," + czsx + "," + tzed + ","
                      + sqrq + "," + cssqrq + "," + oldprice + "," + newprice + "," + sxrq + "," + sxbj + "," + result + ")");
            WriteRet ret = new WriteRet();

            try
            {
                ICard card = GetCard(factory);
                int   r    = card.WriteGasCard(Port, Baud, ref kmm, kh, dqdm, ql, csql, ccsql, cs, ljgql, bjql, czsx,
                                               tzed, sqrq, cssqrq, oldprice, newprice, sxrq, sxbj, result);
                if (r < 0)
                {
                    if (r <= -19)
                    {
                        ret.Err = GetCardSpecificError(card, r);
                    }
                    else
                    {
                        ret.Err = Errors[-r - 1];
                    }
                }
                else
                {
                    ret.Kmm = kmm;
                }
                Log.Debug("WriteGasCard(string factory, string kmm, string kh, string dqdm, Int32 ql, Int32 csql, Int32 ccsql, " +
                          " Int16 cs, Int32 ljgql, Int32 bjql, Int32 czsx, Int32 tzed,  string sqrq, string cssqrq, " +
                          " Int32 oldprice, Int32 newprice, string sxrq, string sxbj,string result)="
                          + factory + "," + kmm + "," + kh + "," + dqdm + "," + ql + "," + csql + ","
                          + ccsql + "," + cs + "," + ljgql + "," + bjql + "," + czsx + "," + tzed + ","
                          + sqrq + "," + cssqrq + "," + oldprice + "," + newprice + "," + sxrq + "," + sxbj + result + ")=" + r);
                return(ret);
            }
            catch (Exception e)
            {
                Log.Debug("WriteGasCard()=" + e.Message);
                ret.Exception = e.Message;
                return(ret);
            }
        }
 //写新卡
 public WriteRet WriteNewCard(
     string factory,     //厂家代码
     string kmm,     //卡密码,写卡后返回新密码
     Int16 kzt,          //卡状态,0开户卡,1用户卡
     string kh,          //卡号
     string dqdm,        //地区代码,从气表管理里取
     string yhh,         //用户号,档案中自己输入
     string tm,          //条码,传用户档案里的条码
     Int32 ql,           //气量
     Int32 csql,         //上次购气量,有些表需要传
     Int32 ccsql,        //上上次购气量,有些表需要传
     Int16 cs,           //购气次数
     Int32 ljgql,        //当前表累计购气量
     Int16 bkcs,         //补卡次数,用户档案里保存补卡次数
     Int32 ljyql,        //累计用气量,有些表要累加原来用气量
     Int32 bjql,         //报警气量
     Int32 czsx,         //充值上限,可以在气表管理中设置
     Int32 tzed,         //透支额度,可以在气表管理中设置
     string sqrq,        //售气日期,格式为YYYYMMDD
     string cssqrq,      //上次售气日期,格式为YYYYMMDD
     Int32 oldprice,     //旧单价,价格管理中取
     Int32 newprice,     //新单价,价格管理中取
     string sxrq,        //生效日期,价格管理中取
     string sxbj         //生效标记,0不生效,1生效,价格管理中取
     )
 {
     Log.Debug("WriteNewCard(string factory, string kmm, Int16 kzt, string kh, string dqdm, string yhh, string tm, Int32 ql,"
         + "Int32 csql,Int32 ccsql,Int16 cs,Int32 ljgql,Int16 bkcs,Int32 ljyql,Int32 bjql,Int32 czsx,Int32 tzed,string sqrq,string cssqrq,"
         + "Int32 oldprice,Int32 newprice,string sxrq,string sxbj)=("
         + factory + "," + kmm + "," + kzt + "," + kh + "," + dqdm + "," + yhh + ","
         + tm + "," + ql + "," + csql + "," + ccsql + "," + cs + "," + ljgql + ","
         + bkcs + "," + ljyql + "," + bjql + "," + czsx + "," + tzed + "," + sqrq + ","
         + cssqrq + "," + oldprice + "," + newprice + "," + sxrq + "," + sxbj 
         + ")");
     WriteRet ret = new WriteRet();
     try
     {
         ICard card = GetCard(factory);
         int r = card.WriteNewCard(Port, Baud, ref kmm, kzt, kh, dqdm, yhh, tm, ql, csql, ccsql, cs, ljgql, bkcs,
             ljyql, bjql, czsx, tzed, sqrq, cssqrq, oldprice, newprice, sxrq, sxbj);
         if (r < 0)
         {
             if (r <= -19)
             {
                 ret.Err = GetCardSpecificError(card, r);
             }
             else
             {
                 ret.Err = Errors[-r - 1];
             }
         }
         else
         {
             ret.Kmm = kmm;
         }
         Log.Debug("WriteNewCard(string factory, string kmm, Int16 kzt, string kh, string dqdm, string yhh, string tm, Int32 ql,"
             + "Int32 csql,Int32 ccsql,Int16 cs,Int32 ljgql,Int16 bkcs,Int32 ljyql,Int32 bjql,Int32 czsx,Int32 tzed,string sqrq,string cssqrq,"
             + "Int32 oldprice,Int32 newprice,string sxrq,string sxbj)=("
             + factory + "," + kmm + "," + kzt + "," + kh + "," + dqdm + "," + yhh + ","
             + tm + "," + ql + "," + csql + "," + ccsql + "," + cs + "," + ljgql + ","
             + bkcs + "," + ljyql + "," + bjql + "," + czsx + "," + tzed + "," + sqrq + ","
             + cssqrq + "," + oldprice + "," + newprice + "," + sxrq + "," + sxbj
             + ")=" + r);
         return ret;
     }
     catch (Exception e)
     {
         Log.Debug("WriteNewCard()=" + e.Message);
         ret.Exception = e.Message;
         return ret;
     }
 }
 //写新卡
 public WriteRet WriteNewCard(
     Stream param,       //附加参数
     string factory,     //厂家代码
     string kmm,     //卡密码,写卡后返回新密码
     string kzt,          //卡状态,0开户卡,1用户卡
     string kh,          //卡号
     string dqdm,        //地区代码,从气表管理里取
     string yhh,         //用户号,档案中自己输入
     string tm,          //条码,传用户档案里的条码
     string ql,           //气量
     string csql,         //上次购气量,有些表需要传
     string ccsql,        //上上次购气量,有些表需要传
     string cs,           //购气次数
     string ljgql,        //当前表累计购气量
     string bkcs,         //补卡次数,用户档案里保存补卡次数
     string ljyql,        //累计用气量,有些表要累加原来用气量
     string bjql,         //报警气量
     string czsx,         //充值上限,可以在气表管理中设置
     string tzed,         //透支额度,可以在气表管理中设置
     string sqrq,        //售气日期,格式为YYYYMMDD
     string cssqrq,      //上次售气日期,格式为YYYYMMDD
     string oldprice,     //旧单价,价格管理中取
     string newprice,     //新单价,价格管理中取
     string sxrq,        //生效日期,价格管理中取
     string sxbj,         //生效标记,0不生效,1生效,价格管理中取
     string klx,             //表类型 in)表类型,0->6系 1->8A/8B/8H 2->8C 3->6E6F
     string meterid      //表号
     )
 {
     Log.Debug("WriteNewCard(string factory, string kmm, Int16 kzt, string kh, string dqdm, string yhh, string tm, Int32 ql,"
         + "Int32 csql,Int32 ccsql,Int16 cs,Int32 ljgql,Int16 bkcs,Int32 ljyql,Int32 bjql,Int32 czsx,Int32 tzed,string sqrq,string cssqrq,"
         + "Int32 oldprice,Int32 newprice,string sxrq,string sxbj,int klx,string meterid,string param)=("
         + factory + "," + kmm + "," + kzt + "," + kh + "," + dqdm + "," + yhh + ","
         + tm + "," + ql + "," + csql + "," + ccsql + "," + cs + "," + ljgql + ","
         + bkcs + "," + ljyql + "," + bjql + "," + czsx + "," + tzed + "," + sqrq + ","
         + cssqrq + "," + oldprice + "," + newprice + "," + sxrq + "," + sxbj + "," + klx + "," + meterid + "," + param
         + ")");
     WriteRet ret = new WriteRet();
     try
     {
         ICard card = GetCard(factory);
         SetCardNewParameters(card, param);  //设置新增参数
         short skzt = short.Parse(kzt);
         Int32 iql = Int32.Parse(ql);
         Int32 icsql = Int32.Parse(csql);
         Int32 iccsql = Int32.Parse(ccsql);
         short scs = short.Parse(cs);
         Int32 iljgql = Int32.Parse(ljgql);
         short sbkcs = short.Parse(bkcs);
         Int32 iljyql = Int32.Parse(ljyql);
         Int32 ibjql = Int32.Parse(bjql);
         Int32 iczsx = Int32.Parse(czsx);
         Int32 itzed = Int32.Parse(tzed);
         Int32 ioldprice = Int32.Parse(oldprice);
         Int32 inewprice = Int32.Parse(newprice);
         Int32 iklx = Int32.Parse(klx);
         int r = card.WriteNewCard(Port, Baud, ref kmm, skzt, kh, dqdm, yhh, tm, iql, icsql, iccsql, scs, iljgql, sbkcs,
             iljyql, ibjql, iczsx, itzed, sqrq, cssqrq, ioldprice, inewprice, sxrq, sxbj, iklx, meterid);
         if (r != 0)
         {
             if (r <= -19 || r > 0)
             {
                 ret.Err = GetCardSpecificError(card, r);
             }
             else
             {
                 ret.Err = Errors[-r - 1];
             }
         }
         else
         {
             ret.Kmm = kmm;
         }
         Log.Debug("WriteNewCard(string factory, string kmm, Int16 kzt, string kh, string dqdm, string yhh, string tm, Int32 ql,"
             + "Int32 csql,Int32 ccsql,Int16 cs,Int32 ljgql,Int16 bkcs,Int32 ljyql,Int32 bjql,Int32 czsx,Int32 tzed,string sqrq,string cssqrq,"
             + "Int32 oldprice,Int32 newprice,string sxrq,string sxbj,int klx,string meterid)=("
             + factory + "," + kmm + "," + kzt + "," + kh + "," + dqdm + "," + yhh + ","
             + tm + "," + ql + "," + csql + "," + ccsql + "," + cs + "," + ljgql + ","
             + bkcs + "," + ljyql + "," + bjql + "," + czsx + "," + tzed + "," + sqrq + ","
             + cssqrq + "," + oldprice + "," + newprice + "," + sxrq + "," + sxbj + "," + klx + "," + meterid
             + ")=" + r);
         return ret;
     }
     catch (Exception e)
     {
         Log.Debug("WriteNewCard()=" + e.Message);
         ret.Exception = e.Message;
         return ret;
     }
 }
        //写购气卡
        public WriteRet WriteGasCard(
            Stream param,        //附加参数 
            string factory,     //厂家
            string kmm,     //卡密码,写卡后返回新密码
            string kh,          //卡号
            string dqdm,        //地区代码,从气表管理里取
            string ql,           //气量
            string csql,         //上次购气量,有些表需要传
            string ccsql,        //上上次购气量,有些表需要传
            string cs,           //购气次数
            string ljgql,        //当前表累计购气量
            string bjql,         //报警气量
            string czsx,         //充值上限,可以在气表管理中设置
            string tzed,         //透支额度,可以在气表管理中设置
            string sqrq,        //售气日期,格式为YYYYMMDD
            string cssqrq,      //上次售气日期,格式为YYYYMMDD
            string oldprice,     //旧单价,价格管理中取
            string newprice,     //新单价,价格管理中取
            string sxrq,        //生效日期,价格管理中取
            string sxbj         //生效标记,0不生效,1生效,价格管理中取
            )
        {
            Log.Debug("WriteGasCard(string factory, string kmm, string kh, string dqdm, Int32 ql, Int32 csql, Int32 ccsql, " +
                " Int16 cs, Int32 ljgql, Int32 bjql, Int32 czsx, Int32 tzed,  string sqrq, string cssqrq, " +
                " Int32 oldprice, Int32 newprice, string sxrq, string sxbj, Stream param)=" 
                + factory + "," + kmm + "," + kh + "," + dqdm + "," + ql + "," + csql + ","
                + ccsql + "," + cs + "," + ljgql + "," + bjql + "," + czsx + "," + tzed + ","
                + sqrq + "," + cssqrq + "," + oldprice + "," + newprice + "," + sxrq + "," + sxbj + "," + param + ")");
            WriteRet ret = new WriteRet();
            try
            {
                ICard card = GetCard(factory);
                SetCardNewParameters(card, param);  //设置新增参数
                
                Int32 iql = Int32.Parse(ql);
                Int32 icsql = Int32.Parse(csql);
                Int32 iccsql = Int32.Parse(ccsql);
                short scs = short.Parse(cs);
                Int32 iljgql = Int32.Parse(ljgql);
                
                Int32 ibjql = Int32.Parse(bjql);
                Int32 iczsx = Int32.Parse(czsx);
                Int32 itzed = Int32.Parse(tzed);
                Int32 ioldprice = Int32.Parse(oldprice);
                Int32 inewprice = Int32.Parse(newprice);

                int r = card.WriteGasCard(Port, Baud, ref kmm, kh, dqdm, iql, icsql, iccsql, scs, iljgql, ibjql, iczsx,
                    itzed, sqrq, cssqrq, ioldprice, inewprice, sxrq, sxbj);
                if (r != 0)
                {
                    if (r <= -19 || r > 0)
                    {
                        ret.Err = GetCardSpecificError(card, r);
                    }
                    else
                    {
                        ret.Err = Errors[-r - 1];
                    }
                }
                else
                {
                    ret.Kmm = kmm;
                }
                Log.Debug("WriteGasCard(string factory, string kmm, string kh, string dqdm, Int32 ql, Int32 csql, Int32 ccsql, " +
                    " Int16 cs, Int32 ljgql, Int32 bjql, Int32 czsx, Int32 tzed,  string sqrq, string cssqrq, " +
                    " Int32 oldprice, Int32 newprice, string sxrq, string sxbj, Stream param)=" 
                + factory + "," + kmm + "," + kh + "," + dqdm + "," + ql + "," + csql + ","
                + ccsql + "," + cs + "," + ljgql + "," + bjql + "," + czsx + "," + tzed + ","
                + sqrq + "," + cssqrq + "," + oldprice + "," + newprice + "," + sxrq + "," + sxbj + "," + param + ")=" + r); 
                return ret;
            }
            catch (Exception e)
            {
                Log.Debug("WriteGasCard()=" + e.Message);
                ret.Exception = e.Message;
                return ret;
            }
        }
Beispiel #5
0
        //写新卡
        public WriteRet WriteNewCard(
            Stream param,    //附加参数
            string factory,  //厂家代码
            string kmm,      //卡密码,写卡后返回新密码
            string kzt,      //卡状态,0开户卡,1用户卡
            string kh,       //卡号
            string dqdm,     //地区代码,从气表管理里取
            string yhh,      //用户号,档案中自己输入
            string tm,       //条码,传用户档案里的条码
            string ql,       //气量
            string csql,     //上次购气量,有些表需要传
            string ccsql,    //上上次购气量,有些表需要传
            string cs,       //购气次数
            string ljgql,    //当前表累计购气量
            string bkcs,     //补卡次数,用户档案里保存补卡次数
            string ljyql,    //累计用气量,有些表要累加原来用气量
            string bjql,     //报警气量
            string czsx,     //充值上限,可以在气表管理中设置
            string tzed,     //透支额度,可以在气表管理中设置
            string sqrq,     //售气日期,格式为YYYYMMDD
            string cssqrq,   //上次售气日期,格式为YYYYMMDD
            string oldprice, //旧单价,价格管理中取
            string newprice, //新单价,价格管理中取
            string sxrq,     //生效日期,价格管理中取
            string sxbj,     //生效标记,0不生效,1生效,价格管理中取
            string klx,      //表类型 in)表类型,0->6系 1->8A/8B/8H 2->8C 3->6E6F
            string meterid   //表号
            )
        {
            Log.Debug("WriteNewCard(string factory, string kmm, Int16 kzt, string kh, string dqdm, string yhh, string tm, Int32 ql,"
                      + "Int32 csql,Int32 ccsql,Int16 cs,Int32 ljgql,Int16 bkcs,Int32 ljyql,Int32 bjql,Int32 czsx,Int32 tzed,string sqrq,string cssqrq,"
                      + "Int32 oldprice,Int32 newprice,string sxrq,string sxbj,int klx,string meterid,string param)=("
                      + factory + "," + kmm + "," + kzt + "," + kh + "," + dqdm + "," + yhh + ","
                      + tm + "," + ql + "," + csql + "," + ccsql + "," + cs + "," + ljgql + ","
                      + bkcs + "," + ljyql + "," + bjql + "," + czsx + "," + tzed + "," + sqrq + ","
                      + cssqrq + "," + oldprice + "," + newprice + "," + sxrq + "," + sxbj + "," + klx + "," + meterid + "," + param
                      + ")");
            WriteRet ret = new WriteRet();

            try
            {
                ICard card = GetCard(factory);
                SetCardNewParameters(card, param);  //设置新增参数
                short skzt      = short.Parse(kzt);
                Int32 iql       = Int32.Parse(ql);
                Int32 icsql     = Int32.Parse(csql);
                Int32 iccsql    = Int32.Parse(ccsql);
                short scs       = short.Parse(cs);
                Int32 iljgql    = Int32.Parse(ljgql);
                short sbkcs     = short.Parse(bkcs);
                Int32 iljyql    = Int32.Parse(ljyql);
                Int32 ibjql     = Int32.Parse(bjql);
                Int32 iczsx     = Int32.Parse(czsx);
                Int32 itzed     = Int32.Parse(tzed);
                Int32 ioldprice = Int32.Parse(oldprice);
                Int32 inewprice = Int32.Parse(newprice);
                Int32 iklx      = Int32.Parse(klx);
                int   r         = card.WriteNewCard(Port, Baud, ref kmm, skzt, kh, dqdm, yhh, tm, iql, icsql, iccsql, scs, iljgql, sbkcs,
                                                    iljyql, ibjql, iczsx, itzed, sqrq, cssqrq, ioldprice, inewprice, sxrq, sxbj, iklx, meterid);
                if (r != 0)
                {
                    if (r <= -19 || r > 0)
                    {
                        ret.Err = GetCardSpecificError(card, r);
                    }
                    else
                    {
                        ret.Err = Errors[-r - 1];
                    }
                }
                else
                {
                    ret.Kmm = kmm;
                }
                Log.Debug("WriteNewCard(string factory, string kmm, Int16 kzt, string kh, string dqdm, string yhh, string tm, Int32 ql,"
                          + "Int32 csql,Int32 ccsql,Int16 cs,Int32 ljgql,Int16 bkcs,Int32 ljyql,Int32 bjql,Int32 czsx,Int32 tzed,string sqrq,string cssqrq,"
                          + "Int32 oldprice,Int32 newprice,string sxrq,string sxbj,int klx,string meterid)=("
                          + factory + "," + kmm + "," + kzt + "," + kh + "," + dqdm + "," + yhh + ","
                          + tm + "," + ql + "," + csql + "," + ccsql + "," + cs + "," + ljgql + ","
                          + bkcs + "," + ljyql + "," + bjql + "," + czsx + "," + tzed + "," + sqrq + ","
                          + cssqrq + "," + oldprice + "," + newprice + "," + sxrq + "," + sxbj + "," + klx + "," + meterid
                          + ")=" + r);
                return(ret);
            }
            catch (Exception e)
            {
                Log.Debug("WriteNewCard()=" + e.Message);
                ret.Exception = e.Message;
                return(ret);
            }
        }
Beispiel #6
0
        //写购气卡
        public WriteRet WriteGasCard(
            Stream param,    //附加参数
            string factory,  //厂家
            string kmm,      //卡密码,写卡后返回新密码
            string kh,       //卡号
            string dqdm,     //地区代码,从气表管理里取
            string ql,       //气量
            string csql,     //上次购气量,有些表需要传
            string ccsql,    //上上次购气量,有些表需要传
            string cs,       //购气次数
            string ljgql,    //当前表累计购气量
            string bjql,     //报警气量
            string czsx,     //充值上限,可以在气表管理中设置
            string tzed,     //透支额度,可以在气表管理中设置
            string sqrq,     //售气日期,格式为YYYYMMDD
            string cssqrq,   //上次售气日期,格式为YYYYMMDD
            string oldprice, //旧单价,价格管理中取
            string newprice, //新单价,价格管理中取
            string sxrq,     //生效日期,价格管理中取
            string sxbj      //生效标记,0不生效,1生效,价格管理中取
            )
        {
            Log.Debug("WriteGasCard(string factory, string kmm, string kh, string dqdm, Int32 ql, Int32 csql, Int32 ccsql, " +
                      " Int16 cs, Int32 ljgql, Int32 bjql, Int32 czsx, Int32 tzed,  string sqrq, string cssqrq, " +
                      " Int32 oldprice, Int32 newprice, string sxrq, string sxbj, Stream param)="
                      + factory + "," + kmm + "," + kh + "," + dqdm + "," + ql + "," + csql + ","
                      + ccsql + "," + cs + "," + ljgql + "," + bjql + "," + czsx + "," + tzed + ","
                      + sqrq + "," + cssqrq + "," + oldprice + "," + newprice + "," + sxrq + "," + sxbj + "," + param + ")");
            WriteRet ret = new WriteRet();

            try
            {
                ICard card = GetCard(factory);
                SetCardNewParameters(card, param);  //设置新增参数

                Int32 iql    = Int32.Parse(ql);
                Int32 icsql  = Int32.Parse(csql);
                Int32 iccsql = Int32.Parse(ccsql);
                short scs    = short.Parse(cs);
                Int32 iljgql = Int32.Parse(ljgql);

                Int32 ibjql     = Int32.Parse(bjql);
                Int32 iczsx     = Int32.Parse(czsx);
                Int32 itzed     = Int32.Parse(tzed);
                Int32 ioldprice = Int32.Parse(oldprice);
                Int32 inewprice = Int32.Parse(newprice);

                int r = card.WriteGasCard(Port, Baud, ref kmm, kh, dqdm, iql, icsql, iccsql, scs, iljgql, ibjql, iczsx,
                                          itzed, sqrq, cssqrq, ioldprice, inewprice, sxrq, sxbj);
                if (r != 0)
                {
                    if (r <= -19 || r > 0)
                    {
                        ret.Err = GetCardSpecificError(card, r);
                    }
                    else
                    {
                        ret.Err = Errors[-r - 1];
                    }
                }
                else
                {
                    ret.Kmm = kmm;
                }
                Log.Debug("WriteGasCard(string factory, string kmm, string kh, string dqdm, Int32 ql, Int32 csql, Int32 ccsql, " +
                          " Int16 cs, Int32 ljgql, Int32 bjql, Int32 czsx, Int32 tzed,  string sqrq, string cssqrq, " +
                          " Int32 oldprice, Int32 newprice, string sxrq, string sxbj, Stream param)="
                          + factory + "," + kmm + "," + kh + "," + dqdm + "," + ql + "," + csql + ","
                          + ccsql + "," + cs + "," + ljgql + "," + bjql + "," + czsx + "," + tzed + ","
                          + sqrq + "," + cssqrq + "," + oldprice + "," + newprice + "," + sxrq + "," + sxbj + "," + param + ")=" + r);
                return(ret);
            }
            catch (Exception e)
            {
                Log.Debug("WriteGasCard()=" + e.Message);
                ret.Exception = e.Message;
                return(ret);
            }
        }
Beispiel #7
0
        //写新卡
        public WriteRet WriteNewCard(
            string factory, //厂家代码
            string kmm,     //卡密码,写卡后返回新密码
            Int16 kzt,      //卡状态,0开户卡,1用户卡
            string kh,      //卡号
            string dqdm,    //地区代码,从气表管理里取
            string yhh,     //用户号,档案中自己输入
            string tm,      //条码,传用户档案里的条码
            Int32 ql,       //气量
            Int32 csql,     //上次购气量,有些表需要传
            Int32 ccsql,    //上上次购气量,有些表需要传
            Int16 cs,       //购气次数
            Int32 ljgql,    //当前表累计购气量
            Int16 bkcs,     //补卡次数,用户档案里保存补卡次数
            Int32 ljyql,    //累计用气量,有些表要累加原来用气量
            Int32 bjql,     //报警气量
            Int32 czsx,     //充值上限,可以在气表管理中设置
            Int32 tzed,     //透支额度,可以在气表管理中设置
            string sqrq,    //售气日期,格式为YYYYMMDD
            string cssqrq,  //上次售气日期,格式为YYYYMMDD
            Int32 oldprice, //旧单价,价格管理中取
            Int32 newprice, //新单价,价格管理中取
            string sxrq,    //生效日期,价格管理中取
            string sxbj     //生效标记,0不生效,1生效,价格管理中取
            )
        {
            Log.Debug("WriteNewCard(string factory, string kmm, Int16 kzt, string kh, string dqdm, string yhh, string tm, Int32 ql,"
                      + "Int32 csql,Int32 ccsql,Int16 cs,Int32 ljgql,Int16 bkcs,Int32 ljyql,Int32 bjql,Int32 czsx,Int32 tzed,string sqrq,string cssqrq,"
                      + "Int32 oldprice,Int32 newprice,string sxrq,string sxbj)=("
                      + factory + "," + kmm + "," + kzt + "," + kh + "," + dqdm + "," + yhh + ","
                      + tm + "," + ql + "," + csql + "," + ccsql + "," + cs + "," + ljgql + ","
                      + bkcs + "," + ljyql + "," + bjql + "," + czsx + "," + tzed + "," + sqrq + ","
                      + cssqrq + "," + oldprice + "," + newprice + "," + sxrq + "," + sxbj
                      + ")");
            WriteRet ret = new WriteRet();

            try
            {
                ICard card = GetCard(factory);
                int   r    = card.WriteNewCard(Port, Baud, ref kmm, kzt, kh, dqdm, yhh, tm, ql, csql, ccsql, cs, ljgql, bkcs,
                                               ljyql, bjql, czsx, tzed, sqrq, cssqrq, oldprice, newprice, sxrq, sxbj);
                if (r < 0)
                {
                    if (r <= -19)
                    {
                        ret.Err = GetCardSpecificError(card, r);
                    }
                    else
                    {
                        ret.Err = Errors[-r - 1];
                    }
                }
                else
                {
                    ret.Kmm = kmm;
                }
                Log.Debug("WriteNewCard(string factory, string kmm, Int16 kzt, string kh, string dqdm, string yhh, string tm, Int32 ql,"
                          + "Int32 csql,Int32 ccsql,Int16 cs,Int32 ljgql,Int16 bkcs,Int32 ljyql,Int32 bjql,Int32 czsx,Int32 tzed,string sqrq,string cssqrq,"
                          + "Int32 oldprice,Int32 newprice,string sxrq,string sxbj)=("
                          + factory + "," + kmm + "," + kzt + "," + kh + "," + dqdm + "," + yhh + ","
                          + tm + "," + ql + "," + csql + "," + ccsql + "," + cs + "," + ljgql + ","
                          + bkcs + "," + ljyql + "," + bjql + "," + czsx + "," + tzed + "," + sqrq + ","
                          + cssqrq + "," + oldprice + "," + newprice + "," + sxrq + "," + sxbj
                          + ")=" + r);
                return(ret);
            }
            catch (Exception e)
            {
                Log.Debug("WriteNewCard()=" + e.Message);
                ret.Exception = e.Message;
                return(ret);
            }
        }
        public WriteRet WriteNewCard(string factory, 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)
        {
            String args = "WriteNewCard";
            Log.Debug(args + " started.");

            args += " " + (String.IsNullOrWhiteSpace(factory) ? "0" : factory);
            args += " " + (String.IsNullOrWhiteSpace(kmm) ? "\"0\"" : "\"" + kmm + "\"");
            args += " " + kzt;
            args += " " + (String.IsNullOrWhiteSpace(kh) ? "0" : kh);
            args += " " + (String.IsNullOrWhiteSpace(dqdm) ? "0" : dqdm);
            args += " " + (String.IsNullOrWhiteSpace(yhh) ? "0" : yhh);
            args += " " + (String.IsNullOrWhiteSpace(tm) ? "0" : tm);
            args += " " + ql;
            args += " " + csql;
            args += " " + ccsql;
            args += " " + cs;
            args += " " + ljgql;
            args += " " + bkcs;
            args += " " + ljyql;
            args += " " + bjql;
            args += " " + czsx;
            args += " " + tzed;
            args += " " + (String.IsNullOrWhiteSpace(sqrq) ? "0" : sqrq);
            args += " " + (String.IsNullOrWhiteSpace(cssqrq) ? "0" : cssqrq);
            args += " " + oldprice;
            args += " " + newprice;
            args += " " + (String.IsNullOrWhiteSpace(sxrq) ? "0" : sxrq);
            args += " " + (String.IsNullOrWhiteSpace(sxbj) ? "0" : sxbj);


            String result = null;
            WriteRet ret = new WriteRet();
            try
            {
                if (this.Spawn(args, out result))
                {
                    ret = JsonConvert.DeserializeObject<WriteRet>(result);
                    Log.Debug(args + "=" + result);
                }
                else
                {
                    ret.Err = "调用未返回。";
                    Log.Debug(args + "=" + ret.Err);
                }
            }
            catch (Exception e)
            {
                ret.Exception = e.Message;
                ret.Err = "调用错误。";
            }
            return ret;
        }
        public Ret OpenCard(string factory, string kmm, string kh, string dqdm)
        {
            String args = "OpenCard";
            Log.Debug(args + " started.");

            args += " " + (String.IsNullOrWhiteSpace(factory) ? "0" : factory);
            args += " " + (String.IsNullOrWhiteSpace(kmm) ? "\"0\"" : "\"" + kmm + "\"");
            args += " " + (String.IsNullOrWhiteSpace(kh) ? "0" : kh);
            args += " " + (String.IsNullOrWhiteSpace(dqdm) ? "0" : dqdm);

            String result = null;
            WriteRet ret = new WriteRet();
            try
            {
                if (this.Spawn(args, out result))
                {
                    ret = JsonConvert.DeserializeObject<WriteRet>(result);
                    Log.Debug(args + "=" + result);
                }
                else
                {
                    ret.Err = "调用未返回。";
                    Log.Debug(args + "=" + ret.Err);
                }
            }
            catch (Exception e)
            {
                ret.Exception = e.Message;
                ret.Err = "调用错误。";
            }
            return ret;
        }
Beispiel #10
0
        static void Main(string[] args)
        {
            // Log.Debug("in");
            //  writeFile(args[0] +"*******"+ args[1]);
            CardInfos ci = new CardInfos();

            try
            {
                StreamReader sr = new StreamReader("card.config");
                string       line;
                while ((line = sr.ReadLine()) != null)
                {
                    string[]   attr   = line.Split(',');
                    String[]   ccPair = attr[0].Split('=');
                    String[]   icard  = attr[1].Split('=');
                    CardConfig cc     = new CardConfig()
                    {
                        Name = ccPair[1].Trim()
                    };
                    ICard card = (ICard)Assembly.GetExecutingAssembly().CreateInstance(icard[1].Trim());
                    cc.Card = card;
                    ci.Add(cc);
                }
                sr.Close();
            }
            catch (Exception e)
            {
                String config = JsonConvert.SerializeObject(new Ret()
                {
                    Err = "卡配置文件错误。"
                });
                Console.Write(config);
                Log.Debug(config);
                return;
            }

            int   BaudRate = int.Parse(Config.GetConfig("Baud"));
            short Port     = short.Parse(Config.GetConfig("Port"));

            Log.Debug(String.Join(" ", args));
            Log.Debug("args[0]: " + args[0] + "--" + args[1]);
            GenericService service = new GenericService(ci, Port, BaudRate);
            Object         obj     = null;
            Object         obj1    = null;

            string result  = null;
            string result1 = null;
            string result2 = null;
            string result3 = null;

            switch (args[0])
            {
            case "ReadCard":
                byte [] b = HexToBytes(args[1]);
                Log.Debug("args[1]: " + args[1]);
                srdCard_ver(256, b);
                obj = service.ReadCard();
                break;

            case "WriteGasCard":
//===================================================================
                byte[] bbbb = HexToBytes(args[19]);
                byte[] bbb  = new byte[3];
                byte[] bb   = new byte[256];
                Log.Debug("card password!!!!!!!!!!!!!!!!!!");

                srdCard_ver(256, bbbb);
                Log.Debug("start read card!!!!!!!!!!!!!!!!!!!!");

                Log.Debug("写卡开始:" + args[1] + "result" + args[19]);
                obj1 = service.WriteGasCard(args[1], args[2], args[3], args[4],
                                            int.Parse(args[5]), int.Parse(args[6]), int.Parse(args[7]), short.Parse(args[8]),
                                            int.Parse(args[9]), int.Parse(args[10]), int.Parse(args[11]), int.Parse(args[12]),
                                            args[13], args[14], int.Parse(args[15]), int.Parse(args[16]), args[17], args[18], args[19]
                                            );

                get_kmm(bbb);
                result1 = ToHexString(bbb);
                Log.Debug("result1" + result1);
                get_Date(bb);
                result2 = ToHexString(bb);
                Log.Debug("result2" + result2);
                WriteRet ret = new WriteRet();
                ret.Kmy   = result1;
                ret.Kdata = result2;
                break;

            case "WriteNewCard":
                byte[] data = HexToBytes(args[24]);
                Log.Debug("data======" + args[24]);
                byte[] password = new byte[3];
                string str      = "WriteNewCard";
                srdCard_ver(256, data);
                Log.Debug("WriteNewCard:" + str);
                obj = service.WriteNewCard(args[1], args[2], short.Parse(args[3]), args[4], args[5], args[6], args[7],
                                           int.Parse(args[8]), int.Parse(args[9]), int.Parse(args[10]), short.Parse(args[11]),
                                           int.Parse(args[12]), short.Parse(args[13]), int.Parse(args[14]), int.Parse(args[15]),
                                           int.Parse(args[16]), int.Parse(args[17]), args[18], args[19], int.Parse(args[20]), int.Parse(args[21]), args[22], args[23], args[24]
                                           );
                get_kmm(password);
                result1 = Convert.ToString(password);
                result2 = JsonConvert.SerializeObject(obj);
                break;

            case "FormatGasCard":
                obj = service.FormatGasCard(args[1], args[2], args[3], args[4]);
                break;

            case "OpenCard":
                obj = service.OpenCard(args[1], args[2], args[3], args[4]);
                break;

            default:
                return;
            }
            result = JsonConvert.SerializeObject(obj);

            result = result1 + result2 + result3;
            Console.Write(result);
            Log.Debug("*******************" + result + "*******************");
            return;
        }
Beispiel #11
0
 public WriteRet WriteNewCard(Stream param, string factory, string kmm, string kzt, string kh, string dqdm, string yhh, string tm,
     string ql, string csql, string ccsql, string cs, string ljgql, string bkcs, string ljyql, string bjql, string czsx, string tzed,
     string sqrq, string cssqrq, string oldprice, string newprice, string sxrq, string sxbj, string klx, string meterid)
 {
     String args = "WriteNewCard";
     Log.Debug(args + " started.");
     StreamReader paramReader = new StreamReader(param);
     string paramStr = paramReader.ReadToEnd();
     args += " " + (String.IsNullOrWhiteSpace(paramStr) ? "0" : paramStr);
     args += " " + (String.IsNullOrWhiteSpace(factory) ? "0" : factory);
     args += " " + (String.IsNullOrWhiteSpace(kmm) ? "\"0\"" : "\"" + kmm + "\"");
     args += " " + kzt;
     args += " " + (String.IsNullOrWhiteSpace(kh) ? "0" : kh);
     args += " " + (String.IsNullOrWhiteSpace(dqdm) ? "0" : dqdm);
     args += " " + (String.IsNullOrWhiteSpace(yhh) ? "0" : yhh);
     args += " " + (String.IsNullOrWhiteSpace(tm) ? "0" : tm);
     args += " " + ql;
     args += " " + csql;
     args += " " + ccsql;
     args += " " + cs;
     args += " " + ljgql;
     args += " " + bkcs;
     args += " " + ljyql;
     args += " " + bjql;
     args += " " + czsx;
     args += " " + tzed;
     args += " " + (String.IsNullOrWhiteSpace(sqrq) ? "0" : sqrq);
     args += " " + (String.IsNullOrWhiteSpace(cssqrq) ? "0" : cssqrq);
     args += " " + oldprice;
     args += " " + newprice;
     args += " " + (String.IsNullOrWhiteSpace(sxrq) ? "0" : sxrq);
     args += " " + (String.IsNullOrWhiteSpace(sxbj) ? "0" : sxbj);
     args += " " +  klx;
     args += " " + (String.IsNullOrWhiteSpace(meterid) ? "0" : meterid);
     
     String result = null;
     WriteRet ret = new WriteRet();
     try
     {
         if (this.Spawn(args, out result))
         {
             ret = JsonConvert.DeserializeObject<WriteRet>(result);
             Log.Debug(args + "=" + result);
         }
         else
         {
             ret.Err = "调用未返回。";
             Log.Debug(args + "=" + ret.Err);
         }
     }
     catch (Exception e)
     {
         ret.Exception = e.Message;
         ret.Err = "调用错误。";
     }
     return ret;
 }