Skip to content

Commit

Permalink
Closes #320 and #327 added Exit and Close command (adding functionali…
Browse files Browse the repository at this point in the history
…ty for SaveBeforeClose)
  • Loading branch information
peterjamesnugent authored and IsakNaslundBh committed Sep 8, 2021
1 parent 3b7a5f8 commit 9bd54d9
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions Lusas_Adapter/AdapterActions/Execute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public bool RunCommand(Save command)
public bool RunCommand(SaveAs command)
{
d_LusasData.saveAs(command.FileName);
m_directory = new FileInfo(command.FileName).Directory.FullName;

return true;
}
Expand All @@ -106,6 +107,7 @@ public bool RunCommand(Open command)
{
m_LusasApplication.openDatabase(command.FileName);
d_LusasData = m_LusasApplication.getDatabase();
m_directory = command.FileName;

return true;
}
Expand Down Expand Up @@ -144,6 +146,48 @@ public bool RunCommand(ClearResults command)

/***************************************************/

public bool RunCommand(Close command)
{
if (command.SaveBeforeClose)
{
if (d_LusasData.getDBFilename() == "")
{
Engine.Reflection.Compute.RecordError("The model file does not have a filename, please SaveAs before attempting to Save.");
return false;
}
else
d_LusasData.save();
}

d_LusasData.close();

return true;
}

/***************************************************/

public bool RunCommand(Exit command)
{
if (command.SaveBeforeClose)
{
if (d_LusasData.getDBFilename() == "")
{
Engine.Reflection.Compute.RecordError("The model file does not have a filename, please SaveAs before attempting to Save.");
return false;
}
else
d_LusasData.save();
}

d_LusasData.close();
m_LusasApplication.quit();
m_LusasApplication = null;

return true;
}

/***************************************************/

public bool RunCommand(IExecuteCommand command)
{
Engine.Reflection.Compute.RecordWarning($"The command {command.GetType().Name} is not supported by this Adapter.");
Expand Down

0 comments on commit 9bd54d9

Please sign in to comment.