public FPTemplateController() { _companyInfoService = new CompanyInfoService(new CompanyInfoRepository(), new CompanyInfoValidator()); _employeeService = new EmployeeService(new EmployeeRepository(), new EmployeeValidator()); _fpUserService = new FPUserService(new FPUserRepository(), new FPUserValidator()); _fpTemplateService = new FPTemplateService(new FPTemplateRepository(), new FPTemplateValidator()); _fpAttLogService = new FPAttLogService(new FPAttLogRepository(), new FPAttLogValidator()); }
public bool ValidCreateObject(FPAttLog fpAttLog, IFPAttLogService _fpAttLogService, IFPUserService _fpUserService) { VHasUser(fpAttLog, _fpUserService); if (!isValid(fpAttLog)) { return(false); } VHasUniqueUserTime(fpAttLog, _fpAttLogService); return(isValid(fpAttLog)); }
public FPAttLog VHasUniqueUserTime(FPAttLog fpAttLog, IFPAttLogService _fpAttLogService) { if (fpAttLog.Time_second == null || fpAttLog.Time_second.Equals(DateTime.FromBinary(0))) { fpAttLog.Errors.Add("Generic", "Time_second tidak valid"); } else if (_fpAttLogService.IsUserTimeDuplicated(fpAttLog)) { fpAttLog.Errors.Add("Generic", "Tidak boleh ada duplikasi waktu di user yang sama"); } return(fpAttLog); }
public bool ValidUpdateObject(FPAttLog fpAttLog, IFPAttLogService _fpAttLogService, IFPUserService _fpUserService) { fpAttLog.Errors.Clear(); ValidCreateObject(fpAttLog, _fpAttLogService, _fpUserService); return(isValid(fpAttLog)); }
public bool DownloadAttLog(FPMachine fpMachine, bool ClearAfterDownload, IFPUserService _fpUserService, IFPAttLogService _fpAttLogService) { if (fpMachine == null || fpMachine.Id <= 0) { fpMachine.Errors.Add("Generic", "FingerPrint Machine ID not found!"); } else { if (FPMachines.fpDevices[fpMachine.Id] == null) { fpMachine.IsConnected = false; // FPMachines.fpDevices.Add(FPMachineId, new FPDevice.ZKEvents()); } else { fpMachine.IsConnected = FPMachines.fpDevices[fpMachine.Id].bIsConnected; } if (fpMachine.IsConnected == false) { fpMachine.Errors.Add("Generic", "Please connect the device first!"); return(false); } bool ok = true; lock (FPMachines.fpDevices[fpMachine.Id]._locker) { FPMachines.fpDevices[fpMachine.Id].Disable(); //.axCZKEM1.DisableDeviceWithTimeOut(fpMachine.MachineNumber, FPMachines.fpDevices[fpMachine.Id].DisabledTime); //.EnableDevice(fpMachine.MachineNumber, false); // Prevent user from using the device try { //int idwErrorCode = 0; int idwEnrollNumber = 0; 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; int idwReserved = 0; int iGLCount = 0; int iIndex = 0; if (FPMachines.fpDevices[fpMachine.Id].axCZKEM1.ReadGeneralLogData(fpMachine.MachineNumber)) //read all the attendance records to the memory { while (FPMachines.fpDevices[fpMachine.Id].axCZKEM1.GetGeneralExtLogData(fpMachine.MachineNumber, ref idwEnrollNumber, ref idwVerifyMode, ref idwInOutMode, ref idwYear, ref idwMonth, ref idwDay, ref idwHour, ref idwMinute, ref idwSecond, ref idwWorkCode, ref idwReserved)) //get records from the memory { iGLCount++; var fpUser = _fpUserService.GetObjectByPIN(idwEnrollNumber); if (fpUser != null) { DateTimeKind dtk = new DateTimeKind(); var fpAttLog = new FPAttLog() { DeviceID = fpMachine.MachineNumber, FPUserId = fpUser.Id, PIN = idwEnrollNumber, PIN2 = fpUser.PIN2, VerifyMode = idwVerifyMode, InOutMode = idwInOutMode, WorkCode = idwWorkCode, Reserved = idwReserved, Time_second = new DateTime(idwYear, idwMonth, idwDay, idwHour, idwMinute, idwSecond), }; //// Convert Server local time to machine local time //DateTime curutc = fpAttLog.Time_second.ToUniversalTime().AddMinutes((double)fpMachine.TimeZoneOffset); //string winTZ = fpMachine.TimeZone.ToUpper(); // FPDevice.Convertion.IanaToWindows(fpMachine.TimeZone); //TimeZoneInfo destTZ = TimeZoneInfo.GetSystemTimeZones().Where(x => x.Id.ToUpper() == winTZ).FirstOrDefault(); //DateTime curlocaltime = TimeZoneInfo.ConvertTime(curutc, destTZ); //fpAttLog.Time_second = curlocaltime; // Add TimeZone info to the new DateTime string winTZ = fpMachine.TimeZone.ToUpper(); // FPDevice.Convertion.IanaToWindows(fpMachine.TimeZone); TimeZoneInfo destTZ = TimeZoneInfo.GetSystemTimeZones().Where(x => x.Id.ToUpper() == winTZ).FirstOrDefault(); DateTimeOffset dto = new DateTimeOffset(fpAttLog.Time_second, destTZ.GetUtcOffset(fpAttLog.Time_second.AddMinutes((double)fpMachine.TimeZoneOffset))); fpAttLog.Time_second = dto.LocalDateTime; _fpAttLogService.FindOrCreateObject(fpAttLog, _fpUserService); } iIndex++; } } int errc = FPMachines.fpDevices[fpMachine.Id].GetLastError(); if (errc != (int)FPDevice.ErrorCode.NoError && errc != (int)FPDevice.ErrorCode.DataNotFound) { fpMachine.Errors.Add("Generic", "Download Failed (Error:" + FPMachines.fpDevices[fpMachine.Id].GetErrorMsg(errc) + ")"); ok = false; } else if (ClearAfterDownload) { // Delete all attendance records on machine if (FPMachines.fpDevices[fpMachine.Id].axCZKEM1.ClearGLog(fpMachine.MachineNumber)) { FPMachines.fpDevices[fpMachine.Id].axCZKEM1.RefreshData(fpMachine.MachineNumber); //the data in the device should be refreshed } } } finally { FPMachines.fpDevices[fpMachine.Id].Enable(); //.axCZKEM1.EnableDevice(fpMachine.MachineNumber, true); } } return(ok); } return(false); }
public FPAttLogController() { _fpUserService = new FPUserService(new FPUserRepository(), new FPUserValidator()); _fpAttLogService = new FPAttLogService(new FPAttLogRepository(), new FPAttLogValidator()); _employeeService = new EmployeeService(new EmployeeRepository(), new EmployeeValidator()); }