2
schangxiang@126.com
2024-06-22 e6553a15db81babd14d2c85718555e6af996cfb9
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
using iWare_SCADA_Model;
using iWare_SCADA_Model.TableModelSC;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace iWare_SCADA_BusinessLogical.BLL
{
    public class DataCaptureConfigManager
    {
        public static List<DataCaptureConfig> GetDataCaptureConfigs()
        {
            using (DbModel db = new DbModel())
            {
                //查询所有未删除数据
                var query = db.DataCaptureConfig.Where(o=>o.IsDeleted==false).ToList();//这个不是延迟查询     
                return query;
            }
        }
 
        public static List<DataCaptureColumnConfig> GetDataCaptureColumnConfig()
        {
            using (DbModel db = new DbModel())
            {
                //查询所有
                var query = db.DataCaptureColumnConfig.Where(o=>1==1).ToList();//这个不是延迟查询       
 
                return query;
 
 
                //var ccSystem = DataCaptureColumnDictManager.GetEquipmentBaseInfo(edm);
                //if (ccSystem == null)
                //{
                //    MessageBox.Show("请联系管理员维护系统调度相关的数据!");
                //    return;
                //};
            }
        }
        public static List<AlarmLog> getdate()
        {
            using (SCModel db = new SCModel())
            {
                List<AlarmLog> query = db.AlarmLog.ToList();
                return query;
            }
        }
 
        public static void InsertDataCaptureConfig(DataCaptureConfig info)
        {
            using (DbModel db = new DbModel())
            {
                db.DataCaptureConfig.Add(info);
                db.SaveChanges();
            }
        }
        public static void UpdateDataCaptureConfig(DataCaptureConfig info,out string message)
        {
            using (DbModel db = new DbModel())
            {
                message = "";
                var model = db.DataCaptureConfig.Where(o => o.Id == info.Id).FirstOrDefault();
                if(model!=null && model.Id > 0)
                {
                    var num=db.DataCaptureConfig.Where(o => o.DataCapturePointCode == info.DataCapturePointCode && o.Id != model.Id).Count();
                    if(num>0)
                    {
                        message = $"收集点代码{info.DataCapturePointCode}已存在,不能重复,请确认后再次修改!";
                        return;
                    }
                    model.EquipmentID = info.EquipmentID;
                    model.WorkingProcedure = info.WorkingProcedure;
                    model.DataCapturePointCode = info.DataCapturePointCode;
                    model.DataCapturePointCname = info.DataCapturePointCname;
                    model.DataCaptureType = info.DataCaptureType;
                    model.DataCapturePLCType = info.DataCapturePLCType;
                    model.PLCIP = info.PLCIP;
                    model.PLCPort = info.PLCPort;
                    model.DbNumber = info.DbNumber;
                    model.Offset = info.Offset;
                    model.DataCaptureColumnType = info.DataCaptureColumnType;
                    db.SaveChanges();
                }
                else
                {
                    message = "当前修改项不存在,请刷新后再次修改!";
                    return;
                }
            }
        }
 
        public static int DeleteDataCaptureConfig(DataCaptureConfig info)
        {
            using (DbModel db = new DbModel())
            {
                var config = db.DataCaptureConfig.FirstOrDefault(m => m.Id == info.Id); 
                if (config != null)
                {
                    db.DataCaptureConfig.Remove(config);
                }
                return db.SaveChanges();
            }
        }
 
    }
}