프로젝트

일반

사용자정보

개정판 45529c16

ID45529c160dc7400fefdadc6ad773d92ec8dd491c
상위 d36e2fe0
하위 502d1d50

이지연이(가) 3년 이상 전에 추가함

issue #000: Validity 수정 0, 1, -1 적용

Change-Id: Id2e85bb48c220b2f5def76b6bc28e655634735a9

차이점 보기:

DTI_PID/ID2PSN/DB.cs
1 1
using System;
2 2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.Threading.Tasks;
6
using System.Data.SQLite;
7 3
using System.Data;
8
using System.Globalization;
9
using System.Text.RegularExpressions;
10 4
using System.Data.Common;
11
using System.Data.SqlClient;
5
using System.Data.SQLite;
6
using System.Linq;
7
using System.Text.RegularExpressions;
12 8

  
13 9
namespace ID2PSN
14 10
{
15
    public class DB 
11
    public class DB
16 12
    {
17 13
        const string PSN_TOPOLOGY_RULE = "T_PSN_TOPOLOGY_RULE";
18 14
        const string PSN_HEADER_SETTING = "T_PSN_HEADER_SETTING";
......
25 21
        const string PSN_EQUIPMENT = "SPPIDEquipment";
26 22
        const string PSN_NOZZLE = "SPPIDNozzle";
27 23
        const string PSN_FLUIDCODE = "SPPIDFluidCode";
28
        const string PSN_PIPINGMATLCLASS = "SPPIDPipingMatClass";       
24
        const string PSN_PIPINGMATLCLASS = "SPPIDPipingMatClass";
29 25
        const string PSN_TOPOLOGYSET = "SPPIDTopologySet";
30 26

  
31 27
        /// <summary>
......
226 222
                    Log.Write(ex.Message + "\r\n" + ex.StackTrace);
227 223
                }
228 224
            }
229
            
225

  
230 226
            return result;
231 227
        }
232 228

  
......
310 306

  
311 307
            return dt;
312 308
        }
313
        
309

  
314 310
        public static DataTable SelectFluidCode()
315 311
        {
316 312
            DataTable dt = null;
......
321 317
                try
322 318
                {
323 319
                    var query = "SELECT * FROM FluidCode";
324
                    using(var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query)))
320
                    using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query)))
325 321
                    {
326 322
                        dt = ds.Tables[0].Copy();
327 323
                    }
......
459 455
            }
460 456

  
461 457
            return dt;
462
        }              
458
        }
463 459

  
464 460
        public static double[] GetDrawingSize()
465 461
        {
......
478 474
                            string value = ds.Tables[0].Rows[0][0].ToString();
479 475
                            string[] split = value.Split(new char[] { ',' });
480 476
                            result = new double[] {
481
                                Convert.ToDouble(Regex.Replace(split[0], @"[^0-9]", "")),
482
                                Convert.ToDouble(Regex.Replace(split[1], @"[^0-9]", "")),
483
                                Convert.ToDouble(Regex.Replace(split[2], @"[^0-9]", "")),
484
                                Convert.ToDouble(Regex.Replace(split[3], @"[^0-9]", ""))
477
                                Convert.ToDouble(Regex.Replace(split[0], @"[^0-9]", string.Empty)),
478
                                Convert.ToDouble(Regex.Replace(split[1], @"[^0-9]", string.Empty)),
479
                                Convert.ToDouble(Regex.Replace(split[2], @"[^0-9]", string.Empty)),
480
                                Convert.ToDouble(Regex.Replace(split[3], @"[^0-9]", string.Empty))
485 481
                                };
486 482
                            result = new double[] {
487 483
                                Math.Min(result[0], result[2]),
......
789 785

  
790 786
            return dt;
791 787
        }
792
               
788

  
793 789
        private static void AddWithValue(DbCommand cmd, string PropName, object Value)
794 790
        {
795 791
            var param = cmd.CreateParameter();
......
917 913
                                AddWithValue(cmd, "@PSNRevisionNumber", row["PSNRevisionNumber"].ToString());
918 914
                                AddWithValue(cmd, "@PBS", row["PBS"].ToString());
919 915
                                AddWithValue(cmd, "@PIDDrawings", row["PIDDrawings"].ToString());
920
                                AddWithValue(cmd, "@Validity", row["Validity"].ToString());
916
                                int Validity = 0;
917
                                if (row["Validity"].ToString() == "OK")
918
                                    Validity = 0;
919
                                else if (row["Validity"].ToString() == "InValid")
920
                                    Validity = 1;
921
                                else if (row["Validity"].ToString() == "Error")
922
                                    Validity = -1;
923
                                AddWithValue(cmd, "@Validity", Validity);
921 924
                                AddWithValue(cmd, "@Status", row["Status"].ToString());
922 925
                                connection.ExecuteNonQuery(cmd, txn);
923 926
                            }
......
1155 1158
                    var query = $"SELECT * FROM {PSN_PIPESYSTEMNETWORK} WHERE PSNRevisionNumber = '{string.Format("V{0:D4}", GetRevision())}'";
1156 1159
                    using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query)))
