JessyRobinson1234
asked on
Auto refresh page when condition is met
I have an asp page that needs to be auto refreshed when following conditions are met:
If DatePart(DateInterval.Hour , Now()) >= 4 And DatePart(DateInterval.Hour , Now()) <= 15 Then
strShift = "1st Shift"
Else
strShift = "2nd Shift"
End If
' Determine Number of Trucks
If strShift = "1st Shift" Then
q = "SELECT V.CVEHICLENUMBER AS [VEHICLE_NUMBER], COUNT(YMH.IYARDMOVEHISTORY ID) AS [COUNT], CAST(AVG((DATEDIFF(S, DADDED, DARCHIVED) / 60.0)) AS DECIMAL(4,2)) AS [CYCLE_TIME] FROM YARDMOVEHISTORY AS YMH WITH(NOLOCK) JOIN VEHICLES AS V WITH(NOLOCK) ON V.IVEHICLEID = YMH.IVEHICLEID WHERE (DATEPART(HH,YMH.DADDED) BETWEEN 4 AND 15) AND DATEDIFF(D,DADDED,GETDATE( )) = 0 AND YMH.CSTATUS = 'COMPLETE' AND YMH.ISITEID IN ('1','2') AND V.LACTIVE = '1' GROUP BY V.CVEHICLENUMBER ORDER BY V.CVEHICLENUMBER;"
cDA.RunQueryDataSetResult( DS, CSYMS, q, "trucks")
End If
If strShift = "2nd Shift" And DatePart(DateInterval.Hour , Now()) >= 16 And DatePart(DateInterval.Hour , Now()) <= 23 Then
q = "SELECT V.CVEHICLENUMBER AS [VEHICLE_NUMBER], COUNT(YMH.IYARDMOVEHISTORY ID) AS [COUNT], CAST(AVG((DATEDIFF(S, DADDED, DARCHIVED) / 60.0)) AS DECIMAL(4,2)) AS [CYCLE_TIME] FROM YARDMOVEHISTORY AS YMH WITH(NOLOCK) JOIN VEHICLES AS V WITH(NOLOCK) ON V.IVEHICLEID = YMH.IVEHICLEID WHERE (DATEPART(HH,YMH.DADDED) BETWEEN 16 AND 23) AND DATEDIFF(D,DADDED,GETDATE( )) = 0 AND YMH.CSTATUS = 'COMPLETE' AND YMH.ISITEID IN ('1','2') AND V.LACTIVE = '1' GROUP BY V.CVEHICLENUMBER ORDER BY V.CVEHICLENUMBER;"
cDA.RunQueryDataSetResult( DS, CSYMS, q, "trucks")
End If
If strShift = "2nd Shift" And DatePart(DateInterval.Hour , Now()) >= 0 And DatePart(DateInterval.Hour , Now()) <= 3 Then
q = "SELECT V.CVEHICLENUMBER AS [VEHICLE_NUMBER], COUNT(YMH.IYARDMOVEHISTORY ID) AS [COUNT], CAST(AVG((DATEDIFF(S, DADDED, DARCHIVED) / 60.0)) AS DECIMAL(4,2)) AS [CYCLE_TIME] FROM YARDMOVEHISTORY AS YMH WITH(NOLOCK) JOIN VEHICLES AS V WITH(NOLOCK) ON V.IVEHICLEID = YMH.IVEHICLEID WHERE ((DATEPART(HH,YMH.DADDED) BETWEEN 16 AND 23) AND DATEDIFF(D,DADDED,GETDATE( )) = 1 AND YMH.CSTATUS = 'COMPLETE' AND YMH.ISITEID IN ('1','2') AND V.LACTIVE = '1') OR ((DATEPART(HH,YMH.DADDED) BETWEEN 0 AND 3) AND DATEDIFF(D,DADDED,GETDATE( )) = 0 AND YMH.CSTATUS = 'COMPLETE' AND YMH.ISITEID IN ('1','2') AND V.LACTIVE = '1') GROUP BY V.CVEHICLENUMBER ORDER BY V.CVEHICLENUMBER;"
cDA.RunQueryDataSetResult( DS, CSYMS, q, "trucks")
End If
How would I do that? I currently use a timer with an interval of 5000 but I want it to refresh only when the next shift starts.
Thanks
If DatePart(DateInterval.Hour
strShift = "1st Shift"
Else
strShift = "2nd Shift"
End If
' Determine Number of Trucks
If strShift = "1st Shift" Then
q = "SELECT V.CVEHICLENUMBER AS [VEHICLE_NUMBER], COUNT(YMH.IYARDMOVEHISTORY
cDA.RunQueryDataSetResult(
End If
If strShift = "2nd Shift" And DatePart(DateInterval.Hour
q = "SELECT V.CVEHICLENUMBER AS [VEHICLE_NUMBER], COUNT(YMH.IYARDMOVEHISTORY
cDA.RunQueryDataSetResult(
End If
If strShift = "2nd Shift" And DatePart(DateInterval.Hour
q = "SELECT V.CVEHICLENUMBER AS [VEHICLE_NUMBER], COUNT(YMH.IYARDMOVEHISTORY
cDA.RunQueryDataSetResult(
End If
How would I do that? I currently use a timer with an interval of 5000 but I want it to refresh only when the next shift starts.
Thanks
JessyRobinson1234,
It seems the condition for the refresh uses ASP code. Is that correct? You need to change that. Can you send something in Javascript to the browser to use for the refresh? More exact than the interval of 5 seconds but still in Javascript? Otherwise you will need to use an interval and just check a number of times. The ASP code can't know that something has changed and "push" it to the browser and page (i.e. force the refresh). AJAX could be useful but just in the fact that it wouldn't be a complete page reload (i.e. the browser and Javascript could check in the background).
Let me know if you have any questions or need more information.
b0lsc0tt
It seems the condition for the refresh uses ASP code. Is that correct? You need to change that. Can you send something in Javascript to the browser to use for the refresh? More exact than the interval of 5 seconds but still in Javascript? Otherwise you will need to use an interval and just check a number of times. The ASP code can't know that something has changed and "push" it to the browser and page (i.e. force the refresh). AJAX could be useful but just in the fact that it wouldn't be a complete page reload (i.e. the browser and Javascript could check in the background).
Let me know if you have any questions or need more information.
b0lsc0tt
ASKER
Here's the asp snippet of the ASPX page:
<asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
</Triggers>
<ContentTemplate>
chart code...
</ContentTemplate>
</asp:UpdatePanel>
I would like to manage the trigger and refresh the update panel programmatically based on the time of the day (Like Onthrax indicated)
If DatePart(DateInterval.Hour , Now()) >= 4 And DatePart(DateInterval.Hour , Now()) <= 15 Then
Update panel and run the associated query to feed the chart.
I have no idea how to even start on this.
<asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
</Triggers>
<ContentTemplate>
chart code...
</ContentTemplate>
</asp:UpdatePanel>
I would like to manage the trigger and refresh the update panel programmatically based on the time of the day (Like Onthrax indicated)
If DatePart(DateInterval.Hour
Update panel and run the associated query to feed the chart.
I have no idea how to even start on this.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If DatePart(DateInterval.Hour
If it's met, you can refresh the page.
Take a look into Ajax and let me know if you have any more questions.