public FbSchedule Load(string fogBugzUrl, string token, out bool isAdmin)
        {
            if (token == String.Empty)
            {
                isAdmin = false;
                return null;
            }

            var groups = GetGroups(fogBugzUrl, token);

            /*
            string cacheKey = MsCacheKey.Gen(MsCacheDataType.FogBugz_ClientCacheByFogBugzUrl, fogBugzUrl);

            object fbAgentCacheObject = null;

            var fbAgentCache = new FogBugzClientCache();

            if (MsCache.TryGet(cacheKey, ref fbAgentCacheObject))
            {
                fbAgentCache = (FogBugzClientCache) fbAgentCacheObject;

                isAdmin = fbAgentCache.IsLoadedByAdminUser;

                if (fbAgentCache.Schedule != null)
                    return fbAgentCache.Schedule;
            }
            */

            var siteSchedule = new Schedule();

            var holidaysHtmlNode = GetHolidaysHtmlNode(token, fogBugzUrl, out isAdmin);

            if (holidaysHtmlNode != null)
            {
                var holidaysTable = holidaysHtmlNode.SelectSingleNode("//table[@id='staticHolidayTable']");
                if (holidaysTable == null)
                    return null;

                var tableRowsOdd = holidaysTable.SelectNodes("//tr[@class='r-a ']");
                var tableRows = holidaysTable.SelectNodes("//tr[@class='row ']");

                if (tableRows != null)
                {
                    foreach (var tableRowOdd in tableRowsOdd)
                    {
                        tableRows.Add(tableRowOdd);
                    }
                }
                else
                {
                    tableRows = tableRowsOdd;
                }

                if (tableRows != null)
                {
                    foreach (var tableRow in tableRows)
                    {
                        var columns = tableRow.SelectNodes("./td");

                        if (columns != null && columns.Count == 5)
                        {
                            var timeOffRange = GetTimeRange(columns[2].InnerText, columns[3].InnerText, columns[4].InnerText);

                            siteSchedule.TimeOffRanges.Add(timeOffRange);
                        }
                    }
                }
            }

            var personalSchedules = new Dictionary<int, Schedule>();

            if (isAdmin)
            {

                foreach (var item in groups)
                {
                    foreach (var person in item.Persons)
                    {
                        Schedule personSchedule = null;

                        personalSchedules.TryGetValue(person.Index.Value, out personSchedule);

                        if (personSchedule == null) personSchedule = new Schedule();

                        personSchedule.TimeOffRanges.AddRange(GetGroupSchedule(siteSchedule, item));

                        personalSchedules.Remove(person.Index.Value);

                        personalSchedules.Add(person.Index.Value, personSchedule);
                    }
                }
            }

            //fbAgentCache.Schedule = new FbSchedule() {SiteSchedule = siteSchedule};

            //MsCache.Set(cacheKey, fbAgentCache);

            return new FbSchedule() { SiteSchedule = siteSchedule, PersonSchedules = personalSchedules};
        }
        private List<TimeOffRange> GetGroupSchedule(Schedule siteSchedule, FbGroup group)
        {
            var groupName = group.Name.TrimEnd('s') + ": ";

            var timeRanges = siteSchedule.TimeOffRanges
                .Where(tr => tr.Name.IndexOf(groupName) == 0)
                .ToList();

            return timeRanges;
        }
 public FbSchedule()
 {
     SiteSchedule = new Schedule();
     PersonSchedules = new Dictionary<int, Schedule>();
 }