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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
| using DataBase;
| using Model;
| using Model.WcsModel;
| using System;
| using System.Collections.Generic;
| using System.Linq;
| using System.Text;
| using System.Threading.Tasks;
|
| namespace BLL.DAL
| {
| public class DAL_AlarmLog
| {
| /// <summary>
| /// 添加报警日志
| /// </summary>
| /// <param name="model"></param>
| /// <param name="loginName">登录人</param>
| /// <returns></returns>
| public bool AddAlarmLog(WCSAlarmLogModel model, string loginName)
| {
| bool result = false;
| try
| {
|
| StringBuilder sqlString = new StringBuilder();
|
| // 新增任务
| sqlString.Append("insert into WCSAlarmLog (PlcIP,AlarmCode,AlarmName,Type,AlarmType,AlarmTime,IsDel,CreateTime,CreateUser) values ( ");
| sqlString.Append($"'{model.PlcIP}','{model.AlarmCode}','{model.AlarmName}','{model.Type}','{model.AlarmType}','{DateTime.Now}','{model.IsDel}',GETDATE(),'{loginName}');");
| var num = DataFactory.SqlDataBase().ExecuteBySql(sqlString);
|
| if (num == 1)
| {
| result = true;
| }
| return result;
| }
| catch (Exception e)
| {
| throw new Exception(e.Message);
| }
| }
|
| /// <summary>
| /// 记录设备报警信息(报警日志表
| /// </summary>
| /// <param name="model"></param>
| /// <returns></returns>
| public bool AddAlarmLogInfo(WCSAlarmLog model)
| {
| try
| {
| bool isReAdd = false;
| //string str = $"Insert WCSAlarmLog into (PlcIP,AlarmCode,AlarmName,Type,AlarmType,AlarmTime,IsDel,CreateTime,CreateUser) Values ('{model.PlcIP}','{model.AlarmCode}','{model.AlarmName}','{model.Type}','{model.AlarmType}','{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ff fff")}','0','getdate()','')";
| //int isAdd = Dapper<WCSAlarmLog>.RUD(str);
| //if (isAdd >= 1)
| //{
| // isReAdd = true;
| //}
| StringBuilder sqlString = new StringBuilder();
| sqlString.Clear();
| sqlString.Append($"Insert WCSAlarmLog into (PlcIP,AlarmCode,AlarmName,Type,AlarmType,AlarmTime,IsDel,CreateTime,CreateUser) Values ('{model.PlcIP}','{model.AlarmCode}','{model.AlarmName}','{model.Type}','{model.AlarmType}','{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ff fff")}','0','getdate()','')");
| int isAdd = DataFactory.SqlDataBase().ExecuteBySql(sqlString);
| if (isAdd >= 1)
| {
| isReAdd = true;
| }
| return isReAdd;
| }
| catch (Exception ex)
| {
|
| throw ex;
| }
| }
|
| }
| }
|
|