Last active
August 29, 2015 14:16
-
-
Save killnine/6cef8955acaa20d89e7f to your computer and use it in GitHub Desktop.
Ordering by secondary group
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
This should return a collection where you can create the following tree: | |
Location 1 | |
|__ Machine 1 | |
|__ Machine 2 | |
Location 2 | |
|__ Machine 3 | |
|__ Machien 4 | |
*/ | |
private IOrderedEnumerable<IGrouping<string,MachineStatus>> GroupByLocation(IEnumerable<MachineStatus> statusData) | |
{ | |
var locationGroups = statusData.GroupBy(s => s.LocationName).OrderBy(g => g.Key); | |
return locationGroups; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MachineStatus | |
{ | |
public string MachineName {get;set;} | |
public ConnectionStatus Status { | |
get{ | |
if(Devices.Count == 0) | |
{ | |
return ConenctionStatus.Connected; | |
} | |
if(Devices.All(d => d.Status == ConnectionStatus.Unknown)) | |
{ | |
return ConnectionStatus.Unknown; | |
} | |
if(Devices.Any(d => d.Status == ConnectionStatus.Disconnected)) | |
{ | |
return ConnectionStatus.Disconnected; | |
} | |
else | |
{ | |
return ConnectionStatus.Connected; | |
} | |
} | |
} | |
public IEnumerable<DeviceStatus> Devices {get;set;} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DeviceStatus | |
{ | |
public string DeviceName {get;set;} | |
public string DeviceType {get;set;} | |
public string IpAddress {get;set;} | |
public ConnectionStatus Status {get;set;} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment