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

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

public 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, string cssqrq, string oldprice, string newprice, string sxrq, string sxbj ) : WriteRet
param Stream
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 string
cssqrq string
oldprice string
newprice string
sxrq string
sxbj string
Результат WriteRet
        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;
            }
        }

Usage Example

Пример #1
0
        static void Main(string[] args)
        {
            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));

            GenericService service = new GenericService(ci, Port, BaudRate);
            Object         obj     = null;

            switch (args[0])
            {
            case "ReadCard":
                obj = service.ReadCard();
                break;

            case "WriteGasCard":
                obj = 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]
                                           );
                break;

            case "WriteNewCard":
                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]
                                           );
                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;
            }

            String result = JsonConvert.SerializeObject(obj);

            Console.Write(result);
            Log.Debug(result);
            return;
        }
All Usage Examples Of Card.GenericService::WriteGasCard