Ejemplo n.º 1
0
        //业务流程

        public void addCar2()
        {
            try
            {
                MS2.Open();
                string error = MS2.checkMachine();
                if (error != null)
                {
                    Log(error);
                    ShowError("设备异常:" + error);
                    return;
                }

                string            addCarError = null;
                MakeJson          mj          = new MakeJson();
                tools.AnalyzeJson aj          = Network3.getJson(mj, "deviceLogin", out error);
                if (error != null)
                {
                    Log(error);
                    addCarError = "网络异常";
                }
                else if (aj != null && aj["statusCode"].ToString() != "200")
                {
                    Log(error);
                    addCarError = "设备登录失败。";
                }
                //处理
                if (addCarError != null)
                {
                    ShowError(addCarError);
                    return;
                }

                MS2.ResetWithOutPrint();
                string   boxs  = Config.dic("addCardBoxs");
                string[] boxs2 = boxs.Split('|');
                foreach (string box_ in boxs2)
                {
                    int box = int.Parse(box_);
                    while (true)
                    {
                        //1、料盒出卡
                        error = MS2.GetCarFromBox(box);
                        if (error != null && error == "-1")
                        {
                            break;
                        }
                        else if (error != null)
                        {
                            ShowError("出卡异常,请联系管理员处理");
                            return;
                        }
                        //2、移到读卡器
                        string atr = MS2.GetATR(out error);
                        if (error != null)
                        {
                            addFailed();
                            MS2.PutCardToReject();
                            if (error.IndexOf("-1") != -1)
                            {
                                ShowError("读卡异常,请联系管理员处理");
                                return;
                            }
                            continue;
                        }
                        //3、读银行卡号
                        string bankcarNum = MS2.ReadBankNum(out error);
                        if (error != null)
                        {
                            addFailed();
                            MS2.PutCardToReject();
                            continue;
                        }
                        //4、读社保基本信息
                        string[] carDatas = MS2.GetBaseMsg(out error);
                        if (error != null)
                        {
                            addFailed();
                            MS2.PutCardToReject();
                            continue;
                        }
                        //5、入库
                        int stlo = 0;
                        error = MS2.PutCardToStore(atr, ref stlo);
                        if (error != null)
                        {
                            addFailed();
                            ShowError(error);
                            return;
                        }
                        //6、接口入库

                        /*
                         * channelcode	String	是	渠道编码
                         * orgCode	String	是	网点编码(接口2.5返回orgCode)
                         * devSeq	String	是	设备序号(接口2.5返回devSeq)
                         * atr	String	是	ATR
                         * ksbm	String	是	卡识别码(社保卡时必填)
                         * yhkh	String	是	银行卡号
                         * shbzh	String	是	社会保障号(社保卡时必填)
                         * sfzh	String	是	身份证(社保卡时必填)
                         * xm	String	是	姓名(社保卡时必填)
                         * slotno	int	是	槽号
                         * orgId	long	是	网点id(2.5接口返回的orgId)
                         * klb	String	是	卡类别 01:社保卡 02:借记卡 03:信用卡
                         * gfbb	String	否	规范版本
                         * jgbm	String	否	机构编码
                         * fkrq	String	否	发卡日期yyyyMMdd
                         * kyxq	String	否	卡有效期
                         * kh	String	否	卡号
                         * sex	String	否	性别
                         * nation	String	否	民族
                         * csrq	String	否	出生日期
                         *
                         */

                        MakeJson mj2 = new MakeJson();
                        mj2.add("orgCode", aj["data"]["orgCode"], DataStyle.STR);
                        mj2.add("devSeq", aj["data"]["devSeq"], DataStyle.STR);
                        mj2.add("orgId", int.Parse(aj["data"]["orgId"].ToString()), DataStyle.INT);
                        mj2.add("atr", atr, DataStyle.STR);
                        mj2.add("yhkh", bankcarNum, DataStyle.STR);
                        mj2.add("slotno", stlo, DataStyle.INT);
                        mj2.add("boxno", 1, DataStyle.INT);
                        //卡识别码、卡类别、规范版本、初始化机构编号、发卡日期、卡有效期、卡号、社会保障号码、姓名、性别、民族、出生地、出生日期
                        //0         1       2         3               4         5         6     7             8     9     10    11      12
                        mj2.add("ksbm", carDatas[0], DataStyle.STR);
                        mj2.add("shbzh", carDatas[7], DataStyle.STR);
                        mj2.add("kh", carDatas[6], DataStyle.STR);
                        mj2.add("sfzh", carDatas[7], DataStyle.STR);
                        mj2.add("xm", carDatas[8], DataStyle.STR);
                        mj2.add("klb", "01", DataStyle.STR);
                        mj2.add("gfbb", carDatas[2], DataStyle.STR);
                        mj2.add("jgbm", carDatas[3], DataStyle.STR);
                        mj2.add("fkrq", carDatas[4], DataStyle.STR);
                        mj2.add("kyxq", carDatas[5], DataStyle.STR);
                        mj2.add("sex", carDatas[9], DataStyle.STR);
                        mj2.add("nation", carDatas[10], DataStyle.STR);
                        mj2.add("csrq", carDatas[12], DataStyle.STR);
                        tools.AnalyzeJson aj2 = Network3.getJson(mj2, "uploadCPCardInfo");
                        if (aj2.error != null)
                        {
                            addFailed();
                            addCarError = "后台入库接口调用失败";
                            error       = MS2.PutCardToIC(atr, stlo);
                            if (error == null)
                            {
                                error = MS2.PutCardToReject();
                            }
                            if (error != null)
                            {
                                ShowTip.show(false, null, "机器故障:" + error);
                                End();
                                return;
                            }
                            continue;
                        }
                        addSuccess();
                    }
                }
                End();
            }
            catch (Exception e)
            {
                Log("加卡异常:" + e.ToString());
                ShowError("加卡异常:" + e.ToString());
            }
        }
