Question Multiple requests sent to console app not working

mmmtbig

New member
Joined
Dec 9, 2014
Messages
2
Programming Experience
10+
I've developed a console app that is not working as expected. (This is my first console app - my experience with vb.net is in Asp.net.

My client has several Access users with an Access app that is used to send out email from a Sql Server database of 130k
customers. Each email is individually addressed.

The VB.net console app gets two arguments from Access that identifies one record in Sql Server that can be used to get and send the mailing list.

Here's the basic flow of the VB.net app:


    Sub Main()
        Dim intEmailCampaignId As Integer = 0
        Dim blnStopSendingCurrentEmailCampaign As Boolean


        Dim strArgs() As String = Environment.GetCommandLineArgs()
        intEmailCampaignId = CInt(strArgs(1))
        blnStopSendingCurrentEmailCampaign = CBool(strArgs(2))


        Dim objSend As New PrepareSendEmail
        objSend.DetermineAction(intEmailCampaignId, blnStopSendingCurrentEmailCampaign)
        objSend = Nothing
    End Sub

    Public Sub DetermineAction(intEmailCampaignId As Integer, blnStopSendingCurrentEmailCampaign As Boolean)
        If blnStopSendingCurrentEmailCampaign = True Then       'stop sending this campaign
            StopSendCampaignEmail(intEmailCampaignId)


        Else        'prepare email for sending
            intCurrentEmailCampaignId = intEmailCampaignId
            GetCampaignData(intCurrentEmailCampaignId)
        End If
    End Sub

    Private Sub GetCampaignData(intCurrentEmailCampaignId As Integer)
        'Gets the record for the Campaign from tblEmailCampaigns, including the Jet sql for the insert

    Public Sub CreateSendToRecordsFromInsertQuery(strEmailToQuerySql As String)
        'gets the Jet INSERT Sql and converts it to T-SQL for use with Sql Server, where it runs the insert 
        '  to create the records for sending

    Private Sub GetSendToRecords()
        'Gets the records inserted to start the send process by creating each email, then loops through 
        '  the recordset sending each email

The problem: when a second user sends the arguments, nothing happened.
 
Last edited by a moderator:
Firstly, lets address something that you seemed confused about in your previous thread. If you invoke this application twice then you are going to have two separate, completely independent instances of the application that don't know anything about each other. Are you aware of that or are you expecting there to only be one instance doing it all?

Assuming that you do realise that there will be independent instances, what EXACTLY are the commandline arguments passed to the second instance, what EXACTLY do you expect to happen and what EXACTLY does happen? If all you can say is "nothing happens" then that's not very helpful because obviously SOMETHING happens but you just don't know what it is. With that in mind, you could add some tracing code that will, for instance, write to a file to tell you where the code is up to and what values your variables are holding at any particular stage. That is how to know what actually is happening.
 
No, I wasn't aware there would be two separate, completely independent instances of the application.

When I test the app from within Visual Studio 2013 here, it works as it should. When my client runs it in a production environment, it works occasionally the first time, but not for the next job. When I run it at the client site with very small test cases, it works as it should.

I'll need to think about the independent instances situation and how I might need to redesign the app.

Thanks
jmcilhinney
 

Latest posts

Back
Top