Genesys CTI User Forum
Genesys CTI User Forum => Genesys CTI Technical Discussion => Topic started by: Harifidy on June 08, 2021, 02:22:38 PM
-
:) Hi,
It' s been a while I've stuck on this. I don't know what to do.
I use RequestOpenStatic to get statistics (I followed the Genesys PSDK documents)
It works perfectly when I implemented the code using Windows form c# and App console c#, I got a real time response.
But when I use the same code with asp.net I doesn't work. I manage to connect to the stat server, but could not get the statistics instantly.
I added log to trace it, it seems there is a problem on handling event from the server. The event is not raised, I think, I don t know.
// code send request
...
// Handling event
StatServerProtocol.Received +=(sender, evArg) =>
{
IMessage mes=((MessageEventArgs)EventArgs).Message;
WriteInFile("result is"+mes) // All things inside this function doesn t work.
}
Help me please.
Thank you.
-
So, where is your StatServerProtocol instantiated? It probably should be a static element initialized on the Application_Start with a preload...
-
Thank you for your reply.
I initialized it in the same class where it is implemented.
public class MyClass{
private static StatServerProtocol statSrvProt;
public static ResultMessage ConnectServer()
{
statSrvProt= new StatServerProtocol(new
Endpoint(statSrv,host,port));
statSrvProt.open()
}
public static void SendRequest(){
// create request with RequestOpenStatistic
// use statSrvProt
}
}
Maybe I do it in a wrong way.
Can you show how to initialize it in App_Start?
-
I don't have any ready example for .Net (I do have one for Java though). But I suggest reading the application lifecycle of ASP NET applications on:
https://docs.microsoft.com/en-us/previous-versions/ms178473(v=vs.140)?redirectedfrom=MSDN
Check the topic "Life Cycle Events and the Global.asax file" on this link.
And also check https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/advanced?view=aspnetcore-5.0
Look at the topic "Application Initialization Module" to change your application to AlwaysRunning
-
Oki, thank you.
I am going to check it.
-
Hi,
I updated the peoject, but it doesn t work yet.
Here are the changes I made.
1- I instantiate the StatServerProtocol in global.asax
Global.asax:
[i]
public class WebAppli: HttpApplication{
public static StatServerProtocol statSrv;
protected void Application_start(object send, EventArgs e){
statSrv=new StatServerProtocol(new Endpoint(statserv,host,port));
statSrv.open();
}
}
[/i]
Controller.cs
[i]
// create RequestOpenStatic
// use statServerProtocol in global.asax
WebAppli.statSrv.Request((IMessage)requestOpenStat);
WebAppli.statSrv.Received += (sen,event)=>
{
// to test I write in a file the statistic
}
[/i]
2- I also did all configurations in IIS, on the
Application pool and the application setting.
-
ASP.Net, like in a web page where content is built dynamically?
If so, there is no active component to behave like a listener, right? Is quite different from a desktop application.
Your request ended when the HTTP content was delivered and even if you created an object instace, the HTTP request is over...so you won't receive new events for it.
-
I have created a simple example to open the connection to the Stat Server on the Application context as a static object:
https://1drv.ms/u/s!AvfK0JSyglrHheU23KcvwFOVA2k38A?e=hZtyu2
Check the class StatServerController on the root folder of the project (not the solution folder).
The connection should remain open for as long as the Application is running on IIS. You can create static methods on that class in order to communicate with StatServer (or use the publicly accessible "StatServer" property of the class)
Refer to the previous links I sent in order to see how to keep the application always running and how to give it a "hot start" using the IIS Application Initialization feature.
This example was created using the default MVC template for ASP.NET with .Net Framework 4.7.2 (not DotNet Core). You might be able to change it to suit your needs.
-
My sincere apologies for the slow reply.
That works fine.
Thank you for your help. :)
-
Hi all.
I don't know if I can use this post or I should create one to ask a question.
Is it possible to request differents statistics at the same time.
For example:
- TotalLoginTime of the Agent agent0
- TotalLoginTime of the agent agent1
- CurrentTime of 30002@mt_out
- ...
We use the same host, port and statServer for all requests.
Thank you very much.
-
Yes, you can. For each RequestOpenStatistic or RequestOpenStatisticEx that you create, there is a related "RequestId" (either auto-generated by the SDK, or provided by yourself the way you want).
Every EventInfo will come with this same RequestId (REQ_ID on the EventInfo) so you know to which statistic it relates to.
-
Ah okey I see.
Thank you.
I am going to work on it.
:)