Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: Stenvang on February 22, 2016, 11:59:00 pm

Title: Get name of project and logged in user
Post by: Stenvang on February 22, 2016, 11:59:00 pm
Hi

How can I get the name of the project and the logged in user using c# and interop.EA?
Title: Re: Get name of project and logged in user
Post by: Geert Bellekens on February 23, 2016, 12:34:55 am
User:
Repository.GetCurrentLoginUser (boolean GetGuid)

"Name of the project" is ambiguous. You might find what you looking for in Repository.ConnectionString or Repository.Models

Geert
Title: Re: Get name of project and logged in user
Post by: Uffe on February 27, 2016, 12:50:42 am
Hej Stenvang!


To Geert's comments (and he means "name of the project", not "name of the report"; he was probably on a break from setting up some fiendishly intricate document generation) I'll just add that EA projects do not, in fact, have names at all. In other words, there's no project name to be found in any table in the EA database.

If you're using a file-based repository (.eap or .feap), you can use the file name as a sort-of project name. If you're using a DBMS repository, you can use the database name. But if people are using EA shortcuts (File -- Save Shortcut) to connect, then the name that you see in EA's main window title is stored inside the shortcut file -- which may be different for different users. And if people are using shortcuts, they might not recognize the database name.

If you need a unique identifier, you'll find it in Repository.ProjectGUID. But there is no Repository.ProjectName.

Hope this complicates matters further.

I mean, helps.


/Uffe
Title: Re: Get name of project and logged in user
Post by: Geert Bellekens on February 27, 2016, 01:03:48 am
To Geert's comments (and he means "name of the project", not "name of the report"; he was probably on a break from setting up some fiendishly intricate document generation)
Thanks Uffe, I corrected it in the meantime.

"project" and "report" have mostly the same letters, and I've been doing a lot of reporting projects lately :-[

Geert
Title: Re: Get name of project and logged in user
Post by: fp123 on July 05, 2019, 12:29:08 am
Can anyone give me a hint, how I can get the first- and surname of the logged in user?

By calling
Code: [Select]
string logInUserGuid = Repository.GetCurrentLoginUser(false);
I only get the login-name. Do I have to search the name via GUID from the database, or is there any method to get that info?
Title: Re: Get name of project and logged in user
Post by: Geert Bellekens on July 05, 2019, 02:03:01 am
Do I have to search the name via GUID from the database?
Yes

Geert
Title: Re: Get name of project and logged in user
Post by: Eve on July 05, 2019, 09:14:03 am
Do I have to search the name via GUID from the database?
Not in EA 15.

Repository.SecurityUser.FirstName
Repository.SecurityUser.Surname

See:
https://www.sparxsystems.com/enterprise_architect_user_guide/15.0/automation/repository3.html (https://www.sparxsystems.com/enterprise_architect_user_guide/15.0/automation/repository3.html)
https://www.sparxsystems.com/enterprise_architect_user_guide/15.0/automation/class_securityuser.html (https://www.sparxsystems.com/enterprise_architect_user_guide/15.0/automation/class_securityuser.html)
Title: Re: Get name of project and logged in user
Post by: Geert Bellekens on July 05, 2019, 01:24:38 pm
Do I have to search the name via GUID from the database?
Not in EA 15.

Repository.SecurityUser.FirstName
Repository.SecurityUser.Surname

See:
https://www.sparxsystems.com/enterprise_architect_user_guide/15.0/automation/repository3.html (https://www.sparxsystems.com/enterprise_architect_user_guide/15.0/automation/repository3.html)
https://www.sparxsystems.com/enterprise_architect_user_guide/15.0/automation/class_securityuser.html (https://www.sparxsystems.com/enterprise_architect_user_guide/15.0/automation/class_securityuser.html)
Nice  :)

Geert
Title: Re: Get name of project and logged in user
Post by: fp123 on July 05, 2019, 07:34:26 pm
Great, one more reason to use V15  :)