Former-commit-id: cfe8abac5ade5b38d0afb61dfe0e9e4ad4e3829d
TangShanKaiPing
wanggang 6 years ago
parent 8f7399d532
commit d1b050e840

@ -7,10 +7,10 @@ namespace Application.Models
public int type { get; set; }
public int code { get; set; }
public string message { get; set; }
public string data { get; set; }
public int format { get; set; }
public object data { get; set; }
public string format { get; set; }
public static ApiResponse Success(string data, int format = 0)
public static ApiResponse Success(object data, string format = "")
{
return new ApiResponse { type = 0, code = 0, data = data, format = format };
}

@ -346,7 +346,7 @@ namespace IoT.Shared.Services
var url = $"http://localhost:{port}{message.FromJson<string>()}";
var httpClient = scope.ServiceProvider.GetService<IHttpClientFactory>().CreateClient();
var result = httpClient.GetStringAsync(url).Result;
this.ClientToServer(Methods.ExecApiResponse, result, from);
this.ClientToServer(Methods.ExecApiResponse, result, from, to);
}
else if (method == Methods.ExecSceneRequest)
{

@ -35,7 +35,7 @@ var f7params = isApp? {
routes: [],
name: 'My App',
id: 'com.myapp.test',
theme: 'ios',
theme: 'ios'
}:null;
//
//log
@ -112,7 +112,7 @@ function loadData() {
function updateItem(list, item) {
var update = false;
for (var i = 0; i < list.length; i++) {
if (list[i].id == item.id) {
if (list[i].id === item.id) {
update = true;
break;
}
@ -126,7 +126,7 @@ function updateItem(list, item) {
}
function deleteItem(list, item) {
for (var i = 0; i < list.length; i++) {
if (list[i].id == item.id) {
if (list[i].id === item.id) {
list.splice(i, 1);
break;
}
@ -253,9 +253,9 @@ function getCode1(code) {
}
//
function hsvToRgb(h, s, v) {
if (h == "") h = 0;
if (s == "") s = 0;
if (v == "") v = 0;
if (h === "") h = 0;
if (s === "") s = 0;
if (v === "") v = 0;
h = parseFloat(h);
s = parseFloat(s);
v = parseFloat(v);
@ -269,7 +269,7 @@ function hsvToRgb(h, s, v) {
v /= 100.0;
C = v * s;
hh = h / 60.0;
X = C * (1.0 - Math.abs((hh % 2) - 1.0));
X = C * (1.0 - Math.abs(hh % 2 - 1.0));
r = g = b = 0;
if (hh >= 0 && hh < 1) {
r = C;
@ -315,7 +315,7 @@ function hsvToRgb(h, s, v) {
}
//
function ajax(url, data, type) {
url = baseUrl + url
url = baseUrl + url;
console.log(url);
type = type || 'get';
$('.overlay').show();
@ -349,68 +349,6 @@ function AjaxCallBack(response) {
}
}
//
function hsvToRgb(h, s, v) {
if (h == "") h = 0;
if (s == "") s = 0;
if (v == "") v = 0;
h = parseFloat(h);
s = parseFloat(s);
v = parseFloat(v);
if (h < 0) h = 0;
if (s < 0) s = 0;
if (v < 0) v = 0;
if (h >= 360) h = 359;
if (s > 100) s = 100;
if (v > 100) v = 100;
s /= 100.0;
v /= 100.0;
C = v * s;
hh = h / 60.0;
X = C * (1.0 - Math.abs((hh % 2) - 1.0));
r = g = b = 0;
if (hh >= 0 && hh < 1) {
r = C;
g = X;
}
else if (hh >= 1 && hh < 2) {
r = X;
g = C;
}
else if (hh >= 2 && hh < 3) {
g = C;
b = X;
}
else if (hh >= 3 && hh < 4) {
g = X;
b = C;
}
else if (hh >= 4 && hh < 5) {
r = X;
b = C;
}
else {
r = C;
b = X;
}
m = v - C;
r += m;
g += m;
b += m;
r *= 255.0;
g *= 255.0;
b *= 255.0;
r = Math.round(r);
g = Math.round(g);
b = Math.round(b);
hex = r * 65536 + g * 256 + b;
hex = hex.toString(16, 6);
len = hex.length;
if (len < 6)
for (i = 0; i < 6 - len; i++)
hex = '0' + hex;
return '#' + hex;
}
//
function changeTime(t) {
time = t;
UpdateChart();
@ -430,7 +368,7 @@ function UpdateChart(deviceNumber) {
})
.catch(function (error) {
console.log(error);
toastr.error(error)
toastr.error(error);
});
}
});
@ -441,7 +379,7 @@ function UpdateChartInternal(canvas, title, data) {
if (instance.chart.canvas.id === canvas.id) {
chart = instance;
}
})
});
if (chart) {
chart.data = data;
chart.update();
@ -451,7 +389,7 @@ function UpdateChartInternal(canvas, title, data) {
var options = {
responsive: true,
legend: {
position: 'bottom',
position: 'bottom'
},
title: {
display: false,
@ -461,7 +399,7 @@ function UpdateChartInternal(canvas, title, data) {
duration: 0
}
};
var chart = new Chart(ctx, {
chart = new Chart(ctx, {
type: 'line',
data: data,
options: options
@ -546,7 +484,7 @@ function playFlv(videoElement) {
livePlayer.muted = muted;
timer = setInterval(function () {
console.log('.');
if (livePlayer.statisticsInfo.speed == 0) {
if (livePlayer.statisticsInfo.speed === 0) {
console.log('reload1');
clearInterval(timer);
playFlv(videoElement);
@ -556,7 +494,7 @@ function playFlv(videoElement) {
clearInterval(timer);
playFlv(videoElement);
}
else if (livePlayer.buffered.end(0) - livePlayer.currentTime > 1) {
else if (livePlayer.buffered.length>0&&livePlayer.buffered.end(0) - livePlayer.currentTime > 1) {
console.log('reset currentTime');
livePlayer.currentTime = livePlayer.buffered.end(0) - 0.001;
}
@ -573,7 +511,7 @@ function closePlayer(livePlayer) {
if (timer) {
clearInterval(timer);
}
if (livePlayer != null) {
if (livePlayer !== null) {
try {
livePlayer.pause();
} catch (e) {
@ -590,7 +528,7 @@ function closePlayer(livePlayer) {
}
}
$(document).on('change', '#camera', function (e) {
UpdateCamera()
UpdateCamera();
});
$(document).on('mousedown touchstart', 'img.camera.ajax', function (e) {
var number = $('#camera').val();

@ -35,6 +35,25 @@ namespace IoTNode.Controllers
}
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:不捕获常规异常类型", Justification = "<挂起>")]
public ApiResponse Action(Func<object> action)
{
if (action is null)
{
throw new ArgumentNullException(nameof(action));
}
try
{
return ApiResponse.Success(action());
}
catch (Exception ex)
{
ex.PrintStack();
return ApiResponse.Error(ex.GetMessage());
}
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:不捕获常规异常类型", Justification = "<挂起>")]
public ApiResponse AsyncAction(Action action)
{

@ -19,9 +19,15 @@ namespace IoTNode.Controllers
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse ScreenShot([SwaggerParameter("设备编号")]string number)
{
return this.AsyncAction(() =>
return this.Action(() =>
{
this._deviceService.ScreenShot(number);
var data = this._deviceService.ScreenShot(number);
return new ApiResponse
{
code = 0,
format = "image/jpeg",
data = data
};
});
}

@ -532,16 +532,24 @@ namespace IoTNode.DeviceServices.Onvif
{
var camera = this.GetCamera(id);
var url = camera.GetDataValue("SnapshotUri");
if (string.IsNullOrEmpty(url))
{
return new byte[] { };
}
var hc = this._httpClientFactory.CreateClient();
if (camera.GetDataValue("NeedAuth") == "否")
if (!string.IsNullOrEmpty(url))
{
return hc.GetByteArrayAsync(url).Result;
var hc = this._httpClientFactory.CreateClient();
if (camera.GetDataValue("NeedAuth") == "否")
{
return hc.GetByteArrayAsync(url).Result;
}
else
{
if (camera.GetDataValue("HasAuth") == "是")
{
return hc.GetByteDigest(new Uri(url), camera.UserName, camera.Password);
}
}
}
return hc.GetByteDigest(new Uri(url), camera.UserName, camera.Password);
return new byte[] { };
}
public void SetPush(string number, bool state)

@ -11,7 +11,7 @@
mounted: function () {
axios.post(this.url)
.then(function (response) {
store.commit('setDevice',response.data);
store.commit('setDevice', response.data);
})
.catch(function (error) {
})
@ -20,7 +20,7 @@
});
},
destroyed: function () {
store.commit('setDevice',null);
store.commit('setDevice', null);
},
methods: {
},
@ -29,7 +29,7 @@
return store.state.device;
}
}
})
});
});
});
}

@ -171,9 +171,9 @@
</div>
<div class="col col-md-8 col-sm-8 align-self-center">
<div class="row" style="line-height:28px;">
<img style="height:32px;" v-on:click="exceApi(device.number,'/Curtain/On')" src="/IoTCenter/images/left.png" />
<img style="height:32px;" v-on:click="exceApi(device.number,'/Curtain/Stop')" src="/IoTCenter/images/stop.png" />
<img style="height:32px;" v-on:click="exceApi(device.number,'/Curtain/Off')" src="/IoTCenter/images/right.png" />
<img style="height:32px;" v-on:click="execApi(device.number,'/Curtain/On')" src="/IoTCenter/images/left.png" />
<img style="height:32px;" v-on:click="execApi(device.number,'/Curtain/Stop')" src="/IoTCenter/images/stop.png" />
<img style="height:32px;" v-on:click="execApi(device.number,'/Curtain/Off')" src="/IoTCenter/images/right.png" />
</div>
</div>
</div>
@ -195,12 +195,12 @@
</div>
<div class="col col-md-8 col-sm-8 align-self-center">
<div class="row" style="line-height:28px;">
<img v-if="getDataValue(device.number,'L1状态')=='开'" v-on:click="exceApi(device.number,'/Switch3/L1Off')" src="/IoTCenter/images/on.png" />
<img v-if="getDataValue(device.number,'L1状态')=='关'" v-on:click="exceApi(device.number,'/Switch3/L1On')" src="/IoTCenter/images/off.png" />
<img v-if="getDataValue(device.number,'L2状态')=='开'" v-on:click="exceApi(device.number,'/Switch3/L2Off')" src="/IoTCenter/images/on.png" />
<img v-if="getDataValue(device.number,'L2状态')=='关'" v-on:click="exceApi(device.number,'/Switch3/L2On')" src="/IoTCenter/images/off.png" />
<img v-if="getDataValue(device.number,'L3状态')=='开'" v-on:click="exceApi(device.number,'/Switch3/L3Off')" src="/IoTCenter/images/on.png" />
<img v-if="getDataValue(device.number,'L3状态')=='关'" v-on:click="exceApi(device.number,'/Switch3/L3On')" src="/IoTCenter/images/off.png" />
<img v-if="getDataValue(device.number,'L1状态')=='开'" v-on:click="execApi(device.number,'/Switch3/L1Off')" src="/IoTCenter/images/on.png" />
<img v-if="getDataValue(device.number,'L1状态')=='关'" v-on:click="execApi(device.number,'/Switch3/L1On')" src="/IoTCenter/images/off.png" />
<img v-if="getDataValue(device.number,'L2状态')=='开'" v-on:click="execApi(device.number,'/Switch3/L2Off')" src="/IoTCenter/images/on.png" />
<img v-if="getDataValue(device.number,'L2状态')=='关'" v-on:click="execApi(device.number,'/Switch3/L2On')" src="/IoTCenter/images/off.png" />
<img v-if="getDataValue(device.number,'L3状态')=='开'" v-on:click="execApi(device.number,'/Switch3/L3Off')" src="/IoTCenter/images/on.png" />
<img v-if="getDataValue(device.number,'L3状态')=='关'" v-on:click="execApi(device.number,'/Switch3/L3On')" src="/IoTCenter/images/off.png" />
</div>
</div>
</div>
@ -222,8 +222,8 @@
</div>
<div class="col col-md-8 col-sm-8 align-self-center">
<div class="row" style="line-height:28px;">
<img v-if="getDataValue(device.number,'状态')==='开'" v-on:click="exceApi(device.number,'/Socket/Off')" src="/IoTCenter/images/on.png" :data-status="getDataValue(device.number,'状态')" />
<img v-if="getDataValue(device.number,'状态')==='关'" v-on:click="exceApi(device.number,'/Socket/On')" src="/IoTCenter/images/off.png" :data-status="getDataValue(device.number,'状态')" />
<img v-if="getDataValue(device.number,'状态')==='开'" v-on:click="execApi(device.number,'/Socket/Off')" src="/IoTCenter/images/on.png" :data-status="getDataValue(device.number,'状态')" />
<img v-if="getDataValue(device.number,'状态')==='关'" v-on:click="execApi(device.number,'/Socket/On')" src="/IoTCenter/images/off.png" :data-status="getDataValue(device.number,'状态')" />
</div>
</div>
</div>

Loading…
Cancel
Save