개정판 77616eee
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 |
내보내기 Unified diff