コード例 #1
0
        public static IIS_Log_File convertData(this IIS_Log_File logFile)
        {
            var columns = new List <string>();

            if (logFile.File.fileExists())
            {
                foreach (var line in logFile.File.fileContents().split_onLines())
                {
                    if (line.starts("#"))
                    {
                        logFile.Comments.add(line);
                        if (line.starts("#Fields: "))
                        {
                            columns = line.remove("#Fields: ").split_onSpace();
                            //"there are {0} columns".debug(columns.size());
                        }
                    }
                    else
                    {
                        var logEntry = new IIS_Log_Entry();
                        //logEntry.RawLine = line;
                        var items = line.split_onSpace();
                        for (int i = 0; i < items.size(); i++)
                        {
                            //"item #{0} : {1}".info(columns[i], items[i]);
                            var propertyName = columns[i].upperCaseFirstLetter().replace("-", "_").replace("(", "_").replace(")", "_");
                            logEntry.prop(propertyName, items[i]);
                        }
                        logFile.LogEntries.Add(logEntry);
                    }
                }
            }
            return(logFile);
        }
コード例 #2
0
		public static IIS_Log_File convertData(this IIS_Log_File logFile)
		{
			var columns= new List<string>();
			if(logFile.File.fileExists())
			{
				foreach(var line in logFile.File.fileContents().split_onLines())
				{
					if (line.starts("#"))
					{
						logFile.Comments.add(line);
						if (line.starts("#Fields: "))
						{
							columns = line.remove("#Fields: ").split_onSpace();
							//"there are {0} columns".debug(columns.size());
						}
					}					
					else
					{
						var logEntry = new IIS_Log_Entry();
						//logEntry.RawLine = line;
						var items = line.split_onSpace();
						for(int i=0; i < items.size() ; i++)
						{
							//"item #{0} : {1}".info(columns[i], items[i]);
							var propertyName = columns[i].upperCaseFirstLetter().replace("-","_").replace("(","_").replace(")","_");
							logEntry.prop(propertyName, items[i]);
						}
						logFile.LogEntries.Add(logEntry);						
					}
				}
			}
			return logFile;
		}