cancel
Showing results for 
Search instead for 
Did you mean: 

Accessing the current user name

Valued Contributor
Valued Contributor

Is it possible to access the current user name for a Process Simulate session that's connected to an eMServer using the API?

 

I'm using PS V12.1 and V13.1.2.

 

Thanks.

8 REPLIES

Re: Accessing the current user name

Valued Contributor
Valued Contributor

Is anyone from Siemens able to answer this question?

Re: Accessing the current user name

Siemens Pioneer Siemens Pioneer
Siemens Pioneer

Hi.

No there is no API for that.

Regards,

Re: Accessing the current user name

Valued Contributor
Valued Contributor

Thanks for coming back to me.

Re: Accessing the current user name

Creator
Creator
You need to use EmServer COM Library for this,

int session = TxApplication.ActiveDocument.eMSSessionId;
EMPAPPLICATIONLib.EmpApplication empApp = Microsoft.VisualBasic.Interaction.GetObject("","EmpApplication.EmpApplication") as EMPAPPLICATIONLib.EmpApplication;
EmpObjectKey userObjKey = empApp.CurrentUser;
new EmpNodeClass().get_Name(ref session, ref userObjKey);

Re: Accessing the current user name

Valued Contributor
Valued Contributor

Thanks for sharing this.

 

The last line doesn't look to be valid, however. I can't find where EmpNodeClass() is defined. Any help would be appreciated.

Re: Accessing the current user name

Creator
Creator

You can find it in "EMPMODELLib.dll" in emPower folder,

Re: Accessing the current user name

Valued Contributor
Valued Contributor

To get this to work, I had to tweak it slightly:

 

int session = TxApplication.ActiveDocument.eMSSessionId;
EmpApplication empApp = Microsoft.VisualBasic.Interaction.GetObject("", "EmpApplication.EmpApplication") as EmpApplication;
EmpObjectKey userObjKey = empApp.CurrentUser;
EmpContext context = new EmpContext();
context.sessionId = session;
return new EmpNodeClass().get_Name(ref context, ref userObjKey);

 

Thanks again for your help! :-)

Re: Accessing the current user name

Creator
Creator
You are right, I'm missing EmpContext ...