Ejemplo n.º 1
0
        ///<summary>Computer_LostFocus</summary>
        public void Computer_LostFocus(object sender, EventArgs evArgs)
        {
            List <string>         site;
            UtilityIISLogArgument utilityIISLogArgument = new UtilityIISLogArgument(Computer.Text, null, null);

            UtilityIISLog.LoadSite
            (
                utilityIISLogArgument,
                out site
            );
            IISSite.DataSource = site;
        }
Ejemplo n.º 2
0
        public DataTable ParseLog(string computer, string log, string site)
        {
            DataTable             dataTable;
            UtilityIISLogArgument utilityIISLogArgument;

            utilityIISLogArgument = new UtilityIISLogArgument(computer, log, site);
            UtilityIISLog.ParseLog
            (
                utilityIISLogArgument,
                out dataTable
            );
            return(dataTable);
        }
Ejemplo n.º 3
0
        public string[] LoadSite(string computer)
        {
            List <string>         site = new List <string>();
            UtilityIISLogArgument utilityIISLogArgument;

            utilityIISLogArgument = new UtilityIISLogArgument(computer, null, null);
            UtilityIISLog.LoadSite
            (
                utilityIISLogArgument,
                out site
            );
            return(site.ToArray());
        }
Ejemplo n.º 4
0
        public string[] LoadLog(string computer, string site)
        {
            List <string>         log = new List <string>();
            UtilityIISLogArgument utilityIISLogArgument;

            utilityIISLogArgument = new UtilityIISLogArgument(computer, null, site);
            UtilityIISLog.LoadLog
            (
                utilityIISLogArgument,
                out log
            );
            return(log.ToArray());
        }
Ejemplo n.º 5
0
        ///<summary>IISSite_SelectedIndexChanged</summary>
        public void IISSite_SelectedIndexChanged(object sender, EventArgs evArgs)
        {
            List <string>         log;
            String                iisSite = (string)IISSite.SelectedItem;
            UtilityIISLogArgument utilityIISLogArgument = new UtilityIISLogArgument(Computer.Text, null, iisSite);

            UtilityIISLog.LoadLog
            (
                utilityIISLogArgument,
                out log
            );
            IISLog.DataSource = log;
        }
Ejemplo n.º 6
0
        ///<summary>IISLog_SelectedIndexChanged</summary>
        public void IISLog_SelectedIndexChanged(object sender, EventArgs evArgs)
        {
            String                iisLog  = (string)IISLog.SelectedItem;
            String                iisSite = (string)IISSite.SelectedItem;
            DataTable             parseLog;
            UtilityIISLogArgument utilityIISLogArgument = new UtilityIISLogArgument(Computer.Text, iisLog, iisSite);

            UtilityIISLog.ParseLog
            (
                utilityIISLogArgument,
                out parseLog
            );
            LogParser.DataSource = parseLog;
        }
Ejemplo n.º 7
0
        ///<summary>LoadLog</summary>
        public static void LoadLog
        (
            UtilityIISLogArgument utilityIISLogArgument,
            out List <string> log
        )
        {
            string        IISLogPath;
            string        computer = utilityIISLogArgument.computer;
            string        site     = utilityIISLogArgument.site;
            string        windir;
            DirectoryInfo directoryInfo;
            HttpContext   httpContext = HttpContext.Current;

            if (string.IsNullOrEmpty(computer))
            {
                computer = Environment.MachineName;
            }
            if (string.IsNullOrEmpty(site))
            {
                site = WebSite;
            }
            //windir = Environment.GetEnvironmentVariable("windir");
            windir = WinDir(computer);
            if (String.Compare(computer, Environment.MachineName, true) == 0)
            {
                IISLogPath = windir + @"\System32\LogFiles\" + site;
            }
            else
            {
                IISLogPath = @"\\" + computer + @"\" + windir + @"\System32\LogFiles\" + site;
                IISLogPath = IISLogPath.Replace(':', '$');
            }

            /*
             * if ( Directory.Exists( IISLogPath ) == false )
             * {
             *   return;
             * }
             */
            directoryInfo = new DirectoryInfo(IISLogPath);
            log           = new List <string>();
            foreach (FileSystemInfo fileSystemInfo in directoryInfo.GetFileSystemInfos())
            {
                if (fileSystemInfo.Name.StartsWith("ex") && fileSystemInfo.Name.EndsWith(".log"))
                {
                    log.Add(fileSystemInfo.Name);
                }
            }
        }
Ejemplo n.º 8
0
        /// <summary>The entry point for the application.</summary>
        /// <param name="argv">A list of command line arguments</param>
        public static void Main(String[] argv)
        {
            bool parseCommandLineArguments;
            UtilityIISLogArgument utilityIISLogArgument = new UtilityIISLogArgument();

            parseCommandLineArguments = Parser.ParseArgumentsWithUsage
                                        (
                argv,
                utilityIISLogArgument
                                        );
            if (parseCommandLineArguments == false)
            {
                return;
            }
            Stub(utilityIISLogArgument);
        }
