最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
Online CPU Console using a Web Control Library wit
时间:2022-07-02 12:07:10 编辑:袖梨 来源:一聚教程网
WROXControlLib
Step one is to 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 at 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 (our assembly), and the message of the event.
Read from the event log by calling EventLog().Entries to obtain the collection of events from the specified machine. This method may be 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 is called with a machine and log type, that is set by the client application. The collection returns the earliest event first by default; the log must be turned around to view the newest event first. 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 into 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;
Step one is to 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 at 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 (our assembly), and the message of the event.
Read from the event log by calling EventLog().Entries to obtain the collection of events from the specified machine. This method may be 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 is called with a machine and log type, that is set by the client application. The collection returns the earliest event first by default; the log must be turned around to view the newest event first. 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 into 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;
相关文章
- 《原神》5.2卡池抽取建议 11-14
- 《原神》5.2版本新怪物介绍 11-14
- 《原神》希诺宁增伤触发方法 11-14
- 《原神》循音觅奇活动入口 11-14
- 《原神》循音觅奇兑换码获取方法 11-14
- 《原神》花羽会活动飞行技巧介绍 11-14