public void Populate(JMMServerBinary.Contract_GroupFilter contract) { this.GroupFilterID = contract.GroupFilterID; this.GroupFilterName = contract.GroupFilterName; this.ApplyToSeries = contract.ApplyToSeries; this.BaseCondition = contract.BaseCondition; this.PredefinedCriteria = ""; this.FilterConditions.Clear(); GroupCount = 0; SeriesCount = 0; if (contract.FilterConditions != null) { foreach (JMMServerBinary.Contract_GroupFilterCondition gfc_con in contract.FilterConditions) { FilterConditions.Add(new GroupFilterConditionVM(gfc_con)); } } //SortCriteriaList = new ObservableCollection<GroupFilterSortingCriteria>(); SortCriteriaList.Clear(); string sortCriteriaRaw = contract.SortingCriteria; if (!string.IsNullOrEmpty(sortCriteriaRaw)) { string[] scrit = sortCriteriaRaw.Split('|'); foreach (string sortpair in scrit) { string[] spair = sortpair.Split(';'); if (spair.Length != 2) { continue; } int stype = 0; int sdir = 0; int.TryParse(spair[0], out stype); int.TryParse(spair[1], out sdir); if (stype > 0 && sdir > 0) { GroupFilterSortingCriteria gfsc = new GroupFilterSortingCriteria(); gfsc.GroupFilterID = this.GroupFilterID; gfsc.SortType = (GroupFilterSorting)stype; gfsc.SortDirection = (GroupFilterSortDirection)sdir; SortCriteriaList.Add(gfsc); } } } //FilterConditions = new List<GroupFilterConditionVM>(FilterConditions.OrderBy(p => p.ConditionTypeString)); }
public void Populate(JMMServerBinary.Contract_GroupFilter contract) { this.GroupFilterID = contract.GroupFilterID; this.FilterName = contract.GroupFilterName; this.ApplyToSeries = contract.ApplyToSeries; this.BaseCondition = contract.BaseCondition; this.isLocked = contract.Locked.HasValue && contract.Locked == 1; this.FilterType = contract.FilterType; this.PredefinedCriteria = ""; this.InvisibleInClients = contract.InvisibleInClients; this.GroupFilterParentId = contract.ParentGroupFilterID; this.Groups = contract.Groups.ToDictionary(a => a.Key, a => new HashSet <int>(a.Value)); this.Series = contract.Series.ToDictionary(a => a.Key, a => new HashSet <int>(a.Value)); this.Childs = new HashSet <int>(contract.Childs); this.AllowDeletion = true; this.AllowEditing = true; if (this.isLocked) { this.AllowDeletion = false; this.AllowEditing = false; } if (this.FilterType == (int)GroupFilterType.ContinueWatching) { this.AllowDeletion = false; } this.IsSystemGroupFilter = false; this.IsNotSystemGroupFilter = true; //this.FilterConditions = new ObservableCollection<GroupFilterConditionVM>(); this.FilterConditions.Clear(); if (contract.FilterConditions != null) { foreach (JMMServerBinary.Contract_GroupFilterCondition gfc_con in contract.FilterConditions) { FilterConditions.Add(new GroupFilterConditionVM(gfc_con)); } } //SortCriteriaList = new ObservableCollection<GroupFilterSortingCriteria>(); SortCriteriaList.Clear(); string sortCriteriaRaw = contract.SortingCriteria; if (!string.IsNullOrEmpty(sortCriteriaRaw)) { string[] scrit = sortCriteriaRaw.Split('|'); foreach (string sortpair in scrit) { string[] spair = sortpair.Split(';'); if (spair.Length != 2) { continue; } int stype = 0; int sdir = 0; int.TryParse(spair[0], out stype); int.TryParse(spair[1], out sdir); if (stype > 0 && sdir > 0) { GroupFilterSortingCriteria gfsc = new GroupFilterSortingCriteria(); gfsc.GroupFilterID = this.GroupFilterID; gfsc.SortType = (GroupFilterSorting)stype; gfsc.SortDirection = (GroupFilterSortDirection)sdir; SortCriteriaList.Add(gfsc); } } } //Update GroupCount //SortCriteriaList = new ObservableCollection<GroupFilterSortingCriteria>(SortCriteriaList.OrderBy(p => p.GroupFilterSortingString)); //FilterConditions = new ObservableCollection<GroupFilterConditionVM>(FilterConditions.OrderBy(p => p.ConditionTypeString)); }