diff --git a/SmartAPI/erminas.SmartAPI/CMS/ISession.cs b/SmartAPI/erminas.SmartAPI/CMS/ISession.cs index 31e192d..eccb9b9 100644 --- a/SmartAPI/erminas.SmartAPI/CMS/ISession.cs +++ b/SmartAPI/erminas.SmartAPI/CMS/ISession.cs @@ -837,36 +837,31 @@ private void InitConnection() private static bool IsProjectUnavailbaleException(Exception e) { - return - e.Message.Contains( - "The project you have selected is no longer available. Please select a different project via the Main Menu."); + return e.Message.Contains("The project you have selected is no longer available. Please select a different project via the Main Menu.") || + e.Message.Contains("Access to this project has been denied, because you are not assigned to it.") || + e.Message.Contains("Ihnen wird der Zugang zu diesem Projekt verweigert, da Sie ihm nicht zugewiesen sind."); } - private void LoadSelectedProject(XmlDocument xmlDoc) + private void LoadSelectedProject(XmlNode xmlDoc) { var lastModule = (XmlElement) xmlDoc.SelectSingleNode("/IODATA/USER/LASTMODULES/MODULE[@last='1']"); - if (lastModule == null) + var projectStr = lastModule?.GetAttributeValue("project"); + + if (string.IsNullOrEmpty(projectStr)) return; + + try { - return; + SelectProject(Guid.Parse(projectStr)); } - - string projectStr = lastModule.GetAttributeValue("project"); - if (!string.IsNullOrEmpty(projectStr)) + catch (SmartAPIException e) { - try + if (IsProjectUnavailbaleException(e) || e.InnerException != null && IsProjectUnavailbaleException(e.InnerException)) { - SelectProject(Guid.Parse(projectStr)); - } catch (SmartAPIException e) + SelectedProjectGuid = Guid.Empty; + } + else { - if (IsProjectUnavailbaleException(e) || - (e.InnerException != null && IsProjectUnavailbaleException(e.InnerException))) - { - SelectedProjectGuid = Guid.Empty; - } - else - { - throw; - } + throw; } } }