Ejemplo n.º 9
0
        ///<summary>Stub</summary>
        public static void Stub
        (
            UtilityIISLogArgument utilityIISLogArgument
        )
        {
            List <string> log;
            List <string> site;
            DataTable     dataTable;

            LoadSite
            (
                utilityIISLogArgument,
                out site
            );
            if (site != null)
            {
                foreach (string siteCurrent in site)
                {
                    System.Console.WriteLine(siteCurrent);
                }
            }

            LoadLog
            (
                utilityIISLogArgument,
                out log
            );
            if (log != null)
            {
                foreach (string logCurrent in log)
                {
                    System.Console.WriteLine(logCurrent);
                }
            }

            ParseLog
            (
                utilityIISLogArgument,
                out dataTable
            );
        }
Ejemplo n.º 10
0
        ///<summary>LoadSite</summary>
        public static void LoadSite
        (
            UtilityIISLogArgument utilityIISLogArgument,
            out List <string> site
        )
        {
            string        IISLogPath;
            string        computer = utilityIISLogArgument.computer;
            string        windir;
            DirectoryInfo directoryInfo;
            HttpContext   httpContext = HttpContext.Current;

            site = null;
            if (string.IsNullOrEmpty(computer))
            {
                computer = Environment.MachineName;
            }
            //windir = Environment.GetEnvironmentVariable("windir");
            windir     = WinDir(computer);
            IISLogPath = @"\\" + computer + @"\" + windir + @"\System32\LogFiles\";
            IISLogPath = IISLogPath.Replace(':', '$');

            /*
             * if ( Directory.Exists( IISLogPath ) == false )
             * {
             *   return;
             * }
             */
            directoryInfo = new DirectoryInfo(IISLogPath);
            site          = new List <string>();
            foreach (FileSystemInfo fileSystemInfo in directoryInfo.GetFileSystemInfos())
            {
                if (fileSystemInfo.Name.StartsWith("W3"))
                {
                    site.Add(fileSystemInfo.Name);
                }
            }
        }
Ejemplo n.º 11
0
        ///<summary>ParseLog</summary>
        public static void ParseLog
        (
            UtilityIISLogArgument utilityIISLogArgument,
            out DataTable dataTable
        )
        {
            string[] column;
            string   columnName;
            string   computer = utilityIISLogArgument.computer;
            string   content;

            string[] line;
            string   log = utilityIISLogArgument.log;
            string   logFile;
            string   site = utilityIISLogArgument.site;

            string[]     value;
            string       windir;
            DateTime     date;
            HttpContext  httpContext = HttpContext.Current;
            FileStream   fileStream;
            StreamReader streamReader;

            dataTable = null;
            if (string.IsNullOrEmpty(computer))
            {
                computer = Environment.MachineName;
            }
            if (string.IsNullOrEmpty(log))
            {
                log = String.Format("ex{0:yyMMdd}.log", DateTime.Now.AddDays(DayOffset));
            }
            if (string.IsNullOrEmpty(site))
            {
                site = WebSite;
            }
            //windir = Environment.GetEnvironmentVariable("windir");
            windir = WinDir(computer);
            if (String.Compare(computer, Environment.MachineName, true) == 0)
            {
                logFile = windir + @"\System32\LogFiles\" + site + @"\" + log;
            }
            else
            {
                logFile = @"\\" + computer + @"\" + windir + @"\System32\LogFiles\" + site + @"\" + log;
                logFile = logFile.Replace(':', '$');
            }

            /*
             * if ( File.Exists( logFile ) == false )
             * {
             *   return;
             * }
             */
            fileStream = new FileStream
                         (
                logFile,
                FileMode.Open,
                FileAccess.Read,
                FileShare.Read
                         );
            streamReader = new StreamReader(fileStream);
            content      = streamReader.ReadToEnd();
            streamReader.Close();
            fileStream.Close();
            streamReader = null;
            fileStream   = null;
            line         = content.Split('\n');
            //line = File.ReadAllLines(logFile);
            dataTable  = new DataTable("log");
            columnName = line[3].Replace("#Fields: ", "");
            column     = columnName.Split(' ');
            for (int columnIndex = 0; columnIndex < column.Length - 1; ++columnIndex)
            {
                foreach (string columnReplace in ColumnReplace)
                {
                    column[columnIndex] = column[columnIndex].Replace(columnReplace, "");
                }
                dataTable.Columns.Add(column[columnIndex]);
            }
            for (int lineIndex = line.Length - 2; lineIndex > 3; --lineIndex)
            {
                if (string.IsNullOrEmpty(line[lineIndex].Trim()))
                {
                    continue;
                }
                value = line[lineIndex].Split(' ');
                if (DateTime.TryParse(value[0], out date))
                {
                    dataTable.Rows.Add(value);

                    /*
                     * DataRow dataRow;
                     * dataRow = dataTable.NewRow();
                     * for ( int columnIndex = 0; columnIndex < column.Length -1; ++columnIndex )
                     * {
                     * dataRow[columnIndex] = value[columnIndex];
                     * }
                     * dataTable.Rows.Add( dataRow );
                     */
                }
            }
        }