public List <DocumentTreeNode> SetTreeNodeDocumentLibrariesAndFolders() { List <DocumentTreeNode> nodes = new List <DocumentTreeNode>(); if (RSCUtil.Cache.Contains(_cacheKey)) { //Load Cache nodes = RSCUtil.Cache[_cacheKey] as List <DocumentTreeNode>; } else { //Create Cache LibrariesManager manager = new LibrariesManager(); //Folder Focused if (this.FolderId != Guid.Empty) { var album = manager.GetDocumentLibrary(this.LibraryId); if (album != null) { var folders = manager.GetAllFolders(album); var selectedFolder = folders.FirstOrDefault(x => x.Id == this.FolderId); if (selectedFolder != null) { this.ParseSingleFolder(nodes, manager, album, selectedFolder); } else { throw new Exception("Invalid FolderId Specified or Unable to find folder"); } } else { throw new Exception("Invalid LibraryId Specified or Unable to find library"); } } else { //Libary Focused var album = manager.GetDocumentLibrary(this.LibraryId); if (album != null) { this.ParseSingleAlbum(nodes, manager, album); } else { throw new Exception("Invalid LibraryId Specified"); } } if (!SystemManager.IsDesignMode && RSCUtil.SfsConfig.CacheTimeoutMinutes > 0) { //Add to cache RSCUtil.AddToCache(nodes, _cacheKey, TimeSpan.FromMinutes(RSCUtil.SfsConfig.CacheTimeoutMinutes)); } } //Bind to the tree return(nodes); }
private void HandleTwitterStatusCallback(List <TwitterStatus> tweets, string cacheKey, TwitterService service, IEnumerable <TwitterStatus> result) { if (service.Response.StatusCode == HttpStatusCode.OK) { tweets.AddRange(result); RSCUtil.AddToCache(tweets, cacheKey, TimeSpan.FromMinutes(RSCUtil.SfsConfig.Twitter.CacheTimeoutMinutes)); } else { Logger.Writer.Write(service.Response.Error.Message); throw new UnauthorizedAccessException(service.Response.Error.Message); } }