@@ -13,9 +13,9 @@ Imports UState = SCrawler.API.Base.UserMedia.States
13
13
Namespace API.Base
14
14
Friend MustInherit Class UserDataBase : Implements IUserData
15
15
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 )
19
19
End Sub
20
20
# Region "Collection buttons"
21
21
Friend WithEvents BTT_CONTEXT_DOWN As ToolStripMenuItem
@@ -43,6 +43,8 @@ Namespace API.Base
43
43
Private Const Name_Site As String = "Site"
44
44
Private Const Name_IsChannel As String = "IsChannel"
45
45
Private Const Name_UserName As String = "UserName"
46
+ Private Const Name_UserExists As String = "UserExists"
47
+ Private Const Name_UserSuspended As String = "UserSuspended"
46
48
Private Const Name_FriendlyName As String = "FriendlyName"
47
49
Private Const Name_UserID As String = "UserID"
48
50
Private Const Name_Description As String = "Description"
@@ -76,6 +78,10 @@ Namespace API.Base
76
78
# Region "Declarations"
77
79
Friend MustOverride Property Site As Sites Implements IContentProvider.Site
78
80
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
79
85
Friend Overridable Property Name As String Implements IContentProvider.Name
80
86
Get
81
87
Return User.Name
@@ -436,10 +442,11 @@ BlockNullPicture:
436
442
If MyFile.Exists Then
437
443
FileExists = True
438
444
Using x As New XmlFile(MyFile) With {.XmlReadOnly = True }
439
- x.DefaultsLoading( False )
440
445
User.Site = Site
441
446
Site = x.Value(Name_Site).FromXML( Of Integer )( 0 )
442
447
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 )
443
450
ID = x.Value(Name_UserID)
444
451
FriendlyName = x.Value(Name_FriendlyName)
445
452
UserDescription = x.Value(Name_Description)
@@ -470,6 +477,8 @@ BlockNullPicture:
470
477
Using x As New XmlFile With {.Name = "User" }
471
478
x.Add(Name_Site, CInt (Site))
472
479
x.Add(Name_UserName, User.Name)
480
+ x.Add(Name_UserExists, UserExists.BoolToInteger)
481
+ x.Add(Name_UserSuspended, UserSuspended.BoolToInteger)
473
482
x.Add(Name_UserID, ID)
474
483
x.Add(Name_FriendlyName, FriendlyName)
475
484
x.Add(Name_Description, UserDescription)
@@ -508,9 +517,8 @@ BlockNullPicture:
508
517
Private Overloads Sub LoadContentInformation( ByRef _CLIST As List( Of UserMedia), ByVal f As SFile)
509
518
Try
510
519
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 }
512
521
x.LoadData()
513
- x.DefaultsLoading( False )
514
522
If x.Count > 0 Then
515
523
Dim fs$ = MyFile.CutPath.PathWithSeparator
516
524
Dim gfn As Func( Of String , String ) = Function ( ByVal Input As String ) As String
@@ -589,11 +597,17 @@ BlockNullPicture:
589
597
# End Region
590
598
# Region "Download functions and options"
591
599
Friend Overridable Property DownloadTopCount As Integer ? = Nothing Implements IUserData.DownloadTopCount
600
+ Protected Responser As PersonalUtilities.Tools.WEB.Response
592
601
Friend Overridable Sub DownloadData( ByVal Token As CancellationToken) Implements IContentProvider.DownloadData
593
602
Dim Canceled As Boolean = False
594
603
Try
595
604
UpdateDataFiles()
605
+ If Not Responser Is Nothing Then Responser.Dispose()
606
+ Responser = New PersonalUtilities.Tools.WEB.Response
607
+ Responser.Copy(Settings.Site(Site).Responser)
596
608
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
597
611
_DownloadedPicturesSession = 0
598
612
_DownloadedVideosSession = 0
599
613
_TempMediaList.Clear()
@@ -623,7 +637,7 @@ BlockNullPicture:
623
637
_ContentList.ListAddList(_ContentNew.Where( Function (c) c.State = UState.Downloaded), LNC)
624
638
_CountPictures = _ContentList.LongCount( Function (c) c.Type = UserMedia.Types.Picture)
625
639
_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
627
641
If __SaveData Then
628
642
LastUpdated = Now
629
643
If Labels.Contains(LabelsKeeper.NoParsedUser) Then Labels.Remove(LabelsKeeper.NoParsedUser)
@@ -634,12 +648,13 @@ BlockNullPicture:
634
648
_ContentList.Clear()
635
649
CreatedByChannel = False
636
650
End If
651
+ If Not UserExists Then ReadyForDownload = False
637
652
UpdateUserInformation()
638
653
End If
639
654
ThrowIfDisposed()
640
655
_DownloadedPicturesTotal += _DownloadedPicturesSession
641
656
_DownloadedVideosTotal += _DownloadedVideosSession
642
- If UpPic Then Raise_OnPictureUpdated ()
657
+ If UpPic Or EnvirChanged.Invoke Then Raise_OnUserUpdated ()
643
658
Catch oex As OperationCanceledException When Token.IsCancellationRequested
644
659
MyMainLOG = $"{Site} - {Name}: downloading canceled"
645
660
Canceled = True
@@ -649,6 +664,7 @@ BlockNullPicture:
649
664
LogError(ex, "downloading data error" )
650
665
HasError = True
651
666
Finally
667
+ If Not Responser Is Nothing Then Responser.Dispose() : Responser = Nothing
652
668
If Not Canceled Then _DataParsed = True ': LastUpdated = Now
653
669
_ContentNew.Clear()
654
670
DownloadTopCount = Nothing
@@ -927,6 +943,7 @@ BlockNullPicture:
927
943
_ContentNew.Clear()
928
944
_TempMediaList.Clear()
929
945
_TempPostsList.Clear()
946
+ If Not Responser Is Nothing Then Responser.Dispose()
930
947
If Not BTT_CONTEXT_DOWN Is Nothing Then BTT_CONTEXT_DOWN.Dispose()
931
948
If Not BTT_CONTEXT_EDIT Is Nothing Then BTT_CONTEXT_EDIT.Dispose()
932
949
If Not BTT_CONTEXT_DELETE Is Nothing Then BTT_CONTEXT_DELETE.Dispose()
@@ -959,7 +976,7 @@ BlockNullPicture:
959
976
Sub DownloadData( ByVal Token As CancellationToken)
960
977
End Interface
961
978
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)
963
980
Property ParseUserMediaOnly As Boolean
964
981
# Region "Images"
965
982
Function GetPicture() As Image
@@ -972,6 +989,8 @@ BlockNullPicture:
972
989
ReadOnly Property Labels As List( Of String )
973
990
# End Region
974
991
ReadOnly Property IsChannel As Boolean
992
+ Property Exists As Boolean
993
+ Property Suspended As Boolean
975
994
Property ReadyForDownload As Boolean
976
995
Property [File] As SFile
977
996
Property FileExists As Boolean
0 commit comments