- Joined
- Aug 26, 2019
- Messages
- 16
- Reaction score
- 1
Hi Guys,
I need your help with creating a Predictive/Outbound Dialer. So far one has been created and it seems to skip the check for free extensions component. Could anyone assist on this?
The below script is currently in use but still, I continues to call even iff there is no one in the Queue. Could you assist in updating this. Thanks
using System;
using TCX.Configuration;
public class ExtensionStateHelper
{
public bool IsThereAnyFreeExtension()
{
bool freeExists = true;
Log("HERE3");
Queue queue = (Queue) PhoneSystem.Root.GetDNByNumber("xxxxx");
foreach (var item in queue.QueueAgents)
{
try
{
// Log("HERE4");
Extension ext = item.DN as Extension;
if(ext != null)
{
freeExists = freeExists && ext.GetActiveConnections().Length == 0;
}
}
catch
{
}
}
return freeExists;
}
private bool GetQueueStatus(Extension ext, string qNum)
{
//Here we need to veryfy queue status which should be applied by system
//we need to care about:
//ext.IsOverrideActiveNow, ext.CurrentProfileOverride.ForceQueueStatus, ext.CurrentProfile.ForceQueueStatus
//so:
var status = ext.QueueStatus; // default value
try
{
//currently active profile can force queue status
//so if profile specifies something not equal -1 (means use global status) then we need to show status specified by profile.
int profilequeuestatus = ext.IsOverrideActiveNow ? ext.CurrentProfileOverride.ForceQueueStatus : ext.CurrentProfile.ForceQueueStatus;
if (profilequeuestatus != -1) //means overriden
{
status = (QueueStatusType)profilequeuestatus;
}
}
catch
{
//status left as global
}
if (status == QueueStatusType.LoggedOut)
return false;
Log("HERE2");
var prop = ext.GetPropertyValue("LOGGED_IN_QUEUES");
if (prop == null)
return false;
Log("HERE1");
if (string.IsNullOrEmpty(prop))
return false;
string[] strs = prop.Split(',');
Log("HERE");
Log(prop);
return ((IList<string>)strs).Contains(qNum);
}
public static void Log(string text)
{
string fileName = "/var/lib/3cxpbx/Instance1/Data/Logs/FreeAgentsCheck.log";
string logMessage = String.Format("[{0}]: {1}", DateTime.Now.ToString(), text + "\n");
File.AppendAllText(fileName, logMessage);
}
}
I need your help with creating a Predictive/Outbound Dialer. So far one has been created and it seems to skip the check for free extensions component. Could anyone assist on this?
The below script is currently in use but still, I continues to call even iff there is no one in the Queue. Could you assist in updating this. Thanks
using System;
using TCX.Configuration;
public class ExtensionStateHelper
{
public bool IsThereAnyFreeExtension()
{
bool freeExists = true;
Log("HERE3");
Queue queue = (Queue) PhoneSystem.Root.GetDNByNumber("xxxxx");
foreach (var item in queue.QueueAgents)
{
try
{
// Log("HERE4");
Extension ext = item.DN as Extension;
if(ext != null)
{
freeExists = freeExists && ext.GetActiveConnections().Length == 0;
}
}
catch
{
}
}
return freeExists;
}
private bool GetQueueStatus(Extension ext, string qNum)
{
//Here we need to veryfy queue status which should be applied by system
//we need to care about:
//ext.IsOverrideActiveNow, ext.CurrentProfileOverride.ForceQueueStatus, ext.CurrentProfile.ForceQueueStatus
//so:
var status = ext.QueueStatus; // default value
try
{
//currently active profile can force queue status
//so if profile specifies something not equal -1 (means use global status) then we need to show status specified by profile.
int profilequeuestatus = ext.IsOverrideActiveNow ? ext.CurrentProfileOverride.ForceQueueStatus : ext.CurrentProfile.ForceQueueStatus;
if (profilequeuestatus != -1) //means overriden
{
status = (QueueStatusType)profilequeuestatus;
}
}
catch
{
//status left as global
}
if (status == QueueStatusType.LoggedOut)
return false;
Log("HERE2");
var prop = ext.GetPropertyValue("LOGGED_IN_QUEUES");
if (prop == null)
return false;
Log("HERE1");
if (string.IsNullOrEmpty(prop))
return false;
string[] strs = prop.Split(',');
Log("HERE");
Log(prop);
return ((IList<string>)strs).Contains(qNum);
}
public static void Log(string text)
{
string fileName = "/var/lib/3cxpbx/Instance1/Data/Logs/FreeAgentsCheck.log";
string logMessage = String.Format("[{0}]: {1}", DateTime.Now.ToString(), text + "\n");
File.AppendAllText(fileName, logMessage);
}
}
