unkonwn type aaFactMES.aaClient Session

HI Everyone

I am currently upgrading from MES 2017 to 2023 and there is a script which is working perfectly on 2017 and its giving issues on the new version 2023. 

When I run the script, it says: unkonwn type: aaFactMES.aaClient Session.

The script is supposed to open a session and log users in automatically, but it appears to be failing in the new version, as an error is occurring.

This is the script below:

IF IsGood(EntityName) THEN

LogMessage ("EntityName is Good = " + EntityName);

Dim clientSession as aaFactMES.aaClientSession;
Dim result as aaFactMES.Result;
Dim resultEnt as aaFactMES.Result;
Dim entityID as Integer;

result = aaFactMES.aaClientSession.GetInstance();
clientSession = result.Value;

clientSession.Login("admin", "admin");
LogMessage ("Clientsession =WONDER " + clientSession);
'If (clientsession <> null) Then
If clientSession.SessionId > 0 Then
IntDwntSessionID = clientSession.SessionId;
LogMessage("EXISTING SESSION");
LogMessage("UserID: admin");
LogMessage("UserPW: admin");

IntDwntSessionID = clientsession ;
LogMessage("IntDwntSessionID: " + IntDwntSessionID);
LogMessage("clientsession : " + clientsession );

LogMessage("Logged in to session OK before IF");
LogMessage("Me.Tagname : " + EntityName);

If ( clientSession.curUser <> null and EntityName <> "" ) then
LogMessage("Logged in to session OK Inside IF");
' get Entity ID from input UDA Entity Name
resultEnt = aaFactMES.aaEnt.EntIdFromName( EntityName );
logmessage("resultEnt" + resultEnt);
If ( resultEnt.Success == true and resultEnt.Int32_Value <> -1) then
' go an entity ID - attempt to logon
entityID = resultEnt.Int32_Value;
resultEnt = clientSession.curUser.LogonEnt( entityID, "", 100.0 );
If ( resultEnt.Success == true ) then
' Print Success message
LogMessage(clientSession.curUser.userName + " has logged onto entity " + EntityName + " - id=" + StringFromIntg(entityID, 10) );
Endif;
Else
' Failed to get Entity ID from Entity Name
LogMessage("Entity " + EntityName + " does not seem to exist");
Endif;
Endif;

Else
LogMessage("START SESSION");

result = aaFactMES.aaClientSession.GetInstance();
clientSession = result.Value;
IntDwntSessionID = clientSession.SessionId;

LogMessage("IntDwntSessionID: " + IntDwntSessionID);
LogMessage("clientsession : " + clientsession );

' login to session automatically

'If ( clientSession <> null and clientSession.SessionId == -1) then
' Start the session. Only do this if a session isn't already started
clientSession.Login("admin", "admin");
result = clientSession.StartSession (aaFactMES.aaClientTypes.clientOperator);
If (result.Success == true) then
LogMessage("Session Started!");
' Login a user - this should cause a UserChanged event (see MonitorEvents script)
result = clientSession.Login("admin", "admin");
If (result.Success == true) then
LogMessage("Login succeeded!");

'******************************************
LogMessage("Me.Tagname : " + EntityName);
If ( clientSession.curUser <> null and EntityName <> "" ) then
LogMessage("Logged in to session OK Inside IF");
' get Entity ID from input UDA Entity Name
resultEnt = aaFactMES.aaEnt.EntIdFromName( EntityName );
logmessage("resultEnt" + resultEnt);
If ( resultEnt.Success == true and resultEnt.Int32_Value <> -1) then
' go an entity ID - attempt to logon
entityID = resultEnt.Int32_Value;
resultEnt = clientSession.curUser.LogonEnt( entityID, "", 100.0 );
If ( resultEnt.Success == true ) then
' Print Success message
LogMessage(clientSession.curUser.userName + " has logged onto entity " + EntityName + " : id=" + StringFromIntg(entityID, 10) );
Endif;
Else
' Failed to get Entity ID from Entity Name
LogMessage("Entity " + EntityName + " does not seem to exist");
Endif;
Endif;

'*****************************************

Endif;
Else
LogMessage("Session failed to start!");
Endif;
'Endif;

Endif;

Logmessage("INITIALIZE = True");
Initialised= True;
Endif;

Parents
  • Since you updated the version of MES, did you import the MES 2023 dlls into System Platform?  You will need to import the aaFactMES.aaslib and potentially the aaMES.aaslib library files into the IDE.  This will replace the older versions with the latest ones that match what is installed on the system.  At that point, the validation of the script will succeed.

    If you've already done that and still have the error, can you find which line number is failing the validation?

    The only one I see that could be a problem is 

    IntDwntSessionID = clientsession ;

    This is trying to set an integer to a class.  Other places are using the clientsession.sessionID property which is an integer.

    Between MES 2017 and 2023, we have made some changes to the enumerated list of client types, but the one you are using "ClientOperator" is still valid and the correct one to use.

  • Thank you so much Jefrey, where can I locate the aaFactMES.aaslib and  aaMES.aaslib library files?

Reply Children