private void LoadDataFiles()
        {
            StaticInventoryTracker.LoadDefaults();
            StaticFactoryValuesManager.LoadValues(true);
            var loadschedule = CoatingSchedule.Load();

            if (loadschedule != null)
            {
                schedule = loadschedule;
            }
        }
예제 #2
0
        private void LoadContolData()
        {
            if (StaticInventoryTracker.InventoryChanges.Count == 0 && StaticInventoryTracker.IsLoaded)
            {
                EfficiencyListView.ItemsSource = new List <Label>()
                {
                    new Label()
                    {
                        Content = "No efficiency data"
                    }
                };

                return;
            }

            // try to load if not loaded and no changes logged.
            if (StaticInventoryTracker.InventoryChanges.Count == 0 && !StaticInventoryTracker.IsLoaded)
            {
                if (!StaticInventoryTracker.LoadDefaults())
                {
                    EfficiencyListView.ItemsSource = new List <Label>()
                    {
                        new Label()
                        {
                            Content = "Failed to load efficiency data"
                        }
                    };

                    return;
                }
            }

            // if there are still none, exit
            if (StaticInventoryTracker.InventoryChanges.Count == 0)
            {
                EfficiencyListView.ItemsSource = new List <Label>()
                {
                    new Label()
                    {
                        Content = "No efficiency data loaded"
                    }
                };
                return;
            }

            var trackers = new List <InventoryChange>();

            trackers.AddRange(StaticInventoryTracker.InventoryChanges); // make a copy of the list

            DateTime date = trackers.Min(change => change.Date);

            while (trackers.Count > 0)
            {
                // get starting day, and then that days start of week

                while (date.DayOfWeek != CalendarControl.StartOfWeek)
                {
                    date = date.AddDays(-1);
                }

                var weeklyChanges = new List <InventoryChange>();
                weeklyChanges.AddRange(trackers.Where(change => change.Date >= date && change.Date < date.AddDays(7))); // get the weeks changes.

                WeekControls.Add(new WeeklyEfficiencyControl(weeklyChanges, date));

                foreach (var inventoryChange in weeklyChanges)
                {
                    trackers.Remove(inventoryChange);
                }

                date = date.AddDays(7);
            }
        }