Ignore:
Timestamp:
Oct 3, 2011, 5:09:51 PM (13 years ago)
Author:
bayral
Message:

rename category to Albums

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/PiwigoLib/PiwigoWpf/Services/ImageCacheManager.cs

    r11926 r12336  
    6464            #region DTO
    6565            // local DTO
    66             internal class CategoryDictionnaryItem
     66            internal class AlbumDictionnaryItem
    6767            {
    6868                internal DirectoryInfo BasePath;
    69                 internal String CategorieId;
     69                internal String AlbumId;
    7070            };
    7171
    72             internal class CategoryDictionnary : SortedDictionary<String, CategoryDictionnaryItem> { };
     72            internal class AlbumDictionnary : SortedDictionary<String, AlbumDictionnaryItem> { };
    7373
    7474            internal class ServerDictionnaryItem
    7575            {
    7676                internal DirectoryInfo BasePath;
    77                 internal CategoryDictionnary Categories;
     77                internal AlbumDictionnary Albums;
    7878                internal Uri ServeurUrl;
    7979            };
     
    8686            internal ServerDictionnary _aServerDictionnary;
    8787            internal ServerDictionnaryItem _currentServer;
    88             internal CategoryDictionnaryItem _currentCategory;
     88            internal AlbumDictionnaryItem _currentAlbum;
    8989
    9090            #endregion DTO
     
    100100            }
    101101           
    102             static private String BuildCategoryDirCache(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;
    105105                if (server != null)
    106106                {
    107                     CategoryDirCache = Path.Combine(server.BasePath.FullName, CatgeoryId.Replace("/", "_"));
     107                    AlbumDirCache = Path.Combine(server.BasePath.FullName, CatgeoryId.Replace("/", "_"));
    108108                }
    109109                else
    110110                {
    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;
    115115            }
    116116
     
    147147            public void UnsetCurrentServer()
    148148            {
    149                 _currentCategory = null;
     149                _currentAlbum = null;
    150150                _currentServer = null;
    151151            }
     
    171171                        server.ServeurUrl = new Uri(serveurUri);
    172172                        server.BasePath = new DirectoryInfo(currentserverDir);
    173                         server.Categories = new CategoryDictionnary();
     173                        server.Albums = new AlbumDictionnary();
    174174                        _aServerDictionnary.Add(serveurUri, server);
    175175                        _currentServer = server;
     
    180180                        //Create it
    181181                        Directory.CreateDirectory(currentserverDir);
    182                         _currentServer.Categories.Clear();
    183                     }
    184                 }
    185             }
    186 
    187             public void SetCurrentCategory(String CategorieId)
     182                        _currentServer.Albums.Clear();
     183                    }
     184                }
     185            }
     186
     187            public void SetCurrentAlbum(String AlbumId)
    188188            {
    189189                if (_currentServer != null)
     
    191191                    lock (_lock)
    192192                    {
    193                         String currentsCategoryDir = BuildCategoryDirCache(_currentServer, CategorieId);
    194                         if (_currentServer.Categories.ContainsKey(CategorieId))
    195                         {
    196                             _currentCategory = _currentServer.Categories[CategorieId];
     193                        String currentsAlbumDir = BuildAlbumDirCache(_currentServer, AlbumId);
     194                        if (_currentServer.Albums.ContainsKey(AlbumId))
     195                        {
     196                            _currentAlbum = _currentServer.Albums[AlbumId];
    197197                        }
    198198                        else
    199199                        {
    200                             CategoryDictionnaryItem category = new CategoryDictionnaryItem();
    201                             category.BasePath = new DirectoryInfo(currentsCategoryDir);
    202                             category.CategorieId = CategorieId;
    203                             _currentServer.Categories.Add(CategorieId, category);
    204                             _currentCategory = category;
    205                         }
    206 
    207                         if (!Directory.Exists(currentsCategoryDir))
     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))
    208208                        {
    209209                            //Create it
    210                             Directory.CreateDirectory(currentsCategoryDir);
     210                            Directory.CreateDirectory(currentsAlbumDir);
    211211                        }
    212212                    }
     
    214214                else
    215215                {
    216                     throw new ApplicationException("Current server not set before using category");
     216                    throw new ApplicationException("Current server not set before using Album");
    217217                }
    218218            }
     
    226226                    }
    227227
    228                     if (_currentCategory != null)
    229                     {
    230                         String localDir = Path.Combine(_currentCategory.BasePath.FullName, strImageType);
     228                    if (_currentAlbum != null)
     229                    {
     230                        String localDir = Path.Combine(_currentAlbum.BasePath.FullName, strImageType);
    231231                        if (!Directory.Exists(localDir))
    232232                        {
     
    277277                    else
    278278                    {
    279                         throw new ApplicationException("Current category not set before using image cache.");
     279                        throw new ApplicationException("Current Album not set before using image cache.");
    280280                    }
    281281                }
Note: See TracChangeset for help on using the changeset viewer.