Ejemplo n.º 1
0
        public List<Employee> GetAllEmployee(Terminal terminal)
        {
            string devInfo = GetDeviceInfoStr(terminal);
            string command = "GetEmployeeID()";
            IntPtr result = IntPtr.Zero;

            HwDev_Execute(devInfo, command, ref result);

            if (IsSuccess(result))
            {
                List<int> employeeNumberList = GetEmployeeList(result);
                List<Employee> employeeList = new List<Employee>();

                foreach (int employeeNumber in employeeNumberList)
                {
                    employeeList.Add(GetEmployee(terminal, employeeNumber));
                }

                return employeeList;
            }
            else
            {
                throw new Exception(GetFailedReason(result));
            }
        }
Ejemplo n.º 2
0
        public bool DeleteAttendanceRecord(Terminal terminal)
        {
            string devInfo = GetDeviceInfoStr(terminal);
            string command = "DeleteRecord()";
            IntPtr result = IntPtr.Zero;

            HwDev_Execute(devInfo, command, ref result);

            return IsSuccess(result);
        }
Ejemplo n.º 3
0
        public List<AttendanceRecord> GetAttendanceRecord(Terminal terminal, DateTime dtFrom, DateTime dtTo)
        {
            string devInfo = GetDeviceInfoStr(terminal);
            string command = "GetRecord(start_time=\"" + ConvertToDateTimeString(dtFrom) + "\" end_time=\"" + ConvertToDateTimeString(dtTo) + "\")";

            IntPtr result = IntPtr.Zero;
            HwDev_Execute(devInfo, command, ref result);

            List<AttendanceRecord> attRecordList = new List<AttendanceRecord>();
            string keyName = "time=\"";
            int iFrom, iTo;

            string resultString = Marshal.PtrToStringAnsi(result);
            while ((iFrom = resultString.IndexOf(keyName)) >= 0)
            {
                if (iFrom > resultString.IndexOf(")") && resultString.IndexOf(")") >= 0)
                    break;

                iTo = resultString.IndexOf(keyName, iFrom + 1);
                if(iTo < 0)
                    iTo = resultString.IndexOf(")", iFrom + 1);

                if (iTo < 0)
                    throw new Exception();

                string attString = resultString.Substring(iFrom, iTo - iFrom);

                AttendanceRecord attRecord = new AttendanceRecord();
                attRecord.Time = Convert.ToDateTime(GetValue(attString, "time"));
                attRecord.EmployeeNumber = Convert.ToInt32(GetValue(attString, "id"));

                attRecordList.Add(attRecord);

                resultString = resultString.Substring(iTo);
            }

            return attRecordList;
        }
Ejemplo n.º 4
0
        public int AddTerminal(Terminal terminal)
        {
            if (IsDuplicateTerminal(terminal, false))
                return -1;

            OleDbCommand odCom1 = BuildInsertCmd("Terminal",
                new string[] { "Name"
                ,"IPAddress"
                },
                new object[] { terminal.Name
                ,terminal.IPAddress
                }
            );

            if (ExecuteNonQuery(odCom1) == 1)
            {
                odCom1.CommandText = "SELECT @@IDENTITY";
                return Convert.ToInt32(odCom1.ExecuteScalar().ToString());
            }
            return -1;
        }
Ejemplo n.º 5
0
        public bool UpdateTerminal(Terminal terminal)
        {
            if (IsDuplicateTerminal(terminal, true))
                return false;

            OleDbCommand odCom1 = BuildUpdateCmd("Terminal",
                new string[] { "Name"
                ,"IPAddress"
                },
                new object[] { terminal.Name
                ,terminal.IPAddress
                },
                "ID=@ID", new object[] { "@ID", terminal.ID }
            );

            return ExecuteNonQuery(odCom1) > 0 ? true : false;
        }
Ejemplo n.º 6
0
        public bool IsDuplicateTerminal(Terminal terminal, bool existTerminal)
        {
            OleDbCommand odCom;
            if (existTerminal)
                odCom = BuildSelectCmd("Terminal", "ID", "ID<>@ID AND ([Name]=@Name OR IPAddress=@IPAddress)",
                    new object[] { "@ID", terminal.ID, "@Name", terminal.Name, "@IPAddress", terminal.IPAddress });
            else
                odCom = BuildSelectCmd("Terminal", "ID", "[Name]=@Name OR IPAddress=@IPAddress",
                    new object[] { "@Name", terminal.Name, "@IPAddress", terminal.IPAddress });

            OleDbDataReader odRdr = odCom.ExecuteReader();

            if (odRdr.Read())
            {
                odRdr.Close();
                return true;
            }
            return false;
        }
Ejemplo n.º 7
0
        public List<Terminal> GetTerminalListByEmployee(int employeeNumber)
        {
            OleDbCommand odCom = BuildSelectCmd("Terminal", "*", "ID in (SELECT TerminalID FROM EmployeeTerminal WHERE EmployeeNumber=@EmployeeNumber)", new object[] { "@EmployeeNumber", employeeNumber });
            OleDbDataReader odRdr = odCom.ExecuteReader();

            List<Terminal> terminals = new List<Terminal>();
            Terminal terminal = null;
            while (odRdr.Read())
            {
                terminal = new Terminal();

                terminal.ID = (int)odRdr["ID"];
                terminal.Name = odRdr["Name"].ToString();
                terminal.IPAddress = odRdr["IPAddress"].ToString();

                terminals.Add(terminal);
            }

            odRdr.Close();
            return terminals;
        }
