Hi Guys Please help me.
Actully i create a window service. This window service has timer for update record once in a day at 5 pm.
I have write a code but it is not working fin
Here is my code.
App.Config File:-
<appSettings>
<add key="IsTrace" value="YES"/>
<add key="SourceServerPath" value="Server=DATASERVER\SQL2008R2;database=WDSBHN;User ID=Wireless;pwd=chetu@123"/>
<add key="ArchiveServerPath" value="Server=CHETUIWK091\SQL2008R2;database=Demo;User ID=sa;pwd=Chetu@123"/>
<add key="ReportHour" value="22"/>
<add key="ReportMinut" value="01"/>
<add key="ReportSecond" value="20"/>
<add key="ReportMilisecond" value="230"/>
<add key="DailyTimer" value="tmrProductionDataTransfer"/>
<add key="MonthlyTimer" value="tmrProductionCleanUp"/>
<add key="ActionParameter" value="WDS-DataTransfer"/>
</appSettings>
Vb.Net Code:-
Protected Overrides Sub OnStart(ByVal args() As String)
' Add code here to start your service. This method should set things
' in motion so your service can do its work.
Try
LoggingTracing.WriteTrace("DataTransfer Service START " & Now.ToLongDateString & " " & Now.ToLongTimeString())
'***Get the Time of service run
Dim svcRunTime As System.DateTime = Configuration.ConfigurationManager.AppSettings("ServiceRunTime")
'***differance of these two time
Dim ts As TimeSpan = DateTime.Now.Subtract(svcRunTime)
'***production data transfer
tmrProductionDataTransfer.Enabled = True
tmrProductionDataTransfer.Interval = 1000
tmrProductionDataTransfer.Start()
Catch ex As Exception
LoggingTracing.WriteError(ex.ToString())
End Try
End Sub
Private Sub tmrProductionDataTransfer_Elapsed(sender As Object, e As Timers.ElapsedEventArgs) Handles tmrProductionDataTransfer.Elapsed
Try
Dim time As Date = Date.Now
Dim currHour As Integer
Dim currMinute As Integer
Dim currnSecond As Integer
Dim reportHour As Integer
Dim reportMinute As Integer
Dim reportSecond As Integer
Dim reportMiliSecond As Integer
Dim actionParameter As String = Configuration.ConfigurationManager.AppSettings("ActionParameter")
Dim actionTimerName As String = Configuration.ConfigurationManager.AppSettings("DailyTimer")
currHour = time.Hour
currMinute = time.Minute
currnSecond = time.Second
reportHour = Convert.ToInt32(Configuration.ConfigurationManager.AppSettings("ReportHour"))
reportMinute = Convert.ToInt32(Configuration.ConfigurationManager.AppSettings("ReportMinut"))
reportSecond = Convert.ToInt32(Configuration.ConfigurationManager.AppSettings("ReportSecond"))
reportMiliSecond = Convert.ToInt32(Configuration.ConfigurationManager.AppSettings("ReportMilisecond"))
If currHour = reportHour AndAlso currMinute = reportMinute AndAlso currnSecond = reportSecond Then
ObjProductionDataTransfer.CopyDataToArchiveServerDayWiseDL(Configuration.ConfigurationManager.AppSettings("SourceServerPath"), Configuration.ConfigurationManager.AppSettings("ArchiveServerPath"),
actionTimerName, time, actionParameter)
End If
Catch ex As Exception
LoggingTracing.WriteError(ex.ToString())
End Try
End Sub
-----------------------
It is running at 5 pm , but run 3 times, for that records has updated 3 time
------
How i can resolve it, If any problem in this code please give me the write direction or code. And this thing i have been searching for 3 days , but stile i didn't get any solution
sonesh