private async Task RenderHeadAsync(XmlWriter writer)
        {
            await writer.WriteStartElementAsync("meta");
            await writer.WriteAttributeStringAsync("http-equiv", "X-UA-Compatible");
            await writer.WriteAttributeStringAsync("content", "IE=EmulateIE7");
            await writer.WriteEndElementAsync();

            await writer.WriteElementStringAsync("title", PageTitle);

            await writer.WriteStartElementAsync("link");
            await writer.WriteAttributeStringAsync("rel", "stylesheet");
            await writer.WriteAttributeStringAsync("type", "text/css");
            await writer.WriteAttributeStringAsync("href", BasePageName + "/stylesheet");
            await writer.WriteEndElementAsync();
        }
Exemple #2
0
        public static async Task RenderAsync(XmlWriter writer, params SpeedBarItem[] items)
        {
            if (items == null || items.Length == 0)
                return;

            await writer.WriteStartElementAsync("ul");
            await writer.WriteAttributeStringAsync("id", "SpeedList");

            foreach (var item in items)
            {
                await writer.WriteStartElementAsync("li");

                await writer.WriteStartElementAsync("a");
                await writer.WriteAttributeStringAsync("href", item.Url);
                await writer.WriteAttributeStringAsync("title", item.Title);
                await writer.WriteStringAsync(item.Label);
                await writer.WriteEndElementAsync();

                await writer.WriteEndElementAsync();
            }

            await writer.WriteEndElementAsync();
        }
Exemple #3
0
        private async Task RenderPageNavigatorsAsync(XmlWriter writer)
        {
            await writer.WriteStartElementAsync("p");
            {
                var nextPageIndex = pageIndex + 1;
                var moreErrors = nextPageIndex*pageSize < totalCount;

                if (moreErrors)
                {
                    await writer.WriteStartElementAsync("a");
                    await writer.WriteAttributeStringAsync("href", $"{BasePageName}?page={nextPageIndex + 1}&size={pageSize}");
                    await writer.WriteAttributeStringAsync("rel", "next");
                    {
                        await writer.WriteStringAsync("Next errors");
                    }
                    await writer.WriteEndElementAsync();
                }

                // If not on the first page then render a link to the firs page.

                if (pageIndex > 0 && totalCount > 0)
                {
                    if (moreErrors)
                        await writer.WriteRawAsync("; ");

                    await writer.WriteStartElementAsync("a");
                    await writer.WriteAttributeStringAsync("href", $"{BasePageName}?page=1&size={pageSize}");
                    await writer.WriteAttributeStringAsync("rel", "start");
                    {
                        await writer.WriteStringAsync("Back to first page");
                    }
                    await writer.WriteEndElementAsync();
                }
            }
            await writer.WriteEndElementAsync();
        }
        private async Task RenderDocumentEndAsync(XmlWriter writer)
        {
            //
            // Write the powered-by signature, that includes version information.
            //

            await writer.WriteStartElementAsync("p"); // <p>
            await writer.WriteAttributeStringAsync("id", "Footer");


            //PoweredBy poweredBy = new PoweredBy();
            //poweredBy.RenderControl(writer);

            //
            // Write out server date, time and time zone details.
            //

            var now = DateTime.Now;

            await writer.WriteStringAsync("Server date is ");
            await writer.WriteStringAsync(now.ToString("D", CultureInfo.InvariantCulture));

            await writer.WriteStringAsync(". Server time is ");
            await writer.WriteStringAsync(now.ToString("T", CultureInfo.InvariantCulture));

            await writer.WriteStringAsync(". All dates and times displayed are in the ");
            await writer.WriteStringAsync(TimeZone.CurrentTimeZone.IsDaylightSavingTime(now) ?
                TimeZone.CurrentTimeZone.DaylightName : TimeZone.CurrentTimeZone.StandardName);
            await writer.WriteStringAsync(" zone. ");

            //
            // Write out the source of the log.
            //

            await writer.WriteStringAsync("This log is provided by the ");
            await writer.WriteStringAsync(ErrorLog.Name);
            await writer.WriteStringAsync(".");

            await writer.WriteEndElementAsync();// </p>

            await writer.WriteEndElementAsync(); // </body>
            await writer.WriteEndElementAsync(); // </html>
        }
