Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started 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?
-
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
-
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
-
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
-
Can anyone give me a hint, how I can get the first- and surname of the logged in user?
By calling
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?
-
Do I have to search the name via GUID from the database?
Yes
Geert
-
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)
-
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
-
Great, one more reason to use V15 :)