Changeset 1279

Show
Ignore:
Timestamp:
1/31/2010 4:41:08 AM (6 weeks ago)
Author:
vessper
Message:

31/01/2010 (1.14.0.1279)


- Core: Added threaded code for the EveMail? retrieval functions to avoid lockup
- Core: Added EveMail? download status messages

Location:
trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/EveHQ.Core/EveMail.vb

    r1278 r1279  
    77    Dim MailTimeFormat As String = "yyyy-MM-dd HH:mm:ss" 
    88    Dim culture As System.Globalization.CultureInfo = New System.Globalization.CultureInfo("en-GB") 
     9 
     10    Public Event MailProgress(ByVal Status As String) 
    911 
    1012    Public Sub GetMail() 
     
    3032                    Dim mAccount As EveHQ.Core.EveAccount = CType(EveHQ.Core.HQ.EveHQSettings.Accounts.Item(accountName), Core.EveAccount) 
    3133                    ' Add in the data for mailing lists 
     34                    RaiseEvent MailProgress("Processing Mailing Lists for " & mPilot.Name & "...") 
    3235                    Call EveHQ.Core.DataFunctions.WriteMailingListIDsToDatabase(mPilot) 
    3336                    ' Make a call to the EveHQ.Core.API to fetch the EveMail 
     37                    RaiseEvent MailProgress("Fetching EveMails for " & mPilot.Name & "...") 
    3438                    Dim mailXML As New XmlDocument 
    3539                    mailXML = EveHQ.Core.EveAPI.GetAPIXML(EveHQ.Core.EveAPI.APIRequest.MailMessages, mAccount, mPilot.ID, EveHQ.Core.EveAPI.APIReturnMethod.ReturnStandard) 
     
    7478 
    7579        ' Stage 3: Check the messages which have already been posted 
     80        RaiseEvent MailProgress("Checking for new EveMails for all characters...") 
    7681        Dim existingMails As New ArrayList 
    7782        Dim strExistingMails As New StringBuilder 
     
    9398 
    9499        ' Stage 4: Post all new messages to the database 
     100        RaiseEvent MailProgress("Posting new EveMails to the database...") 
    95101        Dim NewMails As New ArrayList 
    96102        Dim strInsert As String = "INSERT INTO eveMail (messageKey, messageID, originatorID, senderID, sentDate, title, toCorpOrAllianceID, toCharacterIDs, toListIDs, readMail) VALUES " 
     
    128134 
    129135        ' Stage 5: Get all the IDs and parse them 
     136        RaiseEvent MailProgress("Posting EveMail IDs to the database...") 
    130137        Dim IDs As New ArrayList 
    131138        For Each cMail As EveHQ.Core.EveMailMessage In Mails.Values 
     
    143150        ' Add in the Mailing List IDs 
    144151        For Each cMail As EveHQ.Core.EveMailMessage In Mails.Values 
    145             EveHQ.Core.DataFunctions.ParseIDs(IDs, cMail.ToCorpAllianceIDs) 
     152            EveHQ.Core.DataFunctions.ParseIDs(IDs, cMail.ToListIDs) 
    146153        Next 
    147154 
    148155        ' Send E-mail notification of new mails if required 
    149156        If EveHQ.Core.HQ.EveHQSettings.NotifyEveMail = True And NewMails.Count > 0 Then 
     157            RaiseEvent MailProgress("Sending notification of new mails...") 
    150158            Call SendEmailForNewEveMails(NewMails, IDs) 
    151159        End If 
     
    174182                    Dim mAccount As EveHQ.Core.EveAccount = CType(EveHQ.Core.HQ.EveHQSettings.Accounts.Item(accountName), Core.EveAccount) 
    175183                    ' Make a call to the EveHQ.Core.API to fetch the EveMail 
     184                    RaiseEvent MailProgress("Fetching Eve Notifications for " & mPilot.Name & "...") 
    176185                    Dim mailXML As New XmlDocument 
    177186                    mailXML = EveHQ.Core.EveAPI.GetAPIXML(EveHQ.Core.EveAPI.APIRequest.Notifications, mAccount, mPilot.ID, EveHQ.Core.EveAPI.APIReturnMethod.ReturnStandard) 
     
    213222 
    214223        ' Stage 3: Check the messages which have already been posted 
     224        RaiseEvent MailProgress("Checking for new Eve Notifications for all characters...") 
    215225        Dim existingMails As New ArrayList 
    216226        Dim strExistingMails As New StringBuilder 
     
    232242 
    233243        ' Stage 4: Post all new messages to the database 
     244        RaiseEvent MailProgress("Posting new Eve Notifications to the database...") 
    234245        Dim newNotifys As New ArrayList 
    235246        Dim strInsert As String = "INSERT INTO eveNotifications (messageKey, messageID, originatorID, senderID, typeID, sentDate, readMail) VALUES " 
     
    265276 
    266277        ' Stage 5: Get all the IDs and parse them 
     278        RaiseEvent MailProgress("Posting Eve Notification IDs to the database...") 
    267279        Dim IDs As New ArrayList 
    268280        For Each cNotice As EveHQ.Core.EveNotification In Notices.Values 
     
    276288        ' Send E-mail notification of new mails if required 
    277289        If EveHQ.Core.HQ.EveHQSettings.NotifyEveMail = True And newNotifys.Count > 0 Then 
     290            RaiseEvent MailProgress("Sending notification of new notices...") 
    278291            Call SendEmailForNewEveNotifications(newNotifys, IDs) 
    279292        End If 
  • trunk/EveHQ/Forms/frmMail.vb

    r1278 r1279  
    77    Dim displayPilot As New EveHQ.Core.Pilot 
    88    Dim cDisplayPilotName As String = "" 
     9    Dim mailStatus As String = "" 
    910 
    1011    Public Property DisplayPilotName() As String 
     
    7677 
    7778    Private Sub btnDownloadMail_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDownloadMail.Click 
    78  
    79         Me.Cursor = Cursors.WaitCursor 
    80  
     79        Threading.ThreadPool.QueueUserWorkItem(AddressOf MailUpdateThread) 
     80    End Sub 
     81 
     82    Private Sub MailUpdateThread(ByVal state As Object) 
    8183        Dim myMail As New EveHQ.Core.EveMail 
     84        AddHandler myMail.MailProgress, AddressOf DisplayMailProgress 
     85        btnDownloadMail.Enabled = False 
    8286        Call myMail.GetMail() 
    83  
     87        Me.Invoke(New MethodInvoker(AddressOf MailUpdateCompleted)) 
     88    End Sub 
     89 
     90    Private Sub DisplayMailProgress(ByVal Status As String) 
     91        mailStatus = Status 
     92        Me.Invoke(New MethodInvoker(AddressOf UpdateMailProgress)) 
     93    End Sub 
     94 
     95    Private Sub UpdateMailProgress() 
     96        lblDownloadMailStatus.Text = mailStatus 
     97    End Sub 
     98 
     99    Private Sub MailUpdateCompleted() 
    84100        ' Update the display with EveMail 
    85101        Call Me.UpdateMailInfo() 
    86  
    87         Me.Cursor = Cursors.Default 
    88  
     102        lblDownloadMailStatus.Text = "Mail Processing Complete!" 
     103        btnDownloadMail.Enabled = True 
    89104        Call frmEveHQ.UpdateEveMailButton() 
    90  
    91105    End Sub 
    92106 
     
    273287    End Sub 
    274288 
    275     
     289 
    276290End Class 
    277291