Exemple #5
0
        private async Task RenderErrorsAsync(XmlWriter writer)
        {
            //
            // Create a table to display error information in each row.
            //

            await writer.WriteStartElementAsync("table");
            await writer.WriteAttributeStringAsync("id", "ErrorLog");
            await writer.WriteAttributeStringAsync("style", "border-spacing: 0;");
            {

                //
                // Create the table row for headings.
                //

                await writer.WriteStartElementAsync("tr");
                {
                    await RenderCellAsync(writer, "th", "Host", "host-col");
                    await RenderCellAsync(writer, "th", "Code", "code-col");
                    await RenderCellAsync(writer, "th", "Type", "type-col");
                    await RenderCellAsync(writer, "th", "Error", "error-col");
                    await RenderCellAsync(writer, "th", "User", "user-col");
                    await RenderCellAsync(writer, "th", "Date", "date-col");
                    await RenderCellAsync(writer, "th", "Time", "time-col");
                }
                await writer.WriteEndElementAsync();

                //
                // Generate a table body row for each error.
                //

                for (int index = 0; index < errorLogEntries.Count; index++)
                {
                    var errorLogEntry = errorLogEntries[index];

                    await writer.WriteStartElementAsync("tr");
                    await writer.WriteAttributeStringAsync("class", index % 2 == 0 ? "even-row" : "odd-row");
                    {
                        // Format host and status code cells.

                        var error = errorLogEntry.Error;

                        await RenderCellAsync(writer, "td", error.HostName, "host-col");
                        await RenderCellAsync(writer, "td", error.StatusCode.ToString(), "code-col", HttpCodeParser.GetstatusDescription(error.StatusCode));
                        await RenderCellAsync(writer, "td", ErrorShortName(error.TypeName), "host-col", error.TypeName);

                        //
                        // Format the message cell, which contains the message 
                        // text and a details link pointing to the page where
                        // all error details can be viewed.
                        //

                        await writer.WriteStartElementAsync("td");
                        await writer.WriteAttributeStringAsync("class", "error-col");
                        {
                            await writer.WriteStartElementAsync("label");
                            {
                                await writer.WriteStringAsync(error.Message);
                            }
                            await writer.WriteEndElementAsync();

                            await writer.WriteStartElementAsync("a");
                            await writer.WriteAttributeStringAsync("href", $"{BasePageName}/detail?id={errorLogEntry.Id}");
                            {
                                await writer.WriteRawAsync("Details&hellip;");
                            }
                            await writer.WriteEndElementAsync();
                        }
                        await writer.WriteEndElementAsync();

                        // Format the user, date and time cells.
                        await RenderCellAsync(writer, "td", error.User, "user-col");
                        await RenderCellAsync(writer, "td", error.Time.DateTime.ToShortDateString(), "date-col", error.Time.DateTime.ToLongDateString());
                        await RenderCellAsync(writer, "td", error.Time.DateTime.ToShortTimeString(), "time-col", error.Time.DateTime.ToLongTimeString());

                    }
                    await writer.WriteEndElementAsync();
                }
            }
            await writer.WriteEndElementAsync();
        }
Exemple #6
0
        private async Task RenderTitleAsync(XmlWriter writer)
        {
            await writer.WriteStartElementAsync("h1");
            await writer.WriteAttributeStringAsync("id", "PageTitle");
            await writer.WriteStringAsync("Error Log for ");

            await writer.WriteStartElementAsync("span");
            await writer.WriteAttributeStringAsync("id", "ApplicationName");
            await writer.WriteAttributeStringAsync("title", ApplicationName);
            await writer.WriteStringAsync(ApplicationName);

            var machineName = EnvironmentUtilities.GetMachineNameOrDefault();
            if (!string.IsNullOrEmpty(machineName?.Trim()))
            {
                await writer.WriteStringAsync(" on ");
                await writer.WriteStringAsync(machineName);
            }

            await writer.WriteEndElementAsync(); // </span>

            await writer.WriteEndElementAsync(); // </h1>
        }
Exemple #7
0
        private async Task RenderNoErrorsAsync(XmlWriter writer)
        {
            await writer.WriteStartElementAsync("p");

            await writer.WriteStringAsync("No errors found. ");

            //
            // It is possible that there are no error at the requested 
            // page in the log (especially if it is not the first page).
            // However, if there are error in the log
            //

            if (pageIndex > 0 && totalCount > 0)
            {
                var href = $"{BasePageName}?page=1&size={pageSize}";

                await writer.WriteStartElementAsync("a");
                await writer.WriteAttributeStringAsync("href", href);
                await writer.WriteAttributeStringAsync("rel", "start");

                await writer.WriteStringAsync("Go to first page");
                await writer.WriteEndElementAsync();

                await writer.WriteStringAsync(". ");
            }

            await writer.WriteEndElementAsync();
        }
