Member 14706664 Ответов: 1

У меня есть некоторые проблемы с машиной zkt eco uface 800 attandance.


Я сделала программного обеспечения C# и подключение программного обеспечения с устройств ЗКТ. Все работает идеально. Программное обеспечение правильно настраивается вместе с машиной.
Но есть одна проблема, о которой я расскажу вам шаг за шагом со следующим сценарием:
1. когда и программное обеспечение, и устройство подключены, то данные прекрасно читаются и записываются.
2. когда программное обеспечение работает и машина отключена на некоторое время, в это время записи посещаемости считываются машиной и при подключении к программному обеспечению затем автоматически отображаются записи на программном обеспечении, которые вводятся во время отключения.

3. (проблема) когда машина работает и по какой-то причине программное обеспечение отключено или закрыто, то во время отключения машина получает посещаемость в своем журнале, но программное обеспечение не читается. когда программное обеспечение запускается снова, то оно не показывает отсутствующую запись или запись во время отключения.

Может ли кто-нибудь мне помочь??? пожалуйста

Что я уже пробовал:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Oracle.ManagedDataAccess.Client;
using System.Configuration;
using System.IO;


namespace AttendanceSystem
{
    public partial class AttendanceInformation : Form
    {
       public zkemkeeper.CZKEM zkm = new zkemkeeper.CZKEM();

       string connection = ConfigurationManager.ConnectionStrings["oracleDB"].ConnectionString;
       OracleConnection conn;

       private bool bIsConnected = false;
       private int iMachineNumber = 1;
       string path = @"C:\Users\daniyal\Desktop\Save Data.txt";


        public AttendanceInformation()
        {
            InitializeComponent();

        }
      
