Esempio n. 1
0
        private void DisplaySessionStateItem()
        {
            //Get requested item from session state
            object sessionItem = _context.Session[_request.QueryString["Item"]];

            Table sessionItemTable = TableHelper.CreateTable();

            //Table Header
            var mainHeadingRow = new TableRow();

            sessionItemTable.Rows.Add(mainHeadingRow);

            TableCell mainHeading = TableHelper.AddHeaderCell(mainHeadingRow, "<h3><b>Session State Item</b></h3>");

            mainHeading.CssClass   = "alt";
            mainHeading.ColumnSpan = 4;

            //Sub heading
            var secondaryHeadingRow = new TableRow();

            secondaryHeadingRow.CssClass = "subhead";
            sessionItemTable.Rows.Add(secondaryHeadingRow);

            //TableCell headingRowCol1 = TableHelper.AddHeaderCell(secondaryHeadingRow, "Session Item Key: " + _request.QueryString["Item"]); -- chrisme: not used!

            //Explanation heading
            var explanationHeadingRow = new TableRow();

            sessionItemTable.Rows.Add(explanationHeadingRow);

            TableHelper.AddCell(explanationHeadingRow, "The outer xml tags are a result of the Xml serialization used to render the item");

            var dataRow = new TableRow();

            if (sessionItem != null)
            {
                StringWriter swTest = Common.XmlSerialize(sessionItem);

                if (swTest == null)
                {
                    //Could not serialize the data in a human readable form using Xml
                    TableHelper.AddCell(dataRow, "Item was not viewable");
                }
                else
                {
                    TableHelper.AddCell(dataRow, _context.Server.HtmlEncode(swTest.ToString()));
                }
            }
            else
            {
                TableHelper.AddCell(dataRow, "Item is NULL in value");
            }

            sessionItemTable.Rows.Add(dataRow);

            sessionItemTable.RenderControl(_writer);
        }
Esempio n. 2
0
        private void DisplaySessionStateOff()
        {
            Table sessionTable = TableHelper.CreateTable();

            //Table Header
            var mainHeadingRow = new TableRow();

            sessionTable.Rows.Add(mainHeadingRow);

            TableHelper.AddHeaderCell(mainHeadingRow, "Session State is Off");

            sessionTable.RenderControl(_writer);
        }
