logo

The ConnectWise Control forum has moved to ConnectWise University! This forum has been locked and is in read-only mode. Click here for instructions on how to access the new forum.

Welcome Guest! You can not login or register.

Notification

Icon
Error

Options
Go to last post Go to first unread
iw_rylee  
#1 Posted : Tuesday, October 16, 2018 3:31:01 AM(UTC)
iw_rylee


Rank: Guest

Joined: 10/16/2018(UTC)
Posts: 4
Australia
Location: Brisbane

I've been working on an internal extension for some time to improve the functionality for our staff.

While attempting to implement an "IDynamicSessionEventTrigger" (or "DynamicSessionEventTriggerDefinition") I have not been having success

I believe I am implementing it correctly, no errors or warnings.
The issue is that no events are causing the function to fire.

I've tested this by simply trying to write to a file (a script which is confirmed working in various other parts), but on no event/actions does this happen.

Here's some of my code stripped down (also tested)

Manifest.xml
Quote:
<?xml version="1.0" encoding="utf-8"?>
<ExtensionManifest>
<Version>1</Version>
<Name>Internal Extension</Name>
<Author>Internal</Author>
<ShortDescription>Description</ShortDescription>
<Components>
<WebServiceReference SourceFile="Service.ashx" />
<DynamicSessionEventTriggerDefinition SourceFile="SessionEventTrigger.cs" />
<WebResourcesDefinition SourceFile="Web.en-US.resx" />
<ClientScriptInitializer SourceFile="Initializer.js" />
</Components>
</ExtensionManifest>


SessionEventTrigger.cs
Quote:
using ...(various);
using Newtonsoft.Json;

public class SessionEventTriggerAccessor : IDynamicSessionEventTrigger
{
public void DebugToFile(string str){
string cPath = ExtensionContext.Current.BasePath+"\\testme.txt";
File.AppendAllText(cPath,Environment.NewLine+str);
}

public Proc GetDeferredActionIfApplicable(SessionEventTriggerEvent sessionEventTriggerEvent)
{
this.DebugToFile("ActionCalled\n");
return null;
}
}


Running on-premise with version: 6.3.13446.6374

Edited by user Thursday, October 18, 2018 12:18:33 AM(UTC)  | Reason: Not specified

iw_rylee  
#2 Posted : Thursday, October 18, 2018 12:16:09 AM(UTC)
iw_rylee


Rank: Guest

Joined: 10/16/2018(UTC)
Posts: 4
Australia
Location: Brisbane

This seems to be relating to the Newtonsoft.Json package.

I have the dll available and is working within the WebServiceReference files, but when attempting to use Newtonsoft.Json within an event trigger it stops working without any errors or warnings

Has anyone else successfully imported Newtonsoft.Json?
Scott  
#3 Posted : Tuesday, November 13, 2018 6:24:17 PM(UTC)
Scott


Rank: Administration

Medals: Level 4: Wise Old Owl! Received 100 Thanks!

Joined: 3/28/2014(UTC)
Posts: 2,862
United States

Thanks: 3 times
Was thanked: 351 time(s) in 303 post(s)
Are you actually using Newtonsoft within the dynamic session event trigger or just including it as a dependency? Might be easier to just use the built-in deserializer we have in the ScreenConnect namespace.
ScreenConnect Team
iw_rylee  
#4 Posted : Tuesday, November 13, 2018 11:01:42 PM(UTC)
iw_rylee


Rank: Guest

Joined: 10/16/2018(UTC)
Posts: 4
Australia
Location: Brisbane

I reduced the code down to a simple example, but in the full code I do use the Newtonsoft.Json package.
Regardless of whether it gets used or not, as soon as it's included the code just does not run.

In the example, if removing `use Newtonsoft.Json` then all works fine.

I was not aware of a decoder within the ScreenConnect namespace but I have been using the built in functions to complete what I needed as a workaround.
The main reason for using the Newtonsoft.Json package was for performance/simplicity
Scott  
#5 Posted : Wednesday, November 14, 2018 2:23:29 PM(UTC)
Scott


Rank: Administration

Medals: Level 4: Wise Old Owl! Received 100 Thanks!

Joined: 3/28/2014(UTC)
Posts: 2,862
United States

Thanks: 3 times
Was thanked: 351 time(s) in 303 post(s)
Kind of an outside chance, does the Trigger work if you place the Newtonsoft.json libraries within the Bin folder in the ConnectWise Control server installation? By default that should be at C:/Program Files (x86)/ScreenConnect/Bin.

For a brief overview of our Dynamic Session Event Trigger stuff, basically the Session Manager basically loads every GetDeferredActionIfApplicable method implemented by an Extension into a list of procs. When an Event occurs, it executes each method. In general, you want to include some logic within the method to specify only when your method should actually run otherwise it will just execute for every possible event.

Since the implemented functions execute from the SessionManager (as far as I can tell), they may not have knowledge of what libraries/dependencies are included within the Extension since it's in a different location on disk.
ScreenConnect Team
iw_rylee  
#6 Posted : Wednesday, November 14, 2018 10:17:14 PM(UTC)
iw_rylee


Rank: Guest

Joined: 10/16/2018(UTC)
Posts: 4
Australia
Location: Brisbane

I've had the Newtonsoft.json library in the Bin folder from the start, it seemed to be one of the only places it would work

So with it in the Bin folder, any WebServiceReference files will import it and are able to use it fine, I currently have files that are doing so.
I only seem to be having trouble with the DynamicSessionEventTriggerDefinition files.

It's like something is possibly throwing an error when importing it.

If I don't import, and attempt to use a reference to one of the methods, it will throw the standard error about not being able to find the library.
There's no errors (that I have found) when importing it, but it's not working :/
Scott  
#7 Posted : Thursday, November 15, 2018 2:40:36 PM(UTC)
Scott


Rank: Administration

Medals: Level 4: Wise Old Owl! Received 100 Thanks!

Joined: 3/28/2014(UTC)
Posts: 2,862
United States

Thanks: 3 times
Was thanked: 351 time(s) in 303 post(s)
I guess the only other thing I can think of to try is to put the dependency within the Extension's installation directory itself instead of /Bin.

It should be off the server's installation C:/Program Files (x86)/ScreenConnect/App_Extensions/[EXTENSION_ID/
ScreenConnect Team
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.