public void RegisterRunStaffingChart(FrameworkElement el) { _staffingCalculatorArgs = new Dictionary <string, object> { { "contentView", el }, { "getAgents", new System.Func <IEnumerable <IAgent> >(() => _attendances) }, { "getViewRange", new System.Func <DateRange>(() => new DateRange(SelectionTimeRange.Start.Date.AddDays(-1), SelectionTimeRange.End.Date.AddDays(1))) }, { "schedule", _schedule }, { "Invoker", this }, { "WhenReady", new Action <IServiceQueueContainer, Action <string> >((c, switchView) => { _switchView = switchView; _serviceQueueContainer = c; }) }, { "WhenCurrentQueueSelected", new Action <IServiceQueueStatistic>(q => { if (q == null) { return; } SelectedServiceQueue = q.ToString(); //NotifyOfPropertyChange(()=> AssignmentTypes); new Thread(() => { var days = _dateIndexer.Count; for (var i = 0; i < days; i++) { SumOfDailyPlanningServiceLevel(q, i); } NotifyOfPropertyChange(() => StatisticItems); }).Start(); }) } }; _staffingCalculatorService = Container.Resolve <IStaffingCalculatorService>(_staffingCalculatorArgs); _autoReset.Set(); }
public void Fetch(int start, int end, IServiceQueueContainer x, IEnumerable agentsSource) { var agents = ConvertAgentSkillToServiceQeueue(agentsSource, x); // var sumOfCvs = new double[end - start/96 + 1]; for (var i = start; i < end; i++) { var index = i; var groups = new Dictionary <string, Group>(); var queueStaffings = new Dictionary <IServiceQueueStatistic, double>(); var queues = new List <IServiceQueueStatistic>(); //grouping foreach (var item in agents) { var isOnline = index.DvideTo5Min(item.Key.Onlines); item.Value.Distribute((q, productivity) => { var noForecasting = q.ForceastStaffing[index] <= 0; if (!queueStaffings.ContainsKey(q)) { // unique operation, do once q.Reset(index); queues.Add(q); queueStaffings[q] = noForecasting ? 0.1d : q.ForceastStaffing[index]; // atention } q.AssignedMaxStaffing[index] += isOnline ? productivity : 0; return(isOnline); }, ref groups); } if (groups.Count != 0) { Dictionary <int, Tuple <IServiceQueueStatistic, double> > vEx; double[,] dMtx; double[] rhs; int mtxCurrentIndex; LinearAlgebraLib.Build(groups.Values, out mtxCurrentIndex, out dMtx, out rhs, out vEx); LinearAlgebraLib.RatioX(queues, queueStaffings, ref mtxCurrentIndex, ref dMtx, vEx); int info; double[] result; SimplexStaffing.FS(dMtx, groups.Count, rhs, out info, out result); for (var j = 0; j < vEx.Count; j++) { vEx[j].Item1.AssignedStaffing[index] += result[j]; // staffing contribution result } } x.CalculateAssignedStatistics(index, groups.Count == 0 ? 0d : default(double?)); } }
private Dictionary<IServiceQueueStatistic, double> AgentSkillToServiceQeueue(IAgent agent, IServiceQueueContainer serviceQueueContainer) { var mapping = new Dictionary<IServiceQueueStatistic, double>(); foreach (var skill in agent.Profile.Skills) { var q = serviceQueueContainer[skill.Key]; if (q != null) mapping.Add(q, skill.Value); } return mapping; }
protected override void OnShutdown() { _staffingCalculatorModelFetching.Abort(); _serviceQueueContainer.Dispose(); _serviceQueueContainer = null; _staffingCalculatorData.CurrentChanged -= StaffingCalculatorDataCurrentChanged; _staffingCalculatorData.CurrentChanged -= StaffingCalculatorDataCurrentChangedOnEstimationMode; _staffingCalculatorData = null; Invoker.SaftyInvoke <INotifyPropertyChanged>(p => p.PropertyChanged -= InvokerPropertyChanged); WhenCurrentQueueSelected = null; WhenReady = null; _staffingCalculatorModel.Release(); base.OnShutdown(); }
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 }
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 }
private Dictionary<IAgent, Dictionary<IServiceQueueStatistic, double>> ConvertAgentSkillToServiceQeueue(IEnumerable agentsSource, IServiceQueueContainer serviceQueueContainer) { var agents = new Dictionary<IAgent, Dictionary<IServiceQueueStatistic, double>>(); foreach (IAgent agent in agentsSource) { var mapping = AgentSkillToServiceQeueue(agent, serviceQueueContainer); if (0 < mapping.Count)// 技能未能夠匹配到SQ agents[agent] = mapping; //agents[agent] = new Dictionary<IServiceQueueStatistic, double>(); //foreach (var skill in agent.Profile.Skills) //{ // var q = serviceQueueContainer[skill.Key]; // if (q != null) // agents[agent].Add(q, skill.Value); //} //if (0 < agents[agent].Count) //{ // //x agent.BuildOnlines(_enquiryRange.Start, _enquiryRange.End);// 注意:性能消耗 //} //else // agents.Remove(agent); } return agents; }
public void Fetch(int start, int end, IServiceQueueContainer x, IEnumerable agentsSource) { var agents = ConvertAgentSkillToServiceQeueue(agentsSource, x); // var sumOfCvs = new double[end - start/96 + 1]; for (var i = start; i < end; i++) { var index = i; var groups = new Dictionary<string, Group>(); var queueStaffings = new Dictionary<IServiceQueueStatistic, double>(); var queues = new List<IServiceQueueStatistic>(); //grouping foreach (var item in agents) { var isOnline = index.DvideTo5Min(item.Key.Onlines); item.Value.Distribute((q, productivity) => { var noForecasting = q.ForceastStaffing[index] <= 0; if (!queueStaffings.ContainsKey(q)) { // unique operation, do once q.Reset(index); queues.Add(q); queueStaffings[q] = noForecasting ? 0.1d : q.ForceastStaffing[index]; // atention } q.AssignedMaxStaffing[index] += isOnline ? productivity : 0; return isOnline; }, ref groups); } if (groups.Count != 0) { Dictionary<int, Tuple<IServiceQueueStatistic, double>> vEx; double[,] dMtx; double[] rhs; int mtxCurrentIndex; LinearAlgebraLib.Build(groups.Values, out mtxCurrentIndex, out dMtx, out rhs, out vEx); LinearAlgebraLib.RatioX(queues, queueStaffings, ref mtxCurrentIndex, ref dMtx, vEx); int info; double[] result; SimplexStaffing.FS(dMtx, groups.Count, rhs, out info, out result); for (var j = 0; j < vEx.Count; j++) vEx[j].Item1.AssignedStaffing[index] += result[j]; // staffing contribution result } x.CalculateAssignedStatistics(index, groups.Count == 0 ? 0d : default(double?)); } }
public void RegisterRunStaffingChart(FrameworkElement el) { _staffingCalculatorArgs = new Dictionary<string, object> { {"contentView", el}, {"getAgents", new System.Func<IEnumerable<IAgent>>(() => _attendances)}, {"getViewRange", new System.Func<DateRange>(() => new DateRange(SelectionTimeRange.Start.Date.AddDays(-1), SelectionTimeRange.End.Date.AddDays(1)))}, {"schedule", _schedule}, {"Invoker", this}, {"WhenReady", new Action<IServiceQueueContainer, Action<string>>((c, switchView)=> { _switchView = switchView; _serviceQueueContainer = c; })}, {"WhenCurrentQueueSelected", new Action<IServiceQueueStatistic>(q=> { if( q== null) return; SelectedServiceQueue = q.ToString(); //NotifyOfPropertyChange(()=> AssignmentTypes); new Thread(() => { var days = _dateIndexer.Count; for (var i = 0; i < days; i++) SumOfDailyPlanningServiceLevel(q,i); NotifyOfPropertyChange(() => StatisticItems); }).Start(); })} }; _staffingCalculatorService = Container.Resolve<IStaffingCalculatorService>(_staffingCalculatorArgs); _autoReset.Set(); }
protected override void OnShutdown() { _staffingCalculatorModelFetching.Abort(); _serviceQueueContainer.Dispose(); _serviceQueueContainer = null; _staffingCalculatorData.CurrentChanged -= StaffingCalculatorDataCurrentChanged; _staffingCalculatorData.CurrentChanged -= StaffingCalculatorDataCurrentChangedOnEstimationMode; _staffingCalculatorData = null; Invoker.SaftyInvoke<INotifyPropertyChanged>(p => p.PropertyChanged -= InvokerPropertyChanged); WhenCurrentQueueSelected = null; WhenReady = null; _staffingCalculatorModel.Release(); base.OnShutdown(); }
private Dictionary <IAgent, Dictionary <IServiceQueueStatistic, double> > ConvertAgentSkillToServiceQeueue(IEnumerable agentsSource, IServiceQueueContainer serviceQueueContainer) { var agents = new Dictionary <IAgent, Dictionary <IServiceQueueStatistic, double> >(); foreach (IAgent agent in agentsSource) { var mapping = AgentSkillToServiceQeueue(agent, serviceQueueContainer); if (0 < mapping.Count)// 技能未能夠匹配到SQ { agents[agent] = mapping; } //agents[agent] = new Dictionary<IServiceQueueStatistic, double>(); //foreach (var skill in agent.Profile.Skills) //{ // var q = serviceQueueContainer[skill.Key]; // if (q != null) // agents[agent].Add(q, skill.Value); //} //if (0 < agents[agent].Count) //{ // //x agent.BuildOnlines(_enquiryRange.Start, _enquiryRange.End);// 注意:性能消耗 //} //else // agents.Remove(agent); } return(agents); }
private Dictionary <IServiceQueueStatistic, double> AgentSkillToServiceQeueue(IAgent agent, IServiceQueueContainer serviceQueueContainer) { var mapping = new Dictionary <IServiceQueueStatistic, double>(); foreach (var skill in agent.Profile.Skills) { var q = serviceQueueContainer[skill.Key]; if (q != null) { mapping.Add(q, skill.Value); } } return(mapping); }