Ejemplo n.º 8
0
        public List<Terminal> GetTerminalList()
        {
            OleDbCommand odCom = BuildSelectCmd("Terminal", "*", null);
            OleDbDataReader odRdr = odCom.ExecuteReader();
            List<Terminal> terminalList = new List<Terminal>();
            Terminal terminal = null;
            while (odRdr.Read())
            {
                terminal = new Terminal();

                terminal.ID = (int)odRdr["ID"];
                terminal.Name = odRdr["Name"].ToString();
                terminal.IPAddress = odRdr["IPAddress"].ToString();

                terminalList.Add(terminal);
            }

            odRdr.Close();
            return terminalList;
        }
Ejemplo n.º 9
0
        public Terminal GetTerminal(int id)
        {
            OleDbCommand odCom = BuildSelectCmd("Terminal", "*", "ID=@ID", new object[] { "@ID", id });

            OleDbDataReader odRdr = odCom.ExecuteReader();

            Terminal terminal = null;
            if (odRdr.Read())
            {
                terminal = new Terminal();

                terminal.ID = Convert.ToInt32(odRdr["ID"]);
                terminal.Name = odRdr["Name"].ToString();
                terminal.IPAddress = odRdr["IPAddress"].ToString();
            }

            odRdr.Close();
            return terminal;
        }
Ejemplo n.º 10
0
        private Terminal GetTerminalUserInput()
        {
            string terminalName = txtTerminalName.Text;
            string ipAddress = ipcTerminalIP.Text.Replace(" ", "");

            if (string.IsNullOrEmpty(terminalName))
            {
                MessageBox.Show("Terminal Name must not be empty.");
                return null;
            }

            if (Util.IsValidIP(ipAddress) == false)
            {
                MessageBox.Show("Invalid IP Addess.");
                return null;
            }

            Terminal terminal = new Terminal();
            terminal.Name = terminalName;
            terminal.IPAddress = ipAddress;

            return terminal;
        }
Ejemplo n.º 11
0
 private string GetDeviceInfoStr(Terminal terminal)
 {
     return "DeviceInfo( dev_id = \"" + terminal.ID + "\" dev_type = \"HW_HDCP\" comm_type = \"ip\" ip_address = \"" + terminal.IPAddress + "\" )";
 }
Ejemplo n.º 12
0
        public bool UpdateEmployee(Terminal terminal, Employee employee)
        {
            string devInfo = GetDeviceInfoStr(terminal);
            string command = GetSetEmployeeCmdStr(employee);

            IntPtr result = IntPtr.Zero;
            HwDev_Execute(devInfo, command, ref result);

            //MessageBox.Show(Marshal.PtrToStringAnsi(result));

            return IsSuccess(result);
        }
Ejemplo n.º 13
0
        public bool RemoveEmployee(Terminal terminal, int employeeNumber)
        {
            string devInfo = GetDeviceInfoStr(terminal);
            string command = "DeleteEmployee(id=\"" + employeeNumber + "\")";
            IntPtr result = IntPtr.Zero;

            HwDev_Execute(devInfo, command, ref result);

            return IsSuccess(result);
        }
Ejemplo n.º 14
0
        public bool IsTerminalConnected(Terminal terminal)
        {
            System.Net.NetworkInformation.Ping pinger = new System.Net.NetworkInformation.Ping();
            System.Net.NetworkInformation.PingReply pingReply = pinger.Send(terminal.IPAddress);

            return pingReply.Status == System.Net.NetworkInformation.IPStatus.Success;
        }