Esempio n. 3
0
        private void EnumerateAndDisplaySessionState()
        {
            bool displayingObjectSize;

            Table sessionTable = TableHelper.CreateTable();

            //Table Header
            var mainHeadingRow = new TableRow();

            sessionTable.Rows.Add(mainHeadingRow);

            TableCell mainHeading;

            if (_context.Session.Mode == SessionStateMode.SQLServer ||
                _context.Session.Mode == SessionStateMode.StateServer)
            {
                displayingObjectSize = true;
                mainHeading          = TableHelper.AddHeaderCell(mainHeadingRow, "<h3><b>Session State Details including approximate item size</b></h3>");
                mainHeading.CssClass = "alt";
            }
            else
            {
                displayingObjectSize = false;
                mainHeading          = TableHelper.AddHeaderCell(mainHeadingRow, "<h3><b>Session State Details</b></h3>");
            }

            mainHeading.ColumnSpan = 4;
            mainHeading.CssClass   = "alt";

            TableRow secondaryHeadingRow = new TableRow();

            secondaryHeadingRow.CssClass = "subhead";
            sessionTable.Rows.Add(secondaryHeadingRow);

            //TableCell headingRowCol1 = TableHelper.AddHeaderCell(secondaryHeadingRow, "Session Key"); -- chrisme: not used!

            TableCell headingRowCol2 = TableHelper.AddHeaderCell(secondaryHeadingRow, "Object Type");

            if (!displayingObjectSize)
            {
                //Make second column span 2
                headingRowCol2.ColumnSpan = 2;
            }

            //TableCell headingRowCol4 = TableHelper.AddHeaderCell(secondaryHeadingRow, "View Data"); -- chrisme: not used!

            bool     alternatingRowToggle = false;
            TableRow dataRow;

            //Loop through all the session item keys
            foreach (string sessionKey in _context.Session.Keys)
            {
                dataRow = new TableRow();

                //Key column
                TableHelper.AddCell(dataRow, sessionKey);

                if (_context.Session[sessionKey] != null)
                {
                    //Get out of session
                    Object sessionItem = _context.Session[sessionKey];

                    //System.Type type = sessionItem.GetType();  -- chrisme: not used!

                    //Type column
                    TableHelper.AddCell(dataRow, sessionItem.GetType().FullName);

                    if (displayingObjectSize)
                    {
                        //Size column

                        Stream alternativeSerializationStreamSessionKey = BinaryWrite(sessionKey);

                        if (TypeIsInAlternativeSerializationList(sessionItem.GetType()))
                        {
                            Stream alternativeSerializationStream = BinaryWrite(sessionItem);

                            //Alt Serialization Size column
                            TableHelper.AddCell(dataRow,
                                                Convert.ToDouble(alternativeSerializationStream.Length + alternativeSerializationStreamSessionKey.Length)
                                                / Convert.ToDouble(1000) + " KB");
                        }
                        else
                        {
                            MemoryStream m;
                            m = Common.BinarySerialize(sessionItem);

                            TableHelper.AddCell(dataRow,
                                                Convert.ToDouble(m.Length + alternativeSerializationStreamSessionKey.Length)
                                                / Convert.ToDouble(1000) + " KB");
                        }
                    }
                    else
                    {
                        // Make second column span 2 to make up for unused third col
                        dataRow.Cells[1].ColumnSpan = 2;
                    }

                    //Data link column
                    if (_HttpHandlerSettings.SessionView.ShowViewDataLink)
                    {
                        StringWriter swTest = Common.XmlSerialize(sessionItem);

                        if (swTest == null)
                        {
                            //Could not serialize the data in a human readable form using Xml
                            TableHelper.AddCell(dataRow, "Data could not be serialized to Xml");
                        }
                        else
                        {
                            TableHelper.AddCell(dataRow, "Click to view data", "SessionView.axd?Item=" + sessionKey);
                        }
                    }
                    else
                    {
                        TableHelper.AddCell(dataRow, "N/A");
                    }
                }
                else
                {
                    TableHelper.AddCell(dataRow, "N/A");

                    if (displayingObjectSize)
                    {
                        TableHelper.AddCell(dataRow, "N/A");
                    }
                    else
                    {
                        dataRow.Cells[1].ColumnSpan = 3;
                    }
                }

                if (alternatingRowToggle)
                {
                    dataRow.CssClass = "alt";
                }

                alternatingRowToggle = alternatingRowToggle == Convert.ToBoolean(0);
                sessionTable.Rows.Add(dataRow);
            }

            sessionTable.RenderControl(_writer);
        }
        private void EnumerateAndDisplayCache()
        {
            Table cacheTable = TableHelper.CreateTable();

            //Table Header
            var mainHeadingRow = new TableRow();

            cacheTable.Rows.Add(mainHeadingRow);

            TableCell mainHeading = TableHelper.AddHeaderCell(mainHeadingRow, "<h3><b>Cache Details</b></h3>");

            mainHeading.ColumnSpan = 3;
            mainHeading.CssClass   = "alt";

            var secondaryHeadingRow = new TableRow();

            secondaryHeadingRow.CssClass = "subhead";
            cacheTable.Rows.Add(secondaryHeadingRow);

            //TableCell headingRowCol1 = TableHelper.AddHeaderCell(secondaryHeadingRow, "Cache Key"); -- chrisme: <- not used!

            //TableCell headingRowCol2 = TableHelper.AddHeaderCell(secondaryHeadingRow, "Cached Object Type"); -- chrisme: <- not used!

            //TableCell headingRowCol3 = TableHelper.AddHeaderCell(secondaryHeadingRow, "View Data"); -- chrisme: <- not used!

            bool alternatingRowToggle = false;
            //var enumeratedItems = new ArrayList(); -- chrisme: <- not used!
            TableRow dataRow;

            foreach (DictionaryEntry cacheDictionaryItem in _context.Cache)
            {
                dataRow = new TableRow();

                //Key column
                TableHelper.AddCell(dataRow, cacheDictionaryItem.Key.ToString());

                if (_context.Cache[cacheDictionaryItem.Key.ToString()] != null)
                {
                    //Get out of cache
                    Object cacheObjectItem = _context.Cache[cacheDictionaryItem.Key.ToString()];

                    //System.Type type = cacheObjectItem.GetType(); -- chrisme: <- not used!

                    //Type column
                    TableHelper.AddCell(dataRow, cacheObjectItem.GetType().FullName);
                }
                else
                {
                    //Type column
                    TableHelper.AddCell(dataRow, "NULL");
                }

                //Data link column
                if (_httpHandlerSettings.CacheView.ShowViewDataLink)
                {
                    StringWriter swTest = Common.XmlSerialize(cacheDictionaryItem.Value);

                    if (swTest == null)
                    {
                        //Could not serialize the data in a human readable form using Xml
                        TableHelper.AddCell(dataRow, "Data could not be serialized to Xml");
                    }
                    else
                    {
                        TableHelper.AddCell(dataRow, "Click to view data", "CacheView.axd?Item=" + cacheDictionaryItem.Key);
                    }
                }
                else
                {
                    TableHelper.AddCell(dataRow, "N/A");
                }

                if (alternatingRowToggle)
                {
                    dataRow.CssClass = "alt";
                }

                alternatingRowToggle = alternatingRowToggle == Convert.ToBoolean(0);
                cacheTable.Rows.Add(dataRow);
            }

            cacheTable.RenderControl(_writer);
        }