        private void AttendanceInformation_Load(object sender, EventArgs e)
        {
            try
            {
                OnConnected();
                string ip = File.ReadAllText(@"C:\Users\daniyal\Desktop\Machine Ip.txt");
                txtIp.Text = ip.ToString();
                txtIp.Enabled = false;
                
                conn = new OracleConnection(connection);
                if (txtIp.Text.Trim() == "" || txtPort.Text.Trim() == "")
                {
                    MessageBox.Show("IP and Port cannot be null", "Error");
                    return;
                }

                int idwErrorCode = 0;

                Cursor = Cursors.WaitCursor;
                if (connectBtn.Text == "Disconnect")
                {
                    zkm.Disconnect();

                    this.zkm.OnFinger -= new zkemkeeper._IZKEMEvents_OnFingerEventHandler(zkm_OnFinger);
                    this.zkm.OnVerify -= new zkemkeeper._IZKEMEvents_OnVerifyEventHandler(zkm_OnVerify);
                    this.zkm.OnAttTransactionEx -= new zkemkeeper._IZKEMEvents_OnAttTransactionExEventHandler(zkm_OnAttTransactionEx);
                    this.zkm.OnFingerFeature -= new zkemkeeper._IZKEMEvents_OnFingerFeatureEventHandler(zkm_OnFingerFeature);
                    this.zkm.OnEnrollFingerEx -= new zkemkeeper._IZKEMEvents_OnEnrollFingerExEventHandler(zkm_OnEnrollFingerEx);
                    this.zkm.OnDeleteTemplate -= new zkemkeeper._IZKEMEvents_OnDeleteTemplateEventHandler(zkm_OnDeleteTemplate);
                    this.zkm.OnNewUser -= new zkemkeeper._IZKEMEvents_OnNewUserEventHandler(zkm_OnNewUser);
                    this.zkm.OnHIDNum -= new zkemkeeper._IZKEMEvents_OnHIDNumEventHandler(zkm_OnHIDNum);
                    this.zkm.OnAlarm -= new zkemkeeper._IZKEMEvents_OnAlarmEventHandler(zkm_OnAlarm);
                    this.zkm.OnDoor -= new zkemkeeper._IZKEMEvents_OnDoorEventHandler(zkm_OnDoor);
                    this.zkm.OnWriteCard -= new zkemkeeper._IZKEMEvents_OnWriteCardEventHandler(zkm_OnWriteCard);
                    this.zkm.OnEmptyCard -= new zkemkeeper._IZKEMEvents_OnEmptyCardEventHandler(zkm_OnEmptyCard);

                    bIsConnected = false;
                    connectBtn.Text = "Connect";
                    lblState.Text = "Current State:DisConnected";
                    Cursor = Cursors.Default;
                    return;
                }

                bIsConnected = zkm.Connect_Net(txtIp.Text, Convert.ToInt32(txtPort.Text));
                if (bIsConnected == true)
                {
                    connectBtn.Text = "Disconnect";
                    connectBtn.Refresh();
                    lblState.Text = "Current State:Connected";
                    iMachineNumber = 1;//In fact,when you are using the tcp/ip communication,this parameter will be ignored,that is any integer will all right.Here we use 1.
                    if (zkm.RegEvent(iMachineNumber, 65535))//Here you can register the realtime events that you want to be triggered(the parameters 65535 means registering all)
                    {
                        this.zkm.OnFinger += new zkemkeeper._IZKEMEvents_OnFingerEventHandler(zkm_OnFinger);
                        this.zkm.OnVerify += new zkemkeeper._IZKEMEvents_OnVerifyEventHandler(zkm_OnVerify);
                        this.zkm.OnAttTransactionEx += new zkemkeeper._IZKEMEvents_OnAttTransactionExEventHandler(zkm_OnAttTransactionEx);
                        this.zkm.OnFingerFeature += new zkemkeeper._IZKEMEvents_OnFingerFeatureEventHandler(zkm_OnFingerFeature);
                        this.zkm.OnEnrollFingerEx += new zkemkeeper._IZKEMEvents_OnEnrollFingerExEventHandler(zkm_OnEnrollFingerEx);
                        this.zkm.OnDeleteTemplate += new zkemkeeper._IZKEMEvents_OnDeleteTemplateEventHandler(zkm_OnDeleteTemplate);
                        this.zkm.OnNewUser += new zkemkeeper._IZKEMEvents_OnNewUserEventHandler(zkm_OnNewUser);
                        this.zkm.OnHIDNum += new zkemkeeper._IZKEMEvents_OnHIDNumEventHandler(zkm_OnHIDNum);
                        this.zkm.OnAlarm += new zkemkeeper._IZKEMEvents_OnAlarmEventHandler(zkm_OnAlarm);
                        this.zkm.OnDoor += new zkemkeeper._IZKEMEvents_OnDoorEventHandler(zkm_OnDoor);
                        this.zkm.OnWriteCard += new zkemkeeper._IZKEMEvents_OnWriteCardEventHandler(zkm_OnWriteCard);
                        this.zkm.OnEmptyCard += new zkemkeeper._IZKEMEvents_OnEmptyCardEventHandler(zkm_OnEmptyCard);
                    }
                }
                else
                {
                    zkm.GetLastError(ref idwErrorCode);
                    MessageBox.Show("Unable to connect the device,ErrorCode=" + idwErrorCode.ToString(), "Error");
                }
                Cursor = Cursors.Default;
                
                Timer t = new Timer();
                t.Interval = 1000;
                timer1.Enabled = true;
                timer1.Tick += new System.EventHandler(timer2_Tick);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error Detail: "+ex,"Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
            }
        }

        private  void OnConnected()
        {
            
            StreamWriter write;
            //Checking Text File
            if (!File.Exists(path))
            {
                write = new StreamWriter(path);
                write.WriteLine(DateTime.Now);
                write.Close();
            }
            ////Write In text File
            //write = new StreamWriter(path);
            //write.WriteLine(dt1);
            //write.Close();
            using (StreamReader read = File.OpenText(path))
            {

                if ((read.ReadLine()) == null)
                {
                    read.Close();
                    write = new StreamWriter(path);
                    write.WriteLine(DateTime.Now);
                    write.Close();
                }
            }
            string reader = File.ReadLines(path).Last();
            ShowEvents.Items.Add(reader);
        }

        private void zkm_OnFinger()
        {
            ShowEvents.Items.Add("RTEvent OnFinger Has been Triggered");
        }

        private void zkm_OnVerify(int iUserID)
        {
            //ShowEvents.Items.Add("RTEvent OnVerify Has been Triggered,Verifying...");
            if (iUserID != -1)
            {
                ShowEvents.Items.Add("Verified OK,the UserID is " + iUserID.ToString());
            }
            else
            {
                ShowEvents.Items.Add("Verified Failed... ");
            }
        }

