public IDictionary <long, IList <WorkSchedule> > GetAll(short pastMonths, short newMonths)
        {
            SynchronizedDictionary <long, IList <WorkSchedule> > result = new SynchronizedDictionary <long, IList <WorkSchedule> >();
            List <Task> tasks    = new List <Task>();
            DateTime    firstDay = DateTime.Now.AddDays(1 - DateTime.Now.Day).Date;
            DateTime    lastDay  = firstDay.AddMonths(1).AddMilliseconds(-1);

            foreach (ProjectInfoS item in ProjectInfoS.FetchList(Database.Default,
                                                                 p => p.OriginateTime <= lastDay && (p.ClosedDate == null || p.ClosedDate >= firstDay)))
            {
                //项目经理
                long projectManager = item.ProjectManager;
                if (!result.ContainsKey(projectManager))
                {
                    result.Add(projectManager, null);
                    tasks.Add(Task.Run(async() =>
                    {
                        result[projectManager] = await ClusterClient.Default.GetGrain <IWorkScheduleGrain>(projectManager).FetchWorkSchedules(pastMonths, newMonths);
                    }));
                }
                //开发经理
                long developManager = item.DevelopManager;
                if (!result.ContainsKey(developManager))
                {
                    result.Add(developManager, null);
                    tasks.Add(Task.Run(async() =>
                    {
                        result[developManager] = await ClusterClient.Default.GetGrain <IWorkScheduleGrain>(developManager).FetchWorkSchedules(pastMonths, newMonths);
                    }));
                }
            }

            Task.WaitAll(tasks.ToArray());
            return(result);
        }
Ejemplo n.º 2
0
        public IList <ProjectInfoS> GetAll(short year, short month)
        {
            DateTime firstDay = new DateTime(year, month, 1);
            DateTime lastDay  = firstDay.AddMonths(1).AddMilliseconds(-1);

            return(ProjectInfoS.FetchList(Database.Default,
                                          p => p.OriginateTime <= lastDay && (p.ClosedDate == null || p.ClosedDate >= firstDay),
                                          OrderBy.Descending <ProjectInfoS>(p => p.ContApproveDate).
                                          Descending(p => p.UpdateTime).
                                          Descending(p => p.OriginateTime)));
        }