1157 1160
                    {
1158
                        result.PipeSystemNetwork = ds.Tables[0].Copy();
1161
                        result.PipeSystemNetwork = ds.Tables[0].Clone();
1162
                        result.PipeSystemNetwork.Columns["Validity"].DataType = typeof(string);
1163

  
1164
                        foreach (DataRow row in ds.Tables[0].Rows)
1165
                        {
1166
                            DataRow newRow = result.PipeSystemNetwork.NewRow();
1167
                            newRow["OID"] = row["OID"].ToString();
1168
                            newRow["Type"] = row["Type"].ToString();
1169
                            newRow["OrderNumber"] = row["OrderNumber"].ToString();
1170
                            newRow["Pipeline_OID"] = row["Pipeline_OID"].ToString();
1171
                            newRow["FROM_DATA"] = row["FROM_DATA"].ToString();
1172
                            newRow["TO_DATA"] = row["TO_DATA"].ToString();
1173
                            newRow["TopologySet_OID_Key"] = row["TopologySet_OID_Key"].ToString();
1174
                            newRow["PSNRevisionNumber"] = row["PSNRevisionNumber"].ToString();
1175
                            newRow["PBS"] = row["PBS"].ToString();
1176
                            newRow["PIDDrawings"] = row["PIDDrawings"].ToString();
1177
                            string Validity = string.Empty;
1178

  
1179
                            if (Convert.ToInt32(row["Validity"].ToString()) == 0)
1180
                                Validity = string.Empty;//"OK";
1181
                            else if (Convert.ToInt32(row["Validity"].ToString()) == 1)
1182
                                Validity = "InValid";
1183
                            else if (Convert.ToInt32(row["Validity"].ToString()) == -1)
1184
                                Validity = "Error";
1185

  
1186
                            newRow["Validity"] = Validity;
1187

  
1188
                            newRow["Status"] = row["Status"].ToString();
1189
                            result.PipeSystemNetwork.Rows.Add(newRow);
1190
                        }
1159 1191
                    }
1160 1192

  
1161 1193
                    query = $"SELECT * FROM {PSN_EQUIPMENT}";
......
1287 1319
                    var query = $"SELECT * FROM {PSN_PIPESYSTEMNETWORK} WHERE PSNRevisionNumber = '{string.Format("V{0:D4}", GetRevision())}'";
1288 1320
                    using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query)))
1289 1321
                    {
1290
                        dt = ds.Tables[0].Copy();
1322
                        dt = ds.Tables[0].Clone();
1323
                        dt.Columns["Validity"].DataType = typeof(string);
1324
                        foreach (DataRow row in ds.Tables[0].Rows)
1325
                        {
1326
                            DataRow newRow = dt.NewRow();
1327
                            newRow["OID"] = row["OID"].ToString();
1328
                            newRow["Type"] = row["Type"].ToString();
1329
                            newRow["OrderNumber"] = row["OrderNumber"].ToString();
1330
                            newRow["Pipeline_OID"] = row["Pipeline_OID"].ToString();
1331
                            newRow["FROM_DATA"] = row["FROM_DATA"].ToString();
1332
                            newRow["TO_DATA"] = row["TO_DATA"].ToString();
1333
                            newRow["TopologySet_OID_Key"] = row["TopologySet_OID_Key"].ToString();
1334
                            newRow["PSNRevisionNumber"] = row["PSNRevisionNumber"].ToString();
1335
                            newRow["PBS"] = row["PBS"].ToString();
1336
                            newRow["PIDDrawings"] = row["PIDDrawings"].ToString();
1337
                            string Validity = string.Empty;
1338

  
1339
                            if (Convert.ToInt32(row["Validity"].ToString()) == 0)
1340
                                Validity = string.Empty;//"OK";
1341
                            else if (Convert.ToInt32(row["Validity"].ToString()) == 1)
1342
                                Validity = "InValid";
1343
                            else if (Convert.ToInt32(row["Validity"].ToString()) == -1)
1344
                                Validity = "Error";
1345

  
1346
                            newRow["Validity"] = Validity;
1347

  
1348
                            newRow["Status"] = row["Status"].ToString();
1349
                            dt.Rows.Add(newRow);
1350
                        }
1291 1351
                    }
1292 1352
                }
1293 1353
                catch (Exception ex)

내보내기 Unified diff