private List <MakeOrder> GetPredictions() { var predictions = new List <MakeOrder>(); foreach (var master in StaticInventoryTracker.ProductMasterList) //.Where(p => p.MadeIn.Equals("Coating"))) { double pieces = master.PiecesPerUnit * master.TargetSupply; StaticFunctions.OutputDebugLine("Creating new prediction for " + master); MakeOrder newOrder = new MakeOrder(master.MasterID, pieces) { DueDay = CurrentDay }; // assume the current day is the due date unless we have inventory data (Could have no inventory) // forecast out when the order should be due var inv = CurrentInventory.FirstOrDefault(i => i.MasterID == master.MasterID); if (inv != null) { double currentInv = inv.Units; double usedPerDay = GetAvgUnitsPerDay(master) * 30; int daysTillOut = (int)Math.Floor(currentInv / usedPerDay); newOrder.DueDay = CurrentDay.AddDays(daysTillOut); StaticFunctions.OutputDebugLine("Found inventory of " + currentInv + " for prediction " + master + " predicted to run out in " + daysTillOut + " days"); } predictions.Add(newOrder); } return(predictions); }
void BindDdlDays(List <Day> days) { rdoDays.DataSource = days; rdoDays.DataTextField = "DayTitle"; rdoDays.DataValueField = "DayNumber"; rdoDays.DataBind(); foreach (ListItem item in rdoDays.Items) { item.Attributes.Add("class", "mealDay" + item.Value); } hccCartItemCalendar cartCal = hccCartItemCalendar.GetBy(CurrentCartItem.CartItemID, CurrentCalendarId); CurrentDaysWithAllergens(cartCal.CartCalendarID).ForEach(delegate(int a) { ListItem item = rdoDays.Items.FindByValue(a.ToString()); if (item != null) { item.Attributes["class"] += " redFont"; } }); if (CurrentDay != 0) { rdoDays.SelectedValue = CurrentDay.ToString(); } else { rdoDays.SelectedIndex = 0; CurrentDay = int.Parse(rdoDays.SelectedValue); } //ddlDays_SelectedIndexChanged(this, new EventArgs()); }
/// <summary> /// Palauttaa päivästä, seasonista ja vuodesta display stringin. /// </summary> /// <returns></returns> public string GetDateDisplayString() { return(string.Format("D:{0} - Y:{1} - DOW:{2}", CurrentDayOfMonth, CurrentYear, CurrentDay.ToString().Substring(0, 3))); }
void UpdateRangeInfoText() { LblRangeInfo.Text = String.Format("{0} {1}, {2}", CurrentDay.ToString("MMMM", CultureInfo.CurrentCulture), CurrentDay.Day.ToString(), CurrentDay.Year.ToString()); if (_btnGroupTab.CurrentIndex == 0 && null != ViewModel.WeeklyHistoryRangeModel) { LblRangeInfo.Text = ViewModel.WeeklyHistoryRangeModel.RangeInfo; } }
private string GenerateLogFileName(string fileNamePrefix) { return (fileNamePrefix + LogFileSuffix + DateTime.UtcNow.Month.ToString() + CurrentDay.ToString() + ".txt"); }
public async Task OnGetAsync(int id) { DayToEdit = await _context.CurrentDays.FindAsync(id); var activities = from a in _context2.Activities where a.TimeAt.Month == DayToEdit.CurrentDate.Month select a; Activities = await activities.ToListAsync(); }
// %t - minutes // %h - hours // %d - current day // %D - current day name // %m - current month index // %M - current month name // %y - year public string GetTimeAsString(string format) { string ret = format; ret = ret.Replace("%t", CurrentMinutes.ToString()); ret = ret.Replace("%h", CurrentHours.ToString()); ret = ret.Replace("%d", CurrentDay.ToString()); ret = ret.Replace("%D", Days[CurrentDayIndex]); ret = ret.Replace("%m", CurrentMonthIndex.ToString()); ret = ret.Replace("%M", Months.ElementAt(CurrentMonthIndex).Key); ret = ret.Replace("%y", CurrentYear.ToString()); return(ret); }
//Methods //Method to check if this user is equal to another user public override bool Equals(object obj) { bool isEqual = true; User user = (User)obj; if (!CurrentDay.Equals(user.CurrentDay)) { isEqual = false; } else if (!CurrentWeek.Equals(user.CurrentWeek)) { isEqual = false; } return(isEqual); }
void BtnNext_Clicked(object sender, EventArgs e) { if (_btnGroupTab.CurrentIndex == 0) // Week { ViewModel.CurrentWeekDate = ViewModel.CurrentWeekDate.AddDays(7); UpdateWeekModel(); } else // Day { CurrentDay = CurrentDay.AddDays(1); UpdateDayModel(); } CheckDateThresholds(); UpdateRangeInfoText(); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (CurrentDay != null) { hashCode = hashCode * 59 + CurrentDay.GetHashCode(); } if (PreviousDays != null) { hashCode = hashCode * 59 + PreviousDays.GetHashCode(); } return(hashCode); } }
public static void Initialise(CalendarAppContext context) { context.Database.EnsureCreated(); // Look for any Activities. if (context.Activities.Any()) { return; // DB has been seeded } var Activities = new Activity[] { new Activity { Title = "Shopping", Details = "eggs, pineaple, ham", TimeAt = new DateTime(2021, 4, 1, 16, 5, 0) }, new Activity { Title = "Shopping", Details = "eggs, pineaple, ham", TimeAt = new DateTime(2021, 4, 15, 16, 5, 0) } }; foreach (Activity a in Activities) { context.Activities.Add(a); } var CurrentDays = new CurrentDay[365]; DateTime StartThisYear = new DateTime(2021, 1, 1, 12, 0, 0); for (int i = 0; i < CurrentDays.Length; i++) { CurrentDays[i] = new CurrentDay { ID = i + 1, CurrentDate = StartThisYear.AddDays(i) }; } CurrentDays[111].Flag = "Your Birthday!"; foreach (CurrentDay c in CurrentDays) { context.CurrentDays.Add(c); } context.SaveChanges(); }
private void _updateDayHeader() { lblDayNumber.Text = CurrentDay.ToString("MMM d").ToUpper(); if (!InCurrentMonth) { pnlDayLabel.BackColor = Theme.OutOfMonthDayBG; lblDayNumber.ForeColor = Theme.OutOfMonthDayFG; } else if (DateTime.Now.ToString("MMM d").ToUpper() == lblDayNumber.Text) { pnlDayLabel.BackColor = Theme.TodayBG; lblDayNumber.ForeColor = Theme.TodayFG; } else { pnlDayLabel.BackColor = Theme.InMonthDayBG; lblDayNumber.ForeColor = Theme.InMonthDayFG; } }
/// <summary> /// Returns true if InvocationMetricsUnauthenticated instances are equal /// </summary> /// <param name="other">Instance of InvocationMetricsUnauthenticated to be compared</param> /// <returns>Boolean</returns> public bool Equals(InvocationMetricsUnauthenticated other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( CurrentDay == other.CurrentDay || CurrentDay != null && CurrentDay.Equals(other.CurrentDay) ) && ( PreviousDays == other.PreviousDays || PreviousDays != null && PreviousDays.SequenceEqual(other.PreviousDays) )); }
public TasksViewModel(User user, TaskService taskService, ProjectService projectService, DateTime?day = null) { var timeZone = TimeZoneInfo.FindSystemTimeZoneById(user.TimeZoneId); var x = DateTime.UtcNow; var y = day.GetValueOrDefault(); CurrentDay = day == null ? TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, timeZone).Date : TimeZoneInfo.ConvertTime(day.GetValueOrDefault(), timeZone).Date; WeekStart = CurrentDay.AddDays(-(int)CurrentDay.DayOfWeek).Date; WeekEnd = CurrentDay.AddDays(6 - (int)CurrentDay.DayOfWeek).Date; Tasks = taskService.GetTaskRange(user.Id, CurrentDay.AddDays(-1), CurrentDay.AddDays(2).Date).ToList(); foreach (var task in Tasks) { task.From = TimeZoneInfo.ConvertTimeFromUtc(task.From, timeZone); task.To = TimeZoneInfo.ConvertTimeFromUtc(task.To, timeZone); } Tasks = Tasks.Where(z => (z.From.Date == CurrentDay.Date && z.To.Date == CurrentDay.Date)).ToList(); Projects = projectService.GetAll(user.CompanyId.GetValueOrDefault()).ToList(); }
/// <summary> /// Returns true if AverageTPSMetrics instances are equal /// </summary> /// <param name="other">Instance of AverageTPSMetrics to be compared</param> /// <returns>Boolean</returns> public bool Equals(AverageTPSMetrics other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( CurrentDay == other.CurrentDay || CurrentDay != null && CurrentDay.Equals(other.CurrentDay) ) && ( PreviousDays == other.PreviousDays || PreviousDays != null && PreviousDays.SequenceEqual(other.PreviousDays) )); }
public virtual void CalcCurrentMonthDays() { DayOfWeek firstDayOfWeekOfCurrentCulture = Culture.DateTimeFormat.FirstDayOfWeek; List <DayOfWeekInfo> daysOfWeek = Enum.GetValues(typeof(DayOfWeek)) .Cast <DayOfWeek>() .OrderBy(d => (d - firstDayOfWeekOfCurrentCulture + 7) % 7) .Select((d, i) => new DayOfWeekInfo { DayOfWeekNumber = i + 1, IsoDayOfWeek = (IsoDayOfWeek)Enum.Parse(typeof(IsoDayOfWeek), d.ToString()), DayOfWeekName = Culture.DateTimeFormat.GetAbbreviatedDayName(d) }) .ToList(); DaysOfWeekNames = daysOfWeek.Select(d => d.DayOfWeekName).ToArray(); if (CalendarSystem != CalendarSystemProperty.DefaultValue) { CurrentDay = CurrentDay.WithCalendar(CalendarSystem); } CalendarTitle = CurrentDay.ToString(Culture.DateTimeFormat.YearMonthPattern, Culture); int thisMonthDaysCount = CurrentDay.Calendar.GetDaysInMonth(CurrentDay.Year, CurrentDay.Month); LocalDate firstDayOfMonth = CurrentDay; while (firstDayOfMonth.Day != 1) { firstDayOfMonth = LocalDate.Subtract(firstDayOfMonth, Period.FromDays(1)); } DayOfWeekInfo firstDayOfMonthDayOfWeek = daysOfWeek.Single(d => d.IsoDayOfWeek == firstDayOfMonth.DayOfWeek); int prevMonthDaysInCurrentMonthView = (firstDayOfMonthDayOfWeek.DayOfWeekNumber - 1); int nextMonthDaysInCurrentMonthView = 42 - thisMonthDaysCount - prevMonthDaysInCurrentMonthView; Days = new List <CalendarDay>(42); LocalDate today = new LocalDate(DateTimeOffset.Now.Year, DateTimeOffset.Now.Month, DateTimeOffset.Now.Day, CalendarSystem.Gregorian).WithCalendar(CalendarSystem); for (int i = 0; i < prevMonthDaysInCurrentMonthView; i++) { Days.Add(null); } for (int i = 1; i <= thisMonthDaysCount; i++) { Days.Add(new CalendarDay { LocalDate = new LocalDate(CurrentDay.Year, CurrentDay.Month, i, CurrentDay.Calendar), IsToday = today.Year == CurrentDay.Year && today.Month == CurrentDay.Month && today.Day == i ? true : false }); } for (int i = 0; i < nextMonthDaysInCurrentMonthView; i++) { Days.Add(null); } if (Days.Count != 42) { throw new InvalidOperationException($"{nameof(Days)}'s count is {Days.Count}, but it should be 42"); } }
protected void Button_NextDay_Click(object sender, RoutedEventArgs e) { // Go forward a day, reload the timetable CurrentDay = CurrentDay.AddDays(1); Timetable.Dispatcher.Invoke((Action <User, DateTime>)Timetable.SetTimetable, CurrentUser, CurrentDay); }