I've been tasked with creating some call routing rules that are based on the time of day. 3CX (the system we use) provide documentation on how to do this, and I have it working to a degree. However, to get the time they provide this C# snippet which is a method in the call flow designer:
return DateTime.Now.Hour < 9;
This returns true or false, and a condition reads this boolean output, and determines where to send calls based on that output.
I need to edit this code snippet to give me a boolean output based on whether or not is is between 8:00 and 16:30.
I am not a developer - I dabbled in Python ages ago but that is not helping me here.
I'm not even sure if this is valid C# code to begin with, but it does work as-is.
The line in the configuration looks like this:
<ns0:ExecuteCSharpCodeComponent ReturnsValue="True" Code="return DateTime.Now.Hour < 9;" ParameterList="<?xml version="1.0" encoding="utf-16"?><ArrayOfScriptParameter xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" />" Description="IsTime0to9" MethodName="IsTime0to9" DebugModeActive="False" x:Name="timeFrom0To9" />
This config line checks if the hour is between 9 and 12:
<ns0:ExecuteCSharpCodeComponent ReturnsValue="True" Code="return DateTime.Now.Hour >= 9 && DateTime.Now.Hour < 12;" ParameterList="<?xml version="1.0" encoding="utf-16"?><ArrayOfScriptParameter xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" />" MethodName="IsTime9to12" DebugModeActive="False" x:Name="timeFrom9To12" />
Any input would be welcome.
Thank you