@@ -13,9 +13,9 @@ Imports UState = SCrawler.API.Base.UserMedia.States
1313Namespace API.Base
1414 Friend MustInherit Class UserDataBase : Implements IUserData
1515 Friend Const UserFileAppender As String = "User"
16- Friend Event OnPictureUpdated As IUserData.OnPictureUpdatedEventHandler Implements IUserData.OnPictureUpdated
17- Protected Sub Raise_OnPictureUpdated ()
18- RaiseEvent OnPictureUpdated (Me )
16+ Friend Event OnUserUpdated As IUserData.OnUserUpdatedEventHandler Implements IUserData.OnUserUpdated
17+ Protected Sub Raise_OnUserUpdated ()
18+ RaiseEvent OnUserUpdated (Me )
1919 End Sub
2020# Region "Collection buttons"
2121 Friend WithEvents BTT_CONTEXT_DOWN As ToolStripMenuItem
@@ -43,6 +43,8 @@ Namespace API.Base
4343 Private Const Name_Site As String = "Site"
4444 Private Const Name_IsChannel As String = "IsChannel"
4545 Private Const Name_UserName As String = "UserName"
46+ Private Const Name_UserExists As String = "UserExists"
47+ Private Const Name_UserSuspended As String = "UserSuspended"
4648 Private Const Name_FriendlyName As String = "FriendlyName"
4749 Private Const Name_UserID As String = "UserID"
4850 Private Const Name_Description As String = "Description"
@@ -76,6 +78,10 @@ Namespace API.Base
7678# Region "Declarations"
7779 Friend MustOverride Property Site As Sites Implements IContentProvider.Site
7880 Friend User As UserInfo
81+ Protected Const NonExistendUserHelp As String = "404"
82+ Protected Const SuspendedUserHelp As String = "403"
83+ Friend Overridable Property UserExists As Boolean = True Implements IUserData.Exists
84+ Friend Overridable Property UserSuspended As Boolean = False Implements IUserData.Suspended
7985 Friend Overridable Property Name As String Implements IContentProvider.Name
8086 Get
8187 Return User.Name
@@ -436,10 +442,11 @@ BlockNullPicture:
436442 If MyFile.Exists Then
437443 FileExists = True
438444 Using x As New XmlFile(MyFile) With {.XmlReadOnly = True }
439- x.DefaultsLoading( False )
440445 User.Site = Site
441446 Site = x.Value(Name_Site).FromXML( Of Integer )( 0 )
442447 User.Name = x.Value(Name_UserName)
448+ UserExists = x.Value(Name_UserExists).FromXML( Of Boolean )( True )
449+ UserSuspended = x.Value(Name_UserSuspended).FromXML( Of Boolean )( False )
443450 ID = x.Value(Name_UserID)
444451 FriendlyName = x.Value(Name_FriendlyName)
445452 UserDescription = x.Value(Name_Description)
@@ -470,6 +477,8 @@ BlockNullPicture:
470477 Using x As New XmlFile With {.Name = "User" }
471478 x.Add(Name_Site, CInt (Site))
472479 x.Add(Name_UserName, User.Name)
480+ x.Add(Name_UserExists, UserExists.BoolToInteger)
481+ x.Add(Name_UserSuspended, UserSuspended.BoolToInteger)
473482 x.Add(Name_UserID, ID)
474483 x.Add(Name_FriendlyName, FriendlyName)
475484 x.Add(Name_Description, UserDescription)
@@ -508,9 +517,8 @@ BlockNullPicture:
508517 Private Overloads Sub LoadContentInformation( ByRef _CLIST As List( Of UserMedia), ByVal f As SFile)
509518 Try
510519 If Not f.Exists Then Exit Sub
511- Using x As New XmlFile(f, ProtectionLevels .All, False ) With {.XmlReadOnly = True , .AllowSameNames = True }
520+ Using x As New XmlFile(f, Protector.Modes .All, False ) With {.XmlReadOnly = True , .AllowSameNames = True }
512521 x.LoadData()
513- x.DefaultsLoading( False )
514522 If x.Count > 0 Then
515523 Dim fs$ = MyFile.CutPath.PathWithSeparator
516524 Dim gfn As Func( Of String , String ) = Function ( ByVal Input As String ) As String
@@ -589,11 +597,17 @@ BlockNullPicture:
589597# End Region
590598# Region "Download functions and options"
591599 Friend Overridable Property DownloadTopCount As Integer ? = Nothing Implements IUserData.DownloadTopCount
600+ Protected Responser As PersonalUtilities.Tools.WEB.Response
592601 Friend Overridable Sub DownloadData( ByVal Token As CancellationToken) Implements IContentProvider.DownloadData
593602 Dim Canceled As Boolean = False
594603 Try
595604 UpdateDataFiles()
605+ If Not Responser Is Nothing Then Responser.Dispose()
606+ Responser = New PersonalUtilities.Tools.WEB.Response
607+ Responser.Copy(Settings.Site(Site).Responser)
596608 Dim UpPic As Boolean = Settings.ViewModeIsPicture AndAlso GetPicture( False ) Is Nothing
609+ Dim sEnvir() As Boolean = {UserExists, UserSuspended}
610+ Dim EnvirChanged As Func( Of Boolean ) = Function () Not sEnvir( 0 ) = UserExists Or Not sEnvir( 1 ) = UserSuspended
597611 _DownloadedPicturesSession = 0
598612 _DownloadedVideosSession = 0
599613 _TempMediaList.Clear()
@@ -623,7 +637,7 @@ BlockNullPicture:
623637 _ContentList.ListAddList(_ContentNew.Where( Function (c) c.State = UState.Downloaded), LNC)
624638 _CountPictures = _ContentList.LongCount( Function (c) c.Type = UserMedia.Types.Picture)
625639 _CountVideo = _ContentList.LongCount( Function (c) c.Type = UserMedia.Types.Video)
626- If DownloadedPictures + DownloadedVideos > 0 Then
640+ If DownloadedPictures + DownloadedVideos > 0 Or EnvirChanged.Invoke Then
627641 If __SaveData Then
628642 LastUpdated = Now
629643 If Labels.Contains(LabelsKeeper.NoParsedUser) Then Labels.Remove(LabelsKeeper.NoParsedUser)
@@ -634,12 +648,13 @@ BlockNullPicture:
634648 _ContentList.Clear()
635649 CreatedByChannel = False
636650 End If
651+ If Not UserExists Then ReadyForDownload = False
637652 UpdateUserInformation()
638653 End If
639654 ThrowIfDisposed()
640655 _DownloadedPicturesTotal += _DownloadedPicturesSession
641656 _DownloadedVideosTotal += _DownloadedVideosSession
642- If UpPic Then Raise_OnPictureUpdated ()
657+ If UpPic Or EnvirChanged.Invoke Then Raise_OnUserUpdated ()
643658 Catch oex As OperationCanceledException When Token.IsCancellationRequested
644659 MyMainLOG = $"{Site} - {Name}: downloading canceled"
645660 Canceled = True
@@ -649,6 +664,7 @@ BlockNullPicture:
649664 LogError(ex, "downloading data error" )
650665 HasError = True
651666 Finally
667+ If Not Responser Is Nothing Then Responser.Dispose() : Responser = Nothing
652668 If Not Canceled Then _DataParsed = True ': LastUpdated = Now
653669 _ContentNew.Clear()
654670 DownloadTopCount = Nothing
@@ -927,6 +943,7 @@ BlockNullPicture:
927943 _ContentNew.Clear()
928944 _TempMediaList.Clear()
929945 _TempPostsList.Clear()
946+ If Not Responser Is Nothing Then Responser.Dispose()
930947 If Not BTT_CONTEXT_DOWN Is Nothing Then BTT_CONTEXT_DOWN.Dispose()
931948 If Not BTT_CONTEXT_EDIT Is Nothing Then BTT_CONTEXT_EDIT.Dispose()
932949 If Not BTT_CONTEXT_DELETE Is Nothing Then BTT_CONTEXT_DELETE.Dispose()
@@ -959,7 +976,7 @@ BlockNullPicture:
959976 Sub DownloadData( ByVal Token As CancellationToken)
960977 End Interface
961978 Friend Interface IUserData : Inherits IContentProvider, IComparable( Of UserDataBase), IComparable, IEquatable( Of UserDataBase), IDisposable
962- Event OnPictureUpdated (ByVal User As IUserData)
979+ Event OnUserUpdated (ByVal User As IUserData)
963980 Property ParseUserMediaOnly As Boolean
964981# Region "Images"
965982 Function GetPicture() As Image
@@ -972,6 +989,8 @@ BlockNullPicture:
972989 ReadOnly Property Labels As List( Of String )
973990# End Region
974991 ReadOnly Property IsChannel As Boolean
992+ Property Exists As Boolean
993+ Property Suspended As Boolean
975994 Property ReadyForDownload As Boolean
976995 Property [File] As SFile
977996 Property FileExists As Boolean
0 commit comments