프로젝트

일반

사용자정보

개정판 269a15c8

ID269a15c877b4e4357934bae023b0bf623c885d8e
상위 71358cbe
하위 017524f0

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

dev issue #640: edit lineProperty

차이점 보기:

DTI_PID/DTI_PID/AppDocData.py
715 715
            # Get a cursor object
716 716
            cursor = db.cursor()
717 717

  
718
            sql = "select Name from LineProperties order by Name" 
718
            sql = "select UID, Name, DisplayName, Type, LimitNumber, [index] from LineProperties order by [index]" 
719 719
            cursor.execute(sql)
720 720
            rows = cursor.fetchall()
721 721
            for row in rows:
722
                res.append(row[0])
722
                res.append((row[0], row[1], row[2], row[3], row[4], row[5]))
723
        # Catch the exception
724
        except Exception as ex:
725
            # Roll back any change if something goes wrong
726
            db.rollback()
727
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
728
        finally:
729
            # Close the db connection
730
            db.close()
731

  
732
        return res
733

  
734
    '''
735
        @brief  return line properties
736
        @author humkyung
737
        @date   2018.04.09
738
    '''
739
    def getLinePropertiesByUID(self, UID):
740
        res = []
741
        try:
742
            # Creates or opens a file called mydb with a SQLite3 DB
743
            dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db')
744
            db = sqlite3.connect(dbPath)
745
            # Get a cursor object
746
            cursor = db.cursor()
747

  
748
            sql = "select UID, Name, DisplayName, Type, LimitNumber, [index] from LineProperties where uid = '{}'".format(UID)
749
            cursor.execute(sql)
750
            rows = cursor.fetchall()
751
            for row in rows:
752
                res.append((row[0], row[1], row[2], row[3], row[4], row[5]))
723 753
        # Catch the exception
724 754
        except Exception as ex:
725 755
            # Roll back any change if something goes wrong
......
1599 1629
            conn.close()
1600 1630

  
1601 1631
    '''
1632
        @brief      save symbol attributes
1633
        @author     humkyung
1634
        @date       2018.08.14
1635
    '''
1636
    def saveLineAttributes(self, attrs):
1637
        try:
1638
            # Creates or opens a file called mydb with a SQLite3 DB
1639
            dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db')
1640
            conn = sqlite3.connect(dbPath)
1641
            # Get a cursor object
1642
            cursor = conn.cursor()
1643

  
1644
            sql = 'delete from LineProperties'
1645
            cursor.execute(sql)
1646

  
1647
            for attr in attrs:
1648
                sql = 'insert into LineProperties(UID, Name, DisplayName, Type, LimitNumber, [index]) values(?, ?, ?, ?, ?, ?)'
1649
                param = tuple(attr)
1650
                cursor.execute(sql, param)
1651

  
1652
            conn.commit()
1653
            # Catch the exception
1654
        except Exception as ex:
1655
            # Roll back any change if something goes wrong
1656
            conn.rollback()
1657
            
1658
            from App import App 
1659
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
1660
            App.mainWnd().addMessage.emit(MessageType.Error, message)
1661
        finally:
1662
            # Close the db connection
1663
            conn.close()
1664

  
1665
    '''
1602 1666
        @brief      get symbol type id
1603 1667
        @author     kyouho
1604 1668
        @date       2018.08.17
......
1668 1732
        return result
1669 1733

  
1670 1734
    '''
1735
        @brief      get Code Table Data
1736
        @author     kyouho
1737
        @date       2018.07.10
1738
    '''
1739
    def getCodeTable(self, property, forCheckLineNumber = False):
1740
        result = []
1741
        try:
1742
            # Creates or opens a file called mydb with a SQLite3 DB
1743
            dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db')
1744
            conn = sqlite3.connect(dbPath)
1745
            # Get a cursor object
1746
            cursor = conn.cursor()
1747

  
1748
            if property == "NominalDiameter" and forCheckLineNumber:
1749
                sql = 'select InchStr, MetricStr from [{}] order by length(code) DESC'.format(property)
1750
                cursor.execute(sql)
1751
                rows = cursor.fetchall()
1752
                for index in range(2):
1753
                    for row in rows:
1754
                        if row[index] != '':
1755
                            result.append(row[index])
1756
            else:
1757
                sql = 'select uid, code, description from [{}] order by length(code) DESC'.format(property)
1758
                cursor.execute(sql)
1759
                rows = cursor.fetchall()
1760
                for row in rows:
1761
                    if forCheckLineNumber:
1762
                        data = row[1]
1763
                    else:
1764
                        data = (row[0], row[1], row[2])
1765
                    result.append(data)
1766
            # Catch the exception
1767
        except Exception as ex:
1768
            # Roll back any change if something goes wrong
1769
            conn.rollback()
1770
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
1771
        finally:
1772
            # Close the db connection
1773
            conn.close()
1774

  
1775
        return result
1776

  
1777
    '''
1671 1778
        @brief      Set Common Code Data
1672 1779
        @author     kyouho
1673 1780
        @date       2018.07.12

내보내기 Unified diff

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