Exemple #8
0
        private async Task RenderStockPageSizesAsync(XmlWriter writer)
        {
            //
            // Write out a set of stock page size choices. Note that
            // selecting a stock page size re-starts the log 
            // display from the first page to get the right paging.
            //

            await writer.WriteStringAsync("Start with ");

            var stockSizes = new[] { 10, 15, 20, 25, 30, 50, 100 };

            for (var stockSizeIndex = 0; stockSizeIndex < stockSizes.Length; stockSizeIndex++)
            {
                var stockSize = stockSizes[stockSizeIndex];

                if (stockSizeIndex > 0)
                    await writer.WriteStringAsync(stockSizeIndex + 1 < stockSizes.Length ? ", " : " or ");

                var href = $"{BasePageName}?page=1&size={stockSize}";

                await writer.WriteStartElementAsync("a");
                await writer.WriteAttributeStringAsync("href", href);
                await writer.WriteAttributeStringAsync("rel", "start");

                await writer.WriteStringAsync(stockSize.ToString());
                await writer.WriteEndElementAsync();
            }

            await writer.WriteStringAsync(" errors per page.");
        }
Exemple #9
0
        private static async Task RenderCellAsync(XmlWriter writer, string cellType, string contents, string cssClassName, string tooltip = "")
        {
            await writer.WriteStartElementAsync(cellType);
            await writer.WriteAttributeStringAsync("class", cssClassName);

            if (string.IsNullOrEmpty(contents?.Trim()))
            {
                await writer.WriteRawAsync("&nbsp;");
            }
            else
            {
                if (string.IsNullOrEmpty(tooltip?.Trim()))
                {
                    await writer.WriteStringAsync(contents);
                }
                else
                {
                    await writer.WriteStartElementAsync("label");
                    await writer.WriteAttributeStringAsync("title", tooltip);
                    await writer.WriteStringAsync(contents);
                    await writer.WriteEndElementAsync();
                }
            }

            await writer.WriteEndElementAsync();
        }
        private async Task RenderErrorAsync(XmlWriter writer)
        {
            var error = errorLogEntry.Error;

            await writer.WriteStartElementAsync("h1");
            await writer.WriteAttributeStringAsync("id", "PageTitle");
            {
                await writer.WriteStringAsync(error.Message);
            }
            await writer.WriteEndElementAsync();

            await SpeedBarComponent.RenderAsync(writer, SpeedBarComponent.GetHome(BasePageName));

            await writer.WriteStartElementAsync("p");
            await writer.WriteAttributeStringAsync("id", "ErrorTitle");
            {
                await writer.WriteStartElementAsync("span");
                await writer.WriteAttributeStringAsync("id", "ErrorType");
                {
                    await writer.WriteStringAsync(error.TypeName);
                }
                await writer.WriteEndElementAsync();

                await writer.WriteStartElementAsync("span");
                await writer.WriteAttributeStringAsync("id", "ErrorTypeMessageSeparator");
                {
                    await writer.WriteStringAsync(": ");
                }
                await writer.WriteEndElementAsync();

                await writer.WriteStartElementAsync("span");
                await writer.WriteAttributeStringAsync("id", "ErrorMessage");
                {
                    await writer.WriteStringAsync(error.Message);
                }
                await writer.WriteEndElementAsync();
            }
            await writer.WriteEndElementAsync();

            await writer.WriteStartElementAsync("pre");
            await writer.WriteAttributeStringAsync("id", "ErrorDetail");
            {
                await writer.WriteStringAsync(error.Detail);
            }
            await writer.WriteEndElementAsync();

            await writer.WriteStartElementAsync("p");
            await writer.WriteAttributeStringAsync("id", "ErrorLogTime");
            {
                await writer.WriteStringAsync($"Logged on {error.Time}.");
            }
            await writer.WriteEndElementAsync();

            await writer.WriteStartElementAsync("p");
            {
                await writer.WriteStringAsync("See also:");
            }
            await writer.WriteEndElementAsync();

            await writer.WriteStartElementAsync("ul");
            {
                await writer.WriteStartElementAsync("li");
                {
                    await writer.WriteStringAsync("Raw/Source data in ");

                    await writer.WriteStartElementAsync("a");
                    await writer.WriteAttributeStringAsync("href", "json" + requestQuery);
                    await writer.WriteAttributeStringAsync("rel", "alternate");
                    await writer.WriteAttributeStringAsync("type", "application/json");
                    {
                        await writer.WriteStringAsync("JSON");
                    }
                    await writer.WriteEndElementAsync();
                }
                await writer.WriteEndElementAsync();
            }
            await writer.WriteEndElementAsync();

            await RenderDictionaryAsync(writer, error.ServerEnvironment, "ServerVariables", "Server Environment");
            await RenderDictionaryAsync(writer, error.Headers.ToDictionary(pair => pair.Key, pair => string.Join(", ", pair.Value)), "ServerVariables", "Headers");
            await RenderDictionaryAsync(writer, error.Query.ToDictionary(pair => pair.Key, pair => string.Join(", ", pair.Value)), "ServerVariables", "Query");
            await RenderDictionaryAsync(writer, error.Cookies, "ServerVariables", "Cookies");
        }
        private static async Task RenderDictionaryAsync(XmlWriter writer, Dictionary<string, string> dictionary, string id, string title)
        {
            if (!dictionary.Any())
                return;

            await writer.WriteStartElementAsync("div");
            await writer.WriteAttributeStringAsync("id", id);
            {
                await writer.WriteStartElementAsync("p");
                await writer.WriteAttributeStringAsync("class", "table-caption");
                {
                    await writer.WriteStringAsync(title);
                }
                await writer.WriteEndElementAsync();

                await writer.WriteStartElementAsync("div");
                await writer.WriteAttributeStringAsync("class", "scroll-view");
                {
                    await writer.WriteStartElementAsync("table");
                    {
                        await writer.WriteStartElementAsync("tr");
                        {
                            await writer.WriteStartElementAsync("th");
                            await writer.WriteAttributeStringAsync("class", "name-col");
                            {
                                await writer.WriteStringAsync("Name");
                            }
                            await writer.WriteEndElementAsync();

                            await writer.WriteStartElementAsync("th");
                            await writer.WriteAttributeStringAsync("class", "value-col");
                            {
                                await writer.WriteStringAsync("Value");
                            }
                            await writer.WriteEndElementAsync();
                        }
                        await writer.WriteEndElementAsync();

                        var count = 0;
                        foreach (var line in dictionary)
                        {
                            await writer.WriteStartElementAsync("tr");
                            await writer.WriteAttributeStringAsync("class", count%2 == 0 ? "even-row" : "odd-row");
                            {
                                await writer.WriteStartElementAsync("td");
                                await writer.WriteAttributeStringAsync("class", "key-col");
                                {
                                    await writer.WriteStringAsync(line.Key);
                                }
                                await writer.WriteEndElementAsync();

                                await writer.WriteStartElementAsync("td");
                                await writer.WriteAttributeStringAsync("class", "value-col");
                                {
                                    await writer.WriteStringAsync(line.Value);
                                }
                                await writer.WriteEndElementAsync();
                            }
                            await writer.WriteEndElementAsync();
                        }
                    }
                    await writer.WriteEndElementAsync();
                }
                await writer.WriteEndElementAsync();
            }
            await writer.WriteEndElementAsync();

            await writer.WriteElementStringAsync("br", string.Empty);
        }
 public static Task WriteAttributeStringAsync(this XmlWriter writer, string name, string value) => writer.WriteAttributeStringAsync(null, name, null, value);
 public static Task WriteAttributeString([NotNull] this XmlWriter writer, [NotNull] string name, [NotNull] string value) => writer.WriteAttributeStringAsync(null, name, null, value);
    public async Task ToAml(XmlWriter writer)
    {
      var factory = ElementFactory.Local;
      await writer.WriteStartElementAsync(null, "Item", null);
      var id = (string)Property("id");
      var type = (string)Property(Extensions.AmlTable_TypeName);
      var typeId = (string)Property(Extensions.AmlTable_TypeId);
      if (!string.IsNullOrEmpty(id))
        await writer.WriteAttributeStringAsync(null, "id", null, id);
      if (!string.IsNullOrEmpty(type))
        await writer.WriteAttributeStringAsync(null, "type", null, type);
      if (!string.IsNullOrEmpty(typeId))
        await writer.WriteAttributeStringAsync(null, "typeId", null, typeId);

      var cols = _row.Table.Columns.OfType<DataColumn>()
        .Where(c => !_row.IsNull(c))
        .OrderBy(c => c.ColumnName)
        .ToArray();
      for (var i = 0; i < cols.Length; i++)
      {
        await writer.WriteStartElementAsync(null, cols[i].ColumnName, null);
        var j = i + 1;
        var prefix = cols[i].ColumnName + "/";
        while (j < cols.Length && cols[j].ColumnName.StartsWith(prefix))
        {
          await writer.WriteAttributeStringAsync(null, cols[j].ColumnName.Substring(prefix.Length), null
            , factory.FormatAmlValue(_row[cols[j]]));
          j++;
        }
        await writer.WriteStringAsync(factory.FormatAmlValue(_row[cols[i]]));
        await writer.WriteEndElementAsync();
        i += (j - i) - 1;
      }
      await writer.WriteEndElementAsync();
    }