Click here to Skip to main content
15,891,431 members

Comments by justin1204 (Top 6 by date)

justin1204 23-Feb-18 5:59am View    
Actually i am reading the event logs from the system(Application, System and Security).Where the logs for each channel(application, system, security) are fetched. it may contain repeated logs, so i need to sort them and show like

Application:
provider name repeated 3 times.

Security:
Provider name1 repeated 10 times,
provider name2 repeated 4 times,
provider name3 once.

system:
provider name1 repeated 4 times,
provider name2 once.


this is the output i want.. if there are multiple entries, they need to be shown in different lines with comma at the end and for the last entry it should end with full stop

am i clear, thanks for your patience
justin1204 23-Feb-18 5:35am View    
ok sure.. and sorry for my unclear comment

logEventDataList = (IList<eventlogsdatatype>)eventLogs.SetChannelType(EventChannelType.Application).SetLogType(EventLogLevel.Error).SetDays(1).GetLogs();
if (logEventDataList.Count > 0)
{
var app = logEventDataList.GroupBy(n => n.Provider).Select(c => new { Key = c.Key, total = c.Count() }).ToList();
if (app.Count > 0)
{
noErrors = false;
result += "Application: \r\n ";
for (int i = 0; i < app.Count(); i++)
{
var item = app[i];
if (item.total > 1 ) result += item.Key + " repeated " + item.total + ((app.Count > 1) ? " times\r\n" : " times");
else result += item.Key + ((app.Count > 1)?" once\r\n" : " once");
result += i == (app.Count() - 1) ? "." : ",";
}
result += Environment.NewLine + Environment.NewLine;
}
}

this is my output after modifying the code:

Application:
SupportAssistAgent repeated 3 times.

System:
Microsoft-Windows-DistributedCOM repeated 10 times
,BTHUSB once
.


comma starts at the start of the second line and full stop in the next line.
justin1204 23-Feb-18 4:49am View    
thanks for the reaply.. yes it worked but the issue is after the first line break if it has a second line, the coma starts at the start of the second line and after the last line, the full stop comes in the next line
justin1204 7-Dec-17 4:47am View    
thankyou Richard, will check that
justin1204 7-Dec-17 4:47am View    
thankyou Jochen for the reply.. sure will check that