- Joined
- Dec 11, 2019
- Messages
- 3
- Reaction score
- 0
Hello,
We a new to the 3CX family but have our new system up and running, ~50 extensions on an enterprise licence.
For our support team I would like to utilise an external indicator light for showing when they are on the phone or on an incoming call.
I realise that this is not officially supported, however from reading other posts on the forum I can see that I can utilise existing dll files for the windows client to obtain the call status.
Using C# I am referencing the MyPhoneCRMIntegration.dll file and then hooking into CallHandler.
I'm then saving the DLL file in the C:\ProgramData\3CXPhone for Windows\PhoneApp using the filename E4eBlinkStick.dll and then finally editing the 3CXWin8Phone.user.config file and adding E4eBlinkStick to the CRMPlugin key.
My code didn't seem to be triggering so I added some logging functionality, which confirms that my code is never being triggered.
Is there anything I can do to see what plugins have been loaded successfully, or somewhere that 3CX will log errors?
I have copied my code below if it would be of help.
Thanks
We a new to the 3CX family but have our new system up and running, ~50 extensions on an enterprise licence.
For our support team I would like to utilise an external indicator light for showing when they are on the phone or on an incoming call.
I realise that this is not officially supported, however from reading other posts on the forum I can see that I can utilise existing dll files for the windows client to obtain the call status.
Using C# I am referencing the MyPhoneCRMIntegration.dll file and then hooking into CallHandler.
I'm then saving the DLL file in the C:\ProgramData\3CXPhone for Windows\PhoneApp using the filename E4eBlinkStick.dll and then finally editing the 3CXWin8Phone.user.config file and adding E4eBlinkStick to the CRMPlugin key.
My code didn't seem to be triggering so I added some logging functionality, which confirms that my code is never being triggered.
Is there anything I can do to see what plugins have been loaded successfully, or somewhere that 3CX will log errors?
I have copied my code below if it would be of help.
Thanks
C#:
using System;
using System.IO;
using BlinkStickDotNet;
using MyPhonePlugins;
namespace _3CX_BlinkStick
{
[CRMPluginLoader]
public class E4eBlinkStick{
private static E4eBlinkStick _instance;
private static IMyPhoneCallHandler _callHandler;
private static BlinkStick device;
[CRMPluginInitializer]
public static void Loader(IMyPhoneCallHandler callHandler)
{
WriteToTextFile("Call status = Loader");
_instance = new E4eBlinkStick(callHandler);
device = BlinkStick.FindFirst();
device.SetMode(2);
SetFreeStatus();
}
public E4eBlinkStick(IMyPhoneCallHandler callHandler)
{
WriteToTextFile("Call status = Initialise");
_callHandler = callHandler;
_callHandler.OnCallStatusChanged += CallHandlerOnOnCallStatusChanged;
_callHandler.OnMyPhoneStatusChanged += CallHandlerOnOnMyPhoneStatusChanged;
}
public void CallHandlerOnOnCallStatusChanged(object sender, CallStatus callInfo)
{
if (callInfo.State == CallState.Connected)
{
WriteToTextFile("Call status = Connected");
SetOnCallStatus();
}
else if (callInfo.State == CallState.Ringing)
{
WriteToTextFile("Call status = Ringing");
SetRingingStatus();
}
else if (callInfo.State == CallState.Ended)
{
WriteToTextFile("Call status = Ended");
SetFreeStatus();
}
else if (callInfo.State == CallState.Dialing)
{
WriteToTextFile("Call status = Dialing");
SetDialingStatus();
}
}
private void CallHandlerOnOnMyPhoneStatusChanged(object sender, MyPhoneStatus Status)
{
}
public static void SetOnCallStatus()
{
if (device != null)
{
if (device.OpenDevice())
{
byte[] data = new byte[3 * 8]
{0, 255, 0,
0, 255, 0,
0, 255, 0,
0, 255, 0,
0, 255, 0,
0, 255, 0,
0, 255, 0,
0, 255, 0
};
device.SetColors(0, data);
}
}
}
public static void SetRingingStatus()
{
if (device != null)
{
if (device.OpenDevice())
{
byte[] data = new byte[3 * 8]
{0, 255, 0,
255, 255, 0,
255, 255, 255,
0, 255, 255,
50, 100, 150,
200, 50, 167,
0, 255, 0,
0, 255, 0
};
device.SetColors(0, data);
}
}
}
public static void SetFreeStatus()
{
if (device != null)
{
if (device.OpenDevice())
{
byte[] data = new byte[3 * 8]
{255, 0, 0,
255, 0, 0,
255, 0, 0,
255, 0, 0,
255, 0, 0,
255, 0, 0,
255, 0, 0,
255, 0, 0
};
device.SetColors(0, data);
}
}
}
public static void SetDialingStatus()
{
if (device != null)
{
if (device.OpenDevice())
{
byte[] data = new byte[3 * 8]
{0, 0, 255,
0, 0, 255,
0, 0, 255,
0, 0, 255,
0, 0, 255,
0, 0, 255,
0, 0, 255,
0, 0, 255
};
device.SetColors(0, data);
}
}
}
public static void WriteToTextFile(string textLog)
{
FileStream objFS = null;
string strFilePath = "C:\\ProgramData\\3CXPhone for Windows\\PhoneApp\\Exception Log\\" + System.DateTime.Now.ToString("yyyy -MM-dd ") + "Exception.log";
if (!File.Exists(strFilePath))
{
objFS = new FileStream(strFilePath, FileMode.Create);
}
else
objFS = new FileStream(strFilePath, FileMode.Append);
using (StreamWriter Sr = new StreamWriter(objFS))
{
Sr.WriteLine(System.DateTime.Now.ToShortTimeString() + "---" + textLog);
}
}
}
}