Online CPU Console using a Web control Library wit
Source: Internet
Author: User
Wroxcontrollib
The step one was to the set up a Web control Library. Open Visual Studio. NET and choose a Web control Library project. ADD three new Custom Web Controls to the project named Evenlog.cs, Process.cs, and Services.cs. Add System.ServiceProcess as a reference to the project by right-clicking References in the Solutions Explorer.
Eventlog.cs
Events are accessed through the System.Diagnostics assembly. Use this assembly by making a reference in the top of your class.
Write to the event log by calling EventLog.WriteEntry (). The WriteEntry () method provides many parameters such as the type of event (info, error, etc.), the source of the event (O ur assembly), and the message of the event.
Read from the event log by calling EventLog (). Entries to obtain the collection's events from the specified machine. This is called with parameters such as log type (application, System, security), and machine name.
The code below requests the collection of events and loops through them with a for statement. Notice how the collection are called with a machine and log type, which is set by the client application. The collection returns the earliest event, by default; The log must is turned around to view the newest event. Reverse the order by iterating through the collection backwards. Print the content out to the client application using the HtmlTextWriter. HtmlTextWriter is the default parameter passed to a custom control. Let ' s take a look at the code for Eventlog.cs:
Using System;
Using System.Web.UI;
Using System.Web.UI.WebControls;
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service