예제 #1
0
        private void ReadCard()
        {
            int authenticate = CVRSDK.CVR_Authenticate();

            if (authenticate == 1)
            {
                int readContent = CVRSDK.CVR_Read_Content(4);
                //如果读取成功
                if (readContent == 1)
                {
                    IdentificationData data = ReadIdData();
                    if (data != null && user != null && user.身份证号码 == data.身份证号)
                    {
                        this.DialogResult = System.Windows.Forms.DialogResult.OK;
                        this.Close();
                    }
                }
                else
                {
                    this.label10.Text = "读取身份证信息失败!";
                }
            }
            else
            {
                this.label10.Text = "已准备就绪,请将身份证放在阅读器上面";
            }
        }
예제 #2
0
파일: TCPclient.cs 프로젝트: alipov/open-rm
        // Called when a ConnectAsync operation completes
        private void ProcessConnect(SocketAsyncEventArgs e)
        {
            if (e.SocketError == SocketError.Success)
            {
                Logger.WriteStr("Successfully connected to the server on " + ((AgentAsyncUserToken)(e.UserToken)).Socket.LocalEndPoint.ToString());
                retryIntervalCurrent = retryIntervalInitial;          // set it to initial value

                //Send authorization info about this client as soon as connection established
                var idata = new IdentificationData();
                OpProcessor.GetInfo(idata);       // fill required data
                var message = new ResponseMessage {
                    Response = idata
                };
                SendMessage(e, WoxalizerAdapter.SerializeToXml(message, TypeResolving.AssemblyResolveHandler));
            }
            else
            {
                int ex = (int)e.SocketError;
                Console.WriteLine("Cannot connect to server " + e.RemoteEndPoint.ToString() + ". Will try again in " + retryIntervalCurrent + " seconds");
                Logger.WriteStr("Cannot connect to server " + e.RemoteEndPoint.ToString() + ". Will try again in " + retryIntervalCurrent + " seconds");
                Logger.WriteStr("   (Exception: " + ex.ToString() + ")");

                Thread.Sleep(retryIntervalCurrent * 1000);
                if (retryIntervalCurrent < retryIntervalMaximum)     //increase interval between reconnects up to retryIntervalMaximum value.
                {
                    retryIntervalCurrent += 5;
                }

                e.SocketError = 0;  //clear Error info and try to connect again
                ((AgentAsyncUserToken)e.UserToken).Socket.ConnectAsync(e);

                return;
            }
        }
예제 #3
0
        public User user = null;        //登录的用户

        public IdentificationData ReadIdData()
        {
            try
            {
                pictureBox1.ImageLocation = Application.StartupPath + "\\zp.bmp";
                byte[] name   = new byte[30];
                int    length = 30;
                CVRSDK.GetPeopleName(ref name[0], ref length);
                byte[] number = new byte[30];
                length = 36;
                CVRSDK.GetPeopleIDCode(ref number[0], ref length);
                byte[] people = new byte[30];
                length = 3;
                CVRSDK.GetPeopleNation(ref people[0], ref length);
                byte[] validtermOfStart = new byte[30];
                length = 16;
                CVRSDK.GetStartDate(ref validtermOfStart[0], ref length);
                byte[] birthday = new byte[30];
                length = 16;
                CVRSDK.GetPeopleBirthday(ref birthday[0], ref length);
                byte[] address = new byte[200];
                length = 200;
                CVRSDK.GetPeopleAddress(ref address[0], ref length);
                byte[] validtermOfEnd = new byte[30];
                length = 16;
                CVRSDK.GetEndDate(ref validtermOfEnd[0], ref length);
                byte[] signdate = new byte[30];
                length = 30;
                CVRSDK.GetDepartment(ref signdate[0], ref length);
                byte[] sex = new byte[30];
                length = 3;
                CVRSDK.GetPeopleSex(ref sex [0], ref length);

                byte[] samid = new byte[32];
                CVRSDK.CVR_GetSAMID(ref samid[0]);


                lblAddress.Text   = System.Text.Encoding.GetEncoding("GB2312").GetString(address).Replace("\0", "").Trim();
                lblSex.Text       = System.Text.Encoding.GetEncoding("GB2312").GetString(sex).Replace("\0", "").Trim();
                lblBirthday.Text  = System.Text.Encoding.GetEncoding("GB2312").GetString(birthday).Replace("\0", "").Trim();
                lblDept.Text      = System.Text.Encoding.GetEncoding("GB2312").GetString(signdate).Replace("\0", "").Trim();
                lblIdCard.Text    = System.Text.Encoding.GetEncoding("GB2312").GetString(number).Replace("\0", "").Trim();
                lblName.Text      = System.Text.Encoding.GetEncoding("GB2312").GetString(name).Replace("\0", "").Trim();
                lblNation.Text    = System.Text.Encoding.GetEncoding("GB2312").GetString(people).Replace("\0", "").Trim();
                label11.Text      = "安全模块号:" + System.Text.Encoding.GetEncoding("GB2312").GetString(samid).Replace("\0", "").Trim();
                lblValidDate.Text = String.Format("{0}-{1}", System.Text.Encoding.GetEncoding("GB2312").GetString(validtermOfStart).Replace("\0", "").Trim(), System.Text.Encoding.GetEncoding("GB2312").GetString(validtermOfEnd).Replace("\0", "").Trim());

                prevCID = lblIdCard.Text;

                IdentificationData data = new IdentificationData();

                data.身份证号 = lblIdCard.Text;
                data.姓名   = lblName.Text;
                data.性别   = lblSex.Text;
                data.民族   = lblNation.Text;
                data.出生日期 = Convert.ToDateTime(lblBirthday.Text);
                data.地址   = lblAddress.Text;
                data.签发机关 = lblDept.Text;
                data.效期限  = lblValidDate.Text;

                return(data);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            return(null);
        }