diff --git a/docs/参考/美团点评2019年技术年货.pdf b/docs/参考/美团点评2019年技术年货.pdf new file mode 100644 index 00000000..a3f9c039 Binary files /dev/null and b/docs/参考/美团点评2019年技术年货.pdf differ diff --git a/docs/项目/唐山/MX-M2658N_20200117_111136.pdf b/docs/项目/唐山/MX-M2658N_20200117_111136.pdf new file mode 100644 index 00000000..0af3b7d5 Binary files /dev/null and b/docs/项目/唐山/MX-M2658N_20200117_111136.pdf differ diff --git a/projects/IoTCenter/Api/ApiController.cs b/projects/IoTCenter/Api/ApiController.cs index 1f119dbc..de73a861 100644 --- a/projects/IoTCenter/Api/ApiController.cs +++ b/projects/IoTCenter/Api/ApiController.cs @@ -9,9 +9,7 @@ using Microsoft.AspNetCore.SignalR; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Hosting; -using Newtonsoft.Json; using System; -using System.ComponentModel.DataAnnotations; using System.Linq; namespace UserCenter.Controllers @@ -63,7 +61,7 @@ namespace UserCenter.Controllers } [HttpPost] - public ActionResult Exec([FromBody]ApiRequestModel model) + public ActionResult ExecApi([FromBody]ApiRequestModel model) { try { @@ -77,6 +75,25 @@ namespace UserCenter.Controllers } } + [HttpPost] + public ActionResult ExecScene(Guid id) + { + try + { + var scene = this._sceneRepo.ReadOnlyTable().Include(o => o.Node).FirstOrDefault(o => o.Id == id); + if (scene != null) + { + this._hub.ServerToClient(Methods.ExecSceneRequest, id, scene.Node.Number, null); + } + return Ok(); + } + catch (Exception ex) + { + ex.PrintStack(); + return Problem(ex.Message); + } + } + private void CallApi(string connectionId, string number, string method, string query) { var device = this._deviceRepo.ReadOnlyTable().Include(o => o.Node).FirstOrDefault(o => o.Number == number); diff --git a/projects/WebApp/wwwroot/js/app.js b/projects/WebApp/wwwroot/js/app.js index 73176d22..02757c3d 100644 --- a/projects/WebApp/wwwroot/js/app.js +++ b/projects/WebApp/wwwroot/js/app.js @@ -68,7 +68,7 @@ router.beforeEach((to, from, next) => { } var route; for (var i = 0; i < routeList.length; i++) { - if (routeList[i].path == to.path) { + if (routeList[i].path === to.path) { route = routeList[i]; } } @@ -80,7 +80,7 @@ router.beforeEach((to, from, next) => { $.getScript(url, function () { var route = { path: to.path, - component: eval(method), + component: eval(method) }; router.addRoutes([route]); routeList.push(route); @@ -95,8 +95,8 @@ router.beforeEach((to, from, next) => { router.afterEach((route, redirect) => { Vue.nextTick(() => { $('#loading').fadeOut(100); - }) -}) + }); +}); /// const app = new Vue({ store: store, @@ -107,5 +107,5 @@ const app = new Vue({ console.log('mounted:app'); }, methods: { - }, + } }).$mount('#app'); diff --git a/projects/WebApp/wwwroot/js/store.js b/projects/WebApp/wwwroot/js/store.js index fdc00179..780c8676 100644 --- a/projects/WebApp/wwwroot/js/store.js +++ b/projects/WebApp/wwwroot/js/store.js @@ -6,13 +6,16 @@ const store = new Vuex.Store({ user: null, products: [], nodes: [], + scenes: [], + timers: [], + tiggers: [], product: null, node: null, - device:null + device: null }, actions: { - update(context,model) { - context.commit(model.event,model); + update(context, model) { + context.commit(model.event, model); } }, mutations: { @@ -60,19 +63,19 @@ const store = new Vuex.Store({ dataEntityUpdated(state, data) { var model = data.model; if (state.node) { - var device = Enumerable.from(state.node.devices).where(function (o) { return o.id === model.deviceId; }).firstOrDefault(); + let device = Enumerable.from(state.node.devices).where(function (o) { return o.id === model.deviceId; }).firstOrDefault(); if (device) { updateByKey(device.data, model); } } if (state.product) { - var device = Enumerable.from(state.product.devices).where(function (o) { return o.id === model.deviceId; }).firstOrDefault(); + let device = Enumerable.from(state.product.devices).where(function (o) { return o.id === model.deviceId; }).firstOrDefault(); if (device) { updateByKey(device.data, model); } } if (state.device) { - var device =state.device.number === model.number; + let device = state.device.number === model.number; if (device) { updateByKey(device.data, model); } @@ -112,5 +115,5 @@ const store = new Vuex.Store({ // product.count -= 1; // } //} - }, -}) \ No newline at end of file + } +}); \ No newline at end of file diff --git a/projects/WebApp/wwwroot/js/util.js b/projects/WebApp/wwwroot/js/util.js index e3979bbd..dc5719bc 100644 --- a/projects/WebApp/wwwroot/js/util.js +++ b/projects/WebApp/wwwroot/js/util.js @@ -29,7 +29,7 @@ function update(list, item, key) { function remove(list, item,key) { var result = false; for (var i = 0; i < list.length; i++) { - if (list[i][key] == item[key]) { + if (list[i][key] === item[key]) { list.splice(i, 1); result = true; break; @@ -48,9 +48,9 @@ function copy(from, to) { } } -function callApi(number, method, query) { +function execApi(number, method, query) { var loading = weui.loading('提交中...'); - axios.post('/IoTCenter/api/v1/api/exec', { connectionId,number,method, query }) + axios.post('/IoTCenter/api/v1/api/execApi', { connectionId,number,method, query }) .then(function (response) { console.log(response); }) @@ -60,4 +60,19 @@ function callApi(number, method, query) { .finally(function () { loading.hide(); }); +} + +function execScene(id) { + var loading = weui.loading('提交中...'); + axios.post('/IoTCenter/api/v1/api/execScene','"'+id+'"') + .then(function (response) { + console.log(response); + }) + .catch(function (error) { + console.log(error); + }) + .finally(function () { + loading.hide(); + }); + } \ No newline at end of file diff --git a/projects/WebApp/wwwroot/pages/iot/node.html b/projects/WebApp/wwwroot/pages/iot/node.html index 0ef1a02c..29a0575e 100644 --- a/projects/WebApp/wwwroot/pages/iot/node.html +++ b/projects/WebApp/wwwroot/pages/iot/node.html @@ -10,7 +10,7 @@