/// <summary> /// Loads the actual image data of the banner /// </summary> /// <param name="replaceOld">If true will replace an old image (if one exists already)</param> /// <returns>true if the banner could be loaded successfully, false otherwise</returns> public async Task <bool> LoadBannerAsync(bool replaceOld, string cachePath) { bool wasLoaded = IsLoaded;//is the banner already loaded at this point await _bannerLoadingLock.WaitAsync().ConfigureAwait(false); try {//if another thread is already loading THIS banner, the lock will block this thread until the other thread //has finished loading if (!wasLoaded && !replaceOld && IsLoaded) {////the banner has already been loaded from a different thread and we don't want to replace it return(false); } BannerLoading = true; if (BannerPath.Equals("")) { return(false); } try { Image img = null; String cacheName = CreateCacheName(Id, BannerPath); if (CacheProvider != null && CacheProvider.Initialised) {//try to load the image from cache first img = CacheProvider.LoadImageFromCache(SeriesId, cachePath, cacheName); } if (img == null) {//couldn't load image from cache -> load it from http://thetvdb.com img = await LoadImageAsync(TvdbLinkCreator.CreateBannerLink(BannerPath)).ConfigureAwait(false); if (img != null && CacheProvider != null && CacheProvider.Initialised) {//store the image to cache CacheProvider.SaveToCache(img, SeriesId, cachePath, cacheName); } } if (img != null) {//image was successfully loaded BannerImage = img; IsLoaded = true; BannerLoading = false; return(true); } } catch (WebException ex) { Log.Error("Couldn't load banner " + BannerPath, ex); } IsLoaded = false; BannerLoading = false; return(false); } finally { _bannerLoadingLock.Release(); } }
/// <summary> /// Load the thumb from tvdb /// </summary> /// <param name="_replaceOld">if true, an existing banner will be replaced, /// if false the banner will only be loaded if there is no existing banner</param> /// <returns>true if the loading completed sccessfully, false otherwise</returns> public bool LoadThumb(bool _replaceOld) { bool wasLoaded = m_thumbLoaded;//is the banner already loaded at this point lock (m_thumbLoadingLock) {//if another thread is already loading THIS banner, the lock will block this thread until the other thread //has finished loading if (!wasLoaded && !_replaceOld && m_thumbLoaded) {////the banner has already been loaded from a different thread and we don't want to replace it return(false); } m_thumbLoading = true; /* * every banner (except actors) has a cached thumbnail on tvdb... The path to the thumbnail * is only given for fanart banners via the api, however every thumbnail path is "_cache/" + image_path * so if no path for the thumbnail is given, it is assumed that there is a thumbnail at that location */ if (m_thumbPath == null && (BannerPath != null || BannerPath.Equals(""))) { m_thumbPath = String.Concat("_cache/", BannerPath); } if (m_thumbPath != null) { try { Image img = null; String cacheName = CreateCacheName(m_thumbPath, true); if (this.CacheProvider != null && this.CacheProvider.Initialised) {//try to load the image from cache first img = this.CacheProvider.LoadImageFromCache(this.SeriesId, cacheName); } if (img == null) { img = LoadImage(TvdbLinkCreator.CreateBannerLink(m_thumbPath)); if (img != null && this.CacheProvider != null && this.CacheProvider.Initialised) {//store the image to cache this.CacheProvider.SaveToCache(img, this.SeriesId, cacheName); } } if (img != null) { m_bannerThumb = img; m_thumbLoaded = true; m_thumbLoading = false; return(true); } } catch (WebException ex) { Log.Error("Couldn't load banner thumb" + m_thumbPath, ex); } } m_thumbLoaded = false; m_thumbLoading = false; return(false); } }
public bool Equals(GroupV2 input) { if (input == null) { return(false); } return (( GroupId == input.GroupId || (GroupId.Equals(input.GroupId)) ) && ( Name == input.Name || (Name != null && Name.Equals(input.Name)) ) && ( GroupType == input.GroupType || (GroupType != null && GroupType.Equals(input.GroupType)) ) && ( MembershipIdCreated == input.MembershipIdCreated || (MembershipIdCreated.Equals(input.MembershipIdCreated)) ) && ( CreationDate == input.CreationDate || (CreationDate != null && CreationDate.Equals(input.CreationDate)) ) && ( ModificationDate == input.ModificationDate || (ModificationDate != null && ModificationDate.Equals(input.ModificationDate)) ) && ( About == input.About || (About != null && About.Equals(input.About)) ) && ( Tags == input.Tags || (Tags != null && Tags.SequenceEqual(input.Tags)) ) && ( MemberCount == input.MemberCount || (MemberCount.Equals(input.MemberCount)) ) && ( IsPublic == input.IsPublic || (IsPublic != null && IsPublic.Equals(input.IsPublic)) ) && ( IsPublicTopicAdminOnly == input.IsPublicTopicAdminOnly || (IsPublicTopicAdminOnly != null && IsPublicTopicAdminOnly.Equals(input.IsPublicTopicAdminOnly)) ) && ( Motto == input.Motto || (Motto != null && Motto.Equals(input.Motto)) ) && ( AllowChat == input.AllowChat || (AllowChat != null && AllowChat.Equals(input.AllowChat)) ) && ( IsDefaultPostPublic == input.IsDefaultPostPublic || (IsDefaultPostPublic != null && IsDefaultPostPublic.Equals(input.IsDefaultPostPublic)) ) && ( ChatSecurity == input.ChatSecurity || (ChatSecurity != null && ChatSecurity.Equals(input.ChatSecurity)) ) && ( Locale == input.Locale || (Locale != null && Locale.Equals(input.Locale)) ) && ( AvatarImageIndex == input.AvatarImageIndex || (AvatarImageIndex.Equals(input.AvatarImageIndex)) ) && ( Homepage == input.Homepage || (Homepage != null && Homepage.Equals(input.Homepage)) ) && ( MembershipOption == input.MembershipOption || (MembershipOption != null && MembershipOption.Equals(input.MembershipOption)) ) && ( DefaultPublicity == input.DefaultPublicity || (DefaultPublicity != null && DefaultPublicity.Equals(input.DefaultPublicity)) ) && ( Theme == input.Theme || (Theme != null && Theme.Equals(input.Theme)) ) && ( BannerPath == input.BannerPath || (BannerPath != null && BannerPath.Equals(input.BannerPath)) ) && ( AvatarPath == input.AvatarPath || (AvatarPath != null && AvatarPath.Equals(input.AvatarPath)) ) && ( ConversationId == input.ConversationId || (ConversationId.Equals(input.ConversationId)) ) && ( EnableInvitationMessagingForAdmins == input.EnableInvitationMessagingForAdmins || (EnableInvitationMessagingForAdmins != null && EnableInvitationMessagingForAdmins.Equals(input.EnableInvitationMessagingForAdmins)) ) && ( BanExpireDate == input.BanExpireDate || (BanExpireDate != null && BanExpireDate.Equals(input.BanExpireDate)) ) && ( Features == input.Features || (Features != null && Features.Equals(input.Features)) ) && ( ClanInfo == input.ClanInfo || (ClanInfo != null && ClanInfo.Equals(input.ClanInfo)) )); }
/// <summary> /// Load the thumb from tvdb /// </summary> /// <param name="replaceOld">if true, an existing banner will be replaced, /// if false the banner will only be loaded if there is no existing banner</param> /// <returns>true if the loading completed sccessfully, false otherwise</returns> public async Task <bool> LoadThumbAsync(bool replaceOld) { bool wasLoaded = IsThumbLoaded;//is the banner already loaded at this point await _thumbLoadingLock.WaitAsync().ConfigureAwait(false); try {//if another thread is already loading THIS banner, the lock will block this thread until the other thread //has finished loading if (!wasLoaded && !replaceOld && IsThumbLoaded) {////the banner has already been loaded from a different thread and we don't want to replace it return(false); } ThumbLoading = true; /* * every banner (except actors) has a cached thumbnail on tvdb... The path to the thumbnail * is only given for fanart banners via the api, however every thumbnail path is "_cache/" + image_path * so if no path for the thumbnail is given, it is assumed that there is a thumbnail at that location */ if (ThumbPath == null && (BannerPath != null || BannerPath.Equals(""))) { ThumbPath = String.Concat("_cache/", BannerPath); } if (ThumbPath != null) { try { Image img = null; String cacheName = CreateCacheName(Id, ThumbPath); if (CacheProvider != null && CacheProvider.Initialised) {//try to load the image from cache first img = CacheProvider.LoadImageFromCache(SeriesId, CachePath, cacheName); } if (img == null) { img = await LoadImageAsync(TvdbLinkCreator.CreateBannerLink(ThumbPath)).ConfigureAwait(false); if (img != null && CacheProvider != null && CacheProvider.Initialised) {//store the image to cache CacheProvider.SaveToCache(img, SeriesId, CachePath, cacheName); } } if (img != null) { ThumbImage = img; IsThumbLoaded = true; ThumbLoading = false; return(true); } } catch (WebException ex) { Log.Error("Couldn't load banner thumb" + ThumbPath, ex); } } IsThumbLoaded = false; ThumbLoading = false; return(false); } finally { _thumbLoadingLock.Release(); } }