How to realize the operation log function of enterprise management system

Source: Internet
Author: User
Tags current time datetime
How to realize the operation log function of enterprise management systemThe realization of the thinking: in the enterprise management system, the operation of the log this function is essential; so-called Operation Log is to record a user from the time of landing, to the end of the log-off, recording the process of the user's all operations; Here's the example of. Net MVC
First step: Database

Table 1: User logs ( Sys_userloginlog)

Column Name

Data type

Primary key/FOREIGN key

Description

LoginID

Int

Primary key

Log ID

StaffID

Int

FOREIGN key

Employee ID

Operationlog

NCHAR (50)

Action Content

Operationdate

Datetime

Operating time

Table 2: Employee table (Sys_yuangong)

Column Name

Data type

Primary key/FOREIGN key

Description

Yuangongid

Int

Primary key

Employee ID

Luruyuanid

Int

FOREIGN key

Input Member ID

Yuangongzhuangtaiid

Int

FOREIGN key

Employee Status ID

Mendianid

Int

FOREIGN key

Store ID

Zhiwuid

Int

FOREIGN key

Duties

Jueseid

Int

FOREIGN key

Role ID

Yuangongbianhao

NCHAR (50)

Employee number

Yuangongxingming

NCHAR (50)

Employee Name

Xingbie

NCHAR (50)

Gender

Jiguan

NCHAR (50)

Origin

Xueli

NCHAR (50)

Degree

Chushengriqi

Date

Date of birth

Shenfenzhenghao

NCHAR (18)

ID number

Ruzhiriqi

Data

Date of entry

Ruzhididian

NCHAR (50)

Entry Location

Yidongshouji

Int

Mobile phone

Jiatingdianhua

NCHAR (50)

Home phone

Dixin

Decimal (18, 2)

Salary

Jishifou

Bit

Technology No

Hunfou

Bit

Marriage No

Tongxundizhi

NCHAR (50)

Mailing Address

Beizhu

NCHAR (50)

Note

Mima

NCHAR (50)

Password

Figure 1 Step Two: Controllers (Controller)Write a method in the controller that handles the user's actions, so that you can call this method directly where needed, avoiding duplication of code,
<summary>///set log In///</summary>//
        <param name= "Log" > Operation information </param>
        <param name= "returnstring" > Return value Contents </param>//
        <param name= "Intuesrid" > Login user Id</param >
        //<returns></returns> public string Uesrlog (string log,string returnstring,int Intuesrid)
        {
            var logstring = "";
            Models.sys_userloginlog Userlog = new Models.sys_userloginlog ();
            Userlog.staffid = Convert.ToInt32 (Intuesrid);//Login
            userlog.operationlog = log;//Set Log contents
            Userlog.operationdate = datetime.now;//Set Current time
            myMdl.sys_UserLoginLog.AddObject (userlog);
            Int J = mymdl.savechanges ();
            if (J > 0)//Determine if Save succeeded
            {
                logstring = returnstring;
            }
            return logstring;
        }

Call where needed: for example:
public void Loginoff ()//Logoff login
        {
            formsauthentication.signout ();//delete authentication ticket
            uesrlog ("Exit Login", "true", Convert.ToInt32 (session["Yonghuid"));//Call the method of writing the operation Log
            Response.Redirect ("/main/login");
        }

Operation log processing is completely in the background, not in the foreground processing, need to record the place, directly use the written operation log method, so that you can record the user's operation steps
This information is for informational purposes only and is prohibited for commercial use

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.