Skip to content

Commit

Permalink
Merge pull request #45 from GabrielSirtoriCorrea/DevicesProjectsRefor…
Browse files Browse the repository at this point in the history
…mulados

DevicesProjectsReformulados
  • Loading branch information
GabrielSirtoriCorrea authored Jul 20, 2020
2 parents f43eed3 + 6d6657b commit 74c7388
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public void onClick(View view) {
btnDeleteCancel.setCompoundDrawablesWithIntrinsicBounds(cancelIcon, null, null, null);

}else{
connection.sendRequest(connection.prepareUpdateDevice("updateDevice", ID, txtDevice.getText().toString(), txtDescription.getText().toString(),
connection.sendRequest(connection.prepareUpdateDevice("updateDevice",intent.getStringExtra("Device"), ID, txtDevice.getText().toString(), txtDescription.getText().toString(),
Integer.parseInt(txtActions.getText().toString())));

txtDevice.setEnabled(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,12 @@ public JSONObject prepareUpdateInteraction(String request, int updateId, String
return jsonRequest;
}

public JSONObject prepareUpdateDevice(String request, int updateId, String device, String desc, int actions){
public JSONObject prepareUpdateDevice(String request, String deleteName, int updateId, String device, String desc, int actions){
try {
this.jsonRequest = new JSONObject();
this.jsonRequest.put("header", "gazeboindustries09082004");
this.jsonRequest.put("request", request);
this.jsonRequest.put("deleteName", deleteName);
this.jsonRequest.put("updateId", updateId);
this.jsonRequest.put("device", device);
this.jsonRequest.put("description", desc);
Expand Down
2 changes: 1 addition & 1 deletion Server/DataBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def updateProject(self, updateId, type, name):
self.dataBaseConnector.commit()

def updateDevice(self, updateId, name, desc, actions):
self.dataBaseCursor.execute(f"UPDATE Device SET DeviceName = '{name}', DeviceDescription = '{desc}', DeviceJson = '{actions}' WHERE DeviceID = '{updateId}' ")
self.dataBaseCursor.execute(f"UPDATE Device SET DeviceName = '{name}', DeviceDescription = '{desc}', DeviceActions = '{actions}' WHERE DeviceID = '{updateId}' ")
self.dataBaseConnector.commit()


Expand Down
4 changes: 4 additions & 0 deletions Server/DevicesStatus.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@
"Friday": {
"action": 0,
"url": ".com"
},
"Interface": {
"action": 0,
"url": ".com"
}
}
13 changes: 13 additions & 0 deletions Server/Server.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,19 @@ def handle(self):
clientRequest['description'],
clientRequest['actions'])

readFile = open('E:/Sexta-Feira-Mark_6/Server/DevicesStatus.json', 'r')

newJson = json.load(readFile)

print(newJson)

del newJson[clientRequest['deleteName']]

newJson[clientRequest['device']] = {'action': 0, 'url': '.com'}

writeFile = open('E:/Sexta-Feira-Mark_6/Server/DevicesStatus.json', 'w')
json.dump(newJson, writeFile, indent=4)

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

elif clientRequest['request'] == 'updateHomeWork':
Expand Down
Binary file modified Server/__pycache__/DataBase.cpython-36.pyc
Binary file not shown.

0 comments on commit 74c7388

Please sign in to comment.