Genesys Engage on-premises

Discussion Thread View
  • 1.  Wde module does not dispose when I call StatServerProtocol.Open()

    Posted 09-16-2021 03:39
    Hello,

    I have written a custom Wde module. It works fine. It's destructor executes as I close the Wde window.

    But if I open a Stat Server protocol and then close the Wde window, window closes but the destructor of the module class does not execute.
    By the way, everything works fine with Stat Server connection, I register to statistics and get values. The problem is, closed Wde stays in memory.

    Can anyone help we with this?

    Thanks

    using Genesyslab.Desktop.Infrastructure;
    using Genesyslab.Desktop.Infrastructure.DependencyInjection;
    using Genesyslab.Desktop.Modules.Core.Model.Agents;
    using Genesyslab.Platform.Commons.Logging;
    using Genesyslab.Platform.Commons.Protocols;
    using Genesyslab.Platform.Reporting.Protocols;
    using Ucs.Ucp.WdeModule.Common;
    
    namespace Ucs.Ucp.WdeModule
    {
        public class UcpModule : IModule
        {
            private readonly IObjectContainer _container;
            private readonly IAgent _agentManager;
            private readonly ILogger _log;
            private StatServerProtocol _statProtocol { get; set; }
    
            public UcpModule(IObjectContainer container, ILogger logger, IAgent agentManager)
            {
                _log = logger.CreateChildLogger("UcpModule");
                _log.Info("ctor: Creating UcpModule instance");
    
                _container = container;
                _agentManager = agentManager;
            }
    
            ~UcpModule()
            {
                // This doesn't execute if I open stat server protocol...
            }
    
            void IModule.Initialize()
            {
                _log.Info($"Wde module version is {System.Reflection.Assembly.GetExecutingAssembly().GetName().Version}");
    
                _log.Info("Initialize: Initializing the module");
    
                // Register common objects : options, person
                var options = new UcsOptions();
    
                if (options.CanUseUcpModule)
                {
                    _container.RegisterInstance<IUcsOptions>(options);
    
                    // Register types
                    _container.RegisterType<IModuleContext, ModuleContext>("UcpModule", true);
    
                    _agentManager.Initialized += (s, e) =>
                    {
                        _log.Info("Initialize: Resolving IModuleContext");
                        var moduleContext = _container.Resolve<IModuleContext>("UcpModule");
    
                        _log.Info("Initialize: Initializing moduleContext instance");
                        moduleContext.Initialize();
                        _log.Info("Initialize: ModuleContext is initialized");
                    };
                }
    
                _statProtocol = new StatServerProtocol(new Endpoint("ourserver.com", 7005));
                _statProtocol.Open(); // Problem occurs after I call Open.
            }
        }
    }​

    #Implementation

    ------------------------------
    Can Iyidogan
    UCS Bilisim Sistemleri Ltd. Sti
    ------------------------------


  • 2.  RE: Wde module does not dispose when I call StatServerProtocol.Open()

    Posted 15 days ago
    Hello,

    Statserver polling is blocking everything
    You can try to catch the closure event of the application to close the statserver polling
    Add the following in the Initialize:
     Application.Current.Exit += new ExitEventHandler(ApplicationExited);​

    And add the function
            private void ApplicationExited(object sender, EventArgs e)
            {
                Info("ApplicationExited - Application closed");
                _statProtocol.Close();     
    
            } ​


    ------------------------------
    Charles-Henri Vannimenus
    Ceritek Sarl
    ------------------------------



  • 3.  RE: Wde module does not dispose when I call StatServerProtocol.Open()

    Posted 14 days ago
    Hello Charles,

    Thanks for your answer.

    Another workaround that I found is to use the protocol object of IStatServerService, instead of creating my own stat server protocol. It also works fine.

    IStatServerService _statServerService = container.Resolve<IStatServerService>();
    	
    StatServerProtocol _protocol = _statServerService.ProtocolStatServer as StatServerProtocol;
    	
    var requestOpenStatistic = RequestOpenStatistic.Create(
    	StatisticObject.Create(stat.ObjectId, stat.ObjectType, _options.Application.Tenants.First().Name, ""),
    	StatisticMetric.Create(stat.Type, stat.TimeProfile, null, null, null),
    	Notification.Create(stat.NotificationMode, stat.NotificationFrequency, 0));
    
    requestOpenStatistic.ReferenceId = stat.Id;
    
    var response = _protocol.Request(requestOpenStatistic);
    ​


    ------------------------------
    Can Iyidogan
    UCS Bilisim Sistemleri Ltd. Sti
    ------------------------------