download LogFileListPage.cs
Language: C#
LOC: 54
Project Info
WSS / MOSS Log File Reader(wssmosslogfilereader)
Server: CodePlex_zeroloc
Type: svn
...ogViewer\StarznetLogViewer\
   LogFileListPage.cs
   LogFileViewPage.cs
   StarznetLogViewer.csproj
   ...LogViewer.csproj.vspscc

//--------------------------------------------------------
//
//  StarznetLogViewer
//  � Starznet Ltd 2008
//  www.starznet.co.uk
//
//--------------------------------------------------------
using System;
using System.IO;
using System.Web.UI.WebControls;
using System.Collections.Generic;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.ApplicationPages;
using Microsoft.SharePoint.Administration;

namespace Starznet.SharePoint.LogViewer.ApplicationPages.Administration
{
    /// <summary>
    /// Provides functionality for LogFileList.aspx 
    /// </summary>
    public class LogFileListPage : ApplicationsManagementPage
    {
        protected SPGridView GvFiles;
        private MenuTemplate _oFileMenu;
        //private string _sLogLocation = SPUtility.GetGenericSetupPath("LOGS");
        private string _sLogLocation = string.Empty;
        private List<FileInfo> oFiles;
      
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            _sLogLocation = SPDiagnosticsService.Local.LogLocation;

            GvFiles.Columns.Clear();

            _oFileMenu = new MenuTemplate();
            _oFileMenu.ID = "FileMenu";

            SPMenuField oMenu = new SPMenuField();
            oMenu.HeaderText = "File Name";
            oMenu.TextFields = "Name";
            oMenu.MenuTemplateId = "FileMenu";
            oMenu.NavigateUrlFields = "Name";
            oMenu.NavigateUrlFormat = "LogFileView.aspx?Name={0}";
            oMenu.TokenNameAndValueFields = "NAME=Name";
            oMenu.SortExpression = "Name";

            MenuItemTemplate oView = new MenuItemTemplate("View File", "/_layouts/images/EDITITEM.GIF");
            oView.ClientOnClickNavigateUrl = "LogFileView.aspx?Name=%NAME%";
            _oFileMenu.Controls.Add(oView);

            Page.Controls.Add(_oFileMenu);
            GvFiles.Columns.Add(oMenu);

            BoundField oDateCreated = new BoundField();
            oDateCreated.DataField = "CreationTime";
            oDateCreated.HeaderText = "Date Created";
            oDateCreated.SortExpression = "CreationTime";
            GvFiles.Columns.Add(oDateCreated);

            //if (IsPostBack) return;

            oFiles = new List<FileInfo>();
            FileInfo oInfo;
            foreach (string sFile in Directory.GetFiles(_sLogLocation))
            {
                oInfo = new FileInfo(sFile);
                //Dont add the technology configuration wizard file logs
                if(!oInfo.Name.ToUpper().StartsWith("PSCDIAGNOSTICS") && !oInfo.Name.ToUpper().StartsWith("UPGRADE"))
                    oFiles.Add(new FileInfo(sFile));
            }
            GvFiles.DataSource = oFiles;
            GvFiles.DataBind();
        }
    }
}

About Koders | Resources | Downloads | Support | Black Duck | Submit Project | Terms of Service | DMCA | Privacy Policy | Site Map| Contact Us