Ejemplo n.º 1
0
        private void createConnection()
        {
            try
            {
                string connectionString =
                    "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)" +
                    "(HOST=" + netDet.IP_DB + ")(PORT=" + netDet.PORT_DB + ")))" +
                    "(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=" + netDet.SID + ")));" +
                    "User Id=" + netDet.DBNAME + ";Password= "******";";
                //             string connectionString = "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=" + netDet.IP_DB + ")(PORT=" + netDet.PORT_DB + "))" +
                //"(CONNECT_DATA=(SID=" + netDet.SID + ")));User Id=" + netDet.DBNAME + ";Password="******";";

                orcConn = new OracleConnection(connectionString);
                orcConn.Open();

                NotificationHelper.CreateNotification("Connection Opened");
                FileHelper.writeToLog("\r\n" + "Connection Opened");
            }
            catch (Exception e)
            {
                NotificationHelper.CreateNotification(e.Message);
                FileHelper.writeToLog(e.Message);
            }
        }
Ejemplo n.º 2
0
        public List <Record> getAllLogData()
        {
            List <Record> records = new List <Record>();

            if (!open())
            {
                return(records);
            }

            int idwErrorCode = 0;

            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;

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

            if (axCZKEM1.ReadGeneralLogData(iMachineNumber)) //read all the attendance records to the memory
            {
                while (axCZKEM1.SSR_GetGeneralLogData(iMachineNumber, 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
                {
                    string hour = idwHour.ToString(),
                           min  = idwMinute.ToString();

                    if (hour.Length == 1)
                    {
                        hour = "0" + hour;
                    }
                    if (min.Length == 1)
                    {
                        min = "0" + min;
                    }

                    Record record = new Record(int.Parse(sdwEnrollNumber),
                                               idwMonth.ToString() + "/" + idwDay.ToString() + "/" + idwYear.ToString(),
                                               hour + "." + min);
                    records.Add(record);
                }

                axCZKEM1.EnableDevice(iMachineNumber, true);//enable the device
                axCZKEM1.Disconnect();

                return(records);
            }
            else
            {
                axCZKEM1.GetLastError(ref idwErrorCode);

                if (idwErrorCode != 0)
                {
                    NotificationHelper.CreateNotification("Reading data from terminal failed,ErrorCode: " + idwErrorCode.ToString());
                    FileHelper.writeToLog("Reading data from terminal failed,ErrorCode: " + idwErrorCode.ToString(), "Error");
                }
                else
                {
                    NotificationHelper.CreateNotification("No data from terminal returns!");
                    FileHelper.writeToLog("No data from terminal returns!", "Error");
                }
            }

            return(null);
        }