/// <summary> /// Created by :Bhushan Dod /// Created Date :05/26/2015 /// Alert on screen on admin and manager if any employee idle for 30 min /// </summary> /// <param name="id"></param> /// <returns></returns> public dynamic EmployeeIdleStatus(long locationId, long userId) { dynamic result = null; workorderEMSEntities _workorderEMSEntities = new workorderEMSEntities(); try { objLoginLogRepository = new LoginLogRepository(); List <EmailToManagerModel> objEmailReturn = new List <EmailToManagerModel>(); var employeedata = _workorderEMSEntities.UserRegistrations.Where(x => x.UserId == userId && x.IsDeleted == false && x.UserType == 3).FirstOrDefault(); var logout = _workorderEMSEntities.LoginLogs.Where(x => x.LocationId == locationId && x.UserID == userId && x.IsActive == false).OrderByDescending(a => a.CreatedOn).FirstOrDefault(); //if (logout != null) //{ // return result; //} //else //{ result = objLoginLogRepository.IdleStatusOfEmployee(userId, locationId); if (result.Response != 0) { //send email and push notification to manager objEmailReturn = objEmailLogRepository.SendEmailToManagerForItemMissing(locationId, userId); //function return data according to location and username if (objEmailReturn.Count() > 0 && result.ResponseMessage == "Employee Idle") { foreach (var item in objEmailReturn) { var time = item.IdleTimeLimit; EmailHelper objEmailHelper = new EmailHelper(); objEmailHelper.emailid = item.ManagerEmail; objEmailHelper.ManagerName = item.ManagerName; //if (item.IdleTimeLimit.Value.ToString("tt") == "AM" && item.IdleTimeLimit.Value.ToString("hh") == "12") //{ // objEmailHelper.ProblemDesc = "00:"+item.IdleTimeLimit.Value.ToString("mm")+ " (hr:mm)"; //} //else{ // objEmailHelper.ProblemDesc = item.IdleTimeLimit.Value.ToString("hh:mm") + " (hr:mm)"; //} //"30 Min";// this is hardcoded time for all employee objEmailHelper.ProblemDesc = item.IdleTimeLimit.Value.ToString("HH:mm") + " (hr:mm)"; objEmailHelper.LocationName = item.LocationName; objEmailHelper.UserName = item.UserName; objEmailHelper.MailType = "EMPLOYEEIDLE"; objEmailHelper.SentBy = item.RequestBy; objEmailHelper.LocationID = item.LocationID; bool IsSent = objEmailHelper.SendEmailWithTemplate(); if (IsSent == true) { objEmailog = new EmailLog(); try { objEmailog.CreatedBy = item.RequestBy; objEmailog.CreatedDate = DateTime.UtcNow; objEmailog.DeletedBy = null; objEmailog.DeletedOn = null; objEmailog.LocationId = item.LocationID; objEmailog.ModifiedBy = null; objEmailog.ModifiedOn = null; objEmailog.SentBy = item.RequestBy; objEmailog.SentEmail = item.ManagerEmail; objEmailog.Subject = objEmailHelper.Subject; objEmailog.SentTo = item.ManagerUserId; objEmailLogRepository.SaveEmailLog(objEmailog); } catch (Exception) { throw; } } if (item.DeviceId != null && item.DeviceId.Trim() != "") { message = PushNotificationMessages.EmployeeIdle(item.LocationName, item.UserName); PushNotification.GCMAndroid(message, item.DeviceId, objEmailHelper); } } } } //} } catch (Exception ex) { Exception_B.Exception_B.exceptionHandel_Runtime(ex, " public dynamic EmployeeIdleStatus(string id)", "Exception while fetching employee idle status", locationId); } return(result); }