프로젝트

일반

사용자정보

개정판 5c248ee3

ID5c248ee33907d706392e8e86d7a57c124c8e7c13
상위 4c76a67a
하위 bcfe3202, 0491c447, 678760c6

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

dev issue #000 : dev

Change-Id: Ic71cc75fde98ca5133984da93be5f0e5c3acb030

차이점 보기:

DTI_PID/ID2PSN/DB.cs
23 23
        const string PSN_NOZZLE = "SPPIDNozzle";
24 24
        const string PSN_FLUIDCODE = "SPPIDFluidCode";
25 25
        const string PSN_PIPINGMATLCLASS = "SPPIDPipingMatClass";
26
        const string PSN_VIEW = "T_PSN_VIEW";
26 27
        public static bool ConnTestAndCreateTable()
27 28
        {
28 29
            bool result = false;
......
88 89
                                    cmd.CommandText = string.Format("CREATE TABLE {0} (UID TEXT, Priority TEXT, Code TEXT, Description TEXT, Condition TEXT, Remarks TEXT, GroundLevel TEXT)", PSN_PIPINGMATLCLASS);
89 90
                                    cmd.ExecuteNonQuery();
90 91
                                }
92
                                if (dt.Select(string.Format("NAME = '{0}'", PSN_VIEW)).Length == 0)
93
                                {
94
                                    cmd.CommandText = string.Format("CREATE TABLE {0} (OID TEXT)", PSN_VIEW);
95
                                    cmd.ExecuteNonQuery();
96
                                }
91 97
                            }
92 98
                        }
93 99
                        result = true;
......
469 475
            return dt;
470 476
        }
471 477

  
472
        public static bool SavePSNFluidCode(DataTable dt)
478
        public static bool SavePSNData(PSN item)
