Exemplo n.º 1
0
        private void SetupJobsAndResources(ProjectDataSet dataSet, IConstraints constraints)
        {
            //foreach (var shift in dataSet.Shifts)
            //{
            //    var cshift = CreateShiftFromShift(shift);
            //    _shiftManager.AddShift(cshift);
            //    _shifts.GetOrAdd(shift.Name, cshift);

            //    if (constraints.ConstrainOnLaborPool)
            //    {
            //        foreach (var laborLink in shift.LaborLinks)
            //        {
            //            foreach (var w in CreateWorkerFromLaborLink(laborLink))
            //            {
            //                _workers.GetOrAdd(w.ID, w);
            //                _shifts[shift.Name].Workers.Add(w);
            //            }
            //        }
            //    }

            //    if (constraints.ConstrainOnTools)
            //    {
            //        foreach (var toolLink in shift.ToolLinks)
            //        {
            //            foreach (var t in CreateToolFromToolLink(toolLink))
            //            {
            //                _tools.GetOrAdd(t.ID, t);
            //                _shifts[shift.Name].Tools.Add(t);
            //            }
            //        }
            //    }
            //}

            if (constraints.ConstrainOnZones)
            {
                foreach (var zone in dataSet.GetZoneResources())
                {
                    var z = CreateZoneFromZone(zone);
                    _zones.GetOrAdd(z.ID, z);
                    _zonesMap.GetOrAdd(z.ID, zone);
                }
            }
        }
        public async Task <ConstraintSolverResult> InitializeDataAsync()
        {
            _activitiesMap = new ConcurrentDictionary <int, IActivity>();
            _scheduledJobs = new ConcurrentDictionary <Guid, IActivitySchedule>();

            await Task.Run(() =>
            {
                var cp = new CriticalPathHelper();
                cp.OrderActivitySchedule(_model, _solverResult);

                foreach (var scheduledItem in _solverResult.Schedule)
                {
                    var activity = scheduledItem.ScheduledItem;
                    _scheduledJobs.GetOrAdd(activity.UID, scheduledItem);
                }
            });

            ShiftManager.ProcessModel(_model, _solverResult.Constraints);
            JobManager.ProcessModelActivities(_solverResult.Schedule);
            ZoneManager.ProcessZones(_model.GetZoneResources());

            return(_solverResult);
        }
        private void SetupJobsAndResources(ProjectDataSet dataSet, IConstraints constraints)
        {

            //foreach (var shift in dataSet.Shifts)
            //{
            //    var cshift = CreateShiftFromShift(shift);
            //    _shiftManager.AddShift(cshift);
            //    _shifts.GetOrAdd(shift.Name, cshift);

            //    if (constraints.ConstrainOnLaborPool)
            //    {
            //        foreach (var laborLink in shift.LaborLinks)
            //        {
            //            foreach (var w in CreateWorkerFromLaborLink(laborLink))
            //            {
            //                _workers.GetOrAdd(w.ID, w);
            //                _shifts[shift.Name].Workers.Add(w);
            //            }
            //        }
            //    }

            //    if (constraints.ConstrainOnTools)
            //    {
            //        foreach (var toolLink in shift.ToolLinks)
            //        {
            //            foreach (var t in CreateToolFromToolLink(toolLink))
            //            {
            //                _tools.GetOrAdd(t.ID, t);
            //                _shifts[shift.Name].Tools.Add(t);
            //            }
            //        }
            //    }
            //}

            if (constraints.ConstrainOnZones)
            {
                foreach (var zone in dataSet.GetZoneResources())
                {
                    var z = CreateZoneFromZone(zone);
                    _zones.GetOrAdd(z.ID, z);
                    _zonesMap.GetOrAdd(z.ID, zone);
                }
            }

            
        }