프로젝트

일반

사용자정보

통계
| 개정판:

hytos / DTI_PID / APIDConverter / AvevaInfo.cs @ faba1fc7

이력 | 보기 | 이력해설 | 다운로드 (3.43 KB)

1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.Threading.Tasks;
6
using AVEVA.PID.CustomizationUtility.DB;
7
using AVEVA.PID.CustomizationUtility.Model;
8
using AVEVA.PID.CustomizationUtility.Properties;
9
using System.Data;
10

    
11
namespace AVEVA.PID.CustomizationUtility
12
{
13
    public class AvevaInfo
14
    {
15
        static AvevaInfo avevaInfo;
16

    
17
        public DataTable AvevaSymbolTable { get; set; }
18
        public List<SymbolInfo> SymbolInfo { get; set; }
19
        public List<AttributeInfo> AttributeInfo { get; set; }
20
        public static AvevaInfo GetInstance()
21
        {
22
            if (avevaInfo == null)
23
            {
24
                avevaInfo = new AvevaInfo();
25
                Refresh();
26
            }
27
            return avevaInfo;
28
        }
29
        public static void Refresh()
30
        {
31
            if (avevaInfo == null)
32
                avevaInfo = new AvevaInfo();
33

    
34
            avevaInfo.AvevaSymbolTable = Project_DB.SelectSymbolTable();
35
            SetSymbolInfo();
36
            SetAttributeInfo();
37
        }
38
        private static void SetSymbolInfo()
39
        {
40
            avevaInfo.SymbolInfo = new List<SymbolInfo>();
41
            DataTable dt = Project_DB.GetSymbolMappingTableOnlySymbol();
42
            foreach (DataRow row in dt.Rows)
43
            {
44
                SymbolInfo info = new SymbolInfo();
45
                info.UID = DBNull.Value.Equals(row["UID"]) ? string.Empty : row["UID"].ToString();
46
                info.NAME = DBNull.Value.Equals(row["NAME"]) ? string.Empty : row["NAME"].ToString();
47
                info.APID_SYMBOL = DBNull.Value.Equals(row["APID_SYMBOL"]) ? string.Empty : row["APID_SYMBOL"].ToString();
48
                info.DATA1 = DBNull.Value.Equals(row["DATA1"]) ? string.Empty : row["DATA1"].ToString();
49
                avevaInfo.SymbolInfo.Add(info);
50
            }
51
            dt.Dispose();
52
        }
53
        private static void SetAttributeInfo()
54
        {
55
            avevaInfo.AttributeInfo = new List<AttributeInfo>();
56
            DataTable dt = Project_DB.GetAttributeMappingTableOnlyAttribute();
57
            foreach (DataRow row in dt.Rows)
58
            {
59
                AttributeInfo info = new AttributeInfo();
60
                info.UID = DBNull.Value.Equals(row["UID"]) ? string.Empty : row["UID"].ToString();
61
                info.APID_ATTRIBUTE = DBNull.Value.Equals(row["APID_ATTRIBUTE"]) ? string.Empty : row["APID_ATTRIBUTE"].ToString();
62
                //string sType = DBNull.Value.Equals(row["APID_ATTRIBUTE_TYPE"]) ? string.Empty : row["APID_ATTRIBUTE_TYPE"].ToString();
63
                //if (!string.IsNullOrEmpty(info.APID_ATTRIBUTE) && !string.IsNullOrEmpty(sType))
64
                //{
65
                //    string sRemove = "|" + sType;
66
                //    info.APID_ATTRIBUTE = info.APID_ATTRIBUTE.Remove(info.APID_ATTRIBUTE.LastIndexOf(sRemove), sRemove.Length);
67
                //    AvevaAttributeType type;
68
                //    if (Enum.TryParse(sType, out type))
69
                //        info.APID_ATTRIBUTE_TYPE = type;
70
                //}
71
                avevaInfo.AttributeInfo.Add(info);
72
            }
73
            dt.Dispose();
74
        }
75
    }
76

    
77
    public class SymbolInfo
78
    {
79
        public string UID { get; set; }
80
        public string NAME { get; set; }
81
        public string APID_SYMBOL { get; set; }
82
        public string DATA1 { get; set; }
83
    }
84

    
85
    public class AttributeInfo
86
    {
87
        public string UID { get; set; }
88
        public string APID_ATTRIBUTE { get; set; }
89
    }
90
}
클립보드 이미지 추가 (최대 크기: 500 MB)