Skip to content

Commit

Permalink
Merge pull request #1 from daltskin/bugfix
Browse files Browse the repository at this point in the history
Fix reported bugs
  • Loading branch information
daltskin authored Jul 2, 2020
2 parents 1d0bbcd + a1ee389 commit cc9a983
Show file tree
Hide file tree
Showing 14 changed files with 145 additions and 166 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/dotnet-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ jobs:
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore /p:AssemblyVersion=${{ env.GitVersion_SemVer }} /p:FileVersion=${{ env.GitVersion_SemVer }} /p:InformationalVersion=${{ env.GitVersion_SemVer }}
run: dotnet build --configuration Release --no-restore /p:AssemblyVersion=${{ env.GitVersion_AssemblySemVer }} /p:FileVersion=${{ env.GitVersion_AssemblySemFileVer }} /p:InformationalVersion=${{ env.GitVersion_InformationalVersion }}
- name: Test
run: dotnet test --no-restore --verbosity normal

- name: Publish ${{ matrix.runtime }}
run: dotnet publish .//SmartThingsTerminal//SmartThingsTerminal.csproj -o publish/v${{ env.GitVersion_SemVer }}/${{ matrix.runtime }} -c Release -r ${{ matrix.runtime }} -f netcoreapp3.1 /p:PublishSingleFile=true /p:PublishTrimmed=true /p:AssemblyVersion=${{ env.GitVersion_SemVer }} /p:FileVersion=${{ env.GitVersion_SemVer }} /p:InformationalVersion=${{ env.GitVersion_SemVer }}
run: dotnet publish .//SmartThingsTerminal//SmartThingsTerminal.csproj -o publish/v${{ env.GitVersion_SemVer }}/${{ matrix.runtime }} -c Release -r ${{ matrix.runtime }} -f netcoreapp3.1 /p:PublishSingleFile=true /p:PublishTrimmed=true /p:AssemblyVersion=${{ env.GitVersion_AssemblySemVer }} /p:FileVersion=${{ env.GitVersion_AssemblySemFileVer }} /p:InformationalVersion=${{ env.GitVersion_InformationalVersion }}

- name: Zip ${{ matrix.runtime }} release
uses: papeloto/action-zip@v1
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -337,4 +337,6 @@ ASALocalRun/
.localhistory/

# BeatPulse healthcheck temp database
healthchecksdb
healthchecksdb