        private void zkm_OnAttTransactionEx(string sEnrollNumber, int iIsInValid, int iAttState, int iVerifyMethod, int iYear, int iMonth, int iDay, int iHour, int iMinute, int iSecond, int iWorkCode)
        {
            ShowEvents.Items.Add("Verified OK");
            ShowEvents.Items.Add("...UserID: " + sEnrollNumber);
            //ShowEvents.Items.Add("...isInvalid:" + iIsInValid.ToString());
            //ShowEvents.Items.Add("...attState:" + iAttState.ToString());
            //ShowEvents.Items.Add("...VerifyMethod:" + iVerifyMethod.ToString());
            //ShowEvents.Items.Add("...User Name:" + userName.ToString());
            //ShowEvents.Items.Add("...Workcode:" + iWorkCode.ToString());//the difference between the event OnAttTransaction and OnAttTransactionEx
            ShowEvents.Items.Add("...Time: " + iYear.ToString() + "-" + iMonth.ToString() + "-" + iDay.ToString() + " " + iHour.ToString() + ":" + iMinute.ToString() + ":" + iSecond.ToString());

            DateTime dt1 = new DateTime(Convert.ToInt16(iYear.ToString()), Convert.ToInt16(iMonth.ToString()), Convert.ToInt16(iDay.ToString()), Convert.ToInt16(iHour.ToString()), Convert.ToInt16(iMinute.ToString()), Convert.ToInt16(iSecond.ToString()));
           
            //DateTime save in Text File
            string path = @"C:\Users\daniyal\Desktop\Save Data.txt";
            StreamWriter write;
            //Checking Text File
            if (!File.Exists(path))
            {
                 write = new StreamWriter(path);
                write.WriteLine(DateTime.Now);
                write.Close();
            }
            ////Write In text File
            //write = new StreamWriter(path);
            //write.WriteLine(dt1);
            //write.Close();
            using (StreamReader read = File.OpenText(path))
            {

                if ((read.ReadLine()) == null)
                {
                    read.Close();
                    write = new StreamWriter(path);
                    write.WriteLine(dt1);
                    write.Close();
                }
            }  

            //get or Read last date
            string reader = File.ReadLines(path).Last();

            DateTime dt2 = new DateTime(Convert.ToInt16(iYear.ToString()), Convert.ToInt16(iMonth.ToString()), Convert.ToInt16(iDay.ToString()), Convert.ToInt16(iHour.ToString()), Convert.ToInt16(iMinute.ToString()), Convert.ToInt16(iSecond.ToString()));

            //Write In text File
            write = new StreamWriter(path);
            write.WriteLine(dt2);
            write.Close();

            DateTime dt = Convert.ToDateTime(reader); //convert Text File DateTime into C# DateTime
            //----------------------------------------------------//

            txtMachineId.Text = sEnrollNumber; //User Id From Machine

            //Save in Database
            string date = dt.ToString("dd-MMM-yyyy");

            conn.Open();
            string query = "insert into attandance (user_id,in_date)values('" + txtMachineId.Text + "','" + date + "')";
            OracleCommand cmd = new OracleCommand(query, conn);
            cmd.ExecuteNonQuery();
            conn.Close();

        }
        private void zkm_OnFingerFeature(int iScore)
        {
            if (iScore < 0)
            {
                ShowEvents.Items.Add("The quality of your fingerprint is poor");
            }
            else
            {
                ShowEvents.Items.Add("RTEvent OnFingerFeature Has been Triggered...Score: " + iScore.ToString());
            }
        }

        private void zkm_OnEnrollFingerEx(string sEnrollNumber, int iFingerIndex, int iActionResult, int iTemplateLength)
        {
            if (iActionResult == 0)
            {
                ShowEvents.Items.Add("RTEvent OnEnrollFigerEx Has been Triggered....");
                ShowEvents.Items.Add(".....UserID: " + sEnrollNumber + " Index: " + iFingerIndex.ToString() + " tmpLen: " + iTemplateLength.ToString());
            }
            else
            {
                ShowEvents.Items.Add("RTEvent OnEnrollFigerEx Has been Triggered Error,actionResult=" + iActionResult.ToString());
            }
        }

