public async Task<IHttpActionResult> GetFavorites() { try { var filter = new FilterDescriptor( Constants.FilterAccount + "Id", FilterOperator.IsEqualTo, Utils.CurrentUserAccountId == -1 ? null : (int?)Utils.CurrentUserAccountId) { MemberType = typeof(int) }; var procList = ProcessList.GetProcessList(); var favoriteList = DynamicTypeManager.GetInfoList<IFavoriteInfo>( new PagedCriteria { ProcessName = Constants.FavoriteProcessName, PageNumber = 0, PageSize = int.MaxValue, NotCalculateAccessDeniedList = true, FilterDefinition = filter.ToJSON() }); var list = procList.Where(x => favoriteList.Select(s => GetProcessSystemName(s.ProcessSystemName)).Contains(x.Name)).Select(x => new FavoriteInfo() { Name = x.Name, ProcessSystemName = x.SystemName, BackgroundColor = ColorTranslator.ToHtml(Color.FromArgb((int)x.ProcessColor)) }).ToList(); return await Task.FromResult<IHttpActionResult>(Ok(list)); } catch (Exception ex) { throw; } }
/// <summary> /// Gets the or create user filter for. /// </summary> /// <param name="filterGuid">The filter unique identifier.</param> /// <param name="callback">The callback.</param> public void GetOrCreateUserFilterFor(Guid filterGuid, Action<IFilterEdit> callback) { var filter = new FilterDescriptor( LogicalOperators.And, new MobileObservableCollection<IFilterDescriptor> { new FilterDescriptor("Guid", FilterOperator.IsEqualTo, filterGuid.ToString()), new FilterDescriptor("Account", FilterOperator.IsEqualTo, Veyron.SharedTypes.Utils.CurrentUserAccountId) }); Action<object, DataPortalResult<IInfoList>> filterLoadedAction = (o, result) => { // error - return null if (result.Error != null) { callback(null); return; } // not filters found - return new filter if (result.Object.Count == 0) { TheDynamicTypeManager.BeginNewEditableRoot(Constants.FilterProcessName, (o1, portalResult) => callback(portalResult.Error == null ? (IFilterEdit)portalResult.Object : null)); return; } // filters found - return found filter TheDynamicTypeManager.BeginGetEditableRoot<IFilterEdit>(Constants.FilterProcessName, ((IInfoClass)result.Object[0]).Id, (o1, portalResult) => callback(portalResult.Error == null ? portalResult.Object : null)); }; TheDynamicTypeManager.BeginGetList(Constants.FilterProcessName, filterLoadedAction, new SortList { new SortDescriptor(Constants.LastModifiedColumnName, SortDirection.Descending) }, pageSize: 1, filterExpression: filter.ToJSON()); }
public void ApplyingSortingPreserveFilteringGottenFrom_MCR_ShowSearchReferenced() { var vm = GetNewSearchListVm(); Mock.Arrange(() => vm.ProcessSystemName).Returns("processName"); Mock.Arrange(() => vm.FilterString).Returns("filterString"); Mock.Arrange(() => vm.SortDescriptors).Returns(new SortList()); Mock.Arrange(() => vm.GroupColumn).Returns("groupColumn"); Mock.Arrange(() => vm.Columns).Returns(new ColumnCollection()); var quickFilterToolbarViewModel = new QuickFilterToolbarViewModel(); vm.QuickFilterToolbarVM = new Lazy<QuickFilterToolbarViewModel>(); Mock.Arrange(() => quickFilterToolbarViewModel.RefreshQuickFilters()).Returns(TaskHelper.GetEmptyTask); Mock.Arrange(() => vm.QuickFilterToolbarVM.Value).Returns(quickFilterToolbarViewModel); var filterListVM = new FilterListViewModel(); Mock.Arrange(() => vm.FilterListVM).Returns(filterListVM); var filterDescriptor = new FilterDescriptor(); Mock.Arrange(() => filterDescriptor.ToJSON()).Returns("expected"); var filterList = new MobileObservableCollection<IFilterDescriptor> { filterDescriptor }; Mock.NonPublic.Arrange(vm, "AddMandatoryFilter", ArgExpr.IsAny<MobileObservableCollection<IFilterDescriptor>>()).DoNothing(); Mock.Arrange(() => vm.TheFetchSearchListService.Refresh( Arg.AnyString, Arg.AnyInt, Arg.AnyInt, Arg.IsAny<SortList>(), Arg.AnyString, Arg.IsAny<ColumnCollection>(), Arg.IsAny<MobileObservableCollection<IFilterDescriptor>>(), Arg.AnyString, Arg.IsAny<Action<DataPortalResult<IInfoList>>>())).DoNothing(); vm.RefreshSearchList(filterList); Assert.AreEqual("expected", vm.AppliedFilter.TempFilterDefinitions); }
private async Task<IFilterInfo> LoadFilterInfo(Guid filterGuid) { var dataFilter = new FilterDescriptor( LogicalOperators.And, new MobileObservableCollection<IFilterDescriptor> { new FilterDescriptor("Guid", FilterOperator.IsEqualTo, filterGuid.ToString()) { MemberType = typeof (string) } }); var list = await TheDynamicTypeManager.BeginGetListAsync<IFilterList<IFilterInfo>>( new PagedCriteria { ProcessName = Constants.FilterProcessName, PageNumber = 0, PageSize = 1, LimitResultColumns = false, FilterDefinition = dataFilter.ToJSON() }); return list.FirstOrDefault(); }