/// <summary> /// Get camera info from database /// </summary> public void GetCameraData() { var en = new cctvEntities(); try { var ls = en.GetAllCamera(); Dictionary<String, List<CameraItem>> camgroupbyname = new Dictionary<string, List<CameraItem>>(); foreach (ComplexType1 complexType1 in ls) { ComplexType1 com = complexType1; var camItem = new CameraItem { Id = com.id, CameraUrl = com.cameraurl, Ip = com.ip, Type = com.type }; if (!camgroupbyname.ContainsKey(com.group_name)) { camgroupbyname.Add(com.group_name, new List<CameraItem> { camItem }); } else { camgroupbyname[com.group_name].Add(camItem); } } var highgroup = new ObservableCollection<CameraGroupViewModel>(); foreach (var cams in camgroupbyname) { highgroup.Add(new CameraGroupViewModel(new CameraGroup { GroupName = cams.Key, CameraList = cams.Value })); } _viewModel.SetCameraGroupViewModel(highgroup); } catch (Exception ex) { } }
public CameraItemViewModel(CameraItem cam) { CamItem = cam; }