Skip to content

Commit

Permalink
Merge pull request #32 from GabrielSirtoriCorrea/CorrigindoBugMetodos…
Browse files Browse the repository at this point in the history
…Update

BugsCorrigidos
  • Loading branch information
GabrielSirtoriCorrea authored Jul 6, 2020
2 parents 3d8039f + 245e72e commit 72b4003
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 7 deletions.
8 changes: 4 additions & 4 deletions Server/DataBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,19 @@ def insertDevice(self, name, desc, json):


def updateInteraction(self, updateId, key1, key2, key3, res1, res2, res3, command):
self.dataBaseCursor.execute('UPDATE Interactions set KeyWord1 = %s, KeyWord2 = %s, KeyWord3 = %s, Response1 = %s, Response2 = %s, Response3 = %s, WHERE InteractionId = %d', (key1, key2, key3, res1, res2, res3, command, updateId))
self.dataBaseCursor.execute(f"UPDATE Interactions set KeyWord1 = '{key1}', KeyWord2 = '{key2}', KeyWord3 = '{key3}', Response1 = '{res1}', Response2 = '{res2}', Response3 = '{res3}', Command = '{command}' WHERE InteractionId = '{updateId}' ")
self.dataBaseConnector.commit()

def updateHomeWork(self, updateId, type, subject, homeWork, delivery, desc):
self.dataBaseCursor.execute('UPDATE HomeWorkManagement set HomeWorkType = %s, HomeWorkSubject = %s, HomeWork = %s, HomeWorkDelivery = %s, HomeWorkDescription = %s, WHERE HomeWorkID = %d', (type, subject, homeWork, delivery, desc, updateId))
self.dataBaseCursor.execute(f"UPDATE HomeWorkManagement set HomeWorkType = '{type}', HomeWorkSubject = '{subject}', HomeWork = '{homeWork}', HomeWorkDelivery = '{datetime.strptime(delivery, '%d/%m/%Y').date()}', HomeWorkDescription = '{desc}' WHERE HomeWorkID ='{updateId}' ")
self.dataBaseConnector.commit()

def updateProject(self, updateId, name, repository):
self.dataBaseCursor.execute('UPDATE Projects set ProjectName = %s, ProjectRepository = %s, WHERE ProjectID = %d' % (name, repository, updateId))
self.dataBaseCursor.execute(f"UPDATE Projects SET ProjectName='{name}', ProjectRepository='{repository}' WHERE ProjectID='{updateId}' ")
self.dataBaseConnector.commit()

def updateDevice(self, updateId, name, desc, json):
self.dataBaseCursor.execute('UPDATE Device set DeviceName = %s, DeviceDescription = %s, DeviceJsonJson = %s, WHERE DeviceID = %d', (name, desc, json))
self.dataBaseCursor.execute(f"UPDATE Device SET DeviceName = '{name}', DeviceDescription = '{desc}', DeviceJson = '{json}' WHERE DeviceID = '{updateId}' ")
self.dataBaseConnector.commit()


Expand Down
36 changes: 33 additions & 3 deletions Server/Server.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def handle(self):
data = self.request.recv(5800).decode()
print(data)

try:
if True:
if data:
clientRequest = json.loads(data)

Expand Down Expand Up @@ -170,12 +170,42 @@ def handle(self):

self.request.send(json.dumps({'requestStatus': True}).encode())

elif clientRequest['request'] == 'updateDevice':
dataBaseConnection.updateDevice(clientRequest['updateId'],
clientRequest['device'],
clientRequest['description'],
clientRequest['json'])

self.request.send(json.dumps({'requestStatus': True}).encode())

elif clientRequest['request'] == 'updateHomeWork':
dataBaseConnection.updateHomeWork(clientRequest['updateId'],
clientRequest['type'],
clientRequest['subject'],
clientRequest['homeWork'],
clientRequest['delivery'],
clientRequest['description'])

self.request.send(json.dumps({'requestStatus': True}).encode())

elif clientRequest['request'] == 'updateInteraction':
dataBaseConnection.updateInteraction(clientRequest['updateId'],
clientRequest['key1'],
clientRequest['key2'],
clientRequest['key3'],
clientRequest['res1'],
clientRequest['res2'],
clientRequest['res3'],
clientRequest['command'])

self.request.send(json.dumps({'requestStatus': True}).encode())


else:
break

except:
print('error')
#except:
# print('error')

server = socketserver.ThreadingTCPServer((host, port), ClientManage)
server.serve_forever()
Binary file modified Server/__pycache__/DataBase.cpython-36.pyc
Binary file not shown.

0 comments on commit 72b4003

Please sign in to comment.