Repository navigation
Expand file tree
/
Copy pathOperationLogDAL.cs
More file actions
58 lines (56 loc) · 1.82 KB
/
Copy pathOperationLogDAL.cs
File metadata and controls
58 lines (56 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using PAMSystem.Model;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PAMSystem.DAL
{
public class OperationLogDAL
{
//添加记录
public bool Insert(Guid operatorId, string actionDesc)
{
int i= SqlHelper.ExecuteNonQuery(@"insert into T_OperationLog(
Id,OperatorId,OperatingDate,ActionDesc)
values(newid(),@OperatorId,getdate(),@ActionDesc)", new SqlParameter("@OperatorId", operatorId)
, new SqlParameter("@ActionDesc", actionDesc));
if (i > 0)
{
return true;
}
else
{
return false;
}
}
/// <summary>
/// 查看操作记录
/// </summary>
/// <param name="sql"></param>
/// <param name="parameters"></param>
/// <returns></returns>
public OperationLog[] Search(Guid operatorId)
{
DataTable table = SqlHelper.ExecuteDataTable(@" select * from T_OperationLog where OperatorId=@OperatorId",
new SqlParameter("@OperatorId",operatorId));
OperationLog[] logs = new OperationLog[table.Rows.Count];
for (int i = 0; i < table.Rows.Count; i++)
{
logs[i] = ToModel(table.Rows[i]);
}
return logs;
}
private OperationLog ToModel(DataRow row)
{
OperationLog model = new OperationLog();
model.Id = (System.Guid)row["Id"];
model.OperatorId = (Guid)row["OperatorId"];
model.OperatingDate = (DateTime)row["OperatingDate"];
model.ActionDesc = (string)row["ActionDesc"];
return model;
}
}
}