/// <summary> /// This is called by the Find dialog to locate the next name /// </summary> /// <param name="finder"></param> private void OnFindNext(FindSearchViewModel finder) { Debug.Assert(finder == _finder); IEnumerable <int> searchRange; if (finder.SearchBackward) { int spos = (FocusedRow != null) ? FocusedRow.Position : TotalRows; searchRange = Enumerable.Range(0, spos).Reverse(); } else { int spos = (FocusedRow != null) ? FocusedRow.Position : -1; searchRange = Enumerable.Range(spos + 1, TotalRows - (spos + 1)); } int foundAt = searchRange.Where(i => VisibleData[i].IsSequence).FirstOrDefault( i => finder.Match(VisibleData[i].Header)); if (foundAt == 0 && !finder.Match(VisibleData[0].Header)) { IErrorVisualizer errorVisualizer = Resolve <IErrorVisualizer>(); if (errorVisualizer != null) { errorVisualizer.Show("No Match", "No matches were found."); } } else { FocusedRow = VisibleData[foundAt]; TopRow = foundAt; } }
protected override void CreateChildControls() { base.CreateChildControls(); string VendorID = Page.Request.QueryString["VendorID"]; gridView = new GridView(); gridView.ID = Gridid; gridView.AutoGenerateColumns = false; gridView.Width = 550; gridView.HeaderStyle.BackColor = System.Drawing.Color.LightGray; gridView.HeaderStyle.Font.Bold = true; gridView.Columns.Clear(); errorVisualizer = new ErrorVisualizer(this); presenter = new VendorTransactionListViewPresenter(this); presenter.VendorId = VendorID; presenter.ErrorVisualizer = errorVisualizer; //Load the data presenter.SetVendorDetails(); Controls.Add(gridView); }
private void EnsureErrorVisualizer(IErrorVisualizer errorVisualizer, Exception originalException) { if (errorVisualizer == null) { string errorMessage = string.Format(CultureInfo.CurrentCulture, "IErrorVisualizer was not found."); throw new ExceptionHandlingException( BuildExceptionHandlingErrorMessage(null, originalException, errorMessage) , originalException); } }
public void HandleViewException(Exception exception, IErrorVisualizer errorVisualizer, int eventId) { try { ILogger logger = GetLogger(exception); logger.LogToOperations(exception, eventId, EventLogEntryType.Error, null); EnsureErrorVisualizer(errorVisualizer, exception); errorVisualizer.ShowDefaultErrorMessage(); } catch (ExceptionHandlingException) { throw; } catch (Exception handlingException) { this.ThrowExceptionHandlingException(handlingException, exception); } }
/// <summary> /// This retrieves a list of databases for this connection /// </summary> /// <returns></returns> public List <string> GetDatabaseList(bool showError) { if (_dbNames.Count == 0 && IsValid) { DbProviderFactory dbFac = DbProviderFactories.GetFactory(Provider); using (DbConnection dbConn = dbFac.CreateConnection()) { dbConn.ConnectionString = BuildConnectionString(); DbCommand cmd = dbConn.CreateCommand(); cmd.CommandText = "sp_databases"; cmd.CommandType = CommandType.StoredProcedure; try { dbConn.Open(); using (var reader = cmd.ExecuteReader()) { while (reader.Read()) { _dbNames.Add(reader[0].ToString()); } } } catch (DbException ex) { if (showError == true) { IErrorVisualizer errorVisualizer = ViewModel.ServiceProvider.Resolve <IErrorVisualizer>(); if (errorVisualizer != null) { errorVisualizer.Show("Error connecting to database", ex.Message); } } } } } return(_dbNames); }
public void ShowPricing(string productSku) { try { if (!string.IsNullOrEmpty(productSku)) { IPricingRepository pricingRepository = SharePointServiceLocator.Current.GetInstance <IPricingRepository>(); Price price = pricingRepository.GetPriceBySku(productSku); if (price == null) { this.PriceText = "There is no price available for this product."; } else { this.PriceText = price.Value.ToString("C", CultureInfo.CurrentUICulture); } } else { PriceText = "The product has not been specified."; } this.DataBind(); } catch (Exception ex) { // If an unknown exception occurs we want to: // 1. Log the error // 2. Display a friendly (Non technical) error message. // The ViewExceptionHandler will do that for us: ViewExceptionHandler viewExceptionHandler = new ViewExceptionHandler(); // In this example, we are looking for an error visualizer up in the tree and using that to display the error. // Find the error Visualizer (in this case, the one that was added by the PricingWebPart.cs: IErrorVisualizer errorVisualizer = ViewExceptionHandler.FindErrorVisualizer(this); // Now log the error and display a friendly error message using the error visualizer. viewExceptionHandler.HandleViewException(ex, errorVisualizer, string.Format(CultureInfo.CurrentUICulture, "Due to a technical problem, the pricing information for sku '{0}' could not be retrieved. Please try again later.", productSku)); } }
public void ShowFunctionalErrorMessage(string errorMessage, IErrorVisualizer errorVisualizer) { try { if (errorVisualizer == null) { throw new ArgumentNullException("errorVisualizer"); } ILogger logger = GetLogger(null); logger.TraceToDeveloper(errorMessage); errorVisualizer.ShowErrorMessage(errorMessage); } catch (ExceptionHandlingException) { throw; } catch (Exception handlingException) { this.ThrowExceptionHandlingException(handlingException, null); } }
public static IErrorVisualizer FindErrorVisualizer(Control control) { if (control == null) { throw new ArgumentNullException("control"); } Control currentControl = control; do { IErrorVisualizer errorVisualizer = currentControl as IErrorVisualizer; if (errorVisualizer != null) { return(errorVisualizer); } currentControl = currentControl.Parent; } while (currentControl != null); return(null); }
public int Load() { string dbConnectionString = _dbConnection.Connection.BuildConnectionString(); try { _dc = CreateDbContext(dbConnectionString); // Retrieve all the TAXIDs we want. We essentially want all taxonomy IDs // which are parented by the selected id. The easiest way to do this is with a // CTE using SQL2005+. Unfortunately, LINQ doesn't support that so we drop to straight // T-SQL for this. const string sqlQuery = @"with cte as (select TaxID from Taxonomy where TaxID={0} " + @"union all select t.TaxID from Taxonomy t join cte tp on t.ParentTaxID = tp.TaxID) " + @"select * from cte"; var results = _dc .ExecuteQuery <Taxonomy>(sqlQuery, _dbConnection.ParentTaxId) .Select(tax => tax.TaxID).ToList(); // BUGBUG: if the # of sequences is > 2100 then we cannot generate the proper // query here since T-SQL doesn't support that many parameters. So, here we'll group // it in batches of 2000. var queryGroups = results.Select((id, index) => new { GroupID = index / 2000, id }).GroupBy(x => x.GroupID); // Now, grab all the sequences from this group of TaxIds. // select distinct seqid from dbo.sequence where alnid = @alignment_id //KJD (10/21/2009) - Change query to use vAlignmentGridUngapped which takes into account column indirection supported by the rCAD schema //instead of querying the Sequence table directly var allSequences = new List <int>(); foreach (var singleGroup in queryGroups) { var thisGroup = singleGroup; var query = from seq in _dc.SequenceMains where thisGroup.Select(x => x.id).Contains(seq.TaxID) && _dc.vAlignmentGridUngappeds.Where(s => ((s.SeqID == seq.SeqID) && (s.AlnID == _dbConnection.AlignmentId))).FirstOrDefault() != null && seq.TaxID > 0 && seq.SeqLength > 0 && (_dbConnection.LocationId == 0 || seq.LocationID == _dbConnection.LocationId) && (seq.SeqTypeID == _dbConnection.SequenceTypeId) select seq.SeqID; allSequences.AddRange(query.Cast <int>()); } // Now get the sequence headers based on the above collection queryGroups = allSequences.Distinct().Select((id, index) => new { GroupID = index / 1000, id }).GroupBy(x => x.GroupID); _entities = new List <IAlignedBioEntity>(); // 2 minute timeout _dc.CommandTimeout = 60 * 2 * 1000; // Now execute the queries //KJD (10/21/2009) - Change query to use vAlignmentGridUngapped which takes into account column indirection supported by the rCAD schema //instead of querying the Sequence table directly foreach (var singleGroup in queryGroups) { var thisGroup = singleGroup; var query = from smd in _dc.SequenceMains from tax in _dc.TaxonomyNamesOrdereds let maxColumnNumber = _dc.vAlignmentGridUngappeds.Where(s => ((s.SeqID == smd.SeqID) && (s.AlnID == _dbConnection.AlignmentId))).Max(s => s.LogicalColumnNumber) where thisGroup.Select(x => x.id).Contains(smd.SeqID) && tax.TaxID == smd.TaxID select new DbAlignedBioEntity(_dc, dbConnectionString, smd.SeqID, _dbConnection.AlignmentId, maxColumnNumber) { ScientificName = tax.ScientificName, TaxonomyId = tax.LineageName, Validator = BioValidator.rRNAValidator }; // Add the results to our list. _entities.AddRange(query.Cast <IAlignedBioEntity>()); } return(_entities.Count); } catch (Exception ex) { IErrorVisualizer errorVisualizer = ViewModel.ServiceProvider.Resolve <IErrorVisualizer>(); if (errorVisualizer != null) { errorVisualizer.Show("Encountered error loading data", ex.Message); } _dc.Dispose(); _dc = null; } return(0); }
public void HandleViewException(Exception exception, IErrorVisualizer errorVisualizer) { HandleViewException(exception, errorVisualizer, defaultEventID); }
public void HandleViewException(Exception exception, IErrorVisualizer errorVisualizer, string customErrorMessage) { HandleViewException(exception, errorVisualizer, customErrorMessage, defaultEventID); }
public override void HandleViewException(Exception exception, IErrorVisualizer errorVisualizer) { errorVisualizer.ShowErrorMessage(exception.Message); }