Click here to Skip to main content
15,903,388 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I have a window services (read data from excel file and save the results into the database).
In time, the program will read the data, other time it dont't read data. When it reading data, the program can read, but time of processing is too long, so services don't return any data at all.
I want to ask is there a way to increase the processing time for my service?
or create a console application,window form like window service?
my code with no errors at all.
I even split into 3 times reading and still not be
VB
Protected Overrides Sub OnStart(ByVal args() As String)
        Me.RequestAdditionalTime(5000)
        Dim db As New Common.filelog()
        Try
           
            timeout = Configuration.ConfigurationManager.AppSettings("timeout")
            aTimer = New System.Timers.Timer(timeout)
            AddHandler aTimer.Elapsed, AddressOf OnTimedEvent
            aTimer.Interval = timeout
            aTimer.Enabled = True
            f = Configuration.ConfigurationManager.AppSettings("pathdc3")
            If Now.Hour <= 7 Then
                curr = Now.AddDays(-1)
            Else
                curr = Now
            End If
            f = f & "D" & format(curr.Month) & format(curr.Day) & curr.Year & ".xls"
         
        Catch ex As Exception
            
        End Try
    End Sub
Private Sub OnTimedEvent(ByVal source As Object, ByVal e As ElapsedEventArgs)
        Dim db As New Common.filelog()
        f = Configuration.ConfigurationManager.AppSettings("pathdc3")
        Dim fromminute As Integer = Configuration.ConfigurationManager.AppSettings("fromminute")
      
        If Now.Hour <= 7 Then
            curr = Now.AddDays(-1)
        Else
            curr = Now
        End If
        f = f & "D" & format(curr.Month) & format(curr.Day) & curr.Year & ".xls"
        If File.Exists(f) Then
                If Now.Minute = fromminute Or Now.Minute = fromminute + 30 Then
                Openfile(f)
                readproductNumber()
                Closefile(f)
                st &= Now & vbCrLf
                db.WriteLog(st & "Insert success P1!")
            End If
            If Now.Minute = fromminute + 2 Or Now.Minute = fromminute + 32 Then
                Openfile(f)
                readElectronic()
                Closefile(f)
                st &= Now & vbCrLf
                db.WriteLog(st & "Insert success P2!")
            End If
            If Now.Minute = fromminute + 4 Or Now.Minute = fromminute + 34 Then
                Openfile(f)
                readDaily()
                Closefile(f)
                st &= Now & vbCrLf
                db.WriteLog(st & " insert success P3!")
            End If
            st &= Now & vbCrLf
            db.WriteLog(st)
        Else
            st &= Now & vbCrLf
            db.WriteLog(st & "not found file " & f)
        End If

    End Sub
Posted
Updated 27-Jun-13 0:38am
v2
Comments
bbirajdar 27-Jun-13 5:38am    
increase or decrease ?????
Michael J. Eber 1-Jul-13 15:18pm    
This is VB.Net so why are you posting in C# forum?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900