Skip to content
This repository was archived by the owner on Jan 30, 2025. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 16 additions & 21 deletions SmartAPI/erminas.SmartAPI/CMS/ISession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
Expand Down