- Timestamp:
- Oct 3, 2011, 5:09:51 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/PiwigoLib/PiwigoWpf/Services/ImageCacheManager.cs
r11926 r12336 64 64 #region DTO 65 65 // local DTO 66 internal class CategoryDictionnaryItem66 internal class AlbumDictionnaryItem 67 67 { 68 68 internal DirectoryInfo BasePath; 69 internal String CategorieId;69 internal String AlbumId; 70 70 }; 71 71 72 internal class CategoryDictionnary : SortedDictionary<String, CategoryDictionnaryItem> { };72 internal class AlbumDictionnary : SortedDictionary<String, AlbumDictionnaryItem> { }; 73 73 74 74 internal class ServerDictionnaryItem 75 75 { 76 76 internal DirectoryInfo BasePath; 77 internal CategoryDictionnary Categories;77 internal AlbumDictionnary Albums; 78 78 internal Uri ServeurUrl; 79 79 }; … … 86 86 internal ServerDictionnary _aServerDictionnary; 87 87 internal ServerDictionnaryItem _currentServer; 88 internal CategoryDictionnaryItem _currentCategory;88 internal AlbumDictionnaryItem _currentAlbum; 89 89 90 90 #endregion DTO … … 100 100 } 101 101 102 static private String Build CategoryDirCache(ServerDictionnaryItem server, String CatgeoryId)103 { 104 String CategoryDirCache = String.Empty;102 static private String BuildAlbumDirCache(ServerDictionnaryItem server, String CatgeoryId) 103 { 104 String AlbumDirCache = String.Empty; 105 105 if (server != null) 106 106 { 107 CategoryDirCache = Path.Combine(server.BasePath.FullName, CatgeoryId.Replace("/", "_"));107 AlbumDirCache = Path.Combine(server.BasePath.FullName, CatgeoryId.Replace("/", "_")); 108 108 } 109 109 else 110 110 { 111 throw new ApplicationException ("Current server not set before using category");112 } 113 114 return CategoryDirCache;111 throw new ApplicationException ("Current server not set before using Album"); 112 } 113 114 return AlbumDirCache; 115 115 } 116 116 … … 147 147 public void UnsetCurrentServer() 148 148 { 149 _current Category= null;149 _currentAlbum = null; 150 150 _currentServer = null; 151 151 } … … 171 171 server.ServeurUrl = new Uri(serveurUri); 172 172 server.BasePath = new DirectoryInfo(currentserverDir); 173 server. Categories = new CategoryDictionnary();173 server.Albums = new AlbumDictionnary(); 174 174 _aServerDictionnary.Add(serveurUri, server); 175 175 _currentServer = server; … … 180 180 //Create it 181 181 Directory.CreateDirectory(currentserverDir); 182 _currentServer. Categories.Clear();183 } 184 } 185 } 186 187 public void SetCurrent Category(String CategorieId)182 _currentServer.Albums.Clear(); 183 } 184 } 185 } 186 187 public void SetCurrentAlbum(String AlbumId) 188 188 { 189 189 if (_currentServer != null) … … 191 191 lock (_lock) 192 192 { 193 String currents CategoryDir = BuildCategoryDirCache(_currentServer, CategorieId);194 if (_currentServer. Categories.ContainsKey(CategorieId))195 { 196 _current Category = _currentServer.Categories[CategorieId];193 String currentsAlbumDir = BuildAlbumDirCache(_currentServer, AlbumId); 194 if (_currentServer.Albums.ContainsKey(AlbumId)) 195 { 196 _currentAlbum = _currentServer.Albums[AlbumId]; 197 197 } 198 198 else 199 199 { 200 CategoryDictionnaryItem category = new CategoryDictionnaryItem();201 category.BasePath = new DirectoryInfo(currentsCategoryDir);202 category.CategorieId = CategorieId;203 _currentServer. Categories.Add(CategorieId, category);204 _current Category = category;205 } 206 207 if (!Directory.Exists(currents CategoryDir))200 AlbumDictionnaryItem Album = new AlbumDictionnaryItem(); 201 Album.BasePath = new DirectoryInfo(currentsAlbumDir); 202 Album.AlbumId = AlbumId; 203 _currentServer.Albums.Add(AlbumId, Album); 204 _currentAlbum = Album; 205 } 206 207 if (!Directory.Exists(currentsAlbumDir)) 208 208 { 209 209 //Create it 210 Directory.CreateDirectory(currents CategoryDir);210 Directory.CreateDirectory(currentsAlbumDir); 211 211 } 212 212 } … … 214 214 else 215 215 { 216 throw new ApplicationException("Current server not set before using category");216 throw new ApplicationException("Current server not set before using Album"); 217 217 } 218 218 } … … 226 226 } 227 227 228 if (_current Category!= null)229 { 230 String localDir = Path.Combine(_current Category.BasePath.FullName, strImageType);228 if (_currentAlbum != null) 229 { 230 String localDir = Path.Combine(_currentAlbum.BasePath.FullName, strImageType); 231 231 if (!Directory.Exists(localDir)) 232 232 { … … 277 277 else 278 278 { 279 throw new ApplicationException("Current categorynot set before using image cache.");279 throw new ApplicationException("Current Album not set before using image cache."); 280 280 } 281 281 }
Note: See TracChangeset
for help on using the changeset viewer.