From 6d6657b6b67586b569e60e952df0d2f3b1ffd14e Mon Sep 17 00:00:00 2001 From: Gazebo Date: Sun, 19 Jul 2020 21:58:28 -0300 Subject: [PATCH] DevicesProjectsReformulados --- .../DevicesFragments/ViewDevicesFragment.java | 2 +- .../sextafeiramobile/ServerConnection.java | 3 ++- Server/DataBase.py | 2 +- Server/DevicesStatus.json | 4 ++++ Server/Server.py | 13 +++++++++++++ Server/__pycache__/DataBase.cpython-36.pyc | Bin 5361 -> 5364 bytes 6 files changed, 21 insertions(+), 3 deletions(-) diff --git a/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/DevicesFragments/ViewDevicesFragment.java b/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/DevicesFragments/ViewDevicesFragment.java index 9a21b21..0cf12b7 100644 --- a/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/DevicesFragments/ViewDevicesFragment.java +++ b/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/DevicesFragments/ViewDevicesFragment.java @@ -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); diff --git a/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/ServerConnection.java b/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/ServerConnection.java index 5651800..f51559f 100644 --- a/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/ServerConnection.java +++ b/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/ServerConnection.java @@ -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); diff --git a/Server/DataBase.py b/Server/DataBase.py index 2529788..09c9322 100644 --- a/Server/DataBase.py +++ b/Server/DataBase.py @@ -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() diff --git a/Server/DevicesStatus.json b/Server/DevicesStatus.json index 9c0ceb3..61855b6 100644 --- a/Server/DevicesStatus.json +++ b/Server/DevicesStatus.json @@ -2,5 +2,9 @@ "Friday": { "action": 0, "url": ".com" + }, + "Interface": { + "action": 0, + "url": ".com" } } \ No newline at end of file diff --git a/Server/Server.py b/Server/Server.py index ab9c90d..19ea1fc 100644 --- a/Server/Server.py +++ b/Server/Server.py @@ -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': diff --git a/Server/__pycache__/DataBase.cpython-36.pyc b/Server/__pycache__/DataBase.cpython-36.pyc index 1fadfd547e552623b3988654b519b4cf80d31591..734ad1f55e67041ecdf57ce5552a0bdd5ce036f1 100644 GIT binary patch delta 41 xcmeyU`9+h{n3tDp?tYQ@u8o|l`2|JPbrf7u%QBNw9g|Bk^Ye-~AL7?%1pp!a4b}hv delta 38 ucmeyO`B9V8n3tF9hN@6}`$o>y{CtAyItnhSWtqvTUd8!&n~(DAvjPC_7YsN6