Exemplo n.º 1
0
        /// <summary>
        ///chenqiang 2018.04.20 add by Case:31026   打印电子健康卡二维码
        /// </summary>
        /// <param name="imgData">电子健康卡二维码base64数据</param>
        private void printVirtualCard(HealthCardInfoStruct Entity)

        {
            try
            {
                string       path  = Application.StartupPath + @"\\Reports\\电子卡二维码.frx";
                PrintManager print = new PrintManager();
                if (System.IO.File.Exists(path) == true)
                {
                    using (PrintManager report = new PrintManager())
                    {
                        DataTable dtQRCode = new DataTable("reportQR");
                        if (Entity.imgData != "" && Entity.imgData != null)
                        {
                            byte[] bytesImg = Convert.FromBase64String(Entity.imgData);//字符串转换为字节
                            dtQRCode.Columns.Add("QRCode", typeof(byte[]));
                            DataRow drQrCode = dtQRCode.NewRow();
                            drQrCode["QRCode"] = bytesImg;
                            dtQRCode.Rows.Add(drQrCode);
                        }
                        else
                        {
                            dtQRCode.Columns.Add("QRCode", typeof(string));
                            DataRow drQrCode = dtQRCode.NewRow();
                            drQrCode["QRCode"] = Entity.QRCode;
                            dtQRCode.Rows.Add(drQrCode);
                        }
                        string cardType = string.Empty;
                        if (Entity.QRCode.IndexOf("EH") == 0)
                        {
                            cardType = "1";
                        }
                        else if (Entity.QRCode.IndexOf("EM") == 0)
                        {
                            cardType = "2";
                        }
                        else
                        {
                            cardType = "0";
                        }
                        print.InitReport("电子卡二维码");
                        print.AddParam("二维码", Entity.QRCode);
                        print.AddDataSet(dtQRCode, "电子卡二维码");
                        print.AddVariable("姓名", IdInfo.Name);
                        print.AddVariable("性别", IdInfo.Sex);
                        print.AddVariable("年龄", "");
                        print.AddVariable("出生日期", IdInfo.Birthday);
                        string idNumber = IdInfo.Number;
                        print.AddVariable("身份证号", idNumber);
                        print.AddVariable("卡类型", cardType);
                        PrintManager.CanDesign = true;
                        //print.PreView();
                        print.Print();
                        print.Dispose();
                    }
                }
                else
                {
                    SkynetMessage.MsgInfo("系统没有找到报表文件“电子卡二维码.frx”!");
                }
            }
            catch (Exception lex)
            {
                if (lex.Message.IndexOf("灾难性") > 0)
                {
                    SkynetMessage.MsgInfo(lex.Message + ": 打印机连接失败,请检查!");
                }
                else
                {
                    SkynetMessage.MsgInfo(lex.Message);
                }
            }
        }