Ejemplo n.º 2
0
        //3.信息校验
        async private void goToLingKa()
        {
            bool carHasOut = false;

            tellHadGetCard = null;
            string error      = null;
            string bankcarnum = null;

            if (ds == null)
            {
                ds = sc.getSelectItems();
            }
            if (ds == null || ds.Count == 0)
            {
                return;
            }

            updateTitle();
            CD.business1.hidenBackAndExitBtn();
            CD.business1.stop();
            int getIndex = ds[0];

            ds.RemoveAt(0);

            Loading.show1("正在出卡,请稍候....");
            string carMsg = cpCardInfo["data"]["data"][getIndex]["klbName"].ToString() + "-" +
                            cpCardInfo["data"]["data"][getIndex]["yhkh"].ToString() + "-" +
                            cpCardInfo["data"]["data"][getIndex]["kh"].ToString();
            string   msg = cpCardInfo["data"]["data"][getIndex]["cardId"].ToString();
            MakeJson mj2 = new MakeJson();

            mj2.add("orgCode", deviceInfo["data"]["orgCode"], DataStyle.STR);
            mj2.add("devSeq", deviceInfo["data"]["devSeq"], DataStyle.STR);
            mj2.add("sfzh", cpCardInfo["data"]["data"][getIndex]["sfzh"], DataStyle.STR);
            mj2.add("xm", cpCardInfo["data"]["data"][getIndex]["xm"], DataStyle.STR);
            mj2.add("cardId", int.Parse(cpCardInfo["data"]["data"][getIndex]["cardId"].ToString()), DataStyle.INT);
            mj2.add("orgId", deviceInfo["data"]["orgId"], DataStyle.STR);
            mj2.add("applytype", "0", DataStyle.STR);
            string atr_json = cpCardInfo["data"]["data"][getIndex]["atr"].ToString();
            int    kc       = int.Parse(cpCardInfo["data"]["data"][getIndex]["slotno"].ToString());

            await TaskMore.Run(new Action(() =>
            {
                string atr_raed = null;
                string[] carDatas = null;
                error = MS2.PutCardToIC(atr_json, kc);
                if (error == null)
                {
                    atr_raed = MS2.GetATR(out error);
                }
                if (error == null)
                {
                    carDatas = MS2.GetBaseMsg(out error);
                }
                if (error == null)
                {
                    bankcarnum = MS2.ReadBankNum(out error);
                }
                if (error != null)
                {
                    ShowTip.show(false, BackExit.Exit, error);
                    return;
                }
                ssid = carDatas[6];
                //卡识别码、卡类别、规范版本、初始化机构编号、发卡日期、卡有效期、卡号、社会保障号码、姓名、性别、民族、出生地、出生日期
                //0         1       2         3               4         5         6     7             8     9     10    11      12
                if (atr_raed != cpCardInfo["data"]["data"][getIndex]["atr"].ToString() ||
                    carDatas[7] != cpCardInfo["data"]["data"][getIndex]["sfzh"].ToString() ||
                    carDatas[8] != cpCardInfo["data"]["data"][getIndex]["xm"].ToString() ||
                    carDatas[6] != cpCardInfo["data"]["data"][getIndex]["kh"].ToString() ||
                    bankcarnum != cpCardInfo["data"]["data"][getIndex]["yhkh"].ToString()
                    )
                {
                    error = "信息校验失败!";
                    MS2.PutCardToReject();
                }

                if (error != null)
                {
                    mj2.add("status", "2", DataStyle.STR);
                    mj2.add("description", "卡信息校验失败", DataStyle.STR);
                }
                else
                {
                    mj2.add("status", "1", DataStyle.STR);
                    mj2.add("description", "成功", DataStyle.STR);
                }
                tellHadGetCard = Network3.getJson(mj2, "uploadFKRecord");
            })).ConfigureAwait(true);

            if (error != null)
            {
                Log.AddLog("领卡", carMsg + "  error:" + error);
                if (carHasOut)
                {
                    MS2.PutCardToReject();
                }
                ShowTip.show(false, BackExit.Exit, error);
            }
            else if (tellHadGetCard.error != null)
            {
                MS2.PutCardToReject();

                ShowTip.show(false, BackExit.Exit, tellHadGetCard.error);
            }
            else
            {
                checkPsw();
            }
        }