protected virtual void SaveStatus(ProjectStatusListEventArgs e)
 {
     if (SaveStatusEvent != null) SaveStatusEvent(this, e);
 }
        public string BeginGettingProjectStatuses(List<ProjectListItem> combinations)
        {
            var fbClient = FogBugzGateway.GetClientForParallel();

            var persons = fbClient.GetPersons().ToList();

            var milestones = GetOnlyStartedMilstones(combinations);

            var isLoadedByAdmin = FogBugzGateway.GetIsScheduleLoadedByAdmin();
            var fbSchedule = FogBugzGateway.GetFbSchedule();

            Func<object, int> action = (object obj) =>
            {
                ProjectStatusListItem combo = obj as ProjectStatusListItem;

                Core.MsCache.Set(ListProgressStatusKey + "_" + _cacheKey, new ProgressStatusInfo { Value = 66, Label = String.Format("Calculating status for \"{0} {1}\" for tasks {2} of {3}", combo.Project.Name, combo.Milestone.Name, milestones.IndexOf(combo) + 1, milestones.Count) });

                var cases = FogBugzGateway.GetCases(combo.ProjectId, combo.MileStoneId, combo.SubProjectParentCaseId, null, fbClient);

                var caseSet = new CaseSet();
                caseSet.Cases = cases;
                caseSet.Milestone = new Milestone(combo.Milestone);
                caseSet.Project =  new Project(combo.Project);

                var projectStatusCalculator = new ProjectStatusCalculator(caseSet, persons, isLoadedByAdmin, fbSchedule);

                var status = projectStatusCalculator.GetProjectStatus();

                var eventArgs = new ProjectStatusListEventArgs(combo, status, _cacheKey);

                SaveStatus(eventArgs);

                return 0;
            };

            var factory = new TaskFactory();

            var tasks = new Task<int>[milestones.Count()];

            for (int i = 0; i < milestones.Count(); i++)
            {
                tasks[i] = factory.StartNew(action, milestones[i]);
            }

            return GenKeysString(milestones);
        }
        private void OnSaveStatus(object sender, ProjectStatusListEventArgs e)
        {
            var key = String.Format("{0}_{1}", e.CacheKey + ProjectStatusKeyPreffix, e.ProjectMilestone.Key);

            MsCache.Set(key, new ProjectStatusEx(e.Status));
        }