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);
    }
Beispiel #2
0
        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();
        }
Beispiel #3
0
        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();
        }
Beispiel #4
0
 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);
 }