Esempio n. 1
0
        //xprivate readonly IList<IStaffingStatistic> _staffingStatistics;

        public ServiceQueueContainer(IEnumerable serviceQueues, ITerm dateRange, Func <double[], int, string, object, IVisibleLinerData> itemContstruction)
            : base(serviceQueues.Count())
        {
            _entities          = serviceQueues;
            _itemContstruction = itemContstruction;
            _skillMapping      = new Dictionary <Skill, IServiceQueueStatistic>(Count);
            _list = new List <StatisticRaw>(Count);
            //_lines = new List<IVisibleLinerData>();

            //x_staffingStatistics = new List<IStaffingStatistic>(); // estimation

            _calculateForecastStaffing     = (shrinkage, startWeekDayIndex) => { };
            _calculateAssignedServiceLevel = (i, staffing) => { };
            //x_sumForecastStaffing = d => { };

            //使用非排班期起始, 用的是前後扩展過的日期范围
            _dateIndexer = Common.Extensions.DateTimeExt.CreateDateIndexer(dateRange.Start, dateRange.End);

            foreach (ServiceQueue item in serviceQueues)
            {
                var mappedSkill = item.MappedSkill;

                new ServiceQueueStatistic(item, _dateIndexer).Self(t =>
                {
                    var x = new StatisticRaw(t, _itemContstruction);

                    _calculateForecastStaffing += (shrinkage, startWeekDayIndex) =>
                    {
                        t.CalculateForecastStaffing(shrinkage, startWeekDayIndex);
                        x.SetForceastValues();
                    };

                    // check service is single mode
                    //x_sumForecastStaffing += result => { Sum(t.ForceastStaffing, ref result); };

                    _calculateAssignedServiceLevel += (index, staffing) =>
                    {
                        if (staffing != null)
                        {
                            t.AssignedStaffing[index] = staffing.Value;                                       // value always zero
                        }
                        t.CalculateAssignedServiceLevel(index);
                        //t.CalculateStaffingRequirement(index);
                        t.CalculateDailyMisc(index / 96);
                        x.SetAssignedValues(index);
                    };
                    _skillMapping[mappedSkill] = t;
                    this[t.GetHashCode()]      = t;
                    _list.Add(x);
                });
            }
        }
Esempio n. 2
0
        protected override void OnInitialize()
        {
            Invoker.SaftyInvoke<DefaultPresenter>(p =>
                                                      {
                                                          //register ribbon buttons, 并非最佳作法, 导致 CommandBindings.Clear() 然后再重新加入  CommandBindings.AddRange();
                                                          p.CommandBindings.Add(new CommandBinding(WPF.ApplicationFramework.ApplicationCommands.ExportSvcLevelData, OnExportSvcLevelDataExecuted,
                                                              (d, e) => { e.CanExecute = AnalyisComplete; }));
                                                          p.NotifyOfPropertyChange(() => CommandBindings);
                                                          p.PropertyChanged += InvokerPropertyChanged;
                                                      });

            _enquiryRange = new DateRange(_schedule.Start.AddDays(Global.HeadDayAmount), _schedule.End.AddDays(Global.TailDayAmount));

            _serviceQueueContainer = _staffingCalculatorModel.Preparing(_schedule.Id, _enquiryRange, ConvertTo); // 读取预测数据 
            _serviceQueuesView = CollectionViewSource.GetDefaultView(_serviceQueueContainer.GetEntities());

            WhenReady.SaftyInvoke(d => d(_serviceQueueContainer, SwitchView));
            Pop();
            _combinedServiceQueues = new StatisticRaw(new CombinedServiceQueueStatistic(_serviceQueueContainer.Values, _serviceQueueContainer.CoverageDays), ConvertTo);
            _combinedServiceQueues.SetForceastValues();
            _combinedServiceQueues.Items3 = CollectionViewSource.GetDefaultView(_combinedServiceQueues.Items).Self(v =>
            {
                v.Filter = d => d.SaftyGetProperty<bool, IVisibleLinerData>(
                    line => line.Category == _selectedCategory);
            });

            base.OnInitialize();
            FullyFetch();

            #region 合併SQ做估算的code
            //new Thread(() =>
            //{
            //    IEnumerable[] lines = { new List<IStaffingStatistic>() };
            //    var action = new Action(() => StaffingStatistics = CollectionViewSource.GetDefaultView(lines[0]));
            //    _serviceQueueContainer.Output2(out lines[0], ref action);
            //    UIThread.Invoke(action);
            //}).Start();
            #endregion
        }