프로젝트

일반

사용자정보

개정판 710a49f1

ID710a49f1328ca806f09012978a639d17da7faec3
상위 2ada3be8
하위 02a2c496

gaqhf 이(가) 약 3년 전에 추가함

dev issue #000 : add

Change-Id: I0324925039d261f2a9894a3eac033df4c13a3fc3

차이점 보기:

DTI_PID/ID2PSN/PSN.cs
45 45
        public DataTable Equipment { get; set; }
46 46
        public DataTable Nozzle { get; set; }
47 47

  
48

  
49 48
        public string Rule1 = "";
50 49
        public string Rule2 = "";
51 50
        public string Rule3 = "";
52 51
        public string Rule4 = "";
53 52
        public string Rule5 = "";
54 53

  
54
        int tieInPointIndex = 1;
55

  
55 56
        List<Document> Documents;
56 57
        List<Group> groups = new List<Group>();
57 58
        List<PSNItem> PSNItems = new List<PSNItem>();
......
230 231
            // Topology의 subtype을 update(bypass, Header, 등등) 
231 232
            UpdateSubType();
232 233
            // Update Error
233
            //UpdateErrorForPSN();
234
            UpdateErrorForPSN();
234 235
        }
235 236

  
236 237
        private void SetTopologyData()
237 238
        {
239
            // 13번 excel
240
            foreach (Group group in groups)
241
            {
242
                LineNumber prevLineNumber = null;
243
                for (int i = 0; i < group.Items.Count; i++)
244
                {
245
                    Item item = group.Items[i];
246
                    LineNumber lineNumber = item.Document.LineNumbers.Find(x => x.UID == item.Owner);
247
                    if (lineNumber == null)
248
                    {
249
                        if (prevLineNumber != null)
250
                        {
251
                            if (!prevLineNumber.IsCopy)
252
                            {
253
                                prevLineNumber = prevLineNumber.Copy();
254
                                item.Document.LineNumbers.Add(prevLineNumber);
255
                            }
256

  
257
                            item.Owner = prevLineNumber.UID;
258
                        }
259
                    }
260
                    else
261
                        prevLineNumber = lineNumber;
262
                }
263

  
264
                prevLineNumber = null;
265
                for (int i = group.Items.Count - 1; i > -1; i--)
266
                {
267
                    Item item = group.Items[i];
268
                    LineNumber lineNumber = item.Document.LineNumbers.Find(x => x.UID == item.Owner);
269
                    if (lineNumber == null)
270
                    {
271
                        if (prevLineNumber != null)
272
                        {
273
                            if (!prevLineNumber.IsCopy)
274
                            {
275
                                prevLineNumber = prevLineNumber.Copy();
276
                                item.Document.LineNumbers.Add(prevLineNumber);
277
                            }
278

  
279
                            item.Owner = prevLineNumber.UID;
280
                        }
281
                    }
282
                    else
283
                        prevLineNumber = lineNumber;
284
                }
285

  
286
                if (prevLineNumber == null)
287
                {
288
                    List<LineNumber> lineNumbers = group.Document.LineNumbers.FindAll(x => !x.IsCopy);
289
                    Random random = new Random();
290
                    int index = random.Next(lineNumbers.Count - 1);
291
                    
292
                    // Copy
293
                    LineNumber cLineNumber = lineNumbers[index].Copy();
294
                    group.Document.LineNumbers.Add(cLineNumber);
295

  
296
                    foreach (Item item in group.Items)
297
                        item.Owner = cLineNumber.UID;
298
                }
299
            }
300

  
301

  
238 302
            foreach (Document document in Documents)
239 303
            {
240 304
                foreach (Item item in document.Items)
......
304 368
                    if(toDocument != null)
305 369
                    { 
306 370
                        Group toGroup = toDocument.Groups.Find(x => x.Items.Find(y => y.UID == toOPCUID) != null);
371
                        DataRow[] toRows = opcDT.Select(string.Format("ToOPCUID = '{0}'", toGroup.Items.First().UID));
372
                        if (toRows.Length != 1)
373
                        {
374
                            throw new Exception("OPC error(multi connect)");
375
                        }
307 376
                        group.EndGroup = toGroup;
308 377
                        toGroup.StartGroup = group;
309 378
                    }
......
1305 1374
            foreach (DataRow dataRow in errorRows)
1306 1375
            {
1307 1376
                PSNItem PSNItem = PSNItems.Find(x=>x.PSN_OID() == dataRow["OID"].ToString());
1377
                bool change = false;
1378
                if (!PSNItem.EnableType(PSNItem.StartType))
1379
                {
1380
                    change = true;
1381
                    DataRow[] pathItemRows = PathItems.Select(string.Format("PipeSystemNetwork_OID = '{0}'", dataRow["OID"]));
1382
                    int insertIndex = PathItems.Rows.IndexOf(pathItemRows.First());
1383

  
1384
                    Item item = PSNItem.Groups.First().Items.First();
1385
                    foreach (DataRow loopRow in PipeSystemNetwork.Select(string.Format("OID = '{0}'", PSNItem.PSN_OID())))
1386
                        loopRow["FROM_DATA"] = string.Format("TIEINPOINT_{0:D5}V", tieInPointIndex);
1387
                    tieInPointIndex++;
1388

  
1389

  
1390
                    if (item.ItemType == ItemType.Line)
1391
                    {
1392
                        PathItems.Rows.InsertAt(createTerminatorRow(pathItemRows.First()), insertIndex);
1393
                    }
1394
                    else
1395
                    {
1396
                        PathItems.Rows.InsertAt(createLineRow(PathItems.Select(string.Format("PipeLine_OID = '{0}' AND ItemName = 'PipeRun' AND PipeSystemNetwork_OID = '{1}'", item.PSNPipeLineID, dataRow["OID"])).First()), insertIndex);
1397
                        PathItems.Rows.InsertAt(createTerminatorRow(pathItemRows.First()), insertIndex);
1398
                    }
1308 1399

  
1309
                if (PSNItem.StartType == PSNType.OPC)
1310 1400
                    PSNItem.StartType = PSNType.Equipment;
1401
                }
1402

  
1403

  
1404
                if (!PSNItem.EnableType(PSNItem.EndType))
1405
                {
1406
                    change = true;
1407
                    DataRow[] pathItemRows = PathItems.Select(string.Format("PipeSystemNetwork_OID = '{0}'", dataRow["OID"]));
1408
                    int insertIndex = PathItems.Rows.IndexOf(pathItemRows.Last());
1409

  
1410
                    Item item = PSNItem.Groups.Last().Items.Last();
1411
                    foreach (DataRow loopRow in PipeSystemNetwork.Select(string.Format("OID = '{0}'", PSNItem.PSN_OID())))
1412
                        loopRow["TO_DATA"] = string.Format("TIEINPOINT_{0:D5}V", tieInPointIndex);
1413
                    tieInPointIndex++;
1414

  
1415

  
1416
                    if (item.ItemType == ItemType.Line)
1417
                    {
1418
                        PathItems.Rows.InsertAt(createTerminatorRow(pathItemRows.Last()), insertIndex + 1);
1419
                    }
1420
                    else
1421
                    {
1422
                        PathItems.Rows.InsertAt(createTerminatorRow(pathItemRows.Last()), insertIndex + 1);
1423
                        PathItems.Rows.InsertAt(createLineRow(PathItems.Select(string.Format("PipeLine_OID = '{0}' AND ItemName = 'PipeRun' AND PipeSystemNetwork_OID = '{1}'", item.PSNPipeLineID, dataRow["OID"])).Last()), insertIndex + 1);
1424
                    }
1311 1425

  
1312
                if (PSNItem.EndType == PSNType.OPC)
1313 1426
                    PSNItem.EndType = PSNType.Equipment;
1427
                }
1314 1428

  
1315 1429
                dataRow["Type"] = PSNItem.GetPSNType();
1430
                if (change)
1431
                {
1432
                    int rowIndex = 0;
1433
                    foreach (DataRow row in PathItems.Rows)
1434
                    {
1435
                        if (row["PipeSystemNetwork_OID"].ToString() != dataRow["OID"].ToString())
1436
                            continue;
1437
                        string sequenceData = row["SequenceData_OID"].ToString();
1438
                        string[] split = sequenceData.Split(new char[] { '_' });
1439

  
1440
                        StringBuilder sb = new StringBuilder();
1441
                        for (int i = 0; i < split.Length - 1; i++)
1442
                            sb.Append(split[i] + "_");
1443
                        sb.Append(rowIndex++);
1444
                        row["SequenceData_OID"] = sb.ToString(); 
1445
                    }
1446
                }
1447

  
1448
                DataRow createTerminatorRow(DataRow itemRow)
1449
                {
1450
                    DataRow newRow = PathItems.NewRow();
1451
                    newRow["OID"] = Guid.NewGuid().ToString();
1452
                    newRow["SequenceData_OID"] = itemRow["SequenceData_OID"];
1453
                    newRow["TopologySet_OID"] = itemRow["TopologySet_OID"];
1454
                    newRow["BranchTopologySet_OID"] = itemRow["BranchTopologySet_OID"];
1455
                    newRow["PipeLine_OID"] = itemRow["PipeLine_OID"];
1456
                    newRow["ITEMNAME"] = "End of line terminator";
1457
                    newRow["ITEMTAG"] = itemRow["ITEMTAG"];
1458
                    newRow["Class"] = "End of line terminator";
1459
                    newRow["SubClass"] = "End of line terminator";
1460
                    newRow["TYPE"] = "End of line terminator";
1461
                    newRow["PIDNAME"] = itemRow["PIDNAME"];
1462
                    newRow["NPD"] = itemRow["NPD"];
1463
                    newRow["PipeSystemNetwork_OID"] = itemRow["PipeSystemNetwork_OID"];
1464
                    newRow["ViewPipeSystemNetwork_OID"] = itemRow["ViewPipeSystemNetwork_OID"];
1465
                    newRow["PipeRun_OID"] = itemRow["PipeRun_OID"];
1466

  
1467
                    return newRow;
1468
                }
1469

  
1470
                DataRow createLineRow(DataRow itemRow)
1471
                {
1472
                    DataRow newRow = PathItems.NewRow();
1473
                    newRow["OID"] = Guid.NewGuid().ToString();
1474
                    newRow["SequenceData_OID"] = itemRow["SequenceData_OID"];
1475
                    newRow["TopologySet_OID"] = itemRow["TopologySet_OID"];
1476
                    newRow["BranchTopologySet_OID"] = itemRow["BranchTopologySet_OID"];
1477
                    newRow["PipeLine_OID"] = itemRow["PipeLine_OID"];
1478
                    newRow["ITEMNAME"] = itemRow["ITEMNAME"];
1479
                    newRow["ITEMTAG"] = itemRow["ITEMTAG"];
1480
                    newRow["Class"] = itemRow["Class"];
1481
                    newRow["SubClass"] = itemRow["SubClass"];
1482
                    newRow["TYPE"] = itemRow["TYPE"];
1483
                    newRow["PIDNAME"] = itemRow["PIDNAME"];
1484
                    newRow["NPD"] = itemRow["NPD"];
1485
                    newRow["PipeSystemNetwork_OID"] = itemRow["PipeSystemNetwork_OID"];
1486
                    newRow["ViewPipeSystemNetwork_OID"] = itemRow["ViewPipeSystemNetwork_OID"];
1487
                    newRow["PipeRun_OID"] = itemRow["PipeRun_OID"];
1488

  
1489
                    return newRow;
1490
                }
1316 1491
            }            
1317 1492
        }
1318 1493
    }
......
1380 1555

  
1381 1556
            
1382 1557
        }
1383
        private bool EnableType(PSNType type)
1558
        public bool EnableType(PSNType type)
1384 1559
        {
1385 1560
            bool result = false;
1386 1561

  

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)