Very urgent plz help

Posted by Shivanichhabra4u under ASP.NET on 11/25/2008 | Views : 1249 | Status : [Member] | Replies : 2
I have made one web application that takes log from event viewer and it displays in web page.

But i want to make it schedule task.So that it can run automatically everyday.it retrieve logs of previous day and save in database .

Please help me out as soon as poosible.

I have written 2 function in my web application.These are saving logs into database.But how can i make schedule task.


**********Function 1***********************************************


private void filllog()
{
try
{
strPostbackTester = "PostBack";
eventlog.MachineName = whichmachine ;
//eventlog.Source = "Stargate";


////TO save Application logs
eventlog.Log = "Application";
fillLogEntriesIntoDataBase("Application");

////TO save Security logs
eventlog.Log = "Security";
fillLogEntriesIntoDataBase("Security");

////TO save System logs
eventlog.Log = "System";
fillLogEntriesIntoDataBase("System");

//TO save Pointsec logs
eventlog.Log = "Pointsec";
fillLogEntriesIntoDataBase("Pointsec");

//eventlog.MinimumRetentionDays = 20;

}

***********End of function 1******************


*********Function 2**********************************************

private void fillLogEntriesIntoDataBase(string strLogDisplayName)
{

foreach (EventLogEntry entry in eventlog.Entries)
{

SqlConnection conn = new SqlConnection();
string connString = System.Configuration.ConfigurationManager.ConnectionStrings["EventViewerConnectionString"].ConnectionString;
conn.ConnectionString = connString;
conn.Open();
SqlCommand comm1 = new SqlCommand("Set DateFormat dmy", conn);
comm1.ExecuteNonQuery();
string query = "insert into EventViewer..tblEventViewerDetails(MachineName,LogDisplayName,EntryType,Source,IndexLog,Message,TimeGenerated,TimeWritten)";
query = query + "Values ( '" + entry.MachineName.ToString() + "','" + strLogDisplayName + "','" + entry.EntryType.ToString() + "','" + entry.Source.ToString() + "'," + entry.Index + ",'" + entry.Message.Replace("'", "''") + "', convert(datetime,'" + entry.TimeGenerated + "'),convert(datetime,'" + entry.TimeWritten + "'))";
//conn.Open();
SqlCommand comm = new SqlCommand(query, conn);
comm.ExecuteNonQuery();
conn.Close();

}

}

******************Function 2*********************


Please help ...........




Responses

Posted by: Amatya on: 5/30/2015 [Member] Silver | Points: 25

Up
0
Down
Window Service is an option

Feel free to share informations 9731764134
mail Id ' adityagupta200@gmail.com
Thanks

Shivanichhabra4u, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Deysomnath on: 11/25/2008 [Member] Starter

Up
0
Down
U can achive this by using windows services.

Shivanichhabra4u, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response