Properties/launchSettings.json
2 changes: 2 additions & 0 deletions SmartThingsTerminal.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SmartThingsTerminal", "Smar
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8AB9BD79-B877-4441-B6A4-88F1F71EE4E2}"
ProjectSection(SolutionItems) = preProject
.gitignore = .gitignore
.github\workflows\dotnet-core.yml = .github\workflows\dotnet-core.yml
GitVersion.yml = GitVersion.yml
LICENSE.txt = LICENSE.txt
README.md = README.md
Expand Down
160 changes: 34 additions & 126 deletions SmartThingsTerminal/API/SmartThingsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,7 @@ public PagedApps GetAllApps()
{
if (_allApps == null)
{
try
{
_allApps = _appsApi.ListApps();
}
catch (Exception exp)
{
Debug.WriteLine(exp);
}
_allApps = _appsApi.ListApps();
}
return _allApps;
}
Expand All @@ -88,21 +81,15 @@ public PagedInstalledApps GetAllInstalledApps(string locationId = null)
{
if (locationId != null)
{
try
{
_allInstalledApps = _installedAppsApi.ListInstallations(locationId);
}
catch (Exception exp)
{
Debug.WriteLine(exp);
}
_allInstalledApps = _installedAppsApi.ListInstallations(locationId);
}
else
{
_allInstalledApps = new PagedInstalledApps();
foreach (var location in GetAllLocations().Items)
var locations = GetAllLocations();
if (locations?.Items != null)
{
try
foreach (var location in locations.Items)
{
var locationApps = _installedAppsApi.ListInstallations(location.LocationId.ToString());
if (locationApps.Items?.Count > 0)
Expand All @@ -111,10 +98,6 @@ public PagedInstalledApps GetAllInstalledApps(string locationId = null)
_allInstalledApps.Items.AddRange(locationApps.Items);
}
}
catch (Exception exp)
{
Debug.WriteLine(exp);
}
}
}
}
Expand All @@ -127,21 +110,15 @@ public PagedSubscriptions GetAllSubscriptions(string appId = null)
{
if (appId != null)
{
try
{
_allSubscriptions = _subscriptionsApi.ListSubscriptions(appId);
}
catch (Exception exp)
{
Debug.WriteLine(exp);
}
_allSubscriptions = _subscriptionsApi.ListSubscriptions(appId);
}
else
{
_allSubscriptions = new PagedSubscriptions();
foreach (var app in GetAllInstalledApps().Items)
var apps = GetAllInstalledApps();
if (apps?.Items != null)
{
try
foreach (var app in apps.Items)
{
var appSubscriptions = _subscriptionsApi.ListSubscriptions(app.InstalledAppId.ToString());
if (appSubscriptions.Items?.Count > 0)
Expand All @@ -150,10 +127,6 @@ public PagedSubscriptions GetAllSubscriptions(string appId = null)
_allSubscriptions.Items.AddRange(appSubscriptions.Items);
}
}
catch (Exception exp)
{
Debug.WriteLine(exp);
}
}
}
}
Expand All @@ -164,14 +137,7 @@ public async Task<PagedDevices> GetAllDevicesAsync()
{
if (_allDevices == null)
{
try
{
_allDevices = await _devicesApi.GetDevicesAsync();
}
catch (Exception exp)
{
Debug.WriteLine(exp);
}
_allDevices = await _devicesApi.GetDevicesAsync();
}
return _allDevices;
}
Expand All @@ -180,14 +146,7 @@ public PagedDevices GetAllDevices()
{
if (_allDevices == null)
{
try
{
_allDevices = _devicesApi.GetDevices();
}
catch (Exception exp)
{
Debug.WriteLine(exp);
}
_allDevices = _devicesApi.GetDevices();
}
return _allDevices;
}
Expand All @@ -196,14 +155,7 @@ public PagedDeviceProfiles GetAllDeviceProfiles()
{
if (_allDeviceProfiles == null)
{
try
{
_allDeviceProfiles = _deviceProfilesApi.ListDeviceProfiles();
}
catch (Exception exp)
{
Debug.WriteLine(exp);
}
_allDeviceProfiles = _deviceProfilesApi.ListDeviceProfiles();
}
return _allDeviceProfiles;
}
Expand All @@ -221,14 +173,7 @@ public PagedLocations GetAllLocations()
{
if (_allLocations == null)
{
try
{
_allLocations = _locationsApi.ListLocations();
}
catch (Exception exp)
{
Debug.WriteLine(exp);
}
_allLocations = _locationsApi.ListLocations();
}
return _allLocations;
}
Expand All @@ -237,14 +182,7 @@ public async Task<PagedRooms> GetAllRoomsAsync(string locationId)
{
if (_allRooms == null)
{
try
{
_allRooms = await _roomsApi.ListRoomsAsync(locationId);
}
catch (Exception exp)
{
Debug.WriteLine(exp);
}
_allRooms = await _roomsApi.ListRoomsAsync(locationId);
}
return _allRooms;
}
Expand All @@ -255,25 +193,22 @@ public PagedRooms GetAllRooms(string locationId = null)
{
if (locationId != null)
{
try
{
_allRooms = _roomsApi.ListRooms(locationId);
}
catch (Exception exp)
{
Debug.WriteLine(exp);
}
_allRooms = _roomsApi.ListRooms(locationId);
}
else
{
_allRooms = new PagedRooms();
foreach (var location in GetAllLocations().Items)
var locations = GetAllLocations();
if (locations!.Items != null)
{
var locationRooms = _roomsApi.ListRooms(location.LocationId.ToString());
if (locationRooms.Items?.Count > 0)
foreach (var location in locations.Items)
{
_allRooms.Items ??= new List<SmartThingsNet.Model.Room>();
_allRooms.Items.AddRange(locationRooms.Items);
var locationRooms = _roomsApi.ListRooms(location.LocationId.ToString());
if (locationRooms.Items?.Count > 0)
{
_allRooms.Items ??= new List<SmartThingsNet.Model.Room>();
_allRooms.Items.AddRange(locationRooms.Items);
}
}
}
}
Expand All @@ -285,14 +220,7 @@ public PagedScene GetAllScenes(string locationId = null)
{
if (_allScenes == null)
{
try
{
_allScenes = _scenesApi.ListScenes(locationId);
}
catch (Exception exp)
{
Debug.WriteLine(exp);
}
_allScenes = _scenesApi.ListScenes(locationId);
}
return _allScenes;
}
Expand All @@ -303,21 +231,15 @@ public PagedRules GetAllRules(string locationId = null)
{
if (locationId != null)
{
try
{
_allRules = _rulesApi.ListRules(locationId);
}
catch (Exception exp)
{
Debug.WriteLine(exp);
}
_allRules = _rulesApi.ListRules(locationId);
}
else
{
_allRules = new PagedRules();
foreach (var location in GetAllLocations().Items)
var locations = GetAllLocations();
if (locations!.Items != null)
{
try
foreach (var location in locations.Items)
{
var locationRules = _rulesApi.ListRules(location.LocationId.ToString());
if (locationRules.Items?.Count > 0)
Expand All @@ -326,10 +248,6 @@ public PagedRules GetAllRules(string locationId = null)
_allRules.Items.AddRange(locationRules.Items);
}
}
catch (Exception exp)
{
Debug.WriteLine(exp);
}
}
}
}
Expand All @@ -342,21 +260,15 @@ public PagedSchedules GetAllSchedules(string appId = null)
{
if (appId != null)
{
try
{
_allSchedules = _schedulesApi.GetSchedules(appId);
}
catch (Exception exp)
{
Debug.WriteLine(exp);
}
_allSchedules = _schedulesApi.GetSchedules(appId);
}
else
{
_allSchedules = new PagedSchedules();
foreach (var app in GetAllInstalledApps().Items)
var apps = GetAllInstalledApps();
if (apps?.Items != null)
{
try
foreach (var app in apps.Items)
{
var appSchedules = _schedulesApi.GetSchedules(app.InstalledAppId.ToString());
if (appSchedules.Items?.Count > 0)
Expand All @@ -365,10 +277,6 @@ public PagedSchedules GetAllSchedules(string appId = null)
_allSchedules.Items.AddRange(appSchedules.Items);
}
}
catch (Exception exp)
{
Debug.WriteLine(exp);
}
}
}
}
Expand All @@ -388,7 +296,7 @@ protected virtual void Dispose(bool disposing)
_allRules = null;
_allSchedules = null;
_allApps = null;
_allSubscriptions = null;
_allSubscriptions = null;
_allInstalledApps = null;
_allDeviceProfiles = null;