Exemplo n.º 2
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            Log.Info(GetType().ToString(), "执行time1", "开始执行timer1_Tick");

            //检测是否有卡
            Thread.Sleep(200);
            StringBuilder sbinput   = new StringBuilder("<invoke name=\"READCARDTESTINSERTCARD\"><arguments></arguments></invoke>");
            string        strResult = "";

            try
            {
                strResult = XuHuiInterface_DLL.XmlTcp(sbinput, 0);
            }
            catch (Exception exception)
            {
                Log.Info(GetType().ToString(), "检测有卡XuHuiInterface_DLL.XmlTcp", exception.Message);
            }
            LogService.GlobalInfoMessage("调用检测有卡方法输出返回:" + strResult + ",输出参数:" + sbinput.ToString());
            if (string.IsNullOrEmpty(sbinput.ToString()))
            {
                return;
            }

            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            doc.LoadXml(sbinput.ToString());
            System.Xml.XmlNode xnd = doc.SelectSingleNode("/return/arguments/string[@id='CARDSTACKSTATE']");
            if (xnd != null)
            {
                string CardStackState = xnd.InnerText;
                if (CardStackState == "1")
                {
                    timer1.Stop();
                    timer2.Stop();

                    //如果有卡则读取磁条卡号
                    Thread.Sleep(200);
                    if (CardType == "1")
                    {
                        sbinput   = new StringBuilder("<invoke name=\"READCARDREADMAGCARDNO\"><arguments></arguments></invoke>");
                        strResult = XuHuiInterface_DLL.XmlTcp(sbinput, 0);
                        LogService.GlobalInfoMessage("调用读取磁条卡号卡方法返回:" + strResult + ",输出参数:" + sbinput.ToString());
                        doc.LoadXml(sbinput.ToString());
                        xnd = doc.SelectSingleNode("/return/arguments/string[@id='CARDNO']");
                        if (xnd != null)
                        {
                            string strCardNO = xnd.InnerText;
                            //如果读取到的磁条卡号长度不对,则读取居民健康卡
                            if (strCardNO.Length != 15)
                            {
                                try
                                {
                                    //LogService.GlobalInfoMessage("2");
                                    //移动到IC位读居民健康卡
                                    sbinput = new StringBuilder("<invoke name=\"READCARDMOVECARDTOREAR\"><arguments></arguments></invoke>");
                                    Thread.Sleep(200);
                                    LogService.GlobalInfoMessage("调用移动卡到卡后端方法输入参数:" + sbinput.ToString());
                                    strResult = XuHuiInterface_DLL.XmlTcp(sbinput, 0);
                                    LogService.GlobalInfoMessage("调用移动卡到卡后端方法返回:" + strResult + ",输出参数:" + sbinput.ToString());
                                    if (sbinput.ToString().IndexOf("SUCCESS") > 0)
                                    {
                                        //读居民健康卡
                                        //居民健康卡
                                        HealthCardBase       _cardBase = HealthCardBase.CreateInstance(this);
                                        HealthCardInfoStruct Entity    = _cardBase.HisRead();
                                        SkyComm.cardInfoStruct.CardNo = Entity.HealthCardNo;
                                        if (!backgroundWorker1.IsBusy)
                                        {
                                            backgroundWorker1.RunWorkerAsync();
                                        }
                                        if (string.IsNullOrEmpty(SkyComm.cardInfoStruct.CardNo))
                                        {
                                            SkyComm.ShowMessageInfo("读卡失败,请重新检查卡位方向!");
                                            closePort();
                                            this.DialogResult = DialogResult.Cancel;
                                        }
                                    }
                                }
                                catch (Exception ex)
                                {
                                    LogService.GlobalInfoMessage("移动卡到卡后端,读居民健康卡失败:" + ex.Message);

                                    Thread.Sleep(200);
                                    sbinput   = new StringBuilder("<invoke name=\"READCARDOUTCARD\"><arguments></arguments></invoke>");
                                    strResult = AutoServiceSDK.SDK.XuHuiInterface_DLL.XmlTcp(sbinput, 0);
                                    LogService.GlobalInfoMessage("调用退卡卡方法返回:" + strResult + ",输出参数:" + sbinput.ToString());;
                                    SkyComm.ShowMessageInfo("读卡失败,请重新检查卡位方向!");
                                    closePort();
                                    this.DialogResult = DialogResult.Cancel;
                                }
                            }
                            else
                            {
                                //读取就诊卡
                                SkyComm.cardInfoStruct.CardNo = strCardNO;
                                if (!backgroundWorker1.IsBusy)
                                {
                                    backgroundWorker1.RunWorkerAsync();
                                }
                            }
                        }
                        else
                        {
                            //移动到IC位读居民健康卡
                            sbinput = new StringBuilder("<invoke name=\"ReadCardMoveCardToIC\"><arguments></arguments></invoke>");
                            Thread.Sleep(200);
                            strResult = XuHuiInterface_DLL.XmlTcp(sbinput, 0);
                            if (strResult.IndexOf("SUCCESS") > 0)
                            {
                                //读居民健康卡
                                //居民健康卡
                                HealthCardBase       _cardBase = HealthCardBase.CreateInstance(this);
                                HealthCardInfoStruct Entity    = _cardBase.HisRead();
                                SkyComm.cardInfoStruct.CardNo = Entity.HealthCardNo;
                                if (!backgroundWorker1.IsBusy)
                                {
                                    backgroundWorker1.RunWorkerAsync();
                                }
                            }
                        }
                    }
                    else if (CardType == "2")
                    {
                        #region 读取M1卡方法
                        //卡片移到射频位
                        sbinput   = new StringBuilder("<invoke name=\"READCARDMOVECARDTORF\"><arguments></arguments></invoke>");
                        strResult = XuHuiInterface_DLL.XmlTcp(sbinput, 0);
                        LogService.GlobalInfoMessage("调用卡片移到射频位方法返回:" + strResult + ",输出参数:" + sbinput.ToString());

                        //读第8块的数据
                        string strInput = "<invoke name=\"READCARDREADRFCARD\"><arguments>" +
                                          "<string id=\"SECTORNO\">8</string>" +
                                          "<string id=\"BLOCKNO\">2</string>" +
                                          "<string id=\"PASSWORD\">FFFFFFFFFFFF</string>" +
                                          "</arguments></invoke>";
                        LogService.GlobalInfoMessage("调用读射频卡数据方法输入参数1:" + strInput);
                        sbinput   = new StringBuilder(strInput);
                        strResult = XuHuiInterface_DLL.XmlTcp(sbinput, 0);
                        LogService.GlobalInfoMessage("调用读射频卡数据方法返回:" + strResult + ",输出参数:" + sbinput.ToString());

                        doc.LoadXml(sbinput.ToString());
                        xnd = doc.SelectSingleNode("/return/arguments/string[@id='ERROR']");
                        string strCardNO = string.Empty;
                        if (xnd != null && xnd.InnerText == "SUCCESS")
                        {
                            strCardNO = SkyComm.HexStringToString(doc.SelectSingleNode("/return/arguments/string[@id='CARDNO']").InnerText, ASCIIEncoding.ASCII);
                            LogService.GlobalInfoMessage("=============读8扇区的内容===========================" + strCardNO + "======================================");

                            if (strCardNO.Length >= 16)
                            {
                                strCardNO = strCardNO.Substring(0, 16);
                            }
                        }

                        if (strCardNO.Length >= 16)
                        {
                        }


                        LogService.GlobalInfoMessage("读取到的卡号信息:" + strCardNO + "===========================");

                        if (!string.IsNullOrEmpty(strCardNO) && strCardNO.Length >= 15)
                        {
                            //读取就诊卡
                            SkyComm.cardInfoStruct.CardNo = strCardNO.Replace(" ", "").Replace("\0", "").Trim();
                            if (!backgroundWorker1.IsBusy)
                            {
                                backgroundWorker1.RunWorkerAsync();
                            }
                        }
                        else
                        {
                            SkyComm.ShowMessageInfo("读卡失败,请重新检查卡位方向!");
                            closePort();
                            this.DialogResult = DialogResult.Cancel;
                        }
                        #endregion
                    }
                    else if (CardType == "3")
                    {
                        #region 读取芯片卡方法,暂时屏蔽
                        SkyComm.cardInfoStruct.CardNo = CardCpu.getCardNo();


                        if (string.IsNullOrEmpty(SkyComm.cardInfoStruct.CardNo))
                        {
                            try
                            {
                                //LogService.GlobalInfoMessage("2");
                                //移动到IC位读居民健康卡
                                sbinput = new StringBuilder("<invoke name=\"READCARDMOVECARDTOREAR\"><arguments></arguments></invoke>");
                                Thread.Sleep(200);
                                LogService.GlobalInfoMessage("调用移动卡到卡后端方法输入参数:" + sbinput.ToString());
                                strResult = XuHuiInterface_DLL.XmlTcp(sbinput, 0);
                                LogService.GlobalInfoMessage("调用移动卡到卡后端方法返回:" + strResult + ",输出参数:" + sbinput.ToString());
                                if (sbinput.ToString().IndexOf("SUCCESS") > 0)
                                {
                                    //读居民健康卡
                                    //居民健康卡
                                    HealthCardBase       _cardBase = HealthCardBase.CreateInstance(this);
                                    HealthCardInfoStruct Entity    = _cardBase.HisRead();
                                    SkyComm.cardInfoStruct.CardNo = Entity.HealthCardNo;
                                    if (!backgroundWorker1.IsBusy)
                                    {
                                        backgroundWorker1.RunWorkerAsync();
                                    }
                                    if (string.IsNullOrEmpty(SkyComm.cardInfoStruct.CardNo))
                                    {
                                        SkyComm.ShowMessageInfo("读卡失败,请重新检查卡位方向!");
                                        closePort();
                                        this.DialogResult = DialogResult.Cancel;
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                LogService.GlobalInfoMessage("移动卡到卡后端,读居民健康卡失败:" + ex.Message);

                                Thread.Sleep(200);
                                sbinput   = new StringBuilder("<invoke name=\"READCARDOUTCARD\"><arguments></arguments></invoke>");
                                strResult = AutoServiceSDK.SDK.XuHuiInterface_DLL.XmlTcp(sbinput, 0);
                                LogService.GlobalInfoMessage("调用退卡卡方法返回:" + strResult + ",输出参数:" + sbinput.ToString());;
                                SkyComm.ShowMessageInfo("读卡失败,请重新检查卡位方向!");
                                closePort();
                                this.DialogResult = DialogResult.Cancel;
                            }
                        }
                        else
                        {
                            CardRead cardUtility = new CardRead(this);

                            string strMsg = cardUtility.GetPatiantInfo();

                            if (!string.IsNullOrEmpty(strMsg))
                            {
                                SkyComm.ShowMessageInfo(strMsg);
                            }

                            if (!backgroundWorker1.IsBusy)
                            {
                                backgroundWorker1.RunWorkerAsync();
                            }
                        }



                        #endregion
                    }
                }
            }
        }
Exemplo n.º 3
0
        private void lblOK_Click(object sender, EventArgs e)
        {
            if (lbltel.Text.Length != 11)
            {
                lblErr.Text    = "手机号长度必须是11位!";
                lblErr.Visible = true;
                return;
            }


            this.lblOK.Enabled     = false;
            this.btnReturn.Enabled = false;
            this.btnExit.Enabled   = false;
            panel2.Enabled         = false;
            _telphone = this.lbltel.Text.Trim();
            string CardNo = string.Empty;

            CardAuthorizationFacade eCardAuthorizationFacade = new CardAuthorizationFacade();


            try
            {
                isHadCard = false;
                cardNub   = string.Empty;
                string cardType, cardTypeId;
                HealthCardInfoStruct Entity = new HealthCardInfoStruct();
                if (!cardRegulation(out cardType, out cardTypeId))//电子卡注册签约条件判断
                {
                    return;
                }

                #region 卡管平台电子卡注册

                HealthCardBase _healthcardBase = HealthCardBase.CreateEhealthCardInstance(this);

                HealthCardInfoStruct patientInfo = new HealthCardInfoStruct();
                patientInfo.XM   = IdInfo.Name;
                patientInfo.XB   = IdInfo.Sex;
                patientInfo.LXDH = _telphone;
                patientInfo.CSRQ = IdInfo.Birthday;
                patientInfo.SFZH = IdInfo.Number;
                patientInfo.DZ   = IdInfo.Address;
                patientInfo.MZ   = IdInfo.People;

                Entity = _healthcardBase.registerEHC(patientInfo);



                #endregion

                #region  HIS业务机制处理
                PatientInfoFacade pfacade      = new PatientInfoFacade();
                string            ConditionStr = cardType == "0" ? " AND A.IDENTITYCARD='" + IdInfo.Number + "' " : " AND A.GUARDIANIDNUMBER='" + IdInfo.Number + "' ";
                ConditionStr += " AND A.PATIENTNAME='" + IdInfo.Name + "'  ORDER BY  A.DIAGNOSEID DESC ";
                DataSet dsState = pfacade.FindCardPatientinfoByCondition(ConditionStr);
                if (dsState != null && dsState.Tables[0].Rows.Count > 0)
                {
                    strDiagnoseid = dsState.Tables[0].Rows[0]["DIAGNOSEID"].ToString();
                }
                virtualCardId = Entity.ehealthCardId;


                if (string.IsNullOrEmpty(strDiagnoseid))
                {
                    BindHis(virtualCardId);
                    eCardAuthorizationFacade.updateViceCardIdByCardId(IdInfo.Number, virtualCardId);//根据卡号修改电子健康卡号
                }
                else
                {
                    string    sql = "select * from t_card_authorization where DIAGNOSEID = @DIAGNOSEID and CIRCUIT_STATE = 0 and CARDID = @CARDID and TYPEID = 3";
                    Hashtable ht  = new Hashtable();
                    ht.Add("@DIAGNOSEID", strDiagnoseid);
                    ht.Add("@CARDID", IdInfo.Number);
                    DataSet dataSet = query.ExeQuery(sql, ht);
                    if (dataSet.Tables[0].Rows.Count > 0)
                    {
                        bool flag = true;
                        foreach (DataRow dataRow in dataSet.Tables[0].Rows)
                        {
                            if (!string.IsNullOrEmpty(dataRow["VICECARDID"].ToString()))
                            {
                                flag = false;
                                string    sql1      = "update t_card_authorization set VICECARDID = @VICECARDID where ACCOUNT_ID = @ACCOUNT_ID";
                                Hashtable hashtable = new Hashtable();
                                hashtable.Add("@ACCOUNT_ID", dataRow["ACCOUNT_ID"].ToString());
                                hashtable.Add("@VICECARDID", virtualCardId);
                                query.ExeQuery(sql1, hashtable);
                            }
                        }

                        if (flag)
                        {
                            BindHis(virtualCardId);
                            eCardAuthorizationFacade.updateViceCardIdByCardId(IdInfo.Number, virtualCardId);//根据卡号修改电子健康卡号
                        }
                    }
                    else
                    {
                        BindHis(virtualCardId);
                        eCardAuthorizationFacade.updateViceCardIdByCardId(IdInfo.Number, virtualCardId);//根据卡号修改电子健康卡号
                    }
                }



                if (eLCardAuthorizationData != null)
                {
                    cardNub = eLCardAuthorizationData.Tables[0].Rows.Count > 0 ? eLCardAuthorizationData.Tables["T_CARD_AUTHORIZATION"].Rows[0][CardAuthorizationData.T_CARD_AUTHORIZATION_CARDID].ToString() : "";
                }


                if (strDiagnoseid != "")
                {
                    //eCardAuthorizationFacade.updateViceCardIdByCardId(cardNub, virtualCardId);//根据卡号修改电子健康卡号
                }
                printVirtualCard(Entity);//打印二维码
                #endregion
            }
            catch (Exception ex)
            {
                SkynetMessage.MsgInfo(ex.Message);
            }



            DialogResult = System.Windows.Forms.DialogResult.OK;
        }
Exemplo n.º 4
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                isHadCard = false;
                cardNub   = string.Empty;
                string cardType, cardTypeId;
                HealthCardInfoStruct Entity = new HealthCardInfoStruct();
                if (!cardRegulation(out cardType, out cardTypeId))//电子卡注册签约条件判断
                {
                    return;
                }
                decimal decMoney = 0;

                #region 卡管平台电子卡注册
                LogService.GlobalInfoMessage("HIS组织调用电子卡数据");
                HealthCardBase _healthcardBase = HealthCardBase.CreateEhealthCardInstance(this);
                LogService.GlobalInfoMessage("电子XML加载完成");
                HealthCardInfoStruct patientInfo = new HealthCardInfoStruct();
                patientInfo.XM   = patientName;
                patientInfo.XB   = gender;
                patientInfo.LXDH = phoneNo;
                patientInfo.CSRQ = birthday;
                patientInfo.SFZH = cbxCertificateNO;
                patientInfo.DZ   = address;
                patientInfo.MZ   = nation;

                Entity = _healthcardBase.registerEHC(patientInfo);
                if (cardType == "0")
                {
                    //Entity = _healthcardBase.registerEHC(patientInfo);
                }
                else if (cardType == "1")
                {
                    //FrmMaxCard frm = new FrmMaxCard();
                    //frm.labelText = "请扫描家长电子卡......";
                    //if (frm.ShowDialog() == DialogResult.OK)
                    //    patientInfo.ehealthCardId = frm.VirtualNub.Substring(0, frm.VirtualNub.Length - 2);
                    //else
                    //    return;
                    //Entity = _healthcardBase.registerEHC_Child(patientInfo);
                }
                else
                {
                    //if (strDiagnoseid == "")
                    //{
                    //    BindHis("00000000000000000");
                    //    strDiagnoseid = eLCardAuthorizationData.Tables["T_CARD_AUTHORIZATION"].Rows[0][CardAuthorizationData.T_CARD_AUTHORIZATION_DIAGNOSEID].ToString();
                    //    cardNub = eLCardAuthorizationData.Tables["T_CARD_AUTHORIZATION"].Rows[0][CardAuthorizationData.T_CARD_AUTHORIZATION_CARDID].ToString();
                    //    this.txtCureID.Text = cardNub;
                    //}
                    //patientInfo.diagnoseId = strDiagnoseid;
                    //patientInfo.cardId = cardNub;
                    //Entity = _healthcardBase.registerEHC_medicalCard(patientInfo);
                }

                #endregion

                #region  HIS业务机制处理
                //if (cardType != "2")
                //{
                //    PatientInfoFacade pfacade = new PatientInfoFacade();
                //    string ConditionStr = cardType == "0" ? " AND A.IDENTITYCARD='" + cbxCertificateNO.Text.Trim() + "' " : " AND A.GUARDIANIDNUMBER='" + txtGudrdianIDNumber.Text.Trim() + "' ";
                //    ConditionStr += " AND A.PATIENTNAME='" + this.tbxName.Text + "'  ORDER BY  A.DIAGNOSEID DESC ";
                //    DataSet dsState = pfacade.FindCardPatientinfoByCondition(ConditionStr);
                //    if (dsState != null && dsState.Tables[0].Rows.Count > 0)
                //    {
                //        this.txtCureID.Text = dsState.Tables[0].Rows[0]["DIAGNOSEID"].ToString();
                //    }
                //}
                //virtualCardId = cardType == "1" ? Entity.childEhealthCardId : Entity.ehealthCardId;
                //if (strDiagnoseid == "")//未办卡,办卡完成后获取患者院内卡号
                //{
                //    LogService.GlobalInfoMessage("患者未办理院内卡");

                //    BindHis(virtualCardId);
                //    if (eLCardAuthorizationData != null)
                //    {
                //        cardNub = eLCardAuthorizationData.Tables[0].Rows.Count > 0 ? eLCardAuthorizationData.Tables["T_CARD_AUTHORIZATION"].Rows[0][CardAuthorizationData.T_CARD_AUTHORIZATION_CARDID].ToString() : "";
                //    }
                //}

                //if (cardNub != "")
                //{
                //    LogService.GlobalInfoMessage("患者已办理院内卡");
                //    eCardAuthorizationFacade.updateViceCardIdByCardId(cardNub, virtualCardId);//根据卡号修改电子健康卡号
                //    printVirtualCard(Entity);//打印二维码
                //}
                #endregion
            }
            catch (Exception ex)
            {
                SkynetMessage.MsgInfo(ex.Message);
            }
        }