public ProfileCache GetProfileByID(string id) { int profileID = -1; if (!Int32.TryParse(id, out profileID)) { Log.Error("Could not parse id."); return(null); } ICacheContent profileCache = this.Get(profileID); if (profileCache == null) { Log.Error("Cache did not retrieve any cacheContent."); return(null); } ProfileCache profileCacheObj = profileCache as ProfileCache; if (profileCacheObj == null) { Log.Error("CacheObject could not be passed into ProfileCache"); return(null); } return(profileCacheObj); }
public override void CacheService(IService service) { // SUMMARY: Adding profile groups for service List <ServiceProfileGroupMap> spgMap = ServiceProfileGroupMap.CreateManager().Load(service.ServiceData); List <ProfileGroup> tempGroups = new List <ProfileGroup>(); foreach (ServiceProfileGroupMap spgm in spgMap) { if (spgm.ProfileGroup.Instance.ID == this._application.Instance.ID && !this._profileGroups.Contains(spgm.ProfileGroup)) { this._profileGroups.Add(spgm.ProfileGroup); tempGroups.Add(spgm.ProfileGroup); } } // SUMMARY: Adding profiles from profile groups IProfileManager pManager = Profile.CreateManager(); foreach (ProfileGroup pg in tempGroups) { List <Profile> profiles = pManager.Load(pg); foreach (Profile p in profiles) { ProfileCache tempCache = new ProfileCache(p); if (!tempCache.HasError) { this._content.Add(tempCache); } else { Log.Error(string.Format("ProfileCache:CacheService Proflie with id '{0}' could not be cached", p.ID)); } } } Log.Debug(string.Format("Cache is created for '{0}' service", service.ServiceData.Name)); }