/* XENDMV- EXECUTE END OF MOVE FUNCTIONS. */ public void xendmv_(bool flag) { bool f; if (!(flag)) { MessageHandler.rspeak_(this, 341); } /* !DEFAULT REMARK. */ if (this.Hack.thfact) { actors.thiefd_(this); } /* !THIEF DEMON. */ if (this.ParserVectors.prswon) { DemonHandler.fightd_(this); } /* !FIGHT DEMON. */ if (this.Hack.swdact) { DemonHandler.swordd_(this); } /* !SWORD DEMON. */ if (this.ParserVectors.prswon) { f = ClockEvents.clockd_(this); } /* !CLOCK DEMON. */ if (this.ParserVectors.prswon) { f = xvehic_(2); } /* !VEHICLE READOUT. */ }
///<summary>When the date is changed on the calendar control we initialize and start our animation for the daily metrics and calculate the user's clock events for the given week selected. ///This method also grabs the user's schedule and populates the calendar grid.</summary> private void OnCalendarDateChanged() { labelArrived.Foreground = Brushes.Gray; DailyMetrics.Visibility = Visibility.Visible; DateTime selectedDate = (DateTime)dailyCalendar.SelectedDate; //starts animation and sets the values of the fields being animated DoubleAnimation da = new DoubleAnimation(0, AnimationRow.ActualHeight, TimeSpan.FromMilliseconds(200)); DailyMetrics.BeginAnimation(Grid.HeightProperty, da); DataTable dt = ClockEvents.GetTimeClockedInOnDate(selectedEng.EmployeeNum, selectedDate); string arrivedAt = ""; string leftAt = ""; if (dt.Rows.Count != 0) { arrivedAt = string.Format("{0:hh:mm:ss tt}", dt.Rows[0][0]); leftAt = string.Format("{0:hh:mm:ss tt}", dt.Rows[0][1]); } //reflect the change in selected date in our date range DateTime weekStart = selectedDate.AddDays(-(int)selectedDate.DayOfWeek); DateTime weekEnd = selectedDate.AddDays(7 - ((int)selectedDate.DayOfWeek)); string dateRange = weekStart.ToShortDateString() + "-" + weekEnd.ToShortDateString(); ClockEventsInRange(weekStart, weekEnd); FillEngineerCalendar(weekStart, weekEnd); DateForSched.Content = dateRange; ClearDailyLabels(); //TODO: Fix the clock in but not clocked out bug labelArrived.Content = arrivedAt; labelLeftAt.Content = leftAt; if (dt.Rows.Count == 0) { labelArrived.Content = "--"; labelLeftAt.Content = "--"; labelHoursWorked.Content = "--"; return; } TimeSpan timeWorked = (DateTime)dt.Rows[0][1] - (DateTime)dt.Rows[0][0]; labelHoursWorked.Content = timeWorked.ToString(); //check to see if the clock in time is past 10 minutes and mark red to indicate tardiness List <Schedule> timeScheduled = Schedules.GetSchedListForDateRange(selectedEng.EmployeeNum, (DateTime)dailyCalendar.SelectedDate, (DateTime)dailyCalendar.SelectedDate); if (timeScheduled.Count == 0) //If the employee is not scheduled they can't be tardy. { return; } //Find the difference between clock in and the employee's scheduled start time TimeSpan duration = TimeSpan.Parse(((DateTime)dt.Rows[0][0]).ToString("HH:mm")).Subtract(timeScheduled[0].StartTime); if (duration.Minutes > 10) { labelArrived.Foreground = Brushes.Red; } }
///<summary>This is the load method for the class. It initializes the engineer tiles by creating a model and binding it to the ItemsControl template in the xaml code.</summary> public JobManagerDashboardTiles() { InitializeComponent(); //labelActiveJobs.Foreground= Signalods.SubscribeSignalProcessor(this); GridToolbar.Visibility = Visibility.Hidden; EngSpecificInfo.Visibility = Visibility.Collapsed; Jobs.FillInMemoryLists(_listJobsAll); _engInfoList.Add( new EngInformation { EngName = "Total Unfinished Quote Jobs: " + JobQuotes.GetUnfinishedJobQuotes().Count, EngClockStatus = "Total Unfinished Quote: $" + JobQuotes.GetUnfinishedJobQuotes().Sum(x => PIn.Double(x.Amount)), EngWorkStatus = "Total Unfinished Jobs: " + _listJobsAll.Where(x => x.PhaseCur != JobPhase.Complete && x.Priority != Defs.GetDefsForCategory(DefCat.JobPriorities, true).FirstOrDefault(y => y.ItemValue.Contains("OnHold")).DefNum).ToList().Count, StatField1 = "Total Jobs being worked on: " + _listJobsAll.Where(x => x.OwnerAction == JobAction.WriteCode).ToList().Count }); //list of jobs in WriteCode status List <Job> listWriteCodeJobs = _listJobsAll.Where(x => x.OwnerAction == JobAction.WriteCode && x.Priority != Defs.GetDefsForCategory(DefCat.JobPriorities, true).FirstOrDefault(y => y.ItemValue.Contains("OnHold")).DefNum).ToList(); foreach (Userod user in Userods.GetUsersByJobRole(JobPerm.Engineer, false)) { if (!_listActualEngineers.Contains(user.UserName)) { continue; } List <TextBlock> jobTitles = new List <TextBlock>(); //get only write code jobs List <string> listEngJobs = listWriteCodeJobs.Where(x => x.UserNumEngineer == user.UserNum).Select(x => x.Title).ToList(); foreach (string j in listEngJobs) { //TODO: Template this in xaml and pass in the object for the template to autogen, save for after initial working commit. TextBlock tb = new TextBlock(); tb.Text = j; tb.TextWrapping = TextWrapping.WrapWithOverflow; jobTitles.Add(tb); } string needsWork = ""; int devHours = 0; //listWriteCodeJobs.Where(x => x.UserNumEngineer==user.UserNum).Sum(x => x.MinutesEstimate); if (devHours < 20) { needsWork = "Needs Work"; } else { needsWork = "~" + devHours.ToString() + " Dev Hours"; } _engInfoList.Add(new EngInformation { EngName = user.UserName, EngClockStatus = ClockEvents.GetLastEvent(user.EmployeeNum).ClockStatus.ToString(), EngWorkStatus = needsWork, EngJobs = jobTitles }); } EngTiles.ItemsSource = _engInfoList; }
public static long InsertWorkPeriod(long emp, DateTime start, DateTime stop) { ClockEvent ce = new ClockEvent(); ce.ClockStatus = TimeClockStatus.Home; ce.EmployeeNum = emp; ce.TimeDisplayed1 = start; ce.TimeEntered1 = start; ce.TimeDisplayed2 = stop; ce.TimeEntered2 = stop; ce.ClockEventNum = ClockEvents.Insert(ce); ClockEvents.Update(ce); //Updates TimeDisplayed1 because it defaults to now(). return(ce.ClockEventNum); }
public static long InsertBreak(long emp, DateTime start, int minutes) { ClockEvent ce = new ClockEvent(); ce.ClockStatus = TimeClockStatus.Break; ce.EmployeeNum = emp; ce.TimeDisplayed1 = start; ce.TimeEntered1 = start; ce.TimeDisplayed2 = start.AddMinutes(minutes); ce.TimeEntered2 = start.AddMinutes(minutes); ce.ClockEventNum = ClockEvents.Insert(ce); ClockEvents.Update(ce); //Updates TimeDisplayed1 because it defaults to now(). return(ce.ClockEventNum); }
///<summary>When the date is changed on the calendar control we initialize and start our animation for the daily metrics and calculate the user's clock events for the given week selected. ///This method also grabs the user's schedule and populates the calendar grid.</summary> private void OnCalendarDateChanged() { labelArrived.Foreground = Brushes.Gray; DailyMetrics.Visibility = Visibility.Visible; DateTime selectedDate = (DateTime)dailyCalendar.SelectedDate; //starts animation and sets the values of the fields being animated DoubleAnimation da = new DoubleAnimation(0, AnimationRow.ActualHeight, TimeSpan.FromMilliseconds(200)); DailyMetrics.BeginAnimation(Grid.HeightProperty, da); DataTable dt = ClockEvents.GetTimeClockedInOnDate(selectedEng.EmployeeNum, selectedDate); //reflect the change in selected date in our date range string weekStart = selectedDate.AddDays(-(int)selectedDate.DayOfWeek).ToShortDateString(); string weekEnd = selectedDate.AddDays(7 - ((int)selectedDate.DayOfWeek)).ToShortDateString(); string dateRange = weekStart + "-" + weekEnd; ClockEventsInRange(weekStart, weekEnd); FillEngineerCalendar(weekStart, weekEnd); DateForSched.Content = dateRange; ClearDailyLabels(); if (dt.Rows.Count == 0) { labelArrived.Content = "--"; labelLeftAt.Content = "--"; labelHoursWorked.Content = "--"; return; } labelArrived.Content = dt.Rows[0][0].ToString(); labelLeftAt.Content = dt.Rows[0][1].ToString(); labelHoursWorked.Content = dt.Rows[0][2].ToString(); //check to see if the clock in time is past 10 minutes and mark red to indicate tardiness string[] clockedInAt = dt.Rows[0][0].ToString().Split(null); //This split removes the 'AM' string at the end of the clock in time if (clockedInAt[0] == null) { return; } List <Schedule> timeScheduled = Schedules.GetSchedListForDateRange(selectedEng.EmployeeNum, dailyCalendar.SelectedDate.ToString(), dailyCalendar.SelectedDate.ToString()); if (timeScheduled.Count == 0) //If the employee is not scheduled they can't be tardy. { return; } TimeSpan duration = TimeSpan.Parse(clockedInAt[0]).Subtract(TimeSpan.Parse(timeScheduled.First().StartTime.ToString())); if (duration.Minutes > 10) { labelArrived.Foreground = Brushes.Red; } }
///<summary>Hits the DB for the clockevents in a given range for the selected engineer tile and databinds to the datagrid in the view.</summary> public void ClockEventsInRange(DateTime fromDate, DateTime toDate) { labelClockEventsWeek.Content = "Clock Events for the Week"; ClockEventsWeek.Visibility = Visibility.Visible; DataTable tableClockEvents = ClockEvents.GetEmployeeClockEventsForDateRange(selectedEng.EmployeeNum, fromDate, toDate); if (tableClockEvents.Rows.Count == 0) { labelClockEventsWeek.Content = "No Clock Events for the Week"; ClockEventsWeek.Visibility = Visibility.Hidden; } else { ClockEventsWeek.ItemsSource = tableClockEvents.AsDataView(); } }
public static long InsertWorkPeriod(long emp, DateTime start, DateTime stop, long clinicNum = 0, double adjustHours = 0) { ClockEvent ce = new ClockEvent(); ce.ClockStatus = TimeClockStatus.Home; ce.EmployeeNum = emp; ce.TimeDisplayed1 = start; ce.TimeEntered1 = start; ce.TimeDisplayed2 = stop; ce.TimeEntered2 = stop; ce.ClinicNum = clinicNum; ce.AdjustAuto = TimeSpan.FromHours(-adjustHours); ce.ClockEventNum = ClockEvents.Insert(ce); ClockEvents.Update(ce); //Updates TimeDisplayed1 because it defaults to now(). return(ce.ClockEventNum); }
public void TimeCardRules_CalculateWeeklyOvertime_CalculationWithManualOvertime() { string suffix = "67"; DateTime startDate = DateTime.Parse("2016-03-14"); Employee emp = EmployeeT.CreateEmployee(suffix); PayPeriod payP1 = PayPeriodT.CreateTwoWeekPayPeriodIfNotExists(startDate); PayPeriods.RefreshCache(); Prefs.UpdateInt(PrefName.TimeCardOvertimeFirstDayOfWeek, 0); TimeCardRules.RefreshCache(); //Each of these are 11 hour days. Should have 4 hours of OT with clinic 3 in the second pay period and 11 hours for clinic 4. //Week 1 - 40.13 (Note: These appear as they should after CalculateDaily is run.) long clockEvent1 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(0).AddHours(6), startDate.AddDays(0).AddHours(6 + 8.06), 0); //Mon long clockEvent2 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(1).AddHours(6), startDate.AddDays(1).AddHours(6 + 8), 0); //Tue long clockEvent3 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(2).AddHours(6), startDate.AddDays(2).AddHours(6 + 8.08), 0); //Wed long clockEvent4 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(3).AddHours(6), startDate.AddDays(3).AddHours(6 + 8), 0, 0.02); //Thurs long clockEvent5 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(4).AddHours(6), startDate.AddDays(4).AddHours(6 + 8.01), 0); //Fri //SATURDAY - 4.1 HRS OF OVERTIME ClockEvent ce = new ClockEvent(); ce.ClinicNum = 0; ce.ClockStatus = TimeClockStatus.Home; ce.EmployeeNum = emp.EmployeeNum; ce.OTimeHours = TimeSpan.FromHours(4.1); ce.TimeDisplayed1 = new DateTime(startDate.Year, startDate.Month, startDate.AddDays(5).Day, 6, 54, 0); ce.TimeDisplayed2 = new DateTime(startDate.Year, startDate.Month, startDate.AddDays(5).Day, 11, 0, 0); ce.TimeEntered1 = ce.TimeDisplayed1; ce.TimeEntered2 = ce.TimeDisplayed2; ce.ClockEventNum = ClockEvents.Insert(ce); ClockEvents.Update(ce); //Week 2 - 41.06 long clockEvent6 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(7).AddHours(6), startDate.AddDays(7).AddHours(6 + 8.02), 0); //Mon long clockEvent7 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(8).AddHours(6), startDate.AddDays(8).AddHours(6 + 8), 0); //Tue long clockEvent8 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(9).AddHours(6), startDate.AddDays(9).AddHours(6 + 8), 0); //Wed long clockEvent9 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(10).AddHours(6), startDate.AddDays(10).AddHours(6 + 9.04), 0); //Thurs long clockEvent10 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(11).AddHours(6), startDate.AddDays(11).AddHours(6 + 8), 0); //Fri TimeCardRules.CalculateWeeklyOvertime(emp, payP1.DateStart, payP1.DateStop); //Validate List <TimeAdjust> listAdjusts = TimeAdjusts.GetValidList(emp.EmployeeNum, startDate, startDate.AddDays(28)).OrderBy(x => x.OTimeHours).ToList(); Assert.AreEqual(2, listAdjusts.Count); Assert.AreEqual(TimeSpan.FromHours(-0.13), listAdjusts[0].RegHours); Assert.AreEqual(TimeSpan.FromHours(0.13), listAdjusts[0].OTimeHours); Assert.AreEqual(TimeSpan.FromHours(-1.06), listAdjusts[1].RegHours); Assert.AreEqual(TimeSpan.FromHours(1.06), listAdjusts[1].OTimeHours); }
public void TimeCardRules_CalculateDailyOvertime_ForHoursWorkedBeforeACertainTime() { string suffix = "33"; DateTime startDate = DateTime.Parse("2001-01-01"); Employee emp = EmployeeT.CreateEmployee(suffix); PayPeriod payP1 = PayPeriodT.CreateTwoWeekPayPeriodIfNotExists(startDate); PayPeriods.RefreshCache(); Prefs.UpdateInt(PrefName.TimeCardOvertimeFirstDayOfWeek, 0); Prefs.UpdateBool(PrefName.TimeCardsMakesAdjustmentsForOverBreaks, true); TimeCardRuleT.CreateAMTimeRule(emp.EmployeeNum, TimeSpan.FromHours(7.5)); TimeCardRules.RefreshCache(); long clockEvent1 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddHours(6), startDate.AddHours(16), 0); ClockEventT.InsertBreak(emp.EmployeeNum, startDate.AddHours(11), 40, 0); CalculateDailyOvertime(emp, payP1.DateStart, payP1.DateStop); //Validate Assert.AreEqual(TimeSpan.FromMinutes(-10), ClockEvents.GetOne(clockEvent1).AdjustAuto); Assert.AreEqual(TimeSpan.FromMinutes(90), ClockEvents.GetOne(clockEvent1).Rate2Auto); }
public void TimeCardRules_CalculateDailyOvertime_WhileEmployeeClockedInTodayDuringPayPeriod() { DateTime startDate = DateTime.Now.Date.AddDays(-1); Employee emp = EmployeeT.CreateEmployee("CalculateDailyWhileEmployeeClockedInDuringPayPeriod"); PayPeriod payP1 = PayPeriodT.CreateTwoWeekPayPeriodIfNotExists(startDate); PayPeriods.RefreshCache(); Prefs.UpdateInt(PrefName.TimeCardOvertimeFirstDayOfWeek, 0); Prefs.UpdateBool(PrefName.TimeCardsMakesAdjustmentsForOverBreaks, true); Prefs.RefreshCache(); TimeCardRules.RefreshCache(); //10 hour day with 45 minute break long clockEvent1 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddHours(8), startDate.AddHours(18)); long break1 = ClockEventT.InsertBreak(emp.EmployeeNum, startDate.AddHours(12), 45); //Next day clock in, but have no clock out event yet. long clockEvent2 = ClockEventT.InsertWorkPeriod(emp.EmployeeNum, startDate.AddDays(1).AddHours(8), DateTime.MinValue); CalculateDailyOvertime(emp, payP1.DateStart, payP1.DateStop); //Ensure that the 15 minutes was subtracted from the shift. Assert.AreEqual(TimeSpan.FromMinutes(-15), ClockEvents.GetOne(clockEvent1).AdjustAuto); }