Skip to content

Commit

Permalink
Merge pull request #53 from thomaslevesque/fix-missing-query-from-wor…
Browse files Browse the repository at this point in the history
…kspace

Fix missing query from workspace
  • Loading branch information
thomaslevesque authored Aug 7, 2021
2 parents 359c515 + ba7f038 commit 569091a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pkg/CosmosDBStudio.Packaging/Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<Identity
Name="20269ThomasLevesque.CosmosDBStudio"
Publisher="CN=BD404AD9-7DBE-4AD8-AD10-DF2AC49893CF"
Version="1.1.0.0" />
Version="1.1.1.0" />

<Properties>
<DisplayName>Cosmos DB Studio</DisplayName>
Expand Down
2 changes: 1 addition & 1 deletion src/CosmosDBStudio/Services/IQueryPersistenceService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace CosmosDBStudio.Services
{
public interface IQueryPersistenceService
{
QuerySheet Load(string path);
QuerySheet? Load(string path);
void Save(QuerySheet querySheet, string path);
IList<string> LoadMruList();
void SaveMruList(IList<string> mruList);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,20 @@ namespace CosmosDBStudio.Services.Implementation
{
public class QueryPersistenceService : IQueryPersistenceService
{
public QuerySheet Load(string path)
public QuerySheet? Load(string path)
{
string json = File.ReadAllText(path);
return JsonConvert.DeserializeObject<QuerySheet>(json);
if (File.Exists(path))
{
try
{
string json = File.ReadAllText(path);
return JsonConvert.DeserializeObject<QuerySheet>(json);
}
catch (FileNotFoundException) { }
catch (DirectoryNotFoundException) { }
}

return null;
}

public IList<string> LoadMruList()
Expand Down Expand Up @@ -85,8 +95,13 @@ public Workspace LoadWorkspace()
var path = Path.Combine(GetWorkspacePath(false), "workspace.json");
if (File.Exists(path))
{
string json = File.ReadAllText(path);
return JsonConvert.DeserializeObject<Workspace>(json);
try
{
string json = File.ReadAllText(path);
return JsonConvert.DeserializeObject<Workspace>(json);
}
catch (FileNotFoundException) { }
catch (DirectoryNotFoundException) { }
}

return new Workspace();
Expand Down
5 changes: 5 additions & 0 deletions src/CosmosDBStudio/ViewModel/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ private void OpenQuerySheet(string path)
}

var querySheet = _queryPersistenceService.Load(path);
if (querySheet is null)
return;

var vm = _viewModelFactory.CreateQuerySheet(
querySheet,
path,
Expand Down Expand Up @@ -270,6 +273,8 @@ private void LoadWorkspace()
}

var querySheet = _queryPersistenceService.Load(path);
if (querySheet is null)
continue;
var vm = _viewModelFactory.CreateQuerySheet(
querySheet,
sheet.SavedPath,
Expand Down

0 comments on commit 569091a

Please sign in to comment.