Ejemplo n.º 15
0
        public Employee GetEmployee(Terminal terminal, int employeeNumber)
        {
            string devInfo = GetDeviceInfoStr(terminal);
            string command = "GetEmployee(id=" + employeeNumber + ")";
            IntPtr result = IntPtr.Zero;

            HwDev_Execute(devInfo, command, ref result);

            if (IsSuccess(result))
            {
                Employee employee = new Employee();

                employee.EmployeeNumber = Convert.ToInt32(GetValue(result, "id"));
                employee.FirstName = GetValue(result, "name");

                employee.FaceData1 = GetValue(result, "face_data", 1);
                employee.FaceData2 = GetValue(result, "face_data", 2);
                employee.FaceData3 = GetValue(result, "face_data", 3);
                employee.FaceData4 = GetValue(result, "face_data", 4);
                employee.FaceData5 = GetValue(result, "face_data", 5);
                employee.FaceData6 = GetValue(result, "face_data", 6);
                employee.FaceData7 = GetValue(result, "face_data", 7);
                employee.FaceData8 = GetValue(result, "face_data", 8);
                employee.FaceData9 = GetValue(result, "face_data", 9);
                employee.FaceData10 = GetValue(result, "face_data", 10);
                employee.FaceData11 = GetValue(result, "face_data", 11);
                employee.FaceData12 = GetValue(result, "face_data", 12);
                employee.FaceData13 = GetValue(result, "face_data", 13);
                employee.FaceData14 = GetValue(result, "face_data", 14);
                employee.FaceData15 = GetValue(result, "face_data", 15);
                employee.FaceData16 = GetValue(result, "face_data", 16);
                employee.FaceData17 = GetValue(result, "face_data", 17);
                employee.FaceData18 = GetValue(result, "face_data", 18);

                //string[] faceData = new string[]
                //{
                //    employee.FaceData1,
                //    employee.FaceData2,
                //    employee.FaceData3,
                //    employee.FaceData4,
                //    employee.FaceData5,
                //    employee.FaceData6,
                //    employee.FaceData7,
                //    employee.FaceData8,
                //    employee.FaceData9,
                //    employee.FaceData10,
                //    employee.FaceData11,
                //    employee.FaceData12,
                //    employee.FaceData13,
                //    employee.FaceData14,
                //    employee.FaceData15,
                //    employee.FaceData16,
                //    employee.FaceData17,
                //    employee.FaceData18
                //};

                //string resultString = Marshal.PtrToStringAnsi(result);

                //int iFrom, iTo, index = 0;
                //string keyName = "face_data=\"";
                //while ((iFrom = resultString.IndexOf(keyName)) >= 0 && index < faceData.Length)
                //{
                //    iFrom += keyName.Length;
                //    iTo = resultString.IndexOf("\"", iFrom);

                //    faceData[index] = resultString.Substring(iFrom, iTo - iFrom);

                //    resultString = resultString.Substring(iTo);
                //    index++;
                //}

                return employee;
            }
            else
            {
                throw new Exception(GetFailedReason(result));
            }
        }
Ejemplo n.º 16
0
        private void AddEmployee()
        {
            //com.Name = DateTime.Now.Ticks.ToString();
            //com.ID = _dtCtrl.AddCompany(com);

            //dep.Name = DateTime.Now.Ticks.ToString();
            //dep.CompanyID = com.ID;
            //dep.SupDepartmentID = 0;
            //dep.ID = _dtCtrl.AddDepartment(dep);

            //wCal.Name = DateTime.Now.Ticks.ToString();
            //wCal.RegularWorkingFrom = DateTime.Today;
            //wCal.RegularWorkingTo = DateTime.Today;

            //List<Break> breakList = new List<Break>();
            //List<Holiday> holidayList = new List<Holiday>();

            //PaymentRate workingDayPaymentRate = new PaymentRate();
            //PaymentRate nonWorkingDayPaymentRate = new PaymentRate();
            //PaymentRate holidayPaymentRate = new PaymentRate();

            //PayPeriod payPeriod = new PayPeriod();
            //payPeriod.CustomPeriod = 5;
            //payPeriod.PayPeriodTypeID = 5; //custom
            //payPeriod.StartFrom = DateTime.Today;

            //wCal.ID = _dtCtrl.AddWorkingCalendar(wCal, breakList, holidayList, workingDayPaymentRate, nonWorkingDayPaymentRate, holidayPaymentRate, payPeriod);

            dep = _dtCtrl.GetDepartmentList()[0];
            com = _dtCtrl.GetCompany(dep.CompanyID);
            wCal = _dtCtrl.GetWorkingCalendarList()[0];
            ter = _dtCtrl.GetTerminalList()[0];

            emp = new Employee();
            emp.Active = true;
            emp.ActiveFrom = DateTime.Today;
            emp.ActiveTo = DateTime.Today.AddDays(1);
            emp.Address = DateTime.Now.Ticks.ToString();
            emp.Birthday = DateTime.Today.AddYears(-20);
            emp.DepartmentID = dep.ID;
            emp.EmployeeNumber = 0;
            emp.FirstName = DateTime.Now.Ticks.ToString();
            emp.JobDescription = DateTime.Now.Ticks.ToString();
            emp.HiredDate = DateTime.Today;
            emp.LeftDate = DateTime.Today.AddYears(1);
            emp.LastName = DateTime.Now.Ticks.ToString();
            emp.PhoneNumber = DateTime.Now.Ticks.ToString();
            emp.WorkingCalendarID = wCal.ID;
            emp.FaceData1 = "";
            emp.FaceData2 = "";
            emp.FaceData3 = "";
            emp.FaceData4 = "";
            emp.FaceData5 = "";
            emp.FaceData6 = "";
            emp.FaceData7 = "";
            emp.FaceData8 = "";
            emp.FaceData9 = "";
            emp.FaceData10 = "";
            emp.FaceData11 = "";
            emp.FaceData12 = "";
            emp.FaceData13 = "";
            emp.FaceData14 = "";
            emp.FaceData15 = "";
            emp.FaceData16 = "";
            emp.FaceData17 = "";
            emp.FaceData18 = "";

            emp.PayrollNumber = _dtCtrl.AddEmployee(emp, new List<Terminal>(){ter});
        }