Expand Down
2 changes: 1 addition & 1 deletion SmartThingsTerminal/Scenario.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public virtual void SetErrorView(string message)
{
X = Pos.Center(),
Y = Pos.Center(),
Width = 50,
Width = Dim.Fill(),
Height = 5
};

Expand Down
16 changes: 12 additions & 4 deletions SmartThingsTerminal/Scenarios/Devices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,21 @@ public override void Setup()
.Select(t => new KeyValuePair<string, Device>(t.Label, t))
.ToDictionary(t => t.Key, t => t.Value);
}
else
{
SetErrorView($"You have no devices configured");
}
}
catch (SmartThingsNet.Client.ApiException exp)
{
SetErrorView($"Error calling API: {exp.Source} {exp.ErrorCode} {exp.Message}");
}
catch (System.Exception exp)
{
SetErrorView($"No data returned from API:{Environment.NewLine}{exp.Message}");
SetErrorView($"Unknown error calling API: {exp.Message}");
}

ClassListView = new ListView(_viewDevices.Keys.ToList())
ClassListView = new ListView(_viewDevices?.Keys?.ToList())
{
X = 0,
Y = 0,
Expand All @@ -68,7 +76,7 @@ public override void Setup()
ColorScheme = Colors.TopLevel
};

if (_viewDevices.Keys.Count > 0)
if (_viewDevices?.Keys?.Count > 0)
{
ClassListView.OpenSelectedItem += (a) =>
{
Expand Down Expand Up @@ -127,7 +135,7 @@ public override void Setup()
Top.Add(LeftPane, SettingsPane, HostPane);
Top.Add(statusBar);

if (_viewDevices.Count > 0)
if (_viewDevices?.Count > 0)
{
var firstItem = _viewDevices?.FirstOrDefault().Value;
if (firstItem != null)
Expand Down
Loading

0 comments on commit cc9a983

Please sign in to comment.