/// <summary> /// Render Error Message Literal Controls /// Error Type and Error Text /// </summary> /// <param name="htmlTextWriter">HtmlTextWriter to Add the Items</param> /// <param name="slkError">Error Items</param> internal static void RenderErrorItems(HtmlTextWriter htmlTextWriter, SlkError slkError) { //Controls to Render Error Literal lcErrorText = new Literal(); lcErrorText.ID = "lcErrorText"; lcErrorText.Text = slkError.ErrorText; htmlTextWriter.AddAttribute(HtmlTextWriterAttribute.Width, "100%"); using (new HtmlBlock(HtmlTextWriterTag.Div, 1, htmlTextWriter)) { // render the "<table>" element and its contents htmlTextWriter.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0"); htmlTextWriter.AddAttribute(HtmlTextWriterAttribute.Width, "100%"); htmlTextWriter.AddAttribute(HtmlTextWriterAttribute.Border, "0"); htmlTextWriter.AddAttribute(HtmlTextWriterAttribute.Class, "ms-summarycustombody"); htmlTextWriter.AddAttribute(HtmlTextWriterAttribute.Style, "padding:3px 2px 4px 4px;"); htmlTextWriter.AddStyleAttribute(HtmlTextWriterStyle.Margin, "0px"); using (new HtmlBlock(HtmlTextWriterTag.Table, 1, htmlTextWriter)) { using (new HtmlBlock(HtmlTextWriterTag.Tr, 1, htmlTextWriter)) { if (!(slkError.ErrorType == ErrorType.Info)) { //Add Attributes for the <TD> tag htmlTextWriter.AddAttribute(HtmlTextWriterAttribute.Style, "width: 22px;"); htmlTextWriter.AddAttribute(HtmlTextWriterAttribute.Valign, "top"); htmlTextWriter.AddAttribute(HtmlTextWriterAttribute.Align, "left"); using (new HtmlBlock(HtmlTextWriterTag.Td, 1, htmlTextWriter)) { Image imgError = RenderImage(slkError.ErrorType); imgError.RenderControl(htmlTextWriter); } } htmlTextWriter.AddAttribute(HtmlTextWriterAttribute.Valign, "top"); htmlTextWriter.AddAttribute(HtmlTextWriterAttribute.Align, "left"); htmlTextWriter.AddAttribute(HtmlTextWriterAttribute.Width, "100%"); htmlTextWriter.AddAttribute(HtmlTextWriterAttribute.Class, "ms-vb"); using (new HtmlBlock(HtmlTextWriterTag.Td, 1, htmlTextWriter)) { lcErrorText.RenderControl(htmlTextWriter); } } } } }
protected override void RenderContents(HtmlTextWriter writer) { try { DumpCultures(writer, "RenderContents"); //Render Assignment List webpart RenderAssignmentList(writer); } catch (System.Threading.ThreadAbortException) { // Not much we can do about this. } catch (SafeToDisplayException e) { SlkError slkError = new SlkError(ErrorType.Error, Constants.Space + e.Message); ErrorBanner.RenderErrorItems(writer, slkError); } catch (UserNotFoundException e) { SlkError slkError = new SlkError(ErrorType.Info, Constants.Space + e.Message); ErrorBanner.RenderErrorItems(writer, slkError); } catch (SqlException e) { ISlkStore store = null; try { store = SlkStore; } catch (Exception) { } SlkError slkError = SlkError.WriteException(store, e); ErrorBanner.RenderErrorItems(writer, slkError); } catch (Exception ex) { ISlkStore store = null; try { store = SlkStore; } catch (Exception) { } SlkError slkError = SlkError.WriteException(store, ex); ErrorBanner.RenderErrorItems(writer, slkError); } }
protected void Page_Load(object sender, EventArgs e) { try { // render the HTML for the page using (HtmlTextWriter hw = new HtmlTextWriter(Response.Output, " ")) { // render the "<html>" element and its contents using (new HtmlBlock(HtmlTextWriterTag.Html, 0, hw)) { RenderHead(hw); try { string querySetName = QueryString.ParseString(QueryStringKeys.QuerySet); // set <querySetDef> to the QuerySetDefinition named <querySetName> QuerySetDefinition querySetDef = SlkStore.Settings.FindQuerySetDefinition(querySetName, true); if (querySetDef == null) { throw new SafeToDisplayException(PageCulture.Resources.AlwpQuerySetNotFound, querySetName); } // render the "<body>" element and its contents //hw.AddAttribute(HtmlTextWriterAttribute.Style, "overflow: hidden;"); hw.AddAttribute(HtmlTextWriterAttribute.Style, "width: 100%; overflow-y: auto;"); hw.AddAttribute(HtmlTextWriterAttribute.Id, "SlkAlwpQuerySet"); hw.AddAttribute(HtmlTextWriterAttribute.Onclick, string.Empty); using (new HtmlBlock(HtmlTextWriterTag.Body, 0, hw)) { AssignmentListWebPart.DumpCultures(hw, "Page_Load"); // begin the query set hw.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0"); hw.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0"); hw.AddAttribute(HtmlTextWriterAttribute.Border, "0"); hw.AddAttribute(HtmlTextWriterAttribute.Class, "ms-toolbar"); hw.AddAttribute(HtmlTextWriterAttribute.Style, "border: none; background-image: none; width:100%; height:100%;"); hw.AddAttribute(HtmlTextWriterAttribute.Onclick, string.Empty); using (new HtmlBlock(HtmlTextWriterTag.Table, 1, hw)) { RenderQueryLines(hw, querySetDef); RenderQuerySummary(hw, querySetDef); } } } catch (Exception ex) { SlkError slkError; //Handles SqlException separately to capture the deadlock //and treat it differently SqlException sqlEx = ex as SqlException; if (sqlEx != null) { slkError = WebParts.ErrorBanner.WriteException(SlkStore, sqlEx); } else { slkError = SlkError.WriteException(SlkStore, ex); } WebParts.ErrorBanner.RenderErrorItems(hw, slkError); } } } } catch (Exception ex) { Response.Write(ex.ToString()); } }
public static void parse( int display, SlkAction action, SlkToken tokens, SlkError error, SlkLog log, short start_symbol ) { short rhs, lhs; short production_number, entry, symbol, token, new_token; int top, index, level; short[] stack = new short[512]; top = 511; stack [ top ] = 0; if ( start_symbol == 0 ) { start_symbol = START_SYMBOL; } if ( top > 0 ) { stack [--top] = start_symbol; } else { log.trace ("SlkParse: stack overflow\n"); return; } token = tokens.get(); new_token = token; if ( display != 0 ) { log.trace ( "\n\n\t\tPARSE DERIVATION\n\n" ); } for ( symbol = (stack[top] != 0 ? stack[top++] : (short) 0); symbol != 0; ) { if ( symbol >= START_SYMBOL ) { // nonterminal symbol entry = 0; level = 1; production_number = get_conditional_production ( symbol ); if ( production_number != 0 ) { entry = get_predicted_entry ( display, tokens, log, production_number, token, level, 1 ); } if ( entry == 0 ) { index = Parse_row [ symbol - (START_SYMBOL-1) ]; index += Terminal_to_index [ token ]; entry = Parse [ index ]; } while ( entry < 0 ) { index = Conflict_row [-entry]; index += Terminal_to_index [tokens.peek (level)]; entry = Conflict [ index ]; ++level; } if ( entry != 0 ) { index = Production_row [ entry ]; lhs = Production [ ++index ]; if ( lhs == symbol ) { // valid row for lhs rhs = Production [++index]; for ( ; rhs != 0; rhs = Production [++index] ) { if ( top > 0 ) { stack [--top] = rhs; } else { log.trace ("SlkParse: stack overflow\n"); return; } } if ( display != 0 ) { log.trace_production ( entry ); } } else { // lhs does not match new_token = error.no_entry ( symbol, token, level-1 ); } } else { // no table entry new_token = error.no_entry ( symbol, token, level-1 ); } } else if ( symbol > 0 ) { // terminal symbol if ( symbol == token ) { token = tokens.get(); new_token = token; } else { // token mismatch new_token = error.mismatch ( symbol, token ); } } else { // action symbol if ( display != 0 ) { log.trace_action ( symbol ); } action.execute ( -symbol ); } if ( token != new_token ) { if ( new_token != 0 ) { token = new_token; } if ( token != END_OF_SLK_INPUT_ ) { continue; // try this token } } symbol = (stack[top] != 0 ? stack[top++] : (short) 0); } if ( token != END_OF_SLK_INPUT_ ) { // input left over error.input_left (); } }
/// <summary> /// Renders the entire query results in the inner table. /// </summary> /// <param name="queryDef">The definition of the query that was executed.</param> /// <param name="renderedRows">Rendered query results.</param> /// <param name="hw">The <c>HtmlTextWriter</c> to write to.</param> /// void RenderQueryResults(QueryDefinition queryDef, List <RenderedCell[]> renderedRows, HtmlTextWriter hw) { // get the column definitions IList <ColumnDefinition> columnDefs = queryDef.Columns; //Get the column index to sort on and sort order int sortColumnIndex; bool sortAscending = GetSortIndex(out sortColumnIndex); // sort <renderedRows> if so specified if ((sortColumnIndex >= 0) && (sortColumnIndex < queryDef.Columns.Count)) { queryDef.SortRenderedRows(renderedRows, sortColumnIndex, sortAscending); } // render the "<table>" element and its contents hw.AddAttribute(HtmlTextWriterAttribute.Class, "ms-summarystandardbody"); // skipped: id=TABLE1 dir=None hw.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0"); hw.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "1"); hw.AddAttribute(HtmlTextWriterAttribute.Style, "width:100%;"); hw.AddAttribute(HtmlTextWriterAttribute.Border, "0"); using (new HtmlBlock(HtmlTextWriterTag.Table, 1, hw)) { // render the header row hw.AddAttribute(HtmlTextWriterAttribute.Class, "ms-viewheadertr"); hw.AddAttribute(HtmlTextWriterAttribute.Valign, "top"); using (new HtmlBlock(HtmlTextWriterTag.Tr, 0, hw)) { // render the column headers int columnIndex = 0; foreach (ColumnDefinition columnDef in columnDefs) { bool?ascendingSort; if (sortColumnIndex == columnIndex) { ascendingSort = sortAscending; } else { ascendingSort = null; } RenderColumnHeader(columnDef, columnIndex, ascendingSort, hw); columnIndex++; } } //If No Items Found if (renderedRows.Count == 0) { using (new HtmlBlock(HtmlTextWriterTag.Tr, 1, hw)) { hw.AddAttribute(HtmlTextWriterAttribute.Colspan, columnDefs.Count.ToString(CultureInfo.InvariantCulture)); using (new HtmlBlock(HtmlTextWriterTag.Td, 1, hw)) { SlkError slkError = new SlkError(ErrorType.Info, Constants.Space + Constants.Space + PageCulture.Resources.AlwpNoItemFound); WebParts.ErrorBanner.RenderErrorItems(hw, slkError); } } } else { // render the rows int rowIndex = 0; foreach (RenderedCell[] renderedRow in renderedRows) { // render the "<tr>"; note that every other row is shaded ("ms-alternating") hw.AddAttribute(HtmlTextWriterAttribute.Class, (((rowIndex & 1) == 0) ? "ms-alternating" : "")); using (new HtmlBlock(HtmlTextWriterTag.Tr, 1, hw)) { // set <webNameRenderedCell> to any cell in the row which is of type // WebNameRenderedCell, i.e. which refers to a SharePoint Web site, // or null if none WebNameRenderedCell webNameRenderedCell = null; Guid learnerAssignmentGUID = Guid.Empty; foreach (RenderedCell renderedCell in renderedRow) { if (webNameRenderedCell == null) { webNameRenderedCell = renderedCell as WebNameRenderedCell; } if (learnerAssignmentGUID == Guid.Empty) { if (renderedCell.Id != null) { if (renderedCell.Id.ItemTypeName == Schema.LearnerAssignmentItem.ItemTypeName) { learnerAssignmentGUID = SlkStore.GetLearnerAssignmentGuidId(renderedCell.Id); } } } if (webNameRenderedCell != null && learnerAssignmentGUID != Guid.Empty) { break; } } // render the cells in this row int columnIndex = 0; foreach (RenderedCell renderedCell in renderedRow) { ColumnDefinition columnDef = columnDefs[columnIndex]; hw.AddAttribute(HtmlTextWriterAttribute.Class, "ms-vb2"); if (!columnDef.Wrap) { hw.AddAttribute(HtmlTextWriterAttribute.Nowrap, "true"); } using (new HtmlBlock(HtmlTextWriterTag.Td, 1, hw)) { if (columnDef.Title.Equals(PageCulture.Resources.AlwpFileSubmissionColumnTitle)) { RenderFileSubmissionCell(renderedCell, webNameRenderedCell, learnerAssignmentGUID, hw); } else { RenderColumnCell(renderedCell, webNameRenderedCell, hw, SlkStore); } } columnIndex++; } } rowIndex++; } } } }
protected void Page_Load(object sender, EventArgs e) { try { String queryCount = String.Empty; // render the HTML for the page using (HtmlTextWriter hw = new HtmlTextWriter(Response.Output, " ")) { // render the "<html>" element and its contents using (new HtmlBlock(HtmlTextWriterTag.Html, 0, hw)) { // render the "<head>" element and its contents using (new HtmlBlock(HtmlTextWriterTag.Head, 1, hw)) { // create a link to "core.css"; // "/_layouts/1033/styles/core.css" except with "1033" replaced with the // current SPWeb language code // Include 1033 one as a back up AddCoreCss(hw, 1033); SlkCulture culture = new SlkCulture(SPWeb); AddCoreCss(hw, culture.Culture.LCID); #if SP2007 //Adds the Theme Css Url to Enable Theming in the frame. hw.AddAttribute(HtmlTextWriterAttribute.Rel, "stylesheet"); hw.AddAttribute(HtmlTextWriterAttribute.Type, "text/css"); hw.AddAttribute(HtmlTextWriterAttribute.Href, SPWeb.ThemeCssUrl); HtmlBlock.WriteFullTag(HtmlTextWriterTag.Link, 0, hw); #endif // create a link to ALWP's "Styles.css" hw.AddAttribute(HtmlTextWriterAttribute.Rel, "stylesheet"); hw.AddAttribute(HtmlTextWriterAttribute.Type, "text/css"); hw.AddAttribute(HtmlTextWriterAttribute.Href, "Include/Styles.css"); HtmlBlock.WriteFullTag(HtmlTextWriterTag.Link, 0, hw); } // render the "<body>" element and its contents hw.AddAttribute(HtmlTextWriterAttribute.Style, "width: 100%; overflow-y: auto; overflow-x: auto;"); using (new HtmlBlock(HtmlTextWriterTag.Body, 0, hw)) { Microsoft.SharePointLearningKit.WebParts.AssignmentListWebPart.DumpCultures(hw, "Page_Load"); // render the outer table -- this contains only one row and one column, which // in turn contains the entire query results table hw.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0"); hw.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0"); hw.AddAttribute(HtmlTextWriterAttribute.Style, "width:100%;"); hw.AddAttribute(HtmlTextWriterAttribute.Border, "0"); RenderForm(hw); RenderSortFunction(hw); using (new HtmlBlock(HtmlTextWriterTag.Table, 0, hw)) { // render the single row and column of the outer table using (new HtmlBlock(HtmlTextWriterTag.Tr, 0, hw)) { using (new HtmlBlock(HtmlTextWriterTag.Td, 0, hw)) { hw.WriteLine(); try { // set <queryDef> to the QueryDefinition named <queryName> QueryDefinition queryDef = null; if (Query != null) { queryDef = SlkStore.Settings.FindQueryDefinition(Query); } if (queryDef == null) { throw new SafeToDisplayException(PageCulture.Resources.AlwpQuerySetNotFound, Query); } List <RenderedCell[]> renderedRows = PerformQuery(queryDef); //Set the QueryCount queryCount = renderedRows.Count.ToString(CultureInfo.InvariantCulture); //Renders the Result RenderQueryResults(queryDef, renderedRows, hw); } catch (Exception ex) { queryCount = PageCulture.Resources.AlwpQueryResultError; SlkError slkError; //Handles SqlException separate to capture the deadlock //and treat it differently SqlException sqlEx = ex as SqlException; if (sqlEx != null) { slkError = WebParts.ErrorBanner.WriteException(SlkStore, sqlEx); } else { slkError = SlkError.WriteException(SlkStore, ex); } WebParts.ErrorBanner.RenderErrorItems(hw, slkError); } finally { //Renders the JavaScript to set the Query Count. RenderQueryCount(queryCount); } } } } } } } } catch (Exception ex) { Response.Write(ex.ToString()); } }