프로젝트

일반

사용자정보

개정판 77616eee

ID77616eeea57481e1706cec36d0d45e23025d67b3
상위 469c42f1
하위 4d80748d, 5b59afff

함의성이(가) 5년 이상 전에 추가함

issue #1190: testing drawing exclusive access

Change-Id: I4260e64ceecbc6c6d495662015415bff9cabe790

차이점 보기:

DTI_PID/DTI_PID/AppDocData.py
122 122
        @date       2018.09.06
123 123
    '''
124 124
    def clear(self):
125
        if self.activeDrawing and self.activeDrawing.UID:
126
            self.clear_occupying_drawing(self.activeDrawing.UID)
127

  
125 128
        self._imgFilePath = None
126 129
        self.imgName = None
127 130
        self._imgSrc = None
......
152 155
        self._associationss = {}
153 156
        self._attributess = {}
154 157

  
158
    def clear_occupying_drawing(self, drawing):
159
        """ clear drawing access """
160
        conn = self.project.database.connect()
161
        with conn:
162
            try:
163
                # Get a cursor object
164
                cursor = conn.cursor()
165
                sql = "UPDATE Drawings SET [OCCUPIED]=null WHERE [OCCUPIED]='{}' and UID='{}'".format(os.environ['COMPUTERNAME'], drawing)
166
                cursor.execute(sql)
167

  
168
                conn.commit()
169
            # Catch the exception
170
            except Exception as ex:
171
                conn.rollback()
172

  
173
                from App import App 
174
                message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
175
                App.mainWnd().addMessage.emit(MessageType.Error, message)
176

  
177
    def set_occupying_drawing(self, drawing):
178
        """ set drawing access return true if success"""
179
        conn = self.project.database.connect()
180
        with conn:
181
            try:
182
                # Get a cursor object
183
                cursor = conn.cursor()
184
                sql = "select OCCUPIED from Drawings where [UID]='{}'".format(drawing)
185
                cursor.execute(sql)
186

  
187
                rows = cursor.fetchall()
188
                if not rows[0][0] or rows[0][0] == os.environ['COMPUTERNAME']:
189
                    sql = "UPDATE Drawings SET [OCCUPIED]='{}' WHERE UID='{}'".format(os.environ['COMPUTERNAME'], drawing)
190
                    cursor.execute(sql)
191
                    conn.commit()
192
                    return True
193
                else:
194
                    return False
195

  
196
            # Catch the exception
197
            except Exception as ex:
198
                conn.rollback()
199

  
200
                from App import App 
201
                message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
202
                App.mainWnd().addMessage.emit(MessageType.Error, message)
203

  
204
                return False
205

  
155 206
    '''
156 207
        @brief      Get drawing file list
157 208
        @author     euisung
DTI_PID/DTI_PID/MainWindow.py
104 104
        self.statusbar.addPermanentWidget(self.labelStatus) 
105 105

  
106 106
        docData = AppDocData.instance()
107
        docData.clear()
107 108
        project = docData.getCurrentProject()
108 109
        _translate = QCoreApplication.translate
109 110
        version = QCoreApplication.applicationVersion()
......
293 294

  
294 295
        return QWidget.eventFilter(self, source, event)
295 296

  
297
    def closeEvent(self, event):
298
        AppDocData.instance().clear()
299

  
296 300
    def inconsistencyTableKeyPressEvent(self, event):
297 301
        try:
298 302
            row = self.tableWidgetInconsistency.selectedIndexes()[0].row()
......
1143 1147
            
1144 1148
            self.path = self.graphicsView.loadImageFromFile(project.getDrawingFilePath(), path if type(path) is str else '')
1145 1149
            if os.path.isfile(self.path):
1146
                appDocData.clear()
1147 1150
                self.onCommandRejected()
1151
                appDocData.clear()
1148 1152

  
1149 1153
                appDocData.setImgFilePath(self.path)
1150 1154
                appDocData.activeDrawing = Drawing(None, appDocData.imgName, None)
1155
                if not appDocData.set_occupying_drawing(appDocData.activeDrawing.UID):
1156
                    QMessageBox.about(self.graphicsView, self.tr("Notice"), self.tr("The drawing is locked for editing by another user"))
1157
                    return
1151 1158
                appDocData.activeDrawing.set_pid_source(Image.open(self.path))
1152 1159
                self.itemTreeWidget.setCurrentPID(appDocData.activeDrawing.name)
1153 1160

  
DTI_PID/DTI_PID/Scripts/MSSQL/ID2.sql
3445 3445
    UID      VARCHAR (37) CONSTRAINT Drawings_PK PRIMARY KEY
3446 3446
                          NOT NULL,
3447 3447
    NAME     VARCHAR(256) NOT NULL,
3448
    DATETIME TEXT
3448
    DATETIME TEXT,
3449
    OCCUPIED VARCHAR(256)
3449 3450
);
3450 3451

  
3451 3452
CREATE TABLE Components (

내보내기 Unified diff

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