Problem Statement: Approved code deployment windows are 1) Overnight (10 pm – 6 am EST) 2) Lunch (12 pm – 1:30 pm EST) 3) Evening (5 pm – 6 pm EST) - but people don't follow the rules. I get automated emails whose 1st line contains deployment results
e.g.
CMD_START: WS restart on ea_awd_services in AWD for UNIX_WAS7_DEV_RPSI_1 at Mon Jul 24 16:03:08 EDT 2017 on pideploy11
and I extract the data as follows:
Mnemonic = AWD
Environment = DEV
Domain = RPSI
Date = Jul 24 16:03:08 EDT 2017 (4:03 pm)
There are hundreds of these emails - and I have a macro that reads the 1st line & extracts the information (from outlook) and writes it to Excel.
However - the code I have that should check to see if the deployment time falls within a valid deployment window or not does not work.
Note - DispTime contains only time values e.g. "11:18:00 PM"
My thought process was as follows:
1. Turn flag on (flag means it's outside an approved deployment window)
2. Check the first approved window - if the deployment is within this timeframe, turn the flag off.
3. Check the other deployment windows ONLY if the flag is still on.
'------- code to check valid deployment windows (DispTime is the time only element extracted from the 1st line in the email)
Note - there is a different approach I tried (using the #time values# - but that didn't work either, so I commented them out.
DispTime = Format(sRelease_Time, "Medium Time")
Overnight_Start = Format("10:00 PM", "Medium Time")
Overnight_End = Format("6:00 AM", "Medium Time")
sFlag = "Y"
'Overnight Window Check
If DispTime > Overnight_Start And DispTime < Overnight_End Then
'If DispTime >= #10:00:00 PM# And DispTime <= #6:00:00 AM# Then
'we're OK for the overnigh window
sFlag = ""
End If
Lunch_Start = Format("12:00 PM", "Medium Time")
Lunch_End = Format("1:30 PM", "Medium Time")
'Only do the next two checks if the flag is still set to "Y"
'Lunch Check
If sFlag = "Y" Then
If DispTime > Lunch_Start And DispTime < Lunch_End Then
'If TimeValue(sRelease_Time) >= TimeValue("12:00:00 PM") And TimeValue(sRelease_Time) <= TimeValue("01:30:00 PM") Then
'we're OK for the overnigh window
sFlag = ""
End If
End If
Evening_Start = Format("5:00 PM", "Medium Time")
Evening_End = Format("6:00 PM", "Medium Time")
'Evening Check
If sFlag = "Y" Then
If DispTime > Evening_Start And DispTime < Evening_End Then
'If TimeValue(sRelease_Time) >= TimeValue("05:00:00 PM") And TimeValue(sRelease_Time) <= TimeValue("06:00:00 PM") Then
'we're OK for the overnigh window
sFlag = ""
End If
End If
Sample output in Excel is as follows:
[TABLE="width: 536"]
<tbody>[TR]
[TD]Mnemonic
[/TD]
[TD]Environment
[/TD]
[TD]Domain
[/TD]
[TD]Release Time
[/TD]
[TD]Flag?
[/TD]
[/TR]
[TR]
[TD]CMR
[/TD]
[TD]QUAL
[/TD]
[TD]RPS-E
[/TD]
[TD]11:18 PM
[/TD]
[TD]Y
[/TD]
[/TR]
</tbody>[/TABLE]
However - you can see this is wrong - 11:18 PM is within the valid overnight deployment window of 10 pm to 6 am - and it should NOT be flagged "y" (flag = Y means it's violated the rules of deploying only during normal deployment windows). Note 2 - no, we can't physically restrict them from deploying - it's a political thing.
e.g.
CMD_START: WS restart on ea_awd_services in AWD for UNIX_WAS7_DEV_RPSI_1 at Mon Jul 24 16:03:08 EDT 2017 on pideploy11
and I extract the data as follows:
Mnemonic = AWD
Environment = DEV
Domain = RPSI
Date = Jul 24 16:03:08 EDT 2017 (4:03 pm)
There are hundreds of these emails - and I have a macro that reads the 1st line & extracts the information (from outlook) and writes it to Excel.
However - the code I have that should check to see if the deployment time falls within a valid deployment window or not does not work.
Note - DispTime contains only time values e.g. "11:18:00 PM"
My thought process was as follows:
1. Turn flag on (flag means it's outside an approved deployment window)
2. Check the first approved window - if the deployment is within this timeframe, turn the flag off.
3. Check the other deployment windows ONLY if the flag is still on.
'------- code to check valid deployment windows (DispTime is the time only element extracted from the 1st line in the email)
Note - there is a different approach I tried (using the #time values# - but that didn't work either, so I commented them out.
DispTime = Format(sRelease_Time, "Medium Time")
Overnight_Start = Format("10:00 PM", "Medium Time")
Overnight_End = Format("6:00 AM", "Medium Time")
sFlag = "Y"
'Overnight Window Check
If DispTime > Overnight_Start And DispTime < Overnight_End Then
'If DispTime >= #10:00:00 PM# And DispTime <= #6:00:00 AM# Then
'we're OK for the overnigh window
sFlag = ""
End If
Lunch_Start = Format("12:00 PM", "Medium Time")
Lunch_End = Format("1:30 PM", "Medium Time")
'Only do the next two checks if the flag is still set to "Y"
'Lunch Check
If sFlag = "Y" Then
If DispTime > Lunch_Start And DispTime < Lunch_End Then
'If TimeValue(sRelease_Time) >= TimeValue("12:00:00 PM") And TimeValue(sRelease_Time) <= TimeValue("01:30:00 PM") Then
'we're OK for the overnigh window
sFlag = ""
End If
End If
Evening_Start = Format("5:00 PM", "Medium Time")
Evening_End = Format("6:00 PM", "Medium Time")
'Evening Check
If sFlag = "Y" Then
If DispTime > Evening_Start And DispTime < Evening_End Then
'If TimeValue(sRelease_Time) >= TimeValue("05:00:00 PM") And TimeValue(sRelease_Time) <= TimeValue("06:00:00 PM") Then
'we're OK for the overnigh window
sFlag = ""
End If
End If
Sample output in Excel is as follows:
[TABLE="width: 536"]
<tbody>[TR]
[TD]Mnemonic
[/TD]
[TD]Environment
[/TD]
[TD]Domain
[/TD]
[TD]Release Time
[/TD]
[TD]Flag?
[/TD]
[/TR]
[TR]
[TD]CMR
[/TD]
[TD]QUAL
[/TD]
[TD]RPS-E
[/TD]
[TD]11:18 PM
[/TD]
[TD]Y
[/TD]
[/TR]
</tbody>[/TABLE]
However - you can see this is wrong - 11:18 PM is within the valid overnight deployment window of 10 pm to 6 am - and it should NOT be flagged "y" (flag = Y means it's violated the rules of deploying only during normal deployment windows). Note 2 - no, we can't physically restrict them from deploying - it's a political thing.