public List <TimeCardModel> GetAllRecords(string username) { List <TimeCardModel> output = new List <TimeCardModel>(); try { using (SqlConnection connection = new SqlConnection(connectionString)) { connection.Open(); SqlCommand cmd = new SqlCommand(SQL_GetAllRecord, connection); cmd.Parameters.AddWithValue("@username", username); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { TimeCardModel r = new TimeCardModel(); r.UserName = Convert.ToString(reader["user_name"]); r.Project = Convert.ToString(reader["project"]); r.StartDate = Convert.ToDateTime(reader["start_datetime"]); r.EndDate = Convert.ToString(reader["end_datetime"]); r.Notes = Convert.ToString(reader["notes"]); output.Add(r); } } }catch (SqlException ex) { throw; } return(output); }
public ActionResult ClockIn(ClockInOutModel input) { TimeCardModel m = new TimeCardModel(); m.UserName = input.Username; m.Project = input.Project; dal.SaveNewRecord(m); return(RedirectToAction("Report")); }
public ActionResult AddTimeCard(TimeCardModel model) { using (var proxy = new TimeCardServiceClient()) { proxy.AddTimeCard(model.ToDTO()); } return(Json("result: 'success'")); }
public ActionResult AddTimeCard(TimeCardModel model) { using (var proxy = new TimeCardServiceClient()) { proxy.AddTimeCard(model.ToDTO()); } return Json("result: 'success'"); }
public ActionResult ClockOut(ClockInOutModel input) { TimeCardModel m = new TimeCardModel(); m.UserName = input.Username; m.Notes = input.Note; dal.ClockOut(m); return(RedirectToAction("Report")); }
public ActionResult ClockOut(int EmployeeId) { TimeCardRepository repo = new TimeCardRepository(sessionWrapper); TimeCardModel model = repo.Get(EmployeeId); new TimeCardRepository(sessionWrapper).Save(model); JsonResult result = new JsonResult(); result.Data = model; return(result); }
public void TestGet_WhenUserHasNoRecord_ReturnNewObject() { paramSet1.Add("@EmployeeId", 1); List <object> resultSet = new List <object>(); broker.Query(TimeCardRepository.TIMECARD_GETFOR_EMPLOYEE).CalledWithInput(paramSet1).Produces(resultSet); TimeCardModel model = repo.Get(1); Assert.AreEqual(1, model.EmployeeId); Assert.IsNull(model.In); Assert.IsNull(model.Out); }
public ActionResult ClockIn(int EmployeeId) { TimeCardModel model = new TimeCardModel(); model.EmployeeId = EmployeeId; model.In = DateTime.Now; model.Out = null; new TimeCardRepository(sessionWrapper).Save(model); JsonResult result = new JsonResult(); result.Data = model; return(result); }
public void TestGet_WhenUserHasFilledRecord_ReturnNewObject() { paramSet1.Add("@EmployeeId", 1); List <TimecardData> resultSet = new List <TimecardData>(); TimecardData data = new TimecardData(); data.Emp_Id = 1; data.Id = 1; data.In = DateTime.Now.Subtract(new TimeSpan(4, 0, 0)); data.Out = DateTime.Now.Subtract(new TimeSpan(3, 0, 0)); resultSet.Add(data); broker.Query(TimeCardRepository.TIMECARD_GETFOR_EMPLOYEE).CalledWithInput(paramSet1).Produces(resultSet); TimeCardModel model = repo.Get(1); Assert.AreEqual(1, model.EmployeeId); Assert.IsNull(model.In); Assert.IsNull(model.Out); }
public bool ClockOut(TimeCardModel r) { try { using (SqlConnection connection = new SqlConnection(connectionString)) { connection.Open(); SqlCommand cmd = new SqlCommand(SQL_ClockOut, connection); cmd.Parameters.AddWithValue("@username", r.UserName); cmd.Parameters.AddWithValue("@enddate", DateTime.Now); cmd.Parameters.AddWithValue("@notes", r.Notes); int rowsAffected = cmd.ExecuteNonQuery(); return(rowsAffected > 0); } }catch (SqlException ex) { throw; } }
public bool SaveNewRecord(TimeCardModel r) { try { using (SqlConnection connection = new SqlConnection(connectionString)) { connection.Open(); SqlCommand cmd = new SqlCommand(SQL_InsertTimeIn, connection); cmd.Parameters.AddWithValue("@username", r.UserName); cmd.Parameters.AddWithValue("@startdate", DateTime.Now); cmd.Parameters.AddWithValue("@project", r.Project); int rowsAffected = cmd.ExecuteNonQuery(); return(rowsAffected > 0); } }catch (SqlException ex) { throw; } }
public static List <TimeCardModel> MapInfoToPunchType(this IEnumerable <GeotabInfoModel> models) { List <TimeCardModel> timeCards = new List <TimeCardModel>(); foreach (var model in models) { foreach (var log in model.Logs) { string punchType = string.Empty; switch (log.Status) { case DutyStatusLogType.ON: case DutyStatusLogType.D: case DutyStatusLogType.YM: punchType = "ID"; break; case DutyStatusLogType.OFF: case DutyStatusLogType.SB: case DutyStatusLogType.PC: case DutyStatusLogType.WT: punchType = "OD"; break; } DateTime dateWithoutSeconds = log.DateTime.Value.AddSeconds(-log.DateTime.Value.Second); TimeCardModel timeCard = new TimeCardModel { EmployeeNumber = model.EmployeeNumber, PunchDateTimeInUnix = dateWithoutSeconds.DateTimetoUnixTimeStamp(), PunchType = punchType }; timeCards.Add(timeCard); } } return(timeCards); }
public ActionResult Login() { TimeCardModel model = new TimeCardModel(); return(View("Login", model)); }
public IEnumerable <TimeCardModel> LastRecordedPunches(GeotabInfoModel driver) { Log.MethodStart(); List <TimeCardModel> driverTimePunches = new List <TimeCardModel>(); LastRecordedTime lastTime = new LastRecordedTime(); employeeNumber = driver.EmployeeNumber; DateTime tempDate = lastTime.ReadLastRunFile().AddDays(-14); //Log.Info($"Getting paycom punches from {tempDate} for {employeeNumber}..."); long startDate = DateTimeExtensions.DateTimetoUnixTimeStamp(tempDate); string url = string.Format(punchAuditWithDate, employeeNumber, startDate); try { using (HttpClient client = new HttpClient()) { client.BaseAddress = new Uri(baseUrl); client.DefaultRequestHeaders.Add("Authorization", AUTH_HEADER); HttpResponseMessage result = client.GetAsync(url).Result; if (result.StatusCode != HttpStatusCode.OK && result.StatusCode != HttpStatusCode.PartialContent) { return(null); } string resultData = result.Content.ReadAsStringAsync().Result; PunchAuditResponseModel data = JsonConvert.DeserializeObject <PunchAuditResponseModel>(resultData); if (data.errors.FirstOrDefault() == "No Content Found") { Log.Info($"No recent punches for {employeeNumber} since {tempDate}..."); return(null); } ActiveResponseModel[] punchData = data.data.Active; foreach (var activePunch in punchData) { TimeCardModel currentTimeCard = new TimeCardModel(); //var change = TimeSpan.Parse(activePunch.punchtime.TrimEnd(new char[] { ' ', 'A', 'M', 'P' })); DateTime temporaryDate = DateTime.Parse($"{activePunch.punchdate} {activePunch.punchtime}"); currentTimeCard.FirstName = driver.FirstName; currentTimeCard.LastName = driver.LastName; currentTimeCard.EmployeeNumber = driver.EmployeeNumber; currentTimeCard.PunchDateTimeInUnix = TimeZoneConverter.ConvertToUtcFromTimeZone(driver.Timezone, temporaryDate); //currentTimeCard.PunchDateTimeInUnix = DateTime.Parse($"{activePunch.punchdate} {activePunch.punchtime}").ConvertToUtcFromEastern().DateTimetoUnixTimeStamp(); currentTimeCard.PunchDate = $"{activePunch.punchdate} {activePunch.punchtime}"; currentTimeCard.PunchType = activePunch.punchtype; driverTimePunches.Add(currentTimeCard); } //Log.Info($"Last punch for employee {employeeNumber} : {resultData}"); //driverTimePunches = punchData.Select(x => new TimeCardModel //{ // EmployeeNumber = driver.EmployeeNumber, // PunchTime = Convert.ToInt64(x.punchtime.TrimEnd(new char[] { ' ', 'A', 'M', 'P' })), // PunchDate = x.punchdate, // PunchType = x.punchtype //}).ToList(); } return(driverTimePunches.OrderBy(x => x.PunchDate).OrderBy(y => y.PunchTime)); } catch (Exception ex) { Log.Error(ex); Log.Info(ex); throw; } }
private List <TimeCardModel> CreateTimeCard(List <GeotabInfoModel> listOfGeotabInfo) { Log.MethodStart(); List <TimeCardModel> timeCards = new List <TimeCardModel>(); foreach (GeotabInfoModel record in listOfGeotabInfo) { bool previousLogIsOnDuty = false; bool previousLogIsOffDuty = false; GeotabInfoModel oldPunch = paycomCalls.IdentifyLastPunch(record); //var auditLastPunch = paycomCalls.AuditIdentifyLastPunch(record); // testing with punchaudit url if (oldPunch.PunchType == "ID") { previousLogIsOnDuty = true; previousLogIsOffDuty = false; } else if (oldPunch.PunchType == "OD") { previousLogIsOnDuty = false; previousLogIsOffDuty = true; } record.Logs = record.Logs.OrderBy(l => l.DateTime).ToList(); List <DutyStatusLog> logs = record.Logs; for (int i = 0; i < record.Logs.Count; i++) { TimeCardModel timeCard = new TimeCardModel(); timeCard.FirstName = record.FirstName; timeCard.LastName = record.LastName; timeCard.EmployeeNumber = record.EmployeeNumber; timeCard.Timezone = record.Timezone; timeCard.ClockType = "S"; timeCard.EntryType = 1; switch (logs[i].Status) { case DutyStatusLogType.D: case DutyStatusLogType.ON: case DutyStatusLogType.YM: if (previousLogIsOnDuty) { continue; } else { timeCard.PunchType = "ID"; timeCard.PunchTime = logs[i].DateTime.Value.DateTimetoUnixTimeStamp(); timeCards.Add(timeCard); } previousLogIsOnDuty = true; previousLogIsOffDuty = false; break; case DutyStatusLogType.OFF: case DutyStatusLogType.PC: case DutyStatusLogType.SB: case DutyStatusLogType.WT: if (previousLogIsOffDuty) { continue; } else { timeCard.PunchType = "OD"; timeCard.PunchTime = logs[i].DateTime.Value.DateTimetoUnixTimeStamp(); timeCards.Add(timeCard); } previousLogIsOffDuty = true; previousLogIsOnDuty = false; break; } } } ; Log.MethodEnd(); return(timeCards); }
public ActionResult Search() { TimeCardModel m = new TimeCardModel(); return(View("Search", m)); }