        private void zkm_OnDeleteTemplate(int iEnrollNumber, int iFingerIndex)
        {
            ShowEvents.Items.Add("RTEvent OnDeleteTemplate Has been Triggered...");
            ShowEvents.Items.Add("...UserID=" + iEnrollNumber.ToString() + " FingerIndex=" + iFingerIndex.ToString());
        }
        private void zkm_OnNewUser(int iEnrollNumber)
        {
            ShowEvents.Items.Add("RTEvent OnNewUser Has been Triggered...");
            ShowEvents.Items.Add("...NewUserID=" + iEnrollNumber.ToString());
        }

        //When you swipe a card to the device, this event will be triggered to show you the card number.
        private void zkm_OnHIDNum(int iCardNumber)
        {
            ShowEvents.Items.Add("RTEvent OnHIDNum Has been Triggered...");
            ShowEvents.Items.Add("...Cardnumber=" + iCardNumber.ToString());
        }

        //When the dismantling machine or duress alarm occurs, trigger this event.
        private void zkm_OnAlarm(int iAlarmType, int iEnrollNumber, int iVerified)
        {
            ShowEvents.Items.Add("RTEvnet OnAlarm Has been Triggered...");
            ShowEvents.Items.Add("...AlarmType=" + iAlarmType.ToString());
            ShowEvents.Items.Add("...EnrollNumber=" + iEnrollNumber.ToString());
            ShowEvents.Items.Add("...Verified=" + iVerified.ToString());
        }

        //Door sensor event
        private void zkm_OnDoor(int iEventType)
        {
            ShowEvents.Items.Add("RTEvent Ondoor Has been Triggered...");
            ShowEvents.Items.Add("...EventType=" + iEventType.ToString());
        }

        //When you have emptyed the Mifare card,this event will be triggered.
        private void zkm_OnEmptyCard(int iActionResult)
        {
            ShowEvents.Items.Add("RTEvent OnEmptyCard Has been Triggered...");
            if (iActionResult == 0)
            {
                ShowEvents.Items.Add("...Empty Mifare Card OK");
            }
            else
            {
                ShowEvents.Items.Add("...Empty Failed");
            }
        }

        //When you have written into the Mifare card ,this event will be triggered.
        private void zkm_OnWriteCard(int iEnrollNumber, int iActionResult, int iLength)
        {
            ShowEvents.Items.Add("RTEvent OnWriteCard Has been Triggered...");
            if (iActionResult == 0)
            {
                ShowEvents.Items.Add("...Write Mifare Card OK");
                ShowEvents.Items.Add("...EnrollNumber=" + iEnrollNumber.ToString());
                ShowEvents.Items.Add("...TmpLength=" + iLength.ToString());
            }
            else
            {
                ShowEvents.Items.Add("...Write Failed");
            }
        }
        private void connectBtn_Click(object sender, EventArgs e)
        {
             try
        {
            if (txtIp.Text.Trim() == "" || txtPort.Text.Trim() == "")
            {
                MessageBox.Show("IP and Port cannot be null", "Error");
                return;
            }
            int idwErrorCode = 0;

            Cursor = Cursors.WaitCursor;
            if (connectBtn.Text == "Disconnect")
            {
                zkm.Disconnect();

                this.zkm.OnFinger -= new zkemkeeper._IZKEMEvents_OnFingerEventHandler(zkm_OnFinger);
                this.zkm.OnVerify -= new zkemkeeper._IZKEMEvents_OnVerifyEventHandler(zkm_OnVerify);
                this.zkm.OnAttTransactionEx -= new zkemkeeper._IZKEMEvents_OnAttTransactionExEventHandler(zkm_OnAttTransactionEx);
                this.zkm.OnFingerFeature -= new zkemkeeper._IZKEMEvents_OnFingerFeatureEventHandler(zkm_OnFingerFeature);
                this.zkm.OnEnrollFingerEx -= new zkemkeeper._IZKEMEvents_OnEnrollFingerExEventHandler(zkm_OnEnrollFingerEx);
                this.zkm.OnDeleteTemplate -= new zkemkeeper._IZKEMEvents_OnDeleteTemplateEventHandler(zkm_OnDeleteTemplate);
                this.zkm.OnNewUser -= new zkemkeeper._IZKEMEvents_OnNewUserEventHandler(zkm_OnNewUser);
                this.zkm.OnHIDNum -= new zkemkeeper._IZKEMEvents_OnHIDNumEventHandler(zkm_OnHIDNum);
                this.zkm.OnAlarm -= new zkemkeeper._IZKEMEvents_OnAlarmEventHandler(zkm_OnAlarm);
                this.zkm.OnDoor -= new zkemkeeper._IZKEMEvents_OnDoorEventHandler(zkm_OnDoor);
                this.zkm.OnWriteCard -= new zkemkeeper._IZKEMEvents_OnWriteCardEventHandler(zkm_OnWriteCard);
                this.zkm.OnEmptyCard -= new zkemkeeper._IZKEMEvents_OnEmptyCardEventHandler(zkm_OnEmptyCard);

                bIsConnected = false;
                connectBtn.Text = "Connect";
                lblState.Text = "Current State:DisConnected";
                Cursor = Cursors.Default;
                return;
            }

            bIsConnected = zkm.Connect_Net(txtIp.Text, Convert.ToInt32(txtPort.Text));
            if (bIsConnected == true)
            {
                connectBtn.Text = "Disconnect";
                connectBtn.Refresh();
                lblState.Text = "Current State:Connected";
                iMachineNumber = 1;//In fact,when you are using the tcp/ip communication,this parameter will be ignored,that is any integer will all right.Here we use 1.
                if (zkm.RegEvent(iMachineNumber, 65535))//Here you can register the realtime events that you want to be triggered(the parameters 65535 means registering all)
                {
                    this.zkm.OnFinger += new zkemkeeper._IZKEMEvents_OnFingerEventHandler(zkm_OnFinger);
                    this.zkm.OnVerify += new zkemkeeper._IZKEMEvents_OnVerifyEventHandler(zkm_OnVerify);
                    this.zkm.OnAttTransactionEx += new zkemkeeper._IZKEMEvents_OnAttTransactionExEventHandler(zkm_OnAttTransactionEx);
                    this.zkm.OnFingerFeature += new zkemkeeper._IZKEMEvents_OnFingerFeatureEventHandler(zkm_OnFingerFeature);
                    this.zkm.OnEnrollFingerEx += new zkemkeeper._IZKEMEvents_OnEnrollFingerExEventHandler(zkm_OnEnrollFingerEx);
                    this.zkm.OnDeleteTemplate += new zkemkeeper._IZKEMEvents_OnDeleteTemplateEventHandler(zkm_OnDeleteTemplate);
                    this.zkm.OnNewUser += new zkemkeeper._IZKEMEvents_OnNewUserEventHandler(zkm_OnNewUser);
                    this.zkm.OnHIDNum += new zkemkeeper._IZKEMEvents_OnHIDNumEventHandler(zkm_OnHIDNum);
                    this.zkm.OnAlarm += new zkemkeeper._IZKEMEvents_OnAlarmEventHandler(zkm_OnAlarm);
                    this.zkm.OnDoor += new zkemkeeper._IZKEMEvents_OnDoorEventHandler(zkm_OnDoor);
                    this.zkm.OnWriteCard += new zkemkeeper._IZKEMEvents_OnWriteCardEventHandler(zkm_OnWriteCard);
                    this.zkm.OnEmptyCard += new zkemkeeper._IZKEMEvents_OnEmptyCardEventHandler(zkm_OnEmptyCard);
                }
            }
            else
            {
                zkm.GetLastError(ref idwErrorCode);
                MessageBox.Show("Unable to connect the device,ErrorCode=" + idwErrorCode.ToString(), "Error");
            }
            Cursor = Cursors.Default;
            
            //if (connectBtn.Text=="Disconnect")
            //{
            //    MessageBox.Show("Device Connected Successfully", "Device Connection", MessageBoxButtons.OK, MessageBoxIcon.Information);
            //}

            //else
            //{
            //    MessageBox.Show("Device Not Connect", "Device Connection", MessageBoxButtons.OK, MessageBoxIcon.Information);
            //}
        }
               
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message.ToString());
             }
        }
        private void getDataBtn_Click(object sender, EventArgs e)
        {
 
        }

        private void timer2_Tick(object sender, EventArgs e)
        {
            
        }
    }
    
}

1 Ответов

Рейтинг:
0

OriginalGriff

Почти наверняка это не "исправимая проблема" - машина посылает информацию, но там нет ничего, чтобы слушать ее, поэтому она отбрасывается.

Возможно, можно изменить способ работы устройства, чтобы предотвратить потерю данных, но для этого вам придется поговорить с производителями или найти информацию на их веб-сайте.