From 16a0927dc484539dc43dd2d9720efd30ee8fcc39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kay=20F=C3=B6rster?= Date: Wed, 19 Jul 2017 15:54:18 +0200 Subject: [PATCH 1/2] Code Style --- SmartAPI/erminas.SmartAPI/CMS/ISession.cs | 35 +++++++++-------------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/SmartAPI/erminas.SmartAPI/CMS/ISession.cs b/SmartAPI/erminas.SmartAPI/CMS/ISession.cs index 31e192d..f4e37ec 100644 --- a/SmartAPI/erminas.SmartAPI/CMS/ISession.cs +++ b/SmartAPI/erminas.SmartAPI/CMS/ISession.cs @@ -837,36 +837,29 @@ 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."); } - 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; } } } From 1605c70ec6874f30cc0ca47d2462f1991c1b24a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kay=20F=C3=B6rster?= Date: Thu, 20 Jul 2017 09:54:07 +0200 Subject: [PATCH 2/2] Identificatio IsProjectUnavailableException adjusted --- SmartAPI/erminas.SmartAPI/CMS/ISession.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/SmartAPI/erminas.SmartAPI/CMS/ISession.cs b/SmartAPI/erminas.SmartAPI/CMS/ISession.cs index f4e37ec..eccb9b9 100644 --- a/SmartAPI/erminas.SmartAPI/CMS/ISession.cs +++ b/SmartAPI/erminas.SmartAPI/CMS/ISession.cs @@ -837,7 +837,9 @@ 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(XmlNode xmlDoc)