public ProjectStatusListEventArgs(ProjectStatusListItem projectMilestone, ProjectStatus value, string key)
 {
     ProjectMilestone = projectMilestone;
     Status = value;
     CacheKey = key;
 }
        private Dictionary<ProjectStatusListItem, ProjectStatusEx> GetLatestProjectStatuses(ref bool isComplete)
        {
            object storedKeysObject = null;
            string keys = string.Empty;

            if (MsCache.TryGet(FbAccountContext.Current.Url + ProjectStatusesKey, ref storedKeysObject))
                keys = (string)storedKeysObject;

            var result = new Dictionary<ProjectStatusListItem, ProjectStatusEx>();

            if (!String.IsNullOrEmpty(keys))
            {
                var splitKeys = keys.Split(',');

                foreach (var key in splitKeys)
                {
                    var sessionKey = FbAccountContext.Current.Url + ProjectStatusKeyPreffix + "_" + key;
                    object storedStatusObject = null;

                    if (MsCache.TryGet(sessionKey, ref storedStatusObject))
                    {

                        var status = (ProjectStatusEx)storedStatusObject;

                        var ids = key.Split('_');
                        var projectMilesToneItem = new ProjectStatusListItem();
                        projectMilesToneItem.ProjectId = Convert.ToInt32(ids[0]);
                        projectMilesToneItem.MileStoneId = Convert.ToInt32(ids[1]);
                        if (ids.Count() > 2)
                            projectMilesToneItem.SubProjectParentCaseId = Convert.ToInt32(ids[2]);
                        result.Add(projectMilesToneItem, status);
                    }
                }

                isComplete = splitKeys.Count() == result.Count;
            }

            return result;
        }
        public static bool CheckNotStarted(int? projectId, int? milestoneid, int? projectParentCaseId)
        {
            //true if status != NotStarted
            //false if status == NotStarted
            object storedObect = null;

            var projectStatusListItem = new ProjectStatusListItem()
            {
                ProjectId = projectId.Value,
                MileStoneId = milestoneid.Value,
                SubProjectParentCaseId = projectParentCaseId
            };

            var cacheKey = MsCacheKey.Gen(MsCacheDataType.ProjectsStatuses, UserContext.FogBugzUrl);

            Dictionary<ProjectStatusListItem, ProjectStatusEx> result = null;

            if (MsCache.TryGet(cacheKey, ref storedObect))
                result = (Dictionary<ProjectStatusListItem, ProjectStatusEx>) storedObect;
            else
            {
                var sessionKey = FbAccountContext.Current.Url + "ProjectStatusLoader_" + projectStatusListItem.Key;
                object storedStatusObject = null;

                if (MsCache.TryGet(sessionKey, ref storedStatusObject))
                {
                    var status = (ProjectStatusEx)storedStatusObject;

                    var ids = projectStatusListItem.Key.Split('_');
                    var projectMilesToneItem = new ProjectStatusListItem();
                    projectMilesToneItem.ProjectId = Convert.ToInt32(ids[0]);
                    projectMilesToneItem.MileStoneId = Convert.ToInt32(ids[1]);
                    if (ids.Count() > 2)
                        projectMilesToneItem.SubProjectParentCaseId = Convert.ToInt32(ids[2]);
                    result = new Dictionary<ProjectStatusListItem, ProjectStatusEx> {{projectMilesToneItem, status}};
                }
            }

            if (result != null)
            {
                //var listStatuses = result.ToList();

                var projectStatus = result.SingleOrDefault(ps => ps.Key.Key == projectStatusListItem.Key);

                if (projectStatus.Key != null)
                {
                    return projectStatus.Value.Status != FogbugzProjectStatus.NotStarted;
                }

                //string resultStatus = String.Empty;

                //foreach (var status in listStatuses)
                //{
                //	if (projectParentCaseId == null)
                //	{
                //		if (status.Key.MileStoneId == milestoneid && status.Key.ProjectId == projectId)
                //		{
                //			resultStatus = status.Value.ToString();
                //		}
                //	}
                //	else if (status.Key.MileStoneId == milestoneid && status.Key.ProjectId == projectId &&
                //			 status.Key.SubProjectParentCaseId == projectParentCaseId)
                //	{
                //		resultStatus = status.Value.ToString();
                //	}
                //}

                //switch (resultStatus)
                //{
                //	case "NotStarted":
                //		return false;
                //	default:
                //		return true;
                //}
            }
            return true;
        }
        private HtmlString GenerateStatusLabel(ProjectStatusEx status, ProjectStatusListItem projectStatus)
        {
            var sb = new StringBuilder();

            sb.Append(String.Format("<span class=\"btn btn-{0}\" onclick=\"location.href='{1}/Project/Dashboard/{2}/{3}{4}'\">", status.Status.GetStatusClass(), EnvironmentConfig.GetFrontEndWebRootUrl(), projectStatus.ProjectId, projectStatus.MileStoneId, projectStatus.SubProjectParentCaseId.HasValue ? "/" + projectStatus.SubProjectParentCaseId.Value : ""));
            sb.Append(status.Status.GetStringValue());
            if (status.Status != FogbugzProjectStatus.NotStarted)
                sb.Append(String.Format(" ({0})", StringUtils.FormatSignDecimal(status.StatusValue, 1)));
            sb.Append("</span>");

            return new HtmlString(sb.ToString());
        }