public void RefreshData() { if (this.Context == null) throw new Exception("Error, no context set for this task."); List<SearchContext> searches = new List<SearchContext>(); ProcessDonationsMode mode = this.GetDonationsMode(); if (this.HasMode(ProcessDonationsMode.BIDS)) searches.Add(this.Context.DeferredSearch("donation", this.GetBidSearchParams())); if (this.HasMode(ProcessDonationsMode.COMMMENTS)) searches.Add(this.Context.DeferredSearch("donation", this.GetCommentSearchParams())); AggregateSearchContext metaSearcher = new AggregateSearchContext(searches.ToArray()); metaSearcher.Completed += this.OnSearchComplete; metaSearcher.Error += this.OnSearchError; this.DonationBinding.DisableControls(); this.SearchBinding.DisableControls(); metaSearcher.Begin(); }
private void RunTablesRefresh(int id, JoinWaiter waiter) { foreach (var tablePair in this.TableBindings) { var table = tablePair.Item1; var mapping = tablePair.Item2; table.DisableControls(); waiter.AddProcess(); IEnumerable<string> models; if (mapping.GetModel.IsAbstract) { models = mapping.GetModel.GetChildEntities().Select(e => e.ModelName); } else { models = new string[]{ mapping.ModelName }; } AggregateSearchContext searcher = new AggregateSearchContext(models.Select(m => new SearchContext(this.Context, m, Util.CreateRequestParams(mapping.SearchKeyField, id.ToString())))); searcher.Completed += (results) => { table.LoadArray(results); waiter.ProcessComplete(); table.EnableControls(); }; searcher.Error += (errorList) => { foreach (var error in errorList) this.OnError(error.ErrorType, error.Message); waiter.ProcessComplete(); table.EnableControls(); }; searcher.Begin(); } }