Space Data Management Platform 7 (C # Development) based on arcgis10.0 and Oracle10g-log operation

Source: Internet
Author: User

This blog is very simple. It introduces the write operations of various logs. Because log writing operations are required at any time, a class is specially implemented. Generally, logs can be written to files. However, in this project, logs are directly written to the Oracle database, which facilitates query and management of these logs by category. Log Management is mainly a separate function module. The log writing function may be deployed in every other function module. Here we will introduce writing logs, mainly writing three types of logs. The specific implementation is as follows:Code.

1. operation logs are the behavior logs generated by the system, which are used to conveniently monitor the operations performed by users.

/// <Summary> <br/> // write operation log <br/> /// </Summary> <br/> /// <Param name = "username "> operation user </param> <br/> /// <Param name =" type "> operation type </param> <br/> /// <Param name = "content"> operation content </param> <br/> // <returns> </returns> <br/> Public static bool writelog (string username, string type, string content) <br/>{< br/> bool result = false; <br/> sqlhelper SH = new sqlhelper (); <br/> hashtable ht = new hashtable (); </P> <p> ht. add ("username", username); <br/> ht. add ("opttime", datetime. now); <br/> ht. add ("type", type); <br/> ht. add ("Description", content); </P> <p> If (Sh. insert ("optlog", HT)> 0) <br/>{< br/> result = true; <br/>}< br/> else <br/>{< br/> result = false; <br/>}< br/> return result; <br/>}

2. Write the database update log information, which is mainly used for synchronization between databases. It can be divided into space tables and attribute tables for modification. This division is mainly because the synchronization policies of Space tables and general attribute tables are different.

/// <Summary> <br/> // write the Update log <br/> /// </Summary> <br/> /// <Param name = "strtablename "> table name </param> <br/> // <Param name =" strtabletype "> type of the table (0: attribute Table; 1: Space table) </param> <br/> // <Param name = "stropttype"> operation type (currently all are treated as update (modified )) </param> <br/> // <returns> </returns> <br/> Public static bool writeupdatedatalog (string strtablename, string strtabletype, string stropttype) <br/>{< br/> bool result = false; <br/> sqlhelper SH = new sqlhelper (); <br/> string SQL = "select * From updatedata_log "; <br/> // self-increment id <br/> int id = 0; <br/> If (Sh. getrecordcount (SQL)> 0) <br/>{< br/> SQL = "select max (ID) from updatedata_log"; <br/> oracledatareader ODR = Sh. returndatareader (SQL); </P> <p> If (ODR. read () <br/>{< br/> id = int. parse (ODR [0]. tostring (); <br/> ID ++; <br/>}< br/> else <br/> {<br/> id = 0; <br/>}</P> <p> hashtable ht = new hashtable (); <br/> // update a table if it already exists, otherwise, insert a record <br/> SQL = "select * From updatedata_log where tablename = '" + strtablename + "'"; <br/> If (Sh. getrecordcount (SQL)> 0) <br/>{< br/> ht. add ("operdate", datetime. now); </P> <p> If (Sh. update ("updatedata_log", "tablename = '" + strtablename + "'", HT)> 0) <br/>{< br/> result = true; <br/>}< br/> else <br/>{< br/> result = false; <br/>}< br/> else <br/> {<br/> ht. add ("ID", ID); <br/> ht. add ("tablename", strtablename); <br/> ht. add ("tabletype", strtabletype); <br/> ht. add ("opertype", stropttype); <br/> ht. add ("operdate", datetime. now); </P> <p> If (Sh. insert ("updatedata_log", HT)> 0) <br/>{< br/> result = true; <br/>}< br/> else <br/>{< br/> result = false; <br/>}</P> <p> return result; <br/>}

3. database monitoring logs mainly monitor whether the running status of data is good, so that you can detect database problems in time, such as performance problems. You can also execute database optimization solutions based on the log information. These monitoring logs are generated by executing SQL statements of some database monitoring scripts. You can query specific SQL statements online.

/// <Summary> <br/> // write the database monitoring warning log <br/> /// </Summary> <br/> // <Param name = "strtype"> Warning type </param> <br/> // <Param name = "strcontent"> details </param> <br/> // <returns> </returns> <br/> Public static bool writealertlog (string strtype, string strcontent) <br/>{< br/> bool result = false; <br/> sqlhelper SH = new sqlhelper (); <br/> hashtable ht = new hashtable (); </P> <p> ht. add ("happentime", datetime. now); <br/> ht. add ("type", strtype); <br/> ht. add ("content", strcontent); </P> <p> If (Sh. insert ("jcsjk_alert_log", HT)> 0) <br/>{< br/> result = true; <br/>}< br/> else <br/>{< br/> result = false; <br/>}< br/> return result; <br/>}

all the write operations for the three types of logs are described. There is no operation function for reading logs separately, because the system didn't have this need at the time. The management of system logs is centralized management, query, read, and delete logs in an independent module, which will be detailed later!

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.