28 lines
4.4 KiB
XML
28 lines
4.4 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<File>
|
|
<Version>2.1</Version>
|
|
<Variables>
|
|
<ArrayOfVariable xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
|
<Variable>
|
|
<Name>DialedExtensionNo</Name>
|
|
<ShowScopeProperty>true</ShowScopeProperty>
|
|
<DebuggerVisible>true</DebuggerVisible>
|
|
<HelpText />
|
|
</Variable>
|
|
</ArrayOfVariable>
|
|
</Variables>
|
|
<Flows>
|
|
<MainFlow>
|
|
<ns0:MainFlow Description="Callflow execution path." DebugModeActive="False" x:Name="cGetDialedExtension" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:ns0="clr-namespace:TCX.CFD.Classes.Components;Assembly=3CX Call Flow Designer, Version=20.2.84.0, Culture=neutral, PublicKeyToken=7cb95a1a133e706e">
|
|
<ns0:ExecuteCSharpCodeComponent ReturnsValue="True" Code="// https://www.3cx.com/community/threads/get-extension-by-called-number.132441/post-630907
string retval="0";
if(myCall.Caller.DN is ExternalLine externalLine && myCall.IsInbound)
{
 string[] range;
 foreach (var a in externalLine.RoutingRules)
 {
 bool match = (a.Conditions.Condition.Type == RuleConditionType.BasedOnDID &&
 (
 a.Data == myCall.Caller.CalledNumber
 || (a.Data.StartsWith('*') && myCall.Caller.CalledNumber.EndsWith(a.Data[1..]))
 ))
 ||
 (
 a.Conditions.Condition.Type == RuleConditionType.BasedOnCallerID &&
 a.Data.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)
 .Any
 (x =>
 x == "*"
 || x == myCall.Caller.CallerID
 || x.StartsWith('*') && myCall.Caller.CallerID.EndsWith(x[1..])
 || x.EndsWith('*') && myCall.Caller.CallerID.StartsWith(x[..^1])
 || x.StartsWith('*') && x.EndsWith('*') && myCall.Caller.CallerID.Contains(x[1..^1])
 || ((range = x.Split("-", StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)).Length == 2 ?
 (range[0].Length == myCall.Caller.CallerID.Length && range[1].Length == myCall.Caller.CallerID.Length) && (range[0].CompareTo(myCall.Caller.CallerID) <= 0 && range[1].CompareTo(myCall.Caller.CallerID) >= 0) : false)
 )
 )
 ||
 (a.Conditions.Condition.Type == RuleConditionType.ForwardAll);
 
 if (match)
 {
 retval=(a.ForwardDestinations.OfficeHoursDestination).Internal?.Number?? "0";
 break;
 }
 }
}
else
{
 retval=myCall.Caller.AttachedData["extnumber"]?? "0";
}
return retval;" 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="test" Tag="" DebugModeActive="False" x:Name="ExecuteCSharpCode1" />
|
|
<ns0:VariableAssignmentComponent VariableName="callflow$.DialedExtensionNo" Tag="" DebugModeActive="False" Expression="ExecuteCSharpCode1.ReturnValue" x:Name="AssignVariable1" />
|
|
</ns0:MainFlow>
|
|
</MainFlow>
|
|
<ErrorHandlerFlow>
|
|
<ns0:ErrorHandlerFlow Description="Execution path when an error ocurrs." DebugModeActive="False" x:Name="cGetDialedExtension" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:ns0="clr-namespace:TCX.CFD.Classes.Components;Assembly=3CX Call Flow Designer, Version=20.2.84.0, Culture=neutral, PublicKeyToken=7cb95a1a133e706e" />
|
|
</ErrorHandlerFlow>
|
|
<DisconnectHandlerFlow>
|
|
<ns0:DisconnectHandlerFlow Description="Execution path since the call gets disconnected." DebugModeActive="False" x:Name="cGetDialedExtension" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:ns0="clr-namespace:TCX.CFD.Classes.Components;Assembly=3CX Call Flow Designer, Version=20.2.84.0, Culture=neutral, PublicKeyToken=7cb95a1a133e706e" />
|
|
</DisconnectHandlerFlow>
|
|
</Flows>
|
|
</File> |