public JsonResult GetAllStoreList() { EmployeeTrackerModel employeeTrackerModel = new EmployeeTrackerModel(); // ArrayList storeList = employeeTrackerModel.GetStoreList(); ArrayList storeList = ValidationUtility.GetActiveStoreList(false); return Json(storeList, JsonRequestBehavior.AllowGet); }
public JsonResult GetProductivityList(string sId, string selectDate) { EmployeeTrackerModel employeeTrackerModel = new EmployeeTrackerModel(); ProductivityModel productivityModel = new ProductivityModel(); ArrayList productivityList = new ArrayList(); ArrayList list = new ArrayList(); int storeId = ValidationUtility.ToInteger(sId); DateTime formatedDate = DateTime.Now; if (!ValidationUtility.IsNull(selectDate)) { formatedDate = ValidationUtility.ToDate(selectDate); } ArrayList storeList = null; if (storeId == 0) { UserContext cont = (UserContext)Session["UserContext"]; if (!ValidationUtility.IsNull(cont) && ValidationUtility.IsEqual(cont.Role, "Corporate")) { storeList = ValidationUtility.GetCorporateUserAssignActiveStore(cont.Id, true); } else { storeList = ValidationUtility.GetActiveStoreList(true); } // storeList = ValidationUtility.GetStoreList(true); } else { ArrayList tempList = ValidationUtility.GetActiveStoreList(true); foreach (StoreDTO storeDTO in tempList) { if (storeId == storeDTO.Id) { storeList = new ArrayList(); storeList.Add(storeDTO); break; } } } ArrayList weeKInfoList = ValidationUtility.GetWeekStartandEndInfo(formatedDate); DateTime currentWeekStartDate = ValidationUtility.GetActualWeekStartDate(DateTime.Now); DateTime currentWeekEndDate = currentWeekStartDate.AddDays(6); productivityList.Add(weeKInfoList); //Return when selected date > current week end date if (formatedDate.Date > currentWeekEndDate.Date) { productivityList.Add(list); return Json(productivityList, JsonRequestBehavior.AllowGet); } DateTime WeekStartDate = ValidationUtility.GetActualWeekStartDate(formatedDate); employeeTrackerModel.AddEmployeeRecord(formatedDate, storeList); // if (currentWeekStartDate.Date >= formatedDate.Date && formatedDate.Date <= currentWeekEndDate.Date) if (formatedDate.Date >= currentWeekStartDate.Date && formatedDate.Date <= currentWeekEndDate.Date) { foreach (StoreDTO dto in storeList) { if (DateTime.Now.Date.Equals(formatedDate.Date)) { ArrayList employeeList = employeeTrackerModel.GetEmployeeList(dto.Id); foreach (EmployeeInfoDTO empDTO in employeeList) { employeeTrackerModel.UpdateCurrentWeekClockingTime(empDTO.EmpId, dto.Id, DateTime.Now, dto.ConnectionString); } } } } foreach (StoreDTO dto in storeList) { ArrayList employeeList = productivityModel.GetEmployeeList(dto.Id); foreach (EmployeeInfoDTO empDTO in employeeList) { empDTO.EmployeeTrackerDTO = employeeTrackerModel.GetTrackingList(empDTO.Id, WeekStartDate); foreach (EmployeeTrackerDTO empTrakDTO in empDTO.EmployeeTrackerDTO) { empTrakDTO.EmployeeClockingDTO = productivityModel.GetClockingListPerDay(empDTO.Id, empTrakDTO.BusinessDate); } list.Add(empDTO); } } productivityList.Add(list); return Json(productivityList, JsonRequestBehavior.AllowGet); }
public JsonResult UpdateSheduleTime(string tId, string sIn, string sOut, string bDate) { ResponseDTO dto = null; int emplTrackerId = ValidationUtility.ToInteger(tId); EmployeeTrackerModel employeeTrackerModel = new EmployeeTrackerModel(); DateTime formatedDate = ValidationUtility.ToDate(bDate); int inHour = 0; int inSecond = 0; if (sIn.Contains(":")) { string[] str = sIn.Split(':'); if (sIn.ToLower().Contains("pm")) { inHour = ValidationUtility.ToInteger(str[0]) + 12; inSecond = ValidationUtility.ToInteger(str[1]); } else { inHour = ValidationUtility.ToInteger(str[0]); inSecond = ValidationUtility.ToInteger(str[1]); } } DateTime schedulInTime = new DateTime(formatedDate.Year, formatedDate.Month, formatedDate.Day, inHour, inSecond, 0); int outHour = 0; int outSecond = 0; string[] str1 = sOut.Split(':'); if (sOut.Contains(":")) { if (sOut.ToLower().Contains("pm")) { outHour = ValidationUtility.ToInteger(str1[0]) + 12; outSecond = ValidationUtility.ToInteger(str1[1]); } else { outHour = ValidationUtility.ToInteger(str1[0]); outSecond = ValidationUtility.ToInteger(str1[1]); } } DateTime schedulOutTime = new DateTime(formatedDate.Year, formatedDate.Month, formatedDate.Day, outHour, outSecond, 0); if (schedulInTime.TimeOfDay >= schedulOutTime.TimeOfDay) { dto = new ResponseDTO { Error = "Error", Message = "Schedule In Time will not be greater then ScheduleOut Time Please Enter Correct Schedule" }; } else { dto = new ResponseDTO { Error = "Success", Message = "Schedule Updated successfully" }; employeeTrackerModel.UpdateSheduleDateTime(emplTrackerId, schedulInTime, schedulOutTime, formatedDate); } // return Json(dto, JsonRequestBehavior.AllowGet); // employeeTrackerModel. }
public void UpdateEmployeeRecord() { log.Debug(" Call update payroll method "); try { DateTime businessDate = DateTime.Now.AddDays(-1); // DateTime businessDate = new DateTime(2013,10,23); // ArrayList storeList = ValidationUtility.GetStoreList(true); ArrayList storeList = ValidationUtility.GetActiveStoreList(true); foreach (StoreDTO storeDTO in storeList) { EmployeeTrackerModel employeeTrackerModel = new EmployeeTrackerModel(); // From server database ArrayList empList = employeeTrackerModel.GetEmployeeInfo(storeDTO.ConnectionString); foreach (EmployeeInfoDTO employeeInfoDTO in empList) { // If employee Not exsist then add employee (for new Employee) if (!IsEmployeExsist(employeeInfoDTO, storeDTO.Id)) { employeeTrackerModel.AddEmpInfo(storeDTO.Id, employeeInfoDTO); EmployeeInfoDTO newEmployeeInfoDTO = GetEmployeeInfo(storeDTO.Id, employeeInfoDTO.EmpId); AddNewEmployeeInTracking(newEmployeeInfoDTO.Id, businessDate); // TODO Add Employee Traker and Employee clocking } // For exsist Employee else { //DateTime weekStartDate = ValidationUtility.GetActualWeekStartDate(businessDate); //if (weekStartDate.Date.Equals(businessDate.Date) && !IsWeekEmployeeTrakingExsist(employeeInfoDTO.EmpId, storeDTO.Id, businessDate)) //{ // EmployeeInfoDTO newEmployeeInfoDTO = GetEmployeeInfo(storeDTO.Id, employeeInfoDTO.EmpId); // AddNewEmployeeInTracking(newEmployeeInfoDTO.Id, businessDate); // EmployeeTrackerDTO employeeTrakingDTO = GetEmployeeTracking(employeeInfoDTO.EmpId, storeDTO.Id, businessDate); // if (employeeTrakingDTO != null) // { // ArrayList clockingList = GetEmployeClocking(employeeInfoDTO.EmpId, businessDate, storeDTO.ConnectionString); // foreach (EmployeeClockingDTO employeeClockingDTO in clockingList) // { // employeeTrackerModel.AddEmpClockingInfo(employeeTrakingDTO.Id, employeeClockingDTO); // } // // Update Total time worked // if (!ValidationUtility.IsNull(clockingList) && clockingList.Count > 0) // { // employeeTrackerModel.UpdateTotalTimeWorked(employeeTrakingDTO, clockingList); // } // } //} EmployeeTrackerDTO employeeTrakingDTO = GetEmployeeTracking(employeeInfoDTO.EmpId, storeDTO.Id, businessDate); if (employeeTrakingDTO != null) { ArrayList clockingList = GetEmployeClocking(employeeInfoDTO.EmpId, businessDate, storeDTO.ConnectionString); //For delete previous clocking record employeeTrackerModel.DeleteEmpClokingInfo(employeeTrakingDTO.Id); foreach (EmployeeClockingDTO employeeClockingDTO in clockingList) { employeeTrackerModel.AddEmpClockingInfo(employeeTrakingDTO.Id, employeeClockingDTO); } // Update Total time worked if (!ValidationUtility.IsNull(clockingList) && clockingList.Count > 0) { employeeTrackerModel.UpdateTotalTimeWorked(employeeTrakingDTO, clockingList); } } DateTime newWeekStartDate = ValidationUtility.GetActualWeekStartDate(DateTime.Now); if (newWeekStartDate.Date.Equals(DateTime.Now.Date) && !IsWeekEmployeeTrakingExsist(employeeInfoDTO.EmpId, storeDTO.Id, newWeekStartDate)) { EmployeeInfoDTO newEmployeeInfoDTO = GetEmployeeInfo(storeDTO.Id, employeeInfoDTO.EmpId); AddNewEmployeeInTracking(newEmployeeInfoDTO.Id, newWeekStartDate); //EmployeeTrackerDTO employeeTrakingNewDTO = GetEmployeeTracking(employeeInfoDTO.EmpId, storeDTO.Id, newWeekStartDate); //if (employeeTrakingNewDTO != null) //{ // ArrayList clockingList = GetEmployeClocking(employeeInfoDTO.EmpId, businessDate, storeDTO.ConnectionString); // foreach (EmployeeClockingDTO employeeClockingDTO in clockingList) // { // employeeTrackerModel.AddEmpClockingInfo(employeeTrakingNewDTO.Id, employeeClockingDTO); // } // // Update Total time worked // if (!ValidationUtility.IsNull(clockingList) && clockingList.Count > 0) // { // employeeTrackerModel.UpdateTotalTimeWorked(employeeTrakingNewDTO, clockingList); // } //} } } } } } catch (Exception ex) { log.Error(" Exception in UpdateEmployeeRecord Method ", ex); } }