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
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