public ActionResult SearchOption() { SearchOptionsViewModel model = new SearchOptionsViewModel(); model.allIds = ldcr.EmployeeDCR_Vw.Select(emp => emp.Employee_ID).ToList(); model.allCells = ldcr.EmployeeDCR_Vw.Select(emp => emp.HRCCell).Distinct().ToList(); model.Certifications = ldcr.Certifications.OrderBy(cert => cert.Code).ToList(); // System.Diagnostics.Debug.WriteLine(model.allCells.Count()+"MAOAOAOOAOAOAOAOA"); return(View(model)); }
public SearchOptionsPage() { InitializeComponent(); myVM = new SearchOptionsViewModel() { Navigation = this.Navigation }; BindingContext = myVM; Fill(myVM.activeSites); //SeriolizedSiteList sl = SeriolizedSiteList.Create(); }
/// <summary> /// Get searthing data /// </summary> /// <param name="model">model with search settings</param> /// <param name="user">user</param> /// <returns></returns> public IEnumerable <OperationViewModel> GetSearchingData(SearchOptionsViewModel model, IPrincipal user) { return(Database.Operations.Find(x => x.UserId == user.Identity.GetUserId()).ToList() // by user .Where(x => (model.CategoryId.HasValue ? x.CategoryId == model.CategoryId : true)) // by category .Where(x => (model.CurrencyId.HasValue ? x.CurrencyId == model.CurrencyId : true)) // by currency .Where(x => (model.Amount.HasValue ? x.Amount == model.Amount : true)) // by amount .Where(x => (model.CreateDate.HasValue ? x.CreateDate.Date == model.CreateDate.Value.Date : true)) // by date .Select(x => new OperationViewModel { CategoryName = x.Category?.Name, CurrencyName = x.Currency.Name, Comment = x.Comment, Amount = x.Amount, CreateDate = x.CreateDate, OperationType = x.OperationType })); }
public ActionResult _DynamicFilterBody(String keyName) { ViewBag.KeyName = keyName; SearchOptionsViewModel model = new SearchOptionsViewModel(); model.KeyName = keyName; //model.allIds = ldcr.EmployeeDCR_Vw.Select(emp => emp.Employee_ID).ToList(); model.allCells = ldcr.EmployeeDCR_Vw.Select(emp => emp.HRCCell).Distinct().ToList(); model.Certifications = ldcr.Certifications.OrderBy(cert => cert.Code).ToList(); model.allMedals = ldcr.Medals.ToList(); if (Request.IsAjaxRequest()) { return(PartialView(model)); // Here must be return PartialView, not View. } else { return(View()); } }
/// <summary> /// Fill dictionaries for search settings /// </summary> /// <param name="model"></param> /// <param name="user"></param> /// <returns></returns> public SearchOptionsViewModel FillDictionariesSearch(SearchOptionsViewModel model, IPrincipal user) { model.Currencies = new List <SelectListItem> { new SelectListItem() }; model.Categories = new List <SelectListItem> { new SelectListItem() }; model.Currencies.AddRange(_currencyService.GetCurrencies() .Select(x => new SelectListItem { Value = x.Id.ToString(), Text = x.Name })); model.Categories.AddRange(_categoryService.GetAllCategories(user) .Select(x => new SelectListItem { Value = x.Id.ToString(), Text = x.Name })); return(model); }
public TailViewModel Create(IEnumerable <FileInfo> filesInfo) { if (filesInfo == null) { throw new ArgumentNullException(nameof(filesInfo)); } if (!filesInfo.Any()) { throw new ArgumentException(nameof(filesInfo)); } var filesWatcher = _objectProvider.Get <FilesWatcher>(new[] { new ExplictArg("files", filesInfo), new ExplictArg("scheduler", _schedulerProvider.Background) }); var searchMetadataCollection = _objectProvider.Get <ISearchMetadataCollection>(); var searchHints = _objectProvider.Get <SearchHints>(); var searchOptionsViewModel = new SearchOptionsViewModel(searchMetadataCollection, _searchMetadataFactory, _schedulerProvider, _colourProvider, _iconProvider, searchHints); var searchInfo = _objectProvider.Get <ISearchInfoCollection> ( new[] { new ExplictArg("filesWatcher", filesWatcher.List), new ExplictArg("searchMetadataCollection", searchMetadataCollection) } ); return(_objectProvider.Get <TailViewModel>(new[] { new ExplictArg("fileWatcher", filesWatcher), new ExplictArg("searchInfoCollection", searchInfo), new ExplictArg("searchMetadataCollection", searchMetadataCollection), new ExplictArg("searchOptionsViewModel", searchOptionsViewModel) })); }
private TailViewModel CreateView(FileInfo fileInfo) { if (fileInfo == null) { throw new ArgumentNullException(nameof(fileInfo)); } var fileWatcher = _objectProvider.Get <IFileWatcher>(new[] { new ExplictArg("fileInfo", fileInfo), new ExplictArg("scheduler", _schedulerProvider.Background) }); var searchMetadataCollection = _objectProvider.Get <ISearchMetadataCollection>(); var searchHints = _objectProvider.Get <SearchHints>(); var searchOptionsViewModel = new SearchOptionsViewModel(searchMetadataCollection, _searchMetadataFactory, _schedulerProvider, _colourProvider, _iconProvider, _textAssociationCollection, searchHints); var searchInfo = _objectProvider.Get <ISearchInfoCollection> ( new[] { new ExplictArg("fileWatcher", fileWatcher), new ExplictArg("searchMetadataCollection", searchMetadataCollection), } ); //I hate explicity specify named args - so fragile but hey ho. var viewModel = _objectProvider.Get <TailViewModel>(new[] { new ExplictArg("fileWatcher", fileWatcher), new ExplictArg("searchInfoCollection", searchInfo), new ExplictArg("searchMetadataCollection", searchMetadataCollection), new ExplictArg("searchOptionsViewModel", searchOptionsViewModel), new ExplictArg("tailViewStateControllerFactory", _tailViewStateControllerFactory) }); return(viewModel); }
public TailViewModel Create(FileInfo fileInfo) { if (fileInfo == null) { throw new ArgumentNullException(nameof(fileInfo)); } var fileWatcher = _objectProvider.Get <IFileWatcher>(new[] { new ExplictArg("fileInfo", fileInfo), new ExplictArg("scheduler", _schedulerProvider.Background) }); var searchMetadataCollection = _objectProvider.Get <ISearchMetadataCollection>(); var searchHints = _objectProvider.Get <SearchHints>(); var searchOptionsViewModel = new SearchOptionsViewModel(searchMetadataCollection, _schedulerProvider, searchHints); var searchInfo = _objectProvider.Get <ISearchInfoCollection> ( new[] { new ExplictArg("fileWatcher", fileWatcher), new ExplictArg("searchMetadataCollection", searchMetadataCollection), } ); //I hate explicity specify named args - so fragile but hey ho. return(_objectProvider.Get <TailViewModel>(new[] { new ExplictArg("fileWatcher", fileWatcher), new ExplictArg("searchInfoCollection", searchInfo), new ExplictArg("searchMetadataCollection", searchMetadataCollection), new ExplictArg("searchOptionsViewModel", searchOptionsViewModel) })); }
public TailViewModel([NotNull] ILogger logger, [NotNull] ISchedulerProvider schedulerProvider, [NotNull] IFileWatcher fileWatcher, [NotNull] ISelectionMonitor selectionMonitor, [NotNull] IClipboardHandler clipboardHandler, [NotNull] ISearchInfoCollection searchInfoCollection, [NotNull] IInlineViewerFactory inlineViewerFactory, [NotNull] ISetting <GeneralOptions> generalOptions, [NotNull] ISearchMetadataCollection searchMetadataCollection, [NotNull] IStateBucketService stateBucketService, [NotNull] SearchOptionsViewModel searchOptionsViewModel, [NotNull] ITailViewStateRestorer restorer, [NotNull] SearchHints searchHints, [NotNull] ITailViewStateControllerFactory tailViewStateControllerFactory) { if (logger == null) { throw new ArgumentNullException(nameof(logger)); } if (schedulerProvider == null) { throw new ArgumentNullException(nameof(schedulerProvider)); } if (fileWatcher == null) { throw new ArgumentNullException(nameof(fileWatcher)); } if (selectionMonitor == null) { throw new ArgumentNullException(nameof(selectionMonitor)); } if (clipboardHandler == null) { throw new ArgumentNullException(nameof(clipboardHandler)); } if (searchInfoCollection == null) { throw new ArgumentNullException(nameof(searchInfoCollection)); } if (inlineViewerFactory == null) { throw new ArgumentNullException(nameof(inlineViewerFactory)); } if (generalOptions == null) { throw new ArgumentNullException(nameof(generalOptions)); } if (searchMetadataCollection == null) { throw new ArgumentNullException(nameof(searchMetadataCollection)); } if (stateBucketService == null) { throw new ArgumentNullException(nameof(stateBucketService)); } if (searchOptionsViewModel == null) { throw new ArgumentNullException(nameof(searchOptionsViewModel)); } if (searchHints == null) { throw new ArgumentNullException(nameof(searchHints)); } Name = fileWatcher.FullName; SelectionMonitor = selectionMonitor; SearchOptions = searchOptionsViewModel; SearchHints = searchHints; SearchCollection = new SearchCollection(searchInfoCollection, schedulerProvider); CopyToClipboardCommand = new Command(() => clipboardHandler.WriteToClipboard(selectionMonitor.GetSelectedText())); OpenFileCommand = new Command(() => Process.Start(fileWatcher.FullName)); OpenFolderCommand = new Command(() => Process.Start(fileWatcher.Folder)); SearchMetadataCollection = searchMetadataCollection; var horizonalScrollArgs = new ReplaySubject <TextScrollInfo>(1); HorizonalScrollChanged = args => { horizonalScrollArgs.OnNext(args); }; _tailViewStateControllerFactory = tailViewStateControllerFactory; //Move these 2 highlight fields to a service as all views require them UsingDarkTheme = generalOptions.Value .ObserveOn(schedulerProvider.MainThread) .Select(options => options.Theme == Theme.Dark) .ForBinding(); HighlightTail = generalOptions.Value .ObserveOn(schedulerProvider.MainThread) .Select(options => options.HighlightTail) .ForBinding(); //this deals with state when loading the system at start up and at shut-down _persister = new TailViewPersister(this, restorer); //An observable which acts as a scroll command var autoChanged = this.WhenValueChanged(vm => vm.AutoTail); var scroller = _userScrollRequested.CombineLatest(autoChanged, (user, auto) => { var mode = AutoTail ? ScrollReason.Tail : ScrollReason.User; return(new ScrollRequest(mode, user.PageSize, user.FirstIndex)); }) .Do(x => logger.Info("Scrolling to {0}/{1}", x.FirstIndex, x.PageSize)) .DistinctUntilChanged(); FileStatus = fileWatcher.Status.ForBinding(); //command to add the current search to the tail collection var searchInvoker = SearchHints.SearchRequested.Subscribe(request => { searchInfoCollection.Add(request.Text, request.UseRegEx); }); //User feedback to show file size FileSizeText = fileWatcher.Latest.Select(fn => fn.Size) .Select(size => size.FormatWithAbbreviation()) .DistinctUntilChanged() .ForBinding(); //tailer is the main object used to tail, scroll and filter in a file var lineScroller = new LineScroller(SearchCollection.Latest.ObserveOn(schedulerProvider.Background), scroller); MaximumChars = lineScroller.MaximumLines() .ObserveOn(schedulerProvider.MainThread) .ForBinding(); //load lines into observable collection var lineProxyFactory = new LineProxyFactory(new TextFormatter(searchMetadataCollection), new LineMatches(searchMetadataCollection), horizonalScrollArgs.DistinctUntilChanged()); var loader = lineScroller.Lines.Connect() .LogChanges(logger, "Received") .Transform(lineProxyFactory.Create, new ParallelisationOptions(ParallelType.Ordered, 3)) .LogChanges(logger, "Sorting") .Sort(SortExpressionComparer <LineProxy> .Ascending(proxy => proxy)) .ObserveOn(schedulerProvider.MainThread) .Bind(out _data, 100) .LogChanges(logger, "Bound") .DisposeMany() .LogErrors(logger) .Subscribe(); //monitor matching lines and start index, Count = searchInfoCollection.All.Select(latest => latest.Count).ForBinding(); CountText = searchInfoCollection.All.Select(latest => $"{latest.Count.ToString("##,###")} lines").ForBinding(); LatestCount = SearchCollection.Latest.Select(latest => latest.Count).ForBinding(); ////track first visible index var firstIndexMonitor = lineScroller.Lines.Connect() .Buffer(TimeSpan.FromMilliseconds(25)).FlattenBufferResult() .ToCollection() .Select(lines => lines.Count == 0 ? 0 : lines.Select(l => l.Index).Max() - lines.Count + 1) .ObserveOn(schedulerProvider.MainThread) .Subscribe(first => { FirstIndex = first; }); //Create objects required for inline viewing var isUserDefinedChanged = SearchCollection.WhenValueChanged(sc => sc.Selected) .Where(selected => selected != null) .Select(selected => selected.IsUserDefined) .DistinctUntilChanged() .Replay(1) .RefCount(); var inlineViewerVisible = isUserDefinedChanged.CombineLatest(this.WhenValueChanged(vm => vm.ShowInline), (userDefined, showInline) => userDefined && showInline); CanViewInline = isUserDefinedChanged.ForBinding(); InlineViewerVisible = inlineViewerVisible.ForBinding(); //return an empty line provider unless user is viewing inline - this saves needless trips to the file var inline = searchInfoCollection.All.CombineLatest(inlineViewerVisible, (index, ud) => ud ? index : new EmptyLineProvider()); InlineViewer = inlineViewerFactory.Create(inline, this.WhenValueChanged(vm => vm.SelectedItem), searchMetadataCollection); _cleanUp = new CompositeDisposable(lineScroller, loader, firstIndexMonitor, FileStatus, Count, LatestCount, FileSizeText, CanViewInline, InlineViewer, InlineViewerVisible, SearchCollection, searchInfoCollection, HighlightTail, UsingDarkTheme, searchHints, searchMetadataCollection, SelectionMonitor, SearchOptions, searchInvoker, MaximumChars, _stateMonitor, horizonalScrollArgs.SetAsComplete(), _userScrollRequested.SetAsComplete()); }
public TailViewModel([NotNull] ILogger logger, [NotNull] ISchedulerProvider schedulerProvider, [NotNull] IEnumerable <IFileWatcher> fileWatcher, [NotNull] ISelectionMonitor selectionMonitor, [NotNull] IClipboardHandler clipboardHandler, [NotNull] ISearchInfoCollection searchInfoCollection, [NotNull] IInlineViewerFactory inlineViewerFactory, [NotNull] ISetting <GeneralOptions> generalOptions, [NotNull] ISearchMetadataCollection searchMetadataCollection, [NotNull] SearchOptionsViewModel searchOptionsViewModel, [NotNull] SearchHints searchHints) { if (logger == null) { throw new ArgumentNullException(nameof(logger)); } if (schedulerProvider == null) { throw new ArgumentNullException(nameof(schedulerProvider)); } if (fileWatcher == null) { throw new ArgumentNullException(nameof(fileWatcher)); } if (selectionMonitor == null) { throw new ArgumentNullException(nameof(selectionMonitor)); } if (clipboardHandler == null) { throw new ArgumentNullException(nameof(clipboardHandler)); } if (searchInfoCollection == null) { throw new ArgumentNullException(nameof(searchInfoCollection)); } if (inlineViewerFactory == null) { throw new ArgumentNullException(nameof(inlineViewerFactory)); } if (generalOptions == null) { throw new ArgumentNullException(nameof(generalOptions)); } if (searchMetadataCollection == null) { throw new ArgumentNullException(nameof(searchMetadataCollection)); } if (searchOptionsViewModel == null) { throw new ArgumentNullException(nameof(searchOptionsViewModel)); } if (searchHints == null) { throw new ArgumentNullException(nameof(searchHints)); } _stateProvider = new TailViewPersister(this); var enumerable = fileWatcher as IFileWatcher[] ?? fileWatcher.ToArray(); Names = enumerable.Select(t => t.FullName); SelectionMonitor = selectionMonitor; SearchOptions = searchOptionsViewModel; SearchHints = searchHints; SearchCollection = new SearchCollection(searchInfoCollection, schedulerProvider); CopyToClipboardCommand = new Command(() => clipboardHandler.WriteToClipboard(selectionMonitor.GetSelectedText())); OpenFileCommand = new Command(() => Process.Start(enumerable[0].FullName)); OpenFolderCommand = new Command(() => Process.Start(enumerable[0].Folder)); UsingDarkTheme = generalOptions.Value .ObserveOn(schedulerProvider.MainThread) .Select(options => options.Theme == Theme.Dark) .ForBinding(); HighlightTail = generalOptions.Value .ObserveOn(schedulerProvider.MainThread) .Select(options => options.HighlightTail) .ForBinding(); HighlightDuration = generalOptions.Value .ObserveOn(schedulerProvider.MainThread) .Select(options => new Duration(TimeSpan.FromSeconds(options.HighlightDuration))) .ForBinding(); //An observable which acts as a scroll command var autoChanged = this.WhenValueChanged(vm => vm.AutoTail); var scroller = _userScrollRequested.CombineLatest(autoChanged, (user, auto) => { var mode = AutoTail ? ScrollReason.Tail : ScrollReason.User; return(new ScrollRequest(mode, user.PageSize, user.FirstIndex)); }) .Do(x => logger.Info("Scrolling to {0}/{1}", x.FirstIndex, x.PageSize)) .DistinctUntilChanged(); FileStatus = enumerable .Select(t => t.Status) .Merge() .Scan(default(FileStatus), (status, fileStatus) => status | fileStatus) .ForBinding(); //command to add the current search to the tail collection var searchInvoker = SearchHints.SearchRequested.Subscribe( request => { searchInfoCollection.Add(request.Text, request.UseRegEx); }); //User feedback to show file size FileSizeText = enumerable .Select(t => t.Latest) .Merge() .Select(t => t.Size) .Scan(0f, (previousSize, currentSize) => previousSize + currentSize / 2f) .Select(t => ((long)t).FormatWithAbbreviation()) .DistinctUntilChanged() .ForBinding(); //tailer is the main object used to tail, scroll and filter in a file var lineScroller = new LineScroller(SearchCollection.Latest.ObserveOn(schedulerProvider.Background), scroller); //load lines into observable collection var lineProxyFactory = new LineProxyFactory(new TextFormatter(searchMetadataCollection), new LineMatches(searchMetadataCollection)); var loader = lineScroller.Lines.Connect() .RecordChanges(logger, "Received") .Transform(lineProxyFactory.Create, new ParallelisationOptions(ParallelType.Ordered, 3)) .Sort(SortExpressionComparer <LineProxy> .Ascending(proxy => proxy)) .ObserveOn(schedulerProvider.MainThread) .Bind(out _data, 100) .DisposeMany() .LogErrors(logger) .Subscribe(); //monitor matching lines and start index, Count = searchInfoCollection.All .GroupBy(t => t) .Select(groupedProvider => groupedProvider.Key.Count) .Scan(0, (i, providerCount) => i + providerCount) .ForBinding(); CountText = searchInfoCollection.All .GroupBy(t => t) .Select(groupedProvider => groupedProvider.Key.Count) .Scan(0, (i, providerCount) => i + providerCount) .Select(latestCount => $"{latestCount.ToString("##,###")} lines") .ForBinding(); //iterate over every items to evaluate the lines' count LatestCount = SearchCollection.Latest .GroupBy(t => t) .Do(Console.WriteLine) .Scan(0, (acc, provider) => { if (provider.Key is IndexCollection && provider.Key.NumberOfPreviousProvider == 0) { acc = 0; } else if (provider.Key is FileSearchResult && provider.Key.NumberOfPreviousProvider == 0) { acc = 0; } return(provider.Key.Count + acc); }) .ForBinding(); ////track first visible index var firstIndexMonitor = lineScroller.Lines.Connect() .Buffer(TimeSpan.FromMilliseconds(25)).FlattenBufferResult() .ToCollection() .Select(lines => lines.Count == 0 ? 0 : lines.Select(l => l.Index).Max() - lines.Count + 1) .ObserveOn(schedulerProvider.MainThread) .Subscribe(first => { FirstIndex = first; }); //Create objects required for inline viewing var isUserDefinedChanged = SearchCollection.WhenValueChanged(sc => sc.Selected) .Where(selected => selected != null) .Select(selected => selected.IsUserDefined) .DistinctUntilChanged() .Replay(1) .RefCount(); var inlineViewerVisible = isUserDefinedChanged.CombineLatest(this.WhenValueChanged(vm => vm.ShowInline), (userDefined, showInline) => userDefined && showInline); CanViewInline = isUserDefinedChanged.ForBinding(); InlineViewerVisible = inlineViewerVisible.ForBinding(); //return an empty line provider unless user is viewing inline - this saves needless trips to the file var inline = searchInfoCollection.All.CombineLatest(inlineViewerVisible, (index, ud) => ud ? index : new EmptyLineProvider()); var firstVisibleRow = _data.ToObservableChangeSet().ToCollection() .Select(collection => collection.FirstOrDefault()); //var itemToSelect = this.WhenValueChanged(vm => vm.SelectedItem) // .CombineLatest(firstVisibleRow, (selected, first) => selected ?? first); //// InlineViewer = inlineViewerFactory.Create(inline, this.WhenValueChanged(vm => vm.SelectedItem), lineProxyFactory); _cleanUp = new CompositeDisposable(lineScroller, loader, firstIndexMonitor, FileStatus, Count, LatestCount, FileSizeText, CanViewInline, InlineViewer, InlineViewerVisible, SearchCollection, searchInfoCollection, HighlightTail, UsingDarkTheme, searchHints, searchMetadataCollection, searchMetadataCollection, SelectionMonitor, SearchOptions, searchInvoker, _userScrollRequested.SetAsComplete()); }
public ActionResult Search(SearchOptionsViewModel model) { return(View("DataTable", _operationService.GetSearchingData(model, User))); }
public ActionResult Testing(int?page, String Type = "", String data = "") { SearchOptionsViewModel model = new SearchOptionsViewModel(); model.filters = ldcr.Filters.ToList(); var type = Type.Split('-'); var Month = ""; if (type.Count() > 1) { ViewBag.Type = type[0]; Month = type[1]; } else { ViewBag.Type = Type; } ViewBag.Data = data; ViewBag.Month = Month; // Get all Employees from Database //System.Diagnostics.Debug.WriteLine( (!string.IsNullOrEmpty(Type) && !string.IsNullOrEmpty(data))+ "sahdfjsfsdfhjd" ); if (!string.IsNullOrEmpty(Type) && !string.IsNullOrEmpty(data)) { List <EmployeeDCR_Vw> employees = new List <EmployeeDCR_Vw>(); if (Type.ToString().ToUpper().Equals("BYMONTH")) { employees = getEmployeeByMonth(data); } if (Type.ToString().ToUpper().Equals("BYYEAR")) { employees = getEmployeeByYear(data); } if (Type.ToString().ToUpper().Equals("BYCERTIFICATES")) { employees = getEmployeeByCertificates(data); } if (Type.ToString().ToUpper().Equals("BYRCERTIFICATES")) { employees = getEmployeeByRCertificates(data); } if (Type.ToString().ToUpper().Equals("BYCELL")) { employees = getEmployeeByCell(data); } // wala pa neh //if (Type.ToString().ToUpper().Equals("BYMEDAL")) //{ // employees = getEmployeeByMedal(data); //} //if (Type.ToString().ToUpper().Equals("BYLASTNAME")) //{ // employees = getEmployeeByLastName(data); //} if (Type.ToString().ToUpper().Equals("BYMONTHANDYEAR") || type[0].ToString().ToUpper().Equals("BYMONTHANDYEAR")) { employees = getEmployeeByMonthAndYear(data, Month); } // kutob dire ViewBag.EmpCount = employees.Count(); int pageSize = 10; // pagelist number of page int pageNumber = (page ?? 1); return(View(employees.ToPagedList(pageNumber, pageSize))); } else { List <EmployeeDCR_Vw> employees = ldcr.EmployeeDCR_Vw.OrderBy(a => a.Last_Name).ToList(); ViewBag.EmpCount = employees.Count(); int pageSize = 10; // pagelist number of page int pageNumber = (page ?? 1); return(View(employees.ToPagedList(pageNumber, pageSize))); } }