프로젝트

일반

사용자정보

통계
| 개정판:

hytos / DTI_PID / SPPIDConverter / DB / SPPID_DB.cs @ bfa8ddbe

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

1 23eb98bf gaqhf
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.Threading.Tasks;
6
using System.Data;
7
using System.Globalization;
8
using System.IO;
9
using Oracle.ManagedDataAccess.Client;
10 2e92b956 gaqhf
using System.Data.SqlClient;
11 23eb98bf gaqhf
12 b8e2644e gaqhf
namespace Converter.SPPID.DB
13 23eb98bf gaqhf
{
14 2e1e3c12 gaqhf
    public class SPPID_DB
15 23eb98bf gaqhf
    {
16 57428b38 gaqhf
        private const string oracleConnString = "(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST ={0}" + @")(PORT = {1}))(CONNECT_DATA = (SERVICE_NAME = {2})))";
17
        private const string sqlConnString = "(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST ={0}" + @")(PORT = {1}))(CONNECT_DATA = (SERVICE_NAME = {2})))";
18 23eb98bf gaqhf
19 fab4f207 gaqhf
        public static bool CheckAndSetSPPIDInfo(SPPID_DBInfo dbInfo)
20 23eb98bf gaqhf
        {
21
            bool bResult = false;
22
            try
23
            {
24
                if (dbInfo.DBType == "ORACLE")
25
                {
26 57428b38 gaqhf
                    string connString = string.Format(oracleConnString, dbInfo.ServerIP, dbInfo.Port, dbInfo.Service);
27 23eb98bf gaqhf
                    connString = "Data Source=" + connString + ";User Id=" + dbInfo.DBUser + ";Password=" + dbInfo.DBPassword;
28
29
                    using (OracleConnection conn = new OracleConnection(connString))
30
                    {
31
                        conn.Open();
32
                        if (conn.State == System.Data.ConnectionState.Open)
33
                        {
34
                            using (OracleCommand cmd = new OracleCommand())
35
                            {
36
                                cmd.Connection = conn;
37
                                cmd.CommandText = string.Format(CultureInfo.CurrentCulture, "SELECT NAME, PATH FROM {0}.T_ROOTITEM", dbInfo.Site);
38
39
                                using (OracleDataReader reader = cmd.ExecuteReader())
40
                                {
41
                                    while (reader.Read())
42
                                    {
43
                                        dbInfo.Plant = reader["NAME"].ToString();
44
                                        dbInfo.PlantPath = reader["PATH"].ToString();
45
                                    }
46
47
                                    cmd.CommandText = string.Format(CultureInfo.CurrentCulture, @"SELECT SP_SCHEMA_TYPE, USERNAME
48
                                                FROM {0}.T_DB_DATA DB_DATA 
49
                                                INNER JOIN {0}.T_ROOTITEM ROOTITEM ON DB_DATA.SP_ROOTITEMID = ROOTITEM.SP_ID 
50
                                                WHERE ROOTITEM.NAME = '{1}'", dbInfo.Site, dbInfo.Plant);
51
52
53
                                    using (OracleDataAdapter adapter = new OracleDataAdapter())
54
                                    {
55
                                        DataTable dt = new DataTable();
56
                                        adapter.SelectCommand = cmd;
57
                                        adapter.Fill(dt);
58
59
                                        foreach (DataRow row in dt.Rows)
60
                                        {
61
                                            string sType = row["SP_SCHEMA_TYPE"].ToString();
62
                                            switch (sType)
63
                                            {
64
                                                case "SPPIDDATA_DICTIONARY":
65
                                                    dbInfo.PlantPIDDic = row["USERNAME"].ToString();
66
                                                    break;
67
                                                case "DATA_DICTIONARY":
68
                                                    dbInfo.PlantDic = row["USERNAME"].ToString();
69
                                                    break;
70
                                                case "SPAPLANT":
71
                                                    dbInfo.Plant = row["USERNAME"].ToString();
72
                                                    break;
73
                                                case "SPPID":
74
                                                    dbInfo.PlantPID = row["USERNAME"].ToString();
75
                                                    break;
76
                                                default:
77
                                                    break;
78
                                            }
79
                                        }
80
                                        bResult = true;
81
                                    }
82
                                }
83
                            }
84
                        }
85
                    }
86
                }
87 2e92b956 gaqhf
                else if (dbInfo.DBType == "SQLSERVER")
88 23eb98bf gaqhf
                {
89
90
                }
91
            }
92
            catch (Exception ex)
93
            {
94 289e9573 gaqhf
                System.Windows.Forms.MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
95 23eb98bf gaqhf
            }
96
97
            return bResult;
98
        }
99 fab4f207 gaqhf
        public static bool SetPlantDBSetting(SPPID_DBInfo dbInfo)
100 23eb98bf gaqhf
        {
101
            bool bResult = false;
102
            try
103
            {
104
                if (dbInfo.DBType == "ORACLE")
105
                {
106 57428b38 gaqhf
                    string connString = string.Format(oracleConnString, dbInfo.ServerIP, dbInfo.Port, dbInfo.Service);
107 23eb98bf gaqhf
                    connString = "Data Source=" + connString + ";User Id=" + dbInfo.DBUser + ";Password=" + dbInfo.DBPassword;
108
109
                    using (OracleConnection conn = new OracleConnection(connString))
110
                    {
111
                        conn.Open();
112
                        if (conn.State == System.Data.ConnectionState.Open)
113
                        {
114
                            using (OracleCommand cmd = new OracleCommand())
115
                            {
116
                                cmd.Connection = conn;
117
                                cmd.CommandText = string.Format(CultureInfo.CurrentCulture, @"SELECT SP_SCHEMA_TYPE, USERNAME
118
                                                FROM {0}.T_DB_DATA DB_DATA 
119
                                                INNER JOIN {0}.T_ROOTITEM ROOTITEM ON DB_DATA.SP_ROOTITEMID = ROOTITEM.SP_ID 
120
                                                WHERE ROOTITEM.NAME = '{1}'", dbInfo.Site, dbInfo.SelectedPlant);
121
                                using (OracleDataAdapter adapter = new OracleDataAdapter())
122
                                {
123
                                    DataTable dt = new DataTable();
124
                                    adapter.SelectCommand = cmd;
125
                                    adapter.Fill(dt);
126
127
                                    foreach (DataRow row in dt.Rows)
128
                                    {
129
                                        string sType = row["SP_SCHEMA_TYPE"].ToString();
130
                                        switch (sType)
131
                                        {
132
                                            case "SPPIDDATA_DICTIONARY":
133
                                                dbInfo.PlantPIDDic = row["USERNAME"].ToString();
134
                                                break;
135
                                            case "DATA_DICTIONARY":
136
                                                dbInfo.PlantDic = row["USERNAME"].ToString();
137
                                                break;
138
                                            case "SPAPLANT":
139
                                                dbInfo.Plant = row["USERNAME"].ToString();
140
                                                break;
141
                                            case "SPPID":
142
                                                dbInfo.PlantPID = row["USERNAME"].ToString();
143
                                                break;
144
                                            default:
145
                                                break;
146
                                        }
147
                                        bResult = true;
148
                                    }
149
                                }
150 224535bb gaqhf
151
                                cmd.CommandText = string.Format(CultureInfo.CurrentCulture, "SELECT PATH FROM {0}.T_ROOTITEM WHERE NAME = '{1}'", dbInfo.Site, dbInfo.Plant);
152
                                using (OracleDataReader reader = cmd.ExecuteReader())
153
                                {
154
                                    while (reader.Read())
155
                                    {
156
                                        dbInfo.PlantPath = reader["PATH"].ToString();
157
                                    }
158
                                }
159 23eb98bf gaqhf
                            }
160
                        }
161
                    }
162
                }
163 2e92b956 gaqhf
                else if (dbInfo.DBType == "SQLSERVER")
164 23eb98bf gaqhf
                {
165 2e92b956 gaqhf
                    string connString = string.Format("server = {0}; uid = {1}; pwd = {2}; database = {3};", dbInfo.Service, dbInfo.DBUser, dbInfo.DBPassword, dbInfo.SQLSERVER_DBNAME);
166
                    using (SqlConnection conn = new SqlConnection(connString))
167
                    {
168
                        conn.Open();
169
                        if (conn.State == ConnectionState.Open)
170
                        {
171
                            using (SqlCommand cmd = new SqlCommand())
172
                            {
173
                                cmd.Connection = conn;
174 23eb98bf gaqhf
175 04133d37 gaqhf
                                cmd.CommandText = string.Format(CultureInfo.CurrentCulture, @"SELECT SP_SCHEMA_TYPE, USERNAME, DATA_BASE
176 2e92b956 gaqhf
                                                FROM {0}.T_DB_DATA DB_DATA 
177
                                                INNER JOIN {0}.T_ROOTITEM ROOTITEM ON DB_DATA.SP_ROOTITEMID = ROOTITEM.SP_ID 
178
                                                WHERE ROOTITEM.NAME = '{1}'", dbInfo.Site, dbInfo.SelectedPlant);
179
                                using (SqlDataAdapter adapter = new SqlDataAdapter())
180
                                {
181
                                    DataTable dt = new DataTable();
182
                                    adapter.SelectCommand = cmd;
183
                                    adapter.Fill(dt);
184 04133d37 gaqhf
                                    foreach (DataColumn item in dt.Columns)
185
                                        item.ColumnName = item.ColumnName.ToUpper();
186
                                    
187 2e92b956 gaqhf
                                    foreach (DataRow row in dt.Rows)
188
                                    {
189
                                        string sType = row["SP_SCHEMA_TYPE"].ToString();
190
                                        switch (sType)
191
                                        {
192
                                            case "SPPIDDATA_DICTIONARY":
193
                                                dbInfo.PlantPIDDic = row["USERNAME"].ToString();
194 04133d37 gaqhf
                                                dbInfo.PlantPIDDic_DataBase = row["DATA_BASE"].ToString();
195 2e92b956 gaqhf
                                                break;
196
                                            case "DATA_DICTIONARY":
197
                                                dbInfo.PlantDic = row["USERNAME"].ToString();
198 04133d37 gaqhf
                                                dbInfo.PlantDic_DataBase = row["DATA_BASE"].ToString();
199 2e92b956 gaqhf
                                                break;
200
                                            case "SPAPLANT":
201
                                                dbInfo.Plant = row["USERNAME"].ToString();
202 04133d37 gaqhf
                                                dbInfo.Plant_DataBase = row["DATA_BASE"].ToString();
203 2e92b956 gaqhf
                                                break;
204
                                            case "SPPID":
205
                                                dbInfo.PlantPID = row["USERNAME"].ToString();
206 04133d37 gaqhf
                                                dbInfo.PlantPID_DataBase = row["DATA_BASE"].ToString();
207 2e92b956 gaqhf
                                                break;
208
                                            default:
209
                                                break;
210
                                        }
211
                                        bResult = true;
212
                                    }
213
                                }
214
215
                                cmd.CommandText = string.Format(CultureInfo.CurrentCulture, "SELECT PATH FROM {0}.T_ROOTITEM WHERE NAME = '{1}'", dbInfo.Site, dbInfo.SelectedPlant);
216
                                using (SqlDataReader reader = cmd.ExecuteReader())
217
                                {
218
                                    while (reader.Read())
219
                                    {
220
                                        dbInfo.PlantPath = reader["PATH"].ToString();
221
                                    }
222
                                }
223
                            }
224
                        }
225
                    }
226 23eb98bf gaqhf
                }
227
            }
228
            catch (Exception ex)
229
            {
230 289e9573 gaqhf
                System.Windows.Forms.MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
231 23eb98bf gaqhf
            }
232
233
            return bResult;
234
        }
235 fab4f207 gaqhf
        public static List<string> GetPlantList(SPPID_DBInfo dbInfo)
236 23eb98bf gaqhf
        {
237
            List<string> plantList = new List<string>();
238
            try
239
            {
240
                if (dbInfo.DBType == "ORACLE")
241
                {
242 57428b38 gaqhf
                    string connString = string.Format(oracleConnString, dbInfo.ServerIP, dbInfo.Port, dbInfo.Service);
243 23eb98bf gaqhf
                    connString = "Data Source=" + connString + ";User Id=" + dbInfo.DBUser + ";Password=" + dbInfo.DBPassword;
244
245
                    using (OracleConnection conn = new OracleConnection(connString))
246
                    {
247
                        conn.Open();
248
                        if (conn.State == System.Data.ConnectionState.Open)
249
                        {
250
                            using (OracleCommand cmd = new OracleCommand())
251
                            {
252
                                cmd.Connection = conn;
253
                                cmd.CommandText = string.Format(CultureInfo.CurrentCulture, "SELECT NAME, PATH FROM {0}.T_ROOTITEM", dbInfo.Site);
254
255
                                using (OracleDataReader reader = cmd.ExecuteReader())
256
                                {
257
                                    while (reader.Read())
258
                                    {
259
                                        plantList.Add(reader["NAME"].ToString());
260
                                    }
261
                                }
262
                            }
263
                        }
264
                    }
265
                }
266 2e92b956 gaqhf
                else if (dbInfo.DBType == "SQLSERVER")
267 23eb98bf gaqhf
                {
268 2e92b956 gaqhf
                    string connString = string.Format("server = {0}; uid = {1}; pwd = {2}; database = {3};", dbInfo.Service, dbInfo.DBUser, dbInfo.DBPassword, dbInfo.SQLSERVER_DBNAME);
269
                    using (SqlConnection conn = new SqlConnection(connString))
270
                    {
271
                        conn.Open();
272
                        if (conn.State == ConnectionState.Open)
273
                        {
274
                            using (SqlCommand cmd = new SqlCommand())
275
                            {
276
                                cmd.Connection = conn;
277
                                cmd.CommandText = string.Format(CultureInfo.CurrentCulture, "SELECT NAME, PATH FROM {0}.T_ROOTITEM", dbInfo.Site);
278 23eb98bf gaqhf
279 2e92b956 gaqhf
                                using (SqlDataReader reader = cmd.ExecuteReader())
280
                                {
281
                                    while (reader.Read())
282
                                    {
283
                                        plantList.Add(reader["NAME"].ToString());
284
                                    }
285
                                }
286
                            }
287
288
                        }
289
                    }
290 23eb98bf gaqhf
                }
291
            }
292
            catch (Exception ex)
293
            {
294 289e9573 gaqhf
                System.Windows.Forms.MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
295 23eb98bf gaqhf
            }
296
297
            return plantList;
298
        }
299 86c0a45e gaqhf
300
        public static DataTable GetSPPIDCodeList()
301
        {
302
            List<string> attributes = new List<string>();
303
            SPPID_DBInfo dbInfo = SPPID_DBInfo.GetInstance();
304
            DataTable dt = null;
305
            string connString = string.Empty;
306
            try
307
            {
308
                if (dbInfo.DBType == "ORACLE")
309
                {
310
                    connString = string.Format(oracleConnString, dbInfo.ServerIP, dbInfo.Port, dbInfo.Service);
311
                    connString = "Data Source=" + connString + ";User Id=" + dbInfo.DBUser + ";Password=" + dbInfo.DBPassword;
312
313
                    using (OracleConnection conn = new OracleConnection(connString))
314
                    {
315
                        conn.Open();
316
                        if (conn.State == System.Data.ConnectionState.Open)
317
                        {
318
                            string sQuery = string.Format(CultureInfo.CurrentCulture,
319
                                @"SELECT attribute_name, attribute_datatype FROM {0}.attributes WHERE attribute_codelisted = 'T'"
320
                                , dbInfo.PlantPIDDic);
321
                            using (OracleCommand cmd = new OracleCommand(sQuery, conn))
322
                            using (OracleDataAdapter adapter = new OracleDataAdapter())
323
                            {
324
                                adapter.SelectCommand = cmd;
325
                                dt = new DataTable();
326
                                adapter.Fill(dt);
327
                                foreach (DataColumn item in dt.Columns)
328
                                    item.ColumnName = item.ColumnName.ToUpper();
329
                            }
330
                        }
331
                    }
332
                }
333
                else if (dbInfo.DBType == "SQLSERVER")
334
                {
335
                    connString = string.Format("server = {0}; uid = {1}; pwd = {2}; database = {3};", dbInfo.Service, dbInfo.DBUser, dbInfo.DBPassword, dbInfo.PlantPIDDic_DataBase);
336
                    using (SqlConnection conn = new SqlConnection(connString))
337
                    {
338
                        conn.Open();
339
                        if (conn.State == ConnectionState.Open)
340
                        {
341
                            string sQuery = string.Format(CultureInfo.CurrentCulture,
342
                                @"SELECT attribute_name, attribute_datatype FROM {0}.attributes WHERE attribute_codelisted = 'T'"
343
                                , dbInfo.PlantPIDDic);
344
                            using (SqlCommand cmd = new SqlCommand(sQuery, conn))
345
                            using (SqlDataAdapter adapter = new SqlDataAdapter())
346
                            {
347
                                adapter.SelectCommand = cmd;
348
                                dt = new DataTable();
349
                                adapter.Fill(dt);
350
                                foreach (DataColumn item in dt.Columns)
351
                                    item.ColumnName = item.ColumnName.ToUpper();
352
                            }
353
                        }
354
                    }
355
                }
356
357
            }
358
            catch (Exception ex)
359
            {
360
                System.Windows.Forms.MessageBox.Show("Connection String : " + connString + "\r\n" + ex.Message + "\r\n" + ex.StackTrace);
361
            }
362
363
            return dt;
364
        }
365 e88aae98 gaqhf
        public static DataTable GetSPPIDAttribute()
366 23eb98bf gaqhf
        {
367
            List<string> attributes = new List<string>();
368 2e1e3c12 gaqhf
            SPPID_DBInfo dbInfo = SPPID_DBInfo.GetInstance();
369 e88aae98 gaqhf
            DataTable dt = null;
370 8e1eaa19 gaqhf
            string connString = string.Empty;
371 23eb98bf gaqhf
            try
372
            {
373
                if (dbInfo.DBType == "ORACLE")
374
                {
375 8e1eaa19 gaqhf
                    connString = string.Format(oracleConnString, dbInfo.ServerIP, dbInfo.Port, dbInfo.Service);
376 23eb98bf gaqhf
                    connString = "Data Source=" + connString + ";User Id=" + dbInfo.DBUser + ";Password=" + dbInfo.DBPassword;
377
378
                    using (OracleConnection conn = new OracleConnection(connString))
379
                    {
380
                        conn.Open();
381
                        if (conn.State == System.Data.ConnectionState.Open)
382
                        {
383 e88aae98 gaqhf
                            string sQuery = string.Format(CultureInfo.CurrentCulture,
384 e729d459 gaqhf
                                @"SELECT ITEM.description ItemType ,ATTR.displayname, ATTR.name FROM {0}.itemattributions ATTR 
385
                                LEFT OUTER JOIN {0}.item ITEM 
386
                                    ON ITEM.ID = ATTR.ITEMID 
387 e88aae98 gaqhf
                                ORDER BY ATTR.displayname ASC", dbInfo.PlantPIDDic);
388 e729d459 gaqhf
                            //string sQuery = string.Format(CultureInfo.CurrentCulture,
389
                            //    @"SELECT DISTINCT(ATTR.displayname), ATTR.name FROM {0}.itemattributions ATTR
390
                            //    ORDER BY ATTR.displayname ASC", dbInfo.PlantPIDDic);
391 e88aae98 gaqhf
                            using (OracleCommand cmd = new OracleCommand(sQuery, conn))
392
                            using (OracleDataAdapter adapter = new OracleDataAdapter())
393 23eb98bf gaqhf
                            {
394 e88aae98 gaqhf
                                adapter.SelectCommand = cmd;
395
                                dt = new DataTable();
396
                                adapter.Fill(dt);
397 2e92b956 gaqhf
                                foreach (DataColumn item in dt.Columns)
398
                                    item.ColumnName = item.ColumnName.ToUpper();
399 23eb98bf gaqhf
                            }
400
                        }
401
                    }
402
                }
403 2e92b956 gaqhf
                else if (dbInfo.DBType == "SQLSERVER")
404 23eb98bf gaqhf
                {
405 8e1eaa19 gaqhf
                    connString = string.Format("server = {0}; uid = {1}; pwd = {2}; database = {3};", dbInfo.Service, dbInfo.DBUser, dbInfo.DBPassword, dbInfo.PlantPIDDic_DataBase);
406 2e92b956 gaqhf
                    using (SqlConnection conn = new SqlConnection(connString))
407
                    {
408
                        conn.Open();
409
                        if (conn.State == ConnectionState.Open)
410
                        {
411
                            string sQuery = string.Format(CultureInfo.CurrentCulture,
412
                                @"SELECT ITEM.description ItemType ,ATTR.displayname, ATTR.name FROM {0}.itemattributions ATTR 
413
                                LEFT OUTER JOIN {0}.item ITEM 
414
                                    ON ITEM.ID = ATTR.ITEMID 
415
                                ORDER BY ATTR.displayname ASC", dbInfo.PlantPIDDic);
416
                            //string sQuery = string.Format(CultureInfo.CurrentCulture,
417
                            //    @"SELECT DISTINCT(ATTR.displayname), ATTR.name FROM {0}.itemattributions ATTR
418
                            //    ORDER BY ATTR.displayname ASC", dbInfo.PlantPIDDic);
419
                            using (SqlCommand cmd = new SqlCommand(sQuery, conn))
420
                            using (SqlDataAdapter adapter = new SqlDataAdapter())
421
                            {
422
                                adapter.SelectCommand = cmd;
423
                                dt = new DataTable();
424
                                adapter.Fill(dt);
425
                                foreach (DataColumn item in dt.Columns)
426
                                    item.ColumnName = item.ColumnName.ToUpper();
427
                            }
428
                        }
429
                    }
430 23eb98bf gaqhf
                }
431 2e92b956 gaqhf
432 23eb98bf gaqhf
            }
433
            catch (Exception ex)
434
            {
435 8e1eaa19 gaqhf
                System.Windows.Forms.MessageBox.Show("Connection String : " + connString + "\r\n" + ex.Message + "\r\n" + ex.StackTrace);
436 23eb98bf gaqhf
            }
437
438 e88aae98 gaqhf
            return dt;
439 23eb98bf gaqhf
        }
440 41e26743 gaqhf
        public static DataTable GetFluidSystemInfo(string operFluidCode)
441
        {
442
            List<string> attributes = new List<string>();
443
            SPPID_DBInfo dbInfo = SPPID_DBInfo.GetInstance();
444
            DataTable dt = null;
445
            try
446
            {
447
                if (dbInfo.DBType == "ORACLE")
448
                {
449 57428b38 gaqhf
                    string connString = string.Format(oracleConnString, dbInfo.ServerIP, dbInfo.Port, dbInfo.Service);
450 41e26743 gaqhf
                    connString = "Data Source=" + connString + ";User Id=" + dbInfo.DBUser + ";Password=" + dbInfo.DBPassword;
451
452
                    using (OracleConnection conn = new OracleConnection(connString))
453
                    {
454
                        conn.Open();
455
                        if (conn.State == System.Data.ConnectionState.Open)
456
                        {
457
                            string sQuery = string.Format(CultureInfo.CurrentCulture,
458
                                @"SELECT * FROM {0}.CODELISTS OUTATTR 
459
                                WHERE OUTATTR.codelist_index =  
460
                                    (SELECT attr.codelist_constraint FROM {0}.CODELISTS ATTR WHERE ATTR.CODELIST_TEXT = '{1}' AND ATTR.CODELIST_NUMBER = 19) AND OUTATTR.CODELIST_NUMBER = 20", dbInfo.PlantPIDDic, operFluidCode);
461
                            using (OracleCommand cmd = new OracleCommand(sQuery, conn))
462
                            using (OracleDataAdapter adapter = new OracleDataAdapter())
463
                            {
464
                                adapter.SelectCommand = cmd;
465
                                dt = new DataTable();
466
                                adapter.Fill(dt);
467 2e92b956 gaqhf
                                foreach (DataColumn item in dt.Columns)
468
                                    item.ColumnName = item.ColumnName.ToUpper();
469 41e26743 gaqhf
                            }
470
                        }
471
                    }
472
                }
473 2e92b956 gaqhf
                else if (dbInfo.DBType == "SQLSERVER")
474 41e26743 gaqhf
                {
475 04133d37 gaqhf
                    string connString = string.Format("server = {0}; uid = {1}; pwd = {2}; database = {3};", dbInfo.Service, dbInfo.DBUser, dbInfo.DBPassword, dbInfo.PlantPIDDic_DataBase);
476 2e92b956 gaqhf
                    using (SqlConnection conn = new SqlConnection(connString))
477
                    {
478
                        conn.Open();
479
                        if (conn.State == ConnectionState.Open)
480
                        {
481
                            string sQuery = string.Format(CultureInfo.CurrentCulture,
482
                                @"SELECT * FROM {0}.CODELISTS OUTATTR 
483
                                WHERE OUTATTR.codelist_index =  
484
                                    (SELECT attr.codelist_constraint FROM {0}.CODELISTS ATTR WHERE ATTR.CODELIST_TEXT = '{1}' AND ATTR.CODELIST_NUMBER = 19) AND OUTATTR.CODELIST_NUMBER = 20", dbInfo.PlantPIDDic, operFluidCode);
485
                            using (SqlCommand cmd = new SqlCommand(sQuery, conn))
486
                            using (SqlDataAdapter adapter = new SqlDataAdapter())
487
                            {
488
                                adapter.SelectCommand = cmd;
489
                                dt = new DataTable();
490
                                adapter.Fill(dt);
491
                                foreach (DataColumn item in dt.Columns)
492
                                    item.ColumnName = item.ColumnName.ToUpper();
493
                            }
494
                        }
495
                    }
496 41e26743 gaqhf
                }
497
            }
498
            catch (Exception ex)
499
            {
500
                System.Windows.Forms.MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
501
            }
502
503
            return dt;
504
        }
505 23eb98bf gaqhf
    }
506
}
클립보드 이미지 추가 (최대 크기: 500 MB)