How to use resolve the zkemkeeper embedd issue?
Asked Answered
J

3

10

Please check the code below :

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using iTimeService.dsitimeTableAdapters;
using System.IO;

namespace iTimeService
{
    public partial class Service1 : ServiceBase
    {
        public Service1()
        {
            InitializeComponent();
        }
        public zkemkeeper.CZKEMClass axCZKEM1 = new zkemkeeper.CZKEMClass();
        private bool bIsConnected = false;//the boolean value identifies whether the device is connected
        private int iMachineNumber = 1;//the serial number of the device.After connecting the device ,this value will be changed.
        TENTERTableAdapter tenteradapter = new TENTERTableAdapter();
        T012_GATETableAdapter gateadapter = new T012_GATETableAdapter();
    }
}

I am getting an error on the object creation of zkemkeeper.CZKEMClass where it says : interop type 'zkemkeeper.CZKEMClass' cannot be embedded. Use the application interface instead.

Jonasjonathan answered 31/1, 2015 at 9:47 Comment(2)
How did you fix it?Angara
You should mark an answer as correct (if it is), it helps people who come across your question later.Conductor
L
23

click on the reference you have, I think for that specific project that would be 'zkemkeeper'

then on its properties just set the 'Embed Interop Type' to 'False' I hope this would help.

Lette answered 8/9, 2015 at 6:8 Comment(0)
A
0

OK, Thanks!

private MayChamCongBLL _mayChamCongBLL = new MayChamCongBLL();
private MayChamCongDTO _mayChamCongDTO = new MayChamCongDTO();
// private System.Configuration.Configuration _ngonNgu = ConfigurationManager.OpenExeConfiguration("MitaAttendance.exe");
private int a;
private ArrayList arrMayChamCong = new ArrayList();
//public CZKEM axCZKEM1 = new CZKEM();
public zkemkeeper.CZKEMClass axCZKEM1 = new zkemkeeper.CZKEMClass();
private int b;
// private Bar bar1;
private bool bIsConnected = false;
private int c;
private string sMaMayChamCong;
private string sSuDungWeb;
private int iMachineNumber = 1;
private int iNgonNgu;
Archiphoneme answered 22/2, 2018 at 9:31 Comment(0)
G
0
         private CZKEMClass axCZKEM1 = new CZKEMClass();


        private static bool _bIsConnected = false;
        private static int _iMachineNumber = 1;
        private static int _errorCode = 0;
      public bool GetConnectState()
        {
            return _bIsConnected;
        }

        private void SetConnectState(bool state)
        {
            _bIsConnected = state;
        }

        private int GetMachineNumber()
        {
            return _iMachineNumber;
        }

    public int sta_ConnectTCP(string ip, string port, string commKey)
    {
        if (ip == "" || port == "" || commKey == "")
        {
            return -1;// ip or port is null
        }

        if (Convert.ToInt32(port) <= 0 || Convert.ToInt32(port) > 65535)
        {
            return -1;
        }

        if (Convert.ToInt32(commKey) < 0 || Convert.ToInt32(commKey) > 999999)
        {
            return -1;
        }

        int idwErrorCode = 0;

        axCZKEM1.SetCommPassword(Convert.ToInt32(commKey));

        if (_bIsConnected)
        {
            axCZKEM1.Disconnect();
            SetConnectState(false);
            return -2; //disconnect
        }

        if (axCZKEM1.Connect_Net(ip, Convert.ToInt32(port)))
        {
            SetConnectState(true);
            return 1;
        }
        else
        {
            axCZKEM1.GetLastError(ref idwErrorCode);
            return idwErrorCode;
        }
    }

    public void sta_DisConnect()
    {
        if (GetConnectState())
        {
            axCZKEM1.Disconnect();
        }
    }
   public int sta_ReadNewAttLog(DataTable dt_log)
    {
        if (GetConnectState() == false)
        {
            //Please connect first!";
            return -1024;
        }

        int ret = 0;

        axCZKEM1.EnableDevice(GetMachineNumber(), false);//disable the device

        string sdwEnrollNumber = "";
        int idwVerifyMode = 0;
        int idwInOutMode = 0;
        int idwYear = 0;
        int idwMonth = 0;
        int idwDay = 0;
        int idwHour = 0;
        int idwMinute = 0;
        int idwSecond = 0;
        int idwWorkcode = 0;


        if (axCZKEM1.ReadNewGLogData(GetMachineNumber()))
        {
            while (axCZKEM1.SSR_GetGeneralLogData(GetMachineNumber(), out sdwEnrollNumber, out idwVerifyMode,
                        out idwInOutMode, out idwYear, out idwMonth, out idwDay, out idwHour, out idwMinute, out idwSecond, ref idwWorkcode))//get records from the memory
            {
                DataRow dr = dt_log.NewRow();
                dr["User ID"] = sdwEnrollNumber;
                dr["Verify Date"] = idwYear + "-" + idwMonth + "-" + idwDay + " " + idwHour + ":" + idwMinute + ":" + idwSecond;
                dr["idwYear"] = idwYear;
                dr["idwMonth"] = idwMonth;
                dr["idwDay"] = idwDay;
                dr["idwHour"] = idwHour;
                dr["idwMinute"] = idwMinute;
                dr["idwSecond"] = idwSecond;
                dr["Verify Type"] = idwVerifyMode;
                dr["Verify State"] = idwInOutMode;
                dr["WorkCode"] = idwWorkcode;
                dt_log.Rows.Add(dr);
            }
            ret = 1;
        }
        else
        {
            axCZKEM1.GetLastError(ref _errorCode);
            ret = _errorCode;

            if (_errorCode != 0)
            {
                //"*Read attlog by period failed,ErrorCode: " + idwErrorCode.ToString();
            }
            else
            {
                //"No data from terminal returns!";
            }
        }

        //lblOutputInfo.Items.Add("[func ReadNewGLogData]Temporarily unsupported");
        axCZKEM1.EnableDevice(GetMachineNumber(), true);//enable the device

        return ret;
    }
Grillroom answered 11/6, 2020 at 10:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.