コード例 #1
0
 private void SaveNewFilter(IFilterSetupViewModel filterSetupViewModel)
 {
     TheDynamicTypeManager.Value.BeginNewEditableRoot<IFilterEdit>(
         Constants.FilterProcessName,
         async (s, e) =>
         {
             if (e.Error == null)
             {
                 await SaveFilter(filterSetupViewModel, e.Object);
             }
             else
             {
                 ThePopupFactory.Value.NotifyFailure(e.Error);
             }
         });
 }
コード例 #2
0
        private async Task SaveFilter(IFilterSetupViewModel filterSetupViewModel, IFilterEdit filterEdit)
        {
            filterEdit.Name = filterSetupViewModel.Name;
            filterEdit.FilterDefinition = filterSetupViewModel.FilterDefinitions;
            filterEdit.ProcessSystemName = SearchViewModel.ProcessSystemName;
            filterEdit.DefaultLayout = filterSetupViewModel.DefaultLayoutId;

            if (string.IsNullOrWhiteSpace(filterEdit.Guid))
                filterEdit.Guid = FilterDescriptor.GetFilterGuid(filterSetupViewModel.FilterDefinitions);

            var filterVm = FilterList.FirstOrDefault(l => l.Id == filterEdit.Id);
            
            filterEdit.Account = filterVm != null && filterVm.IsAdmin ? null : (int?)Utils.CurrentUserAccountId;

            try
            {
                // ReSharper disable SuspiciousTypeConversion.Global
                var edited = await ((ISavable)filterEdit).SaveAsync() as IFilterEdit;
                // ReSharper restore SuspiciousTypeConversion.Global

                if (edited != null)
                {
                    QuickFilterToolbarVM.Value.SetQuickFilter(filterSetupViewModel.QuickFilter, edited.Id);
                }

                SelectedFilter = filterVm;
                if (SelectedFilter != null)
                {
                    SelectedFilter.OriginalFilterDefinitions = filterSetupViewModel.FilterDefinitions;
                    SelectedFilter.QuickFilter = filterSetupViewModel.QuickFilter;
                }

                ThePopupFactory.Value.NotifySuccess(SharedLocalizedStrings.Msg_FilterSaved);

                await RefreshFilters();
                await QuickFilterToolbarVM.Value.RefreshQuickFilters();
            }
            catch (Exception ex)
            {
                ThePopupFactory.Value.NotifyFailure(ex);
            }
        }
コード例 #3
0
 private static void Static(WeakEventListener<FilterListViewModel, IFilterSetupViewModel, PropertyChangedEventArgs> listener, IFilterSetupViewModel source)
 {
     source.PropertyChanged -= listener.OnEvent;
 }