日期:2014-05-17 浏览次数:20891 次
/// <summary>
/// 任务分配项
/// </summary>
public class WorkDayInfo
{
public DateTime Date { get; set; }
public Task TaskInfo { get; set; }
}
/// <summary>
/// 具体任务
/// </summary>
public class Task
{
public string Desc { get; set; }
}
/// <summary>
/// 安排任务
/// </summary>
/// <param name="date">月份的第一天日期比如:2013-03-01</param>
/// <param name="workDayList">待分配到工作日的任务</param>
/// <param name="satworkDayList">待分配到星期六的任务</param>
/// <returns>返回分配好的任务项</returns>
public List<WorkDayInfo> ArrangeTask(DateTime date, List<Task> workDayList, List<Task> satworkDayList)
{
int days = (date.AddMonths(1) - date).Days;//传入的月份有多少天
var workDayItems = new List<int>();//工作日安排
var satDayItems = new List<int>();//星期六安排
var arrangeTaskItems = new List<WorkDayInfo>();
//生成可分配任务的日期
for (int i = 0; i < days; i++)
{
DateTime current = date.AddDays(i);
if (current.DayOfWeek == DayOfWeek.Sunday) continue;
if (current.DayOfWeek == DayOfWeek.Saturday)
{
satDayItems.Add(i + 1);
&