Пример #1
0
            public ManageTable Clone()
            {
                ManageTable result = new ManageTable(CheckInTime.CheckInTimeList);

                foreach (var item in this)
                {
                    result[item.Time.TimeId] = item;
                }
                return(result);
            }
Пример #2
0
        /// <summary>
        /// 获取Manager为空的可用ManageTable(由ManageTableRecord组成的集合类型)。
        /// </summary>
        /// <returns>Manager为空而包含值班时间的ManageTable</returns>
        public static ManageTable GetEmptyManageTable(List <AvailableTime> availableTimeList)
        {
            var manageTable        = new ManageTable(CheckInTime.CheckInTimeList);
            var availableTimeTable = new AvailableTimeHelper.AvailableTimeTable(availableTimeList);

            for (int i = 11; i != 0; i = CheckInTime.GetNextTimeId(i))
            {
                if (availableTimeTable[i].ManagerList.Count == 0)
                {
                    return(null);
                }
                if (availableTimeTable[i].ManagerList.Count == 1)
                {
                    manageTable[i].Manager = availableTimeTable[i].ManagerList.SingleOrDefault();
                }
            }
            return(manageTable);
        }
Пример #3
0
        private void fillInManageTable(ManageTable table)
        {
            var        availableTimeTable = new AvailableTimeHelper.AvailableTimeTable(availableTimeList);
            List <int> jumpList           = new List <int>();

            manageTableList = new List <ManageTable>();
            manageTableList.Add(new ManageTable(CheckInTime.CheckInTimeList));
            for (int i = 11; i != 0; i = CheckInTime.GetNextTimeId(i))
            {
                if (availableTimeTable[i].ManagerList.Count == 0)
                {
                    return;
                }
                if (availableTimeTable[i].ManagerList.Count == 1)
                {
                    manageTableList.Single()[i].Manager = availableTimeTable[i].ManagerList.Single();
                    jumpList.Add(i);
                }
            }
            for (int i = 11; i != 0; i = CheckInTime.GetNextTimeId(i))
            {
                if (jumpList.Contains(i))
                {
                    continue;
                }
                List <ManageTableRecord> recordList = new List <ManageTableRecord>();
                foreach (var availableTime in availableTimeList)
                {
                    if (availableTime.TimeId == i)
                    {
                        recordList.Add(new ManageTableRecord {
                            Manager = availableTime.Manager, Demand = availableTime.Demand, Time = Manager.FindCheckInTime(availableTime.TimeId)
                        });
                    }
                }
                List <ManageTable> newTableList = new List <ManageTable>();
                foreach (var record in recordList)
                {
                    if (manageTableList.Count == 0)
                    {
                        var initialManageTable = GetEmptyManageTable(availableTimeList);
                        initialManageTable[i] = record;
                        newTableList.Add(initialManageTable);
                    }
                    else
                    {
                        foreach (var manageTable in manageTableList)
                        {
                            var newManageTable = manageTable.Clone();
                            newManageTable[i] = record;
                            newTableList.Add(newManageTable);
                        }
                    }
                }
                if (newTableList.Count == 0)
                {
                    manageTableList = new List <ManageTable>();
                    return;
                }
                newTableList    = newTableList.Distinct(new ManageTableComparer()).ToList();
                manageTableList = checkManageTableList(newTableList);
                if (i == 76)
                {
                    break;
                }
            }
        }