473 479
        {
474 480
            ID2Info id2Info = ID2Info.GetInstance();
475 481

  
......
486 492
                        {
487 493
                            using (SQLiteCommand cmd = connection.CreateCommand())
488 494
                            {
489
                                cmd.CommandText = string.Format("DELETE FROM {0}", PSN_FLUIDCODE);
495
                                // Path Items
496
                                cmd.CommandText = string.Format("DELETE FROM {0}", PSN_PATHITEMS);
490 497
                                cmd.ExecuteNonQuery();
498
                                foreach (DataRow row in item.PathItems.Rows)
499
                                {
500
                                    cmd.CommandText = string.Format("INSERT INTO {0} VALUES (@OID, @SequenceData_OID, @TopologySet_OID, @BranchTopologySet_OID, @PipeLine_OID, @ITEMNAME, @ITEMTAG, @TYPE, @PIDNAME, @NPD, @PipeSystemNetwork_OID, @PipeRun_OID)", PSN_PATHITEMS);
501
                                    cmd.Parameters.Clear();
502
                                    cmd.Parameters.AddWithValue("@OID", row["OID"].ToString());
503
                                    cmd.Parameters.AddWithValue("@SequenceData_OID", row["SequenceData_OID"].ToString());
504
                                    cmd.Parameters.AddWithValue("@TopologySet_OID", row["TopologySet_OID"].ToString());
505
                                    cmd.Parameters.AddWithValue("@BranchTopologySet_OID", row["BranchTopologySet_OID"].ToString());
506
                                    cmd.Parameters.AddWithValue("@PipeLine_OID", row["PipeLine_OID"].ToString());
507
                                    cmd.Parameters.AddWithValue("@ITEMNAME", row["ITEMNAME"].ToString());
508
                                    cmd.Parameters.AddWithValue("@ITEMTAG", row["ITEMTAG"].ToString());
509
                                    cmd.Parameters.AddWithValue("@TYPE", row["TYPE"].ToString());
510
                                    cmd.Parameters.AddWithValue("@PIDNAME", row["PIDNAME"].ToString());
511
                                    cmd.Parameters.AddWithValue("@NPD", row["NPD"].ToString());
512
                                    cmd.Parameters.AddWithValue("@PipeSystemNetwork_OID", row["PipeSystemNetwork_OID"].ToString());
513
                                    cmd.Parameters.AddWithValue("@PipeRun_OID", row["PipeRun_OID"].ToString());
514
                                    cmd.ExecuteNonQuery();
515
                                }
491 516

  
492
                                foreach (DataRow row in dt.Rows)
517
                                // Sequence
518
                                cmd.CommandText = string.Format("DELETE FROM {0}", PSN_SEQUENCEDATA);
519
                                cmd.ExecuteNonQuery();
520
                                foreach (DataRow row in item.SequenceData.Rows)
493 521
                                {
494
                                    cmd.CommandText = string.Format("INSERT INTO {0} VALUES (@UID, @Code, @Description, @Condition, @Remarks, @GroundLevel)", PSN_FLUIDCODE);
522
                                    cmd.CommandText = string.Format("INSERT INTO {0} VALUES (@OID, @SERIALNUMBER, @PathItem_OID, @TopologySet_OID_Key)", PSN_SEQUENCEDATA);
495 523
                                    cmd.Parameters.Clear();
496
                                    cmd.Parameters.AddWithValue("@UID", row["UID"].ToString());
497
                                    cmd.Parameters.AddWithValue("@Code", row["Code"].ToString());
498
                                    cmd.Parameters.AddWithValue("@Description", row["Description"].ToString());
499
                                    cmd.Parameters.AddWithValue("@Condition", row["Condition"].ToString());
500
                                    cmd.Parameters.AddWithValue("@Remarks", row["Remarks"].ToString());
501
                                    cmd.Parameters.AddWithValue("@GroundLevel", row["GroundLevel"].ToString());
524
                                    cmd.Parameters.AddWithValue("@OID", row["OID"].ToString());
525
                                    cmd.Parameters.AddWithValue("@SERIALNUMBER", row["SERIALNUMBER"].ToString());
526
                                    cmd.Parameters.AddWithValue("@PathItem_OID", row["PathItem_OID"].ToString());
527
                                    cmd.Parameters.AddWithValue("@TopologySet_OID_Key", row["TopologySet_OID_Key"].ToString());
528
                                    cmd.ExecuteNonQuery();
529
                                }
530

  
531
                                // Nozzle
532
                                cmd.CommandText = string.Format("DELETE FROM {0}", PSN_NOZZLE);
533
                                cmd.ExecuteNonQuery();
534
                                foreach (DataRow row in item.Nozzle.Rows)
535
                                {
536
                                    cmd.CommandText = string.Format("INSERT INTO {0} VALUES (@OID, @ITEMTAG, @XCOORDS, @YCOORDS, @Equipment_OID, @FLUID, @NPD, @ROTATION, @FlowDirection)", PSN_NOZZLE);
537
                                    cmd.Parameters.Clear();
538
                                    cmd.Parameters.AddWithValue("@OID", row["OID"].ToString());
539
                                    cmd.Parameters.AddWithValue("@ITEMTAG", row["ITEMTAG"].ToString());
540
                                    cmd.Parameters.AddWithValue("@XCOORDS", row["XCOORDS"].ToString());
541
                                    cmd.Parameters.AddWithValue("@YCOORDS", row["YCOORDS"].ToString());
542
                                    cmd.Parameters.AddWithValue("@Equipment_OID", row["Equipment_OID"].ToString());
543
                                    cmd.Parameters.AddWithValue("@FLUID", row["FLUID"].ToString());
544
                                    cmd.Parameters.AddWithValue("@NPD", row["NPD"].ToString());
545
                                    cmd.Parameters.AddWithValue("@ROTATION", row["ROTATION"].ToString());
546
                                    cmd.Parameters.AddWithValue("@FlowDirection", row["FlowDirection"].ToString());
547
                                    cmd.ExecuteNonQuery();
548
                                }
549

  
550
                                //Equipment
551
                                cmd.CommandText = string.Format("DELETE FROM {0}", PSN_EQUIPMENT);
552
                                cmd.ExecuteNonQuery();
553
                                foreach (DataRow row in item.Equipment.Rows)
554
                                {
555
                                    cmd.CommandText = string.Format("INSERT INTO {0} VALUES (@OID, @ITEMTAG, @XCOORDS, @YCOORDS)", PSN_EQUIPMENT);
556
                                    cmd.Parameters.Clear();
557
                                    cmd.Parameters.AddWithValue("@OID", row["OID"].ToString());
558
                                    cmd.Parameters.AddWithValue("@ITEMTAG", row["ITEMTAG"].ToString());
559
                                    cmd.Parameters.AddWithValue("@XCOORDS", row["XCOORDS"].ToString());
560
                                    cmd.Parameters.AddWithValue("@YCOORDS", row["YCOORDS"].ToString());
561
                                    cmd.ExecuteNonQuery();
562
                                }
563

  
564
                                // PSN
565
                                cmd.CommandText = string.Format("DELETE FROM {0} WHERE PSNRevisionNumber = '{1}'", PSN_PIPESYSTEMNETWORK, string.Format("{0:D3}", item.Revision));
566
                                cmd.ExecuteNonQuery();
567
                                foreach (DataRow row in item.PipeSystemNetwork.Rows)
568
                                {
569
                                    cmd.CommandText = string.Format("INSERT INTO {0} VALUES (@OID, @Type, @OrderNumber, @Pipeline_OID, @FROM_DATA, @TO_DATA, @TopologySet_OID_Key, @PSNRevisionNumber, @PathOID, @PBS, @PIDDrawings)", PSN_PIPESYSTEMNETWORK);
570
                                    cmd.Parameters.Clear();
571
                                    cmd.Parameters.AddWithValue("@OID", row["OID"].ToString());
572
                                    cmd.Parameters.AddWithValue("@Type", row["Type"].ToString());
573
                                    cmd.Parameters.AddWithValue("@OrderNumber", row["OrderNumber"].ToString());
574
                                    cmd.Parameters.AddWithValue("@Pipeline_OID", row["Pipeline_OID"].ToString());
575
                                    cmd.Parameters.AddWithValue("@FROM_DATA", row["FROM_DATA"].ToString());
576
                                    cmd.Parameters.AddWithValue("@TO_DATA", row["TO_DATA"].ToString());
577
                                    cmd.Parameters.AddWithValue("@TopologySet_OID_Key", row["TopologySet_OID_Key"].ToString());
578
                                    cmd.Parameters.AddWithValue("@PSNRevisionNumber", row["PSNRevisionNumber"].ToString());
579
                                    cmd.Parameters.AddWithValue("@PathOID", row["PathOID"].ToString());
580
                                    cmd.Parameters.AddWithValue("@PBS", row["PBS"].ToString());
581
                                    cmd.Parameters.AddWithValue("@PIDDrawings", row["PIDDrawings"].ToString());
502 582
                                    cmd.ExecuteNonQuery();
503 583
                                }
584

  
504 585
                            }
505 586
                            transaction.Commit();
506 587
                            connection.Close();
......
530 611
            return result;
531 612
        }
532 613

  
533
        public static bool SavePSNPMC(DataTable dt)
614
        public static bool SavePSNFluidCode(DataTable dt)
534 615
        {
535 616
            ID2Info id2Info = ID2Info.GetInstance();
536 617

  
......
547 628
                        {
548 629
                            using (SQLiteCommand cmd = connection.CreateCommand())
549 630
                            {
550
                                cmd.CommandText = string.Format("DELETE FROM {0}", PSN_PIPINGMATLCLASS);
631
                                cmd.CommandText = string.Format("DELETE FROM {0}", PSN_FLUIDCODE);
551 632
                                cmd.ExecuteNonQuery();
552 633

  
553 634
                                foreach (DataRow row in dt.Rows)
554 635
                                {
555
                                    cmd.CommandText = string.Format("INSERT INTO {0} VALUES (@UID, @Priority, @Code, @Description, @Condition, @Remarks, @GroundLevel)", PSN_PIPINGMATLCLASS);
636
                                    cmd.CommandText = string.Format("INSERT INTO {0} VALUES (@UID, @Code, @Description, @Condition, @Remarks, @GroundLevel)", PSN_FLUIDCODE);
556 637
                                    cmd.Parameters.Clear();
557 638
                                    cmd.Parameters.AddWithValue("@UID", row["UID"].ToString());
558
                                    cmd.Parameters.AddWithValue("@Priority", row["Priority"].ToString());
559 639
                                    cmd.Parameters.AddWithValue("@Code", row["Code"].ToString());
560 640
                                    cmd.Parameters.AddWithValue("@Description", row["Description"].ToString());
561 641
                                    cmd.Parameters.AddWithValue("@Condition", row["Condition"].ToString());
......
592 672
            return result;
593 673
        }
594 674

  
595
        public static bool SavePathItems(DataTable dt)
675
        public static bool SavePSNPMC(DataTable dt)
596 676
        {
597 677
            ID2Info id2Info = ID2Info.GetInstance();
598 678

  
......
609 689
                        {
610 690
                            using (SQLiteCommand cmd = connection.CreateCommand())
611 691
                            {
612
                                cmd.CommandText = string.Format("DELETE FROM {0}", PSN_PATHITEMS);
692
                                cmd.CommandText = string.Format("DELETE FROM {0}", PSN_PIPINGMATLCLASS);
613 693
                                cmd.ExecuteNonQuery();
614 694

  
615 695
                                foreach (DataRow row in dt.Rows)
616 696
                                {
617
                                    cmd.CommandText = string.Format("INSERT INTO {0} VALUES (@OID, @SequenceData_OID, @TopologySet_OID, @BranchTopologySet_OID, @PipeLine_OID, @ITEMNAME, @ITEMTAG, @TYPE, @PIDNAME, @NPD, @PipeSystemNetwork_OID, @PipeRun_OID)", PSN_PATHITEMS);
697
                                    cmd.CommandText = string.Format("INSERT INTO {0} VALUES (@UID, @Priority, @Code, @Description, @Condition, @Remarks, @GroundLevel)", PSN_PIPINGMATLCLASS);
618 698
                                    cmd.Parameters.Clear();
619
                                    cmd.Parameters.AddWithValue("@OID", row["OID"].ToString());
620
                                    cmd.Parameters.AddWithValue("@SequenceData_OID", row["SequenceData_OID"].ToString());
621
                                    cmd.Parameters.AddWithValue("@TopologySet_OID", row["TopologySet_OID"].ToString());
622
                                    cmd.Parameters.AddWithValue("@BranchTopologySet_OID", row["BranchTopologySet_OID"].ToString());
623
                                    cmd.Parameters.AddWithValue("@PipeLine_OID", row["PipeLine_OID"].ToString());
624
                                    cmd.Parameters.AddWithValue("@ITEMNAME", row["ITEMNAME"].ToString());
625
                                    cmd.Parameters.AddWithValue("@ITEMTAG", row["ITEMTAG"].ToString());
626
                                    cmd.Parameters.AddWithValue("@TYPE", row["TYPE"].ToString());
627
                                    cmd.Parameters.AddWithValue("@PIDNAME", row["PIDNAME"].ToString());
628
                                    cmd.Parameters.AddWithValue("@NPD", row["NPD"].ToString());
629
                                    cmd.Parameters.AddWithValue("@PipeSystemNetwork_OID", row["PipeSystemNetwork_OID"].ToString());
630
                                    cmd.Parameters.AddWithValue("@PipeRun_OID", row["PipeRun_OID"].ToString());
699
                                    cmd.Parameters.AddWithValue("@UID", row["UID"].ToString());
700
                                    cmd.Parameters.AddWithValue("@Priority", row["Priority"].ToString());
701
                                    cmd.Parameters.AddWithValue("@Code", row["Code"].ToString());
702
                                    cmd.Parameters.AddWithValue("@Description", row["Description"].ToString());
703
                                    cmd.Parameters.AddWithValue("@Condition", row["Condition"].ToString());
704
                                    cmd.Parameters.AddWithValue("@Remarks", row["Remarks"].ToString());
705
                                    cmd.Parameters.AddWithValue("@GroundLevel", row["GroundLevel"].ToString());
631 706
                                    cmd.ExecuteNonQuery();
632 707
                                }
633 708
                            }
......
659 734
            return result;
660 735
        }
661 736

  
662
        public static bool SaveSequenceData(DataTable dt)
737
        public static bool SaveView(List<string> values)
663 738
        {
664 739
            ID2Info id2Info = ID2Info.GetInstance();
665 740

  
......
676 751
                        {
677 752
                            using (SQLiteCommand cmd = connection.CreateCommand())
678 753
                            {
679
                                cmd.CommandText = string.Format("DELETE FROM {0}", PSN_SEQUENCEDATA);
754
                                cmd.CommandText = string.Format("DELETE FROM {0}", PSN_VIEW);
680 755
                                cmd.ExecuteNonQuery();
681 756

  
682
                                foreach (DataRow row in dt.Rows)
757
                                foreach (string value in values)
683 758
                                {
684
                                    cmd.CommandText = string.Format("INSERT INTO {0} VALUES (@OID, @SERIALNUMBER, @PathItem_OID, @TopologySet_OID_Key)", PSN_SEQUENCEDATA);
759
                                    cmd.CommandText = string.Format("INSERT INTO {0} VALUES (@OID)", PSN_VIEW);
685 760
                                    cmd.Parameters.Clear();
686
                                    cmd.Parameters.AddWithValue("@OID", row["OID"].ToString());
687
                                    cmd.Parameters.AddWithValue("@SERIALNUMBER", row["SERIALNUMBER"].ToString());
688
                                    cmd.Parameters.AddWithValue("@PathItem_OID", row["PathItem_OID"].ToString());
689
                                    cmd.Parameters.AddWithValue("@TopologySet_OID_Key", row["TopologySet_OID_Key"].ToString());
761
                                    cmd.Parameters.AddWithValue("@OID", value);
690 762
                                    cmd.ExecuteNonQuery();
691 763
                                }
692 764
                            }
......
717 789

  
718 790
            return result;
719 791
        }
720

  
721
        public static bool SavePipeSystemNetwork(DataTable dt, string revision)
792
        public static bool DeleteView()
722 793
        {
723 794
            ID2Info id2Info = ID2Info.GetInstance();
724 795

  
......
735 806
                        {
736 807
                            using (SQLiteCommand cmd = connection.CreateCommand())
737 808
                            {
738
                                cmd.CommandText = string.Format("DELETE FROM {0} WHERE PSNRevisionNumber = '{1}'", PSN_PIPESYSTEMNETWORK, revision);
809
                                cmd.CommandText = string.Format("DELETE FROM {0}", PSN_VIEW);
739 810
                                cmd.ExecuteNonQuery();
740

  
741
                                foreach (DataRow row in dt.Rows)
742
                                {
743
                                    cmd.CommandText = string.Format("INSERT INTO {0} VALUES (@OID, @Type, @OrderNumber, @Pipeline_OID, @FROM_DATA, @TO_DATA, @TopologySet_OID_Key, @PSNRevisionNumber, @PathOID, @PBS, @PIDDrawings)", PSN_PIPESYSTEMNETWORK);
744
                                    cmd.Parameters.Clear();
745
                                    cmd.Parameters.AddWithValue("@OID", row["OID"].ToString());
746
                                    cmd.Parameters.AddWithValue("@Type", row["Type"].ToString());
747
                                    cmd.Parameters.AddWithValue("@OrderNumber", row["OrderNumber"].ToString());
748
                                    cmd.Parameters.AddWithValue("@Pipeline_OID", row["Pipeline_OID"].ToString());
749
                                    cmd.Parameters.AddWithValue("@FROM_DATA", row["FROM_DATA"].ToString());
750
                                    cmd.Parameters.AddWithValue("@TO_DATA", row["TO_DATA"].ToString());
751
                                    cmd.Parameters.AddWithValue("@TopologySet_OID_Key", row["TopologySet_OID_Key"].ToString());
752
                                    cmd.Parameters.AddWithValue("@PSNRevisionNumber", row["PSNRevisionNumber"].ToString());
753
                                    cmd.Parameters.AddWithValue("@PathOID", row["PathOID"].ToString());
754
                                    cmd.Parameters.AddWithValue("@PBS", row["PBS"].ToString());
755
                                    cmd.Parameters.AddWithValue("@PIDDrawings", row["PIDDrawings"].ToString());
756
                                    cmd.ExecuteNonQuery();
757
                                }
758 811
                            }
759 812
                            transaction.Commit();
760 813
                            connection.Close();
......
784 837
            return result;
785 838
        }
786 839

  
787
        public static bool SaveEquipment(DataTable dt)
840
        public static PSN GetDBPSN()
788 841
        {
842
            PSN result = new PSN();
789 843
            ID2Info id2Info = ID2Info.GetInstance();
790 844

  
791
            bool result = true;
792 845
            using (SQLiteConnection connection = new SQLiteConnection(string.Format(CultureInfo.CurrentCulture, "Data Source = {0}", id2Info.DBFilePath), true))
793 846
            {
794 847
                try
......
801 854
                        {
802 855
                            using (SQLiteCommand cmd = connection.CreateCommand())
803 856
                            {
804
                                cmd.CommandText = string.Format("DELETE FROM {0}", PSN_EQUIPMENT);
805
                                cmd.ExecuteNonQuery();
857
                                DataTable psnDT = new DataTable();
858
                                cmd.CommandText = string.Format("SELECT * FROM {0} WHERE PSNRevisionNumber = '{1}'", PSN_PIPESYSTEMNETWORK, string.Format("{0:D3}", GetRevision()));
859
                                using (SQLiteDataReader dr = cmd.ExecuteReader())
860
                                    psnDT.Load(dr);
861
                                result.PipeSystemNetwork = psnDT;
806 862

  
807
                                foreach (DataRow row in dt.Rows)
808
                                {
809
                                    cmd.CommandText = string.Format("INSERT INTO {0} VALUES (@OID, @ITEMTAG, @XCOORDS, @YCOORDS)", PSN_EQUIPMENT);
810
                                    cmd.Parameters.Clear();
811
                                    cmd.Parameters.AddWithValue("@OID", row["OID"].ToString());
812
                                    cmd.Parameters.AddWithValue("@ITEMTAG", row["ITEMTAG"].ToString());
813
                                    cmd.Parameters.AddWithValue("@XCOORDS", row["XCOORDS"].ToString());
814
                                    cmd.Parameters.AddWithValue("@YCOORDS", row["YCOORDS"].ToString());
815
                                    cmd.ExecuteNonQuery();
816
                                }
817
                            }
818
                            transaction.Commit();
819
                            connection.Close();
820
                        }
821
                        catch (Exception ex)
822
                        {
823
                            transaction.Rollback();
824
                            result = false;
825
                        }
826
                        finally
827
                        {
828
                            transaction.Dispose();
829
                        }
830
                    }
831
                }
832
                catch (Exception ex)
833
                {
834
                    System.Windows.Forms.MessageBox.Show(ex.Message);
835
                    result = false;
836
                }
837
                finally
838
                {
839
                    connection.Dispose();
840
                }
841
            }
863
                                DataTable equipDT = new DataTable();
864
                                cmd.CommandText = string.Format("SELECT * FROM {0}", PSN_EQUIPMENT);
865
                                using (SQLiteDataReader dr = cmd.ExecuteReader())
866
                                    equipDT.Load(dr);
867
                                result.Equipment = equipDT;
842 868

  
843
            return result;
844
        }
869
                                DataTable nozzleDT = new DataTable();
870
                                cmd.CommandText = string.Format("SELECT * FROM {0}", PSN_NOZZLE);
871
                                using (SQLiteDataReader dr = cmd.ExecuteReader())
872
                                    nozzleDT.Load(dr);
873
                                result.Nozzle = nozzleDT;
845 874

  
846
        public static bool SaveNozzle(DataTable dt)
847
        {
848
            ID2Info id2Info = ID2Info.GetInstance();
849

  
850
            bool result = true;
851
            using (SQLiteConnection connection = new SQLiteConnection(string.Format(CultureInfo.CurrentCulture, "Data Source = {0}", id2Info.DBFilePath), true))
852
            {
853
                try
854
                {
855
                    connection.Open();
875
                                DataTable pathItemDT = new DataTable();
876
                                cmd.CommandText = string.Format("SELECT * FROM {0}", PSN_PATHITEMS);
877
                                using (SQLiteDataReader dr = cmd.ExecuteReader())
878
                                    pathItemDT.Load(dr);
879
                                result.PathItems = pathItemDT;
856 880

  
857
                    using (SQLiteTransaction transaction = connection.BeginTransaction())
858
                    {
859
                        try
860
                        {
861
                            using (SQLiteCommand cmd = connection.CreateCommand())
862
                            {
863
                                cmd.CommandText = string.Format("DELETE FROM {0}", PSN_NOZZLE);
864
                                cmd.ExecuteNonQuery();
881
                                DataTable seqDT = new DataTable();
882
                                cmd.CommandText = string.Format("SELECT * FROM {0}", PSN_SEQUENCEDATA);
883
                                using (SQLiteDataReader dr = cmd.ExecuteReader())
884
                                    seqDT.Load(dr);
885
                                result.SequenceData = seqDT;
865 886

  
866
                                foreach (DataRow row in dt.Rows)
867
                                {
868
                                    cmd.CommandText = string.Format("INSERT INTO {0} VALUES (@OID, @ITEMTAG, @XCOORDS, @YCOORDS, @Equipment_OID, @FLUID, @NPD, @ROTATION, @FlowDirection)", PSN_NOZZLE);
869
                                    cmd.Parameters.Clear();
870
                                    cmd.Parameters.AddWithValue("@OID", row["OID"].ToString());
871
                                    cmd.Parameters.AddWithValue("@ITEMTAG", row["ITEMTAG"].ToString());
872
                                    cmd.Parameters.AddWithValue("@XCOORDS", row["XCOORDS"].ToString());
873
                                    cmd.Parameters.AddWithValue("@YCOORDS", row["YCOORDS"].ToString());
874
                                    cmd.Parameters.AddWithValue("@Equipment_OID", row["Equipment_OID"].ToString());
875
                                    cmd.Parameters.AddWithValue("@FLUID", row["FLUID"].ToString());
876
                                    cmd.Parameters.AddWithValue("@NPD", row["NPD"].ToString());
877
                                    cmd.Parameters.AddWithValue("@ROTATION", row["ROTATION"].ToString());
878
                                    cmd.Parameters.AddWithValue("@FlowDirection", row["FlowDirection"].ToString());
879
                                    cmd.ExecuteNonQuery();
880
                                }
887
                                result.Revision = GetRevision();
881 888
                            }
882 889
                            transaction.Commit();
883 890
                            connection.Close();
......
885 892
                        catch (Exception ex)
886 893
                        {
887 894
                            transaction.Rollback();
888
                            result = false;
895
                            result = null;
889 896
                        }
890 897
                        finally
891 898
                        {
......
896 903
                catch (Exception ex)
897 904
                {
898 905
                    System.Windows.Forms.MessageBox.Show(ex.Message);
899
                    result = false;
906
                    result = null;
900 907
                }
901 908
                finally
902 909
                {
903 910
                    connection.Dispose();
904 911
                }
905 912
            }
906

  
907 913
            return result;
908 914
        }
909 915

  
......
929 935
                            if (result < revisionNumber)
930 936
                                result = revisionNumber;
931 937
                        }
932

  
933
                        result++;
934 938
                    }
935 939
                    connection.Close();
936 940
                }
......
1027 1031

  
1028 1032
            return dt;
1029 1033
        }
1034
        public static DataTable GetPathItem()
1035
        {
1036
            DataTable dt = new DataTable();
1037
            ID2Info id2Info = ID2Info.GetInstance();
1038
            using (SQLiteConnection connection = new SQLiteConnection(string.Format(CultureInfo.CurrentCulture, "Data Source = {0}", id2Info.DBFilePath), true))
1039
            {
1040
                try
1041
                {
1042
                    connection.Open();
1043
                    using (SQLiteCommand cmd = connection.CreateCommand())
1044
                    {
1045
                        cmd.CommandText = string.Format("SELECT * FROM {0}", PSN_PATHITEMS);
1046
                        using (SQLiteDataReader dr = cmd.ExecuteReader())
1047
                            dt.Load(dr);
1048
                    }
1049
                    connection.Close();
1050
                }
1051
                catch (Exception ex)
1052
                {
1053
                    Log.Write(ex.Message + "\r\n" + ex.StackTrace);
1054
                }
1055
                finally
1056
                {
1057
                    connection.Dispose();
1058
                }
1059
            }
1060
            return dt;
1061
        }
1062
        public static DataTable GetTopologySet_OID()
1063
        {
1064
            DataTable dt = new DataTable();
1065
            ID2Info id2Info = ID2Info.GetInstance();
1066
            using (SQLiteConnection connection = new SQLiteConnection(string.Format(CultureInfo.CurrentCulture, "Data Source = {0}", id2Info.DBFilePath), true))
1067
            {
1068
                try
1069
                {
1070
                    connection.Open();
1071
                    using (SQLiteCommand cmd = connection.CreateCommand())
1072
                    {
1073
                        cmd.CommandText = string.Format("SELECT DISTINCT(TopologySet_OID) FROM {0}", PSN_PATHITEMS);
1074
                        using (SQLiteDataReader dr = cmd.ExecuteReader())
1075
                            dt.Load(dr);
1076
                    }
1077
                    connection.Close();
1078
                }
1079
                catch (Exception ex)
1080
                {
1081
                    Log.Write(ex.Message + "\r\n" + ex.StackTrace);
1082
                }
1083
                finally
1084
                {
1085
                    connection.Dispose();
1086
                }
1087
            }
1088
            return dt;
1089
        }
1090
        public static DataTable GetPipeSystemNetwork()
1091
        {
1092
            DataTable dt = new DataTable();
1093
            ID2Info id2Info = ID2Info.GetInstance();
1094
            using (SQLiteConnection connection = new SQLiteConnection(string.Format(CultureInfo.CurrentCulture, "Data Source = {0}", id2Info.DBFilePath), true))
1095
            {
1096
                try
1097
                {
1098
                    connection.Open();
1099
                    using (SQLiteCommand cmd = connection.CreateCommand())
1100
                    {
1101
                        cmd.CommandText = string.Format("SELECT * FROM {0} WHERE PSNRevisionNumber = '{1}'", PSN_PIPESYSTEMNETWORK, string.Format("{0:D3}", GetRevision()));
1102
                        using (SQLiteDataReader dr = cmd.ExecuteReader())
1103
                            dt.Load(dr);
1104
                    }
1105
                    connection.Close();
1106
                }
1107
                catch (Exception ex)
1108
                {
1109
                    Log.Write(ex.Message + "\r\n" + ex.StackTrace);
1110
                }
1111
                finally
1112
                {
1113
                    connection.Dispose();
1114
                }
1115
            }
1116
            return dt;
1117
        }
1118
        public static DataTable GetSequenceData()
1119
        {
1120
            DataTable dt = new DataTable();
1121
            ID2Info id2Info = ID2Info.GetInstance();
1122
            using (SQLiteConnection connection = new SQLiteConnection(string.Format(CultureInfo.CurrentCulture, "Data Source = {0}", id2Info.DBFilePath), true))
1123
            {
1124
                try
1125
                {
1126
                    connection.Open();
1127
                    using (SQLiteCommand cmd = connection.CreateCommand())
1128
                    {
1129
                        cmd.CommandText = string.Format("SELECT * FROM {0}", PSN_SEQUENCEDATA);
1130
                        using (SQLiteDataReader dr = cmd.ExecuteReader())
1131
                            dt.Load(dr);
1132
                    }
1133
                    connection.Close();
1134
                }
1135
                catch (Exception ex)
1136
                {
1137
                    Log.Write(ex.Message + "\r\n" + ex.StackTrace);
1138
                }
1139
                finally
1140
                {
1141
                    connection.Dispose();
1142
                }
1143
            }
1144
            return dt;
1145
        }
1030 1146
    }
1031 1147
}

내보내기 Unified diff

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