移除无用项目和文件

Former-commit-id: ca4f37e05752c7076a58cbba423ba34ae79c416c
TangShanKaiPing
wanggang 6 years ago
parent d8c21e58b2
commit 23033f4ae5

@ -1,16 +0,0 @@
*.bak
*.suo
*.db
*.user
.vs/
obj
Obj
bin
Bin
debug
Debug
release
Release
Logs
logs
node_modules

@ -1,15 +0,0 @@
namespace Application.Domain.Entities
{
public enum ClusterId
{
off = 0xfbee,
light = 0x0400,
alarm = 0x0500,
pm25 = 0x0415,
temperature = 0x0402,
humidity = 0x0405,
voltage = 0x0001,
socket = 0x0702,
SummationDivisor = 0x0b04
}
}

@ -1,30 +0,0 @@
using Infrastructure.Domain;
using System.Collections.Generic;
namespace Application.Domain.Entities
{
public class DeviceId : BaseEntity
{
public static List<DeviceId> List { get; set; } = new List<DeviceId>();
static DeviceId()
{
List.Add(new DeviceId { RawDeviceId = 0x0002, Name = "开关", CategoryName = "照明", CategoryNumber = "30", Icon = "switch" });
List.Add(new DeviceId { RawDeviceId = 0x0009, Name = "插座", CategoryName = "电器", CategoryNumber = "20", Icon = "socket" });
List.Add(new DeviceId { RawDeviceId = 0x0051, Name = "智能插座", CategoryName = "电器", CategoryNumber = "20", Icon = "socket" });
List.Add(new DeviceId { RawDeviceId = 0x0106, Name = "光强检测器", CategoryName = "监测", CategoryNumber = "40", Icon = "light" });
List.Add(new DeviceId { RawDeviceId = 0x0163, Name = "红外转发器", CategoryName = "电器", CategoryNumber = "20", Icon = "control" });
List.Add(new DeviceId { RawDeviceId = 0x0202, Name = "窗帘", CategoryName = "电器", CategoryNumber = "20", Icon = "curtain" });
List.Add(new DeviceId { RawDeviceId = 0x0220, Name = "调色灯", CategoryName = "照明", CategoryNumber = "30", Icon = "curtain" });
List.Add(new DeviceId { RawDeviceId = 0x0309, Name = "粉尘检测器", CategoryName = "监测", CategoryNumber = "40", Icon = "pm25" });
List.Add(new DeviceId { RawDeviceId = 0x0302, Name = "温湿度传感器", CategoryName = "监测", CategoryNumber = "40", Icon = "temperature" });
List.Add(new DeviceId { RawDeviceId = 0x0402, Name = "报警器", CategoryName = "安防", CategoryNumber = "10", Icon = "alarm" });
}
public string Name { get; set; }
public string Icon { get; set; }
public string CategoryNumber { get; set; }
public string CategoryName { get; set; }
public ushort RawDeviceId { get; set; }
}
}

@ -1,61 +0,0 @@
namespace Application.Domain.Entities
{
public enum FBeeDataType
{
null0 = 0x00,
bit1 = 0x08,
bit2,
bit3,
bit4,
bit5,
bit6,
bit7,
bit8,
bool1,
bitmap1 = 0x18,
bitmap2,
bitmpa3,
bitmap4,
bitmap5,
bitmap6,
bitmap7,
bitmap8,
uint1 = 0x20,
uint2,
uint3,
uint4,
uint5,
uint6,
uint7,
uint8,
int1,
int2,
int3,
int4,
int5,
int6,
int7,
int8,
enum1,
enum2,
float2 = 0x38,
float4,
float8,
bitstring = 0x41,
characterstring,
longbitstring,
longcharacterstring,
sequence = 0x4c,
set = 0x50,
bag,
time4 = 0xe0,
date4,
utctime4,
cluster2 = 0xe8,
attribute2,
bacnet4,
ieee1 = 0xf0,
m16,
unknown = 0xff
}
}

@ -1,22 +0,0 @@
namespace Application.Domain.Entities
{
public class RequestType
{
public const int xfe = 0xfe;
public const int x81 = 0x81;
public const int x95 = 0x95;
public const int x9d = 0x9d;
public const int x82 = 0x82;
public const int x83 = 0x83;
public const int x84 = 0x84;
public const int x85 = 0x85;
public const int x86 = 0x86;
public const int x87 = 0x87;
public const int x88 = 0x88;
public const int x8d = 0x8d;
public const int xa9 = 0xa9;
public const int xc1 = 0xc1;
public const int xa7 = 0xa7;
public const int xa8 = 0xa8;
}
}

@ -1,16 +0,0 @@
namespace Application.Domain.Entities
{
public class ResponseType
{
public const int x01 = 0x01;
public const int x07 = 0x07;
public const int x08 = 0x08;
public const int x09 = 0x09;
public const int x0a = 0x0a;
public const int x27 = 0x27;
public const int x70 = 0x70;
public const int x72 = 0x72;
public const int x15 = 0x15;
public const int x29 = 0x29;
}
}

@ -1,20 +0,0 @@
using Infrastructure.Application;
using System.ComponentModel.DataAnnotations;
namespace SPService.Applicaiton.Models
{
[Display(Name = "指令")]
public class EditGatewayModel : EditModel
{
[Required]
[Display(Name = "编号")]
public string Sn { get; set; }
[Required]
[Display(Name = "IP")]
public string IP { get; set; }
[Display(Name = "启用")]
public string Enable { get; set; }
}
}

@ -1,11 +0,0 @@
using System.Net.Sockets;
namespace Application.Models
{
public class TcpClientWrapper
{
public string Sn { get; set; }
public string Ip { get; set; }
public TcpClient Client { get; set; }
}
}

@ -1,33 +0,0 @@
using System.Linq;
using Application.Domain.Entities;
using Application.Models;
using Infrastructure.Data;
using Infrastructure.Extensions;
using Infrastructure.Web.Mvc;
using IoTShared.Controllers;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace IoTCenter.Areas.Admin.Controllers
{
[Authorize]
[Area(nameof(Admin))]
public class DataController : CrudController<Data, DataSearchModel, EditDataModel, EditDataModel>
{
private readonly AjaxController _ajax;
public DataController(IRepository<Data> repo, AjaxController ajax) : base(repo)
{
this._ajax = ajax;
}
public override IQueryable<Data> Query(DataSearchModel model, IQueryable<Data> query)
{
ViewData.SelectList(o => model.NodeId, () => this._ajax.GetNodeSelectList(model.NodeId));
ViewData.SelectList(o => model.DeviceId, () => this._ajax.GetDeviceSelectList(model.NodeId.Value, model.DeviceId), model.NodeId.HasValue);
return query.WhereIf(model.NodeId.HasValue, o => o.Device.NodeId == model.NodeId.Value)
.WhereIf(model.DeviceId.HasValue, o => o.DeviceId == model.DeviceId.Value)
.WhereIf(!string.IsNullOrEmpty(model.Keyword), o => o.Name.Contains(model.Keyword));
}
}
}

@ -1,18 +0,0 @@
using Application.Domain.Entities;
using Application.Models;
using Infrastructure.Data;
using Infrastructure.Web.Mvc;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace IoTCenter.Areas.Admin.Controllers
{
[Authorize]
[Area(nameof(Admin))]
public class DeviceController : CrudController<Device, DeviceSearchMode, EditDeviceModel, EditDeviceModel>
{
public DeviceController(IRepository<Device> repo) : base(repo)
{
}
}
}

@ -1,19 +0,0 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace UserCenter.Areas.Admin.Controllers
{
[Authorize]
[Area(nameof(Admin))]
public class HomeController : Controller
{
public HomeController()
{
}
public IActionResult Index()
{
return View();
}
}
}

@ -1,4 +0,0 @@
@{
ViewData["IsHomePage"] = true;
}
<h1>首页</h1>

@ -1,52 +0,0 @@
<section class="sidebar" style="height: auto;">
<ul class="sidebar-menu" data-widget="tree">
<li class="@GetClass("Home")"><a href="@Url.Action("Index","Home")"><i class="fa fa-circle-o"></i><span>首页</span></a></li>
<li class="@GetClass("Configuration")"><a href="@Url.Action("Index","Configuration")"><i class="fa fa-circle-o"></i><span>网站配置</span></a></li>
<li class="treeview @GetClass("User","Role","Permission")">
<a href="javascript:;" class="dropdown-toggle">
<i class="fa fa-list"></i>
<span>权限管理</span>
<span class="pull-right-container">
<i class="fa fa-angle-left pull-right"></i>
</span>
</a>
<ul class="treeview-menu">
<li class="@GetClass("User")"><a href="@Url.Action("Index","User")"><i class="fa fa-circle-o"></i><span>用户管理</span></a></li>
<li class="@GetClass("Role")"><a href="@Url.Action("Index","Role")"><i class="fa fa-circle-o"></i><span>角色管理</span></a></li>
<li class="@GetClass("Permission")"><a href="@Url.Action("Index","Permission")"><i class="fa fa-circle-o"></i><span>权限管理</span></a></li>
</ul>
</li>
<li class="treeview @GetClass("Node","Device","Data","Api","Parameter","Sence","Command")">
<a href="javascript:;" class="dropdown-toggle">
<i class="fa fa-list"></i>
<span>设备管理</span>
<span class="pull-right-container">
<i class="fa fa-angle-left pull-right"></i>
</span>
</a>
<ul class="treeview-menu">
<li class="@GetClass("Node")"><a href="@Url.Action("Index","Node")"><i class="fa fa-circle-o"></i><span>节点管理</span></a></li>
<li class="@GetClass("Device")"><a href="@Url.Action("Index","Device")"><i class="fa fa-circle-o"></i><span>设备管理</span></a></li>
<li class="@GetClass("Data")"><a href="@Url.Action("Index","Data")"><i class="fa fa-circle-o"></i><span>数据管理</span></a></li>
<li class="@GetClass("Api")"><a href="@Url.Action("Index","Api")"><i class="fa fa-circle-o"></i><span>接口管理</span></a></li>
<li class="@GetClass("Parameter")"><a href="@Url.Action("Index","Parameter")"><i class="fa fa-circle-o"></i><span>参数管理</span></a></li>
<li class="@GetClass("Sence")"><a href="@Url.Action("Index","Sence")"><i class="fa fa-circle-o"></i><span>场景管理</span></a></li>
<li class="@GetClass("Command")"><a href="@Url.Action("Index","Command")"><i class="fa fa-circle-o"></i><span>命令管理</span></a></li>
</ul>
</li>
</ul>
</section>
@functions{
public string GetClass(params string[] controllers)
{
if (controllers.Select(o => o.ToLower()).Contains(this.ViewContext.RouteData.Values["controller"].ToString().ToLower()))
{
if (controllers.Length > 1)
{
return "active open";
}
return "active";
}
return "";
}
}

@ -1,24 +0,0 @@
<script>
function clear() {
for (var i = 0; i < arguments.length; i++) {
$(arguments[i]).find('option').not('[value=""]').remove();
}
}
function update(url, id) {
$.getJSON(url, function (data) {
$.each(data, function (i, v) {
$(id).append('<option value="' + v.Value + '">' + v.Text + '</option>');
});
});
}
$(function () {
$('#NodeId').change(function () {
var id = $(this).find(':selected').val();
clear('#DeviceId');
if (id) {
var url = '@Url.Action("GetDeviceJson", "Ajax")?parentId=' + encodeURI(id);
update(url,'#DeviceId');
}
});
});
</script>

@ -1,7 +0,0 @@
@inherits Infrastructure.Web.Mvc.Razor.MyRazorPage<TModel>
@using Infrastructure.Application
@using Infrastructure.Extensions
@using Infrastructure.Data
@using Application.Domain.Entities
@using Application.Models
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

@ -1,22 +0,0 @@
using Application.Domain.Entities;
using Infrastructure.Data;
using Infrastructure.Email;
using Infrastructure.Resources;
using Infrastructure.Security;
using IoT.UI.Shard.Controllers;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Localization;
namespace FBeeService.Controllers
{
public class AccountController : BaseAccountController
{
public AccountController(IConfiguration configuration,
IRepository<User> userRepo,
IEncryptionService encryptionService,
IStringLocalizer<Resource> localizer,
IEmailSender emaliSender) : base(configuration, userRepo, encryptionService, localizer, emaliSender)
{
}
}
}

@ -1,65 +0,0 @@
using Application.Models;
using Infrastructure.Extensions;
using Microsoft.AspNetCore.Mvc;
using Swashbuckle.AspNetCore.Annotations;
using System;
using System.ComponentModel.DataAnnotations;
namespace FBeeService.Controllers
{
[SwaggerTag("调色灯")]
public class ColorLightController : SwitchController
{
protected readonly DeviceService _deviceService;
public ColorLightController(IServiceProvider applicationServices, DeviceService deviceService) : base(applicationServices, deviceService)
{
this._deviceService = deviceService;
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse SetBrightness([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number, [Range(0, 255)]int brightness)
{
try
{
this._deviceService.X83(gateway, number, (byte)brightness);
}
catch (Exception ex)
{
ex.PrintStack();
return ApiResponse.Error(ex.Message);
}
return ApiResponse.AsyncSuccess();
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse SetColor([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number, [Range(0, 255)]int hue, [Range(0, 255)]int saturation)
{
try
{
this._deviceService.X84(gateway, number, (byte)hue, (byte)saturation);
}
catch (Exception ex)
{
ex.PrintStack();
return ApiResponse.Error(ex.Message);
}
return ApiResponse.AsyncSuccess();
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse SetColorTemperature([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number, [Range(2700, 6500)]int colorTemperature)
{
try
{
this._deviceService.XA8(gateway, number, (ushort)colorTemperature);
}
catch (Exception ex)
{
ex.PrintStack();
return ApiResponse.Error(ex.Message);
}
return ApiResponse.AsyncSuccess();
}
}
}

@ -1,27 +0,0 @@
using Application.Models;
using Microsoft.AspNetCore.Mvc;
using Swashbuckle.AspNetCore.Annotations;
using System;
namespace FBeeService.Controllers
{
[SwaggerTag("窗帘")]
public class CurtainController : SwitchController
{
protected readonly DeviceService _deviceService;
public CurtainController(IServiceProvider applicationServices, DeviceService deviceService) : base(applicationServices, deviceService)
{
this._deviceService = deviceService;
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse Stop([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number)
{
return this.AsyncAction(() =>
{
this._deviceService.X82(gateway, number, 2);
});
}
}
}

@ -1,56 +0,0 @@
using Application.Models;
using IoT.Shared.Controllers;
using Microsoft.AspNetCore.Mvc;
using Swashbuckle.AspNetCore.Annotations;
using System;
namespace FBeeService.Controllers
{
[SwaggerTag("网关")]
public class GatewayController : BaseDeviceController
{
private readonly DeviceService _deviceService;
public GatewayController(IServiceProvider applicationServices, DeviceService deviceService) : base(applicationServices)
{
this._deviceService = deviceService;
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse Refresh()
{
return this.AsyncAction(() =>
{
this._deviceService.Execute();
});
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse X9d([SwaggerParameter("网关Id")]string gateway)
{
return this.AsyncAction(() =>
{
this._deviceService.X9d(gateway);
});
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse X81([SwaggerParameter("网关Id")]string gateway)
{
return this.AsyncAction(() =>
{
this._deviceService.X81(gateway);
});
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse X95([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number)
{
return this.AsyncAction(() =>
{
this._deviceService.X95(gateway, number);
});
}
}
}

@ -1,154 +0,0 @@
using Application.Domain.Entities;
using Application.Models;
using Infrastructure.Data;
using Infrastructure.Extensions;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Swashbuckle.AspNetCore.Annotations;
using System;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Net.Http;
namespace FBeeService.Controllers
{
[ApiExplorerSettings(IgnoreApi = true)]
public class HomeController : Controller
{
private readonly IRepository<Device> _deviceRepo;
private readonly IHttpClientFactory _httpClientFactory;
private readonly DeviceService _deviceService;
public HomeController(IHttpClientFactory httpClientFactory,
DeviceService deviceService,
IRepository<Device> deviceRepo)
{
this._deviceRepo = deviceRepo;
this._httpClientFactory = httpClientFactory;
this._deviceService = deviceService;
}
#region ui
public IActionResult Index()
{
var list = this._deviceRepo.ReadOnlyTable()
.Include(o => o.Data)
.Where(o => o.Info.DeviceType == DeviceType.Gateway)
.OrderBy(o => o.Number)
.ToList();
return View(list);
}
public IActionResult Gateway(string sn)
{
var list = this._deviceRepo.ReadOnlyTable()
.Include(o => o.Data)
.Where(o => o.GatewayNumber == sn)
.OrderBy(o => o.CategoryNumber)
.ToList();
return View(list);
}
#endregion ui
#region IR
[SwaggerOperation("版本")]
[HttpGet]
[Route("/ir/version")]
public ApiResponse Version([SwaggerParameter("网关Id")]string sn, [SwaggerParameter("设备Id")]string id)
{
try
{
this._deviceService.XA70080(sn, id);
}
catch (Exception ex)
{
ex.PrintStack();
return ApiResponse.Error(ex.Message);
}
return ApiResponse.AsyncSuccess();
}
[Route("/ir/test")]
public ApiResponse IRControl([SwaggerParameter("网关Id")]string sn, [SwaggerParameter("设备Id")]string id, byte type, ushort code)
{
try
{
this._deviceService.XA70082(sn, id, type, code);
}
catch (Exception ex)
{
ex.PrintStack();
return ApiResponse.Error(ex.Message);
}
return ApiResponse.AsyncSuccess();
}
[Route("/ir/study")]
public ApiResponse IRStudy([SwaggerParameter("网关Id")]string sn, [SwaggerParameter("设备Id")]string id, byte type, ushort code)
{
try
{
this._deviceService.XA70083(sn, id, type, code);
}
catch (Exception ex)
{
ex.PrintStack();
return ApiResponse.Error(ex.Message);
}
return ApiResponse.AsyncSuccess();
}
[SwaggerOperation("版本")]
[HttpGet]
[Route("/ir/control")]
public ApiResponse IRControl([SwaggerParameter("网关Id")]string sn, [SwaggerParameter("设备Id")]string id, int power, int pattern, int temperature, int direction, int wind)
{
try
{
var keyCode = power == 1 ? 1 : power + pattern + temperature + direction + wind;
this._deviceService.XA70082(sn, id, 0x01, (ushort)keyCode);
}
catch (Exception ex)
{
ex.PrintStack();
return ApiResponse.Error(ex.Message);
}
return ApiResponse.AsyncSuccess();
}
#endregion IR
#region tools
private string GetApiJson(string prefix)
{
var url = new UriBuilder
{
Host = Request.Host.Host,
Port = Request.Host.Port ?? 80,
Path = "/swagger/v1/swagger.json"
}.ToString();
var hc = this._httpClientFactory.CreateClient();
var result = hc.GetStringAsync(url).Result;
var json = JsonConvert.DeserializeObject(result) as JObject;
var paths = json.Properties().FirstOrDefault(o => o.Name == "paths").Value as JObject;
var names = paths.Properties().Select(o => o.Name).ToList();
foreach (var item in names)
{
if (!item.StartsWith(prefix))
{
paths.Remove(item);
}
}
var realResult = JsonConvert.SerializeObject(json);
return realResult;
}
#endregion tools
}
}

@ -1,128 +0,0 @@
using Application.Models;
using IoT.Shared.Controllers;
using Microsoft.AspNetCore.Mvc;
using Swashbuckle.AspNetCore.Annotations;
using System;
namespace FBeeService.Controllers
{
[SwaggerTag("红外转发器")]
public class IrController : BaseDeviceController
{
private readonly DeviceService _deviceService;
public IrController(IServiceProvider applicationServices, DeviceService deviceService) : base(applicationServices)
{
this._deviceService = deviceService;
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse Send([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number, [SwaggerParameter("按键类型")]byte type, [SwaggerParameter("键值")]ushort code)
{
return this.AsyncAction(() =>
{
this._deviceService.XA70082(gateway, number, type, code);
});
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse Study([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number, [SwaggerParameter("按键类型")]byte type, [SwaggerParameter("键值")]ushort code)
{
return this.AsyncAction(() =>
{
this._deviceService.XA70083(gateway, number, type, code);
});
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse KeyCodeType1On([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number)
{
return this.AsyncAction(() =>
{
this._deviceService.SetKeyCodeType(gateway, number, "KeyCodeType1", "开");
});
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse KeyCodeType1Off([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number)
{
return this.AsyncAction(() =>
{
this._deviceService.SetKeyCodeType(gateway, number, "KeyCodeType1", "关");
});
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse KeyCodeType2On([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number)
{
return this.AsyncAction(() =>
{
this._deviceService.SetKeyCodeType(gateway, number, "KeyCodeType2", "开");
});
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse KeyCodeType2Off([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number)
{
return this.AsyncAction(() =>
{
this._deviceService.SetKeyCodeType(gateway, number, "KeyCodeType2", "关");
});
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse KeyCodeType3On([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number)
{
return this.AsyncAction(() =>
{
this._deviceService.SetKeyCodeType(gateway, number, "KeyCodeType3", "开");
});
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse KeyCodeType3Off([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number)
{
return this.AsyncAction(() =>
{
this._deviceService.SetKeyCodeType(gateway, number, "KeyCodeType3", "关");
});
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse KeyCodeType4On([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number)
{
return this.AsyncAction(() =>
{
this._deviceService.SetKeyCodeType(gateway, number, "KeyCodeType4", "开");
});
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse KeyCodeType4Off([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number)
{
return this.AsyncAction(() =>
{
this._deviceService.SetKeyCodeType(gateway, number, "KeyCodeType4", "关");
});
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse KeyCodeType5On([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number)
{
return this.AsyncAction(() =>
{
this._deviceService.SetKeyCodeType(gateway, number, "KeyCodeType5", "开");
});
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse KeyCodeType5Off([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number)
{
return this.AsyncAction(() =>
{
this._deviceService.SetKeyCodeType(gateway, number, "KeyCodeType5", "关");
});
}
}
}

@ -1,13 +0,0 @@
using Swashbuckle.AspNetCore.Annotations;
using System;
namespace FBeeService.Controllers
{
[SwaggerTag("1路插座")]
public class SocketController : SwitchController
{
public SocketController(IServiceProvider applicationService, DeviceService deviceService) : base(applicationService, deviceService)
{
}
}
}

@ -1,75 +0,0 @@
using Application.Models;
using IoT.Shared.Controllers;
using Microsoft.AspNetCore.Mvc;
using Swashbuckle.AspNetCore.Annotations;
using System;
namespace FBeeService.Controllers
{
[SwaggerTag("2路开关")]
public class Switch2Controller : BaseDeviceController
{
private readonly DeviceService _deviceService;
public Switch2Controller(IServiceProvider applicationServices, DeviceService deviceService) : base(applicationServices)
{
this._deviceService = deviceService;
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse On([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number)
{
return this.AsyncAction(() =>
{
this._deviceService.X82(gateway, number, 1, 0x10);
this._deviceService.X82(gateway, number, 1, 0x11);
});
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse Off([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number)
{
return this.AsyncAction(() =>
{
this._deviceService.X82(gateway, number, 0, 0x10);
this._deviceService.X82(gateway, number, 0, 0x11);
});
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("L1")]
public ApiResponse L1On([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number)
{
return this.AsyncAction(() =>
{
this._deviceService.X82(gateway, number, 1, 0x10);
});
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("L1")]
public ApiResponse L1Off([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number)
{
return this.AsyncAction(() =>
{
this._deviceService.X82(gateway, number, 0, 0x10);
});
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("L2")]
public ApiResponse L2On([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number)
{
return this.AsyncAction(() =>
{
this._deviceService.X82(gateway, number, 1, 0x11);
});
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("L2")]
public ApiResponse L2Off([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number)
{
return this.AsyncAction(() =>
{
this._deviceService.X82(gateway, number, 0, 0x11);
});
}
}
}

@ -1,95 +0,0 @@
using Application.Models;
using IoT.Shared.Controllers;
using Microsoft.AspNetCore.Mvc;
using Swashbuckle.AspNetCore.Annotations;
using System;
namespace FBeeService.Controllers
{
[SwaggerTag("3路开关")]
public class Switch3Controller : BaseDeviceController
{
private readonly DeviceService _deviceService;
public Switch3Controller(IServiceProvider applicationServices, DeviceService deviceService) : base(applicationServices)
{
this._deviceService = deviceService;
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse On([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number)
{
return this.AsyncAction(() =>
{
this._deviceService.X82(gateway, number, 1, 0x10);
this._deviceService.X82(gateway, number, 1, 0x11);
this._deviceService.X82(gateway, number, 1, 0x12);
});
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse Off([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number)
{
return this.AsyncAction(() =>
{
this._deviceService.X82(gateway, number, 0, 0x10);
this._deviceService.X82(gateway, number, 0, 0x11);
this._deviceService.X82(gateway, number, 0, 0x12);
});
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("L1")]
public ApiResponse L1On([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number)
{
return this.AsyncAction(() =>
{
this._deviceService.X82(gateway, number, 1, 0x10);
});
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("L1")]
public ApiResponse L1Off([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number)
{
return this.AsyncAction(() =>
{
this._deviceService.X82(gateway, number, 0, 0x10);
});
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("L2")]
public ApiResponse L2On([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number)
{
return this.AsyncAction(() =>
{
this._deviceService.X82(gateway, number, 1, 0x11);
});
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("L2")]
public ApiResponse L2Off([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number)
{
return this.AsyncAction(() =>
{
this._deviceService.X82(gateway, number, 0, 0x11);
});
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("L3")]
public ApiResponse L3On([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number)
{
return this.AsyncAction(() =>
{
this._deviceService.X82(gateway, number, 1, 0x12);
});
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("L3")]
public ApiResponse L3Off([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number)
{
return this.AsyncAction(() =>
{
this._deviceService.X82(gateway, number, 0, 0x12);
});
}
}
}

@ -1,37 +0,0 @@
using Application.Models;
using IoT.Shared.Controllers;
using Microsoft.AspNetCore.Mvc;
using Swashbuckle.AspNetCore.Annotations;
using System;
namespace FBeeService.Controllers
{
[SwaggerTag("1路开关")]
public class SwitchController : BaseDeviceController
{
private readonly DeviceService _deviceService;
public SwitchController(IServiceProvider applicationServices, DeviceService deviceService) : base(applicationServices)
{
this._deviceService = deviceService;
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse On([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number)
{
return this.AsyncAction(() =>
{
this._deviceService.X82(gateway, number, 1);
});
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse Off([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number)
{
return this.AsyncAction(() =>
{
this._deviceService.X82(gateway, number, 0);
});
}
}
}

@ -1,20 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<RootNamespace>FBeeService</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Polly" Version="7.1.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="4.0.1" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="4.0.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Infrastructure\Infrastructure.csproj" />
<ProjectReference Include="..\..\IoT.Shared\IoT.Shared.csproj" />
</ItemGroup>
</Project>

@ -1,43 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28010.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FBeeService", "FBeeService.csproj", "{E25B755D-0074-481F-847B-8D45B33C65A7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Infrastructure", "..\..\..\..\Infrastructure\Infrastructure\src\Infrastructure\Infrastructure.csproj", "{6DC05FAD-C2E7-4C7F-B376-3BEFE56439B9}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IoT.Shared", "..\..\Libraries\src\IoT.Shared\IoT.Shared.csproj", "{8572A0E0-E4E3-466D-8116-5F686040C66D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IoT.UI.Shard", "..\..\Libraries\src\IoT.UI.Shard\IoT.UI.Shard.csproj", "{4D947053-F0FF-4F5B-8E33-CE474BDF0621}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E25B755D-0074-481F-847B-8D45B33C65A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E25B755D-0074-481F-847B-8D45B33C65A7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E25B755D-0074-481F-847B-8D45B33C65A7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E25B755D-0074-481F-847B-8D45B33C65A7}.Release|Any CPU.Build.0 = Release|Any CPU
{6DC05FAD-C2E7-4C7F-B376-3BEFE56439B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6DC05FAD-C2E7-4C7F-B376-3BEFE56439B9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6DC05FAD-C2E7-4C7F-B376-3BEFE56439B9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6DC05FAD-C2E7-4C7F-B376-3BEFE56439B9}.Release|Any CPU.Build.0 = Release|Any CPU
{8572A0E0-E4E3-466D-8116-5F686040C66D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8572A0E0-E4E3-466D-8116-5F686040C66D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8572A0E0-E4E3-466D-8116-5F686040C66D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8572A0E0-E4E3-466D-8116-5F686040C66D}.Release|Any CPU.Build.0 = Release|Any CPU
{4D947053-F0FF-4F5B-8E33-CE474BDF0621}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4D947053-F0FF-4F5B-8E33-CE474BDF0621}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4D947053-F0FF-4F5B-8E33-CE474BDF0621}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4D947053-F0FF-4F5B-8E33-CE474BDF0621}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B5A82048-F0E0-4FA7-9954-E5983781CAAC}
EndGlobalSection
EndGlobal

@ -1,105 +0,0 @@
//using Application.Domain.Entities;
//using Infrastructure.Data;
//using Infrastructure.Extensions;
//using IoT.Shared.Infrastructure;
//using Microsoft.AspNetCore.SignalR.Client;
//using Microsoft.EntityFrameworkCore;
//using Microsoft.Extensions.Configuration;
//using Microsoft.Extensions.DependencyInjection;
//using System;
//using System.Linq;
//using System.Net.Http;
//using System.Threading.Tasks;
//namespace FBeeService
//{
// public class ClientService : BaseClientService
// {
// public ClientService(IServiceProvider applicationServices, IConfiguration configuration) : base(applicationServices, configuration)
// {
// }
// public override void OnConnected()
// {
// using (var scope = this.applicationServices.CreateScope())
// {
// var deviceInfoRepo = scope.ServiceProvider.GetService<IRepository<DeviceInfo>>();
// var deviceInfos = deviceInfoRepo.ReadOnlyTable().ToList();
// foreach (var deviceInfo in deviceInfos)
// {
// this.SendDeviceInfo(deviceInfo);
// }
// var deviceRepo = scope.ServiceProvider.GetService<IRepository<Device>>();
// var devices = deviceRepo.ReadOnlyTable().Include(o => o.Data).ToList();
// foreach (var device in devices)
// {
// this.SendDevice(device);
// }
// }
// }
// public override void OnServerToClient(string method, string message, string fromConnectionId)
// {
// if (method == "GetDeviceInfo")
// {
// var infoNumber = message;
// using (var scope = this.applicationServices.CreateScope())
// {
// var deviceInfoRepo = scope.ServiceProvider.GetService<IRepository<DeviceInfo>>();
// var deviceInfo = deviceInfoRepo.ReadOnlyTable().FirstOrDefault(o => o.Number == infoNumber);
// if (deviceInfo == null)
// {
// throw new Exception($"not has infoNumber:{infoNumber}");
// }
// this.SendDeviceInfo(deviceInfo);
// }
// }
// else if (method == "CallDeviceMethod")
// {
// using (var scope = this.applicationServices.CreateScope())
// {
// var serviceProvider = scope.ServiceProvider;
// var cfg = serviceProvider.GetService<IConfiguration>();
// var port = cfg["server.urls"].Split(':')[2];
// var url = $"http://localhost:{port}{message}";
// var httpClient = serviceProvider.GetService<IHttpClientFactory>().CreateClient();
// var result = httpClient.GetStringAsync(url).Result;
// this.Connection.SendAsync("ClientToServer", "ApiCallback", result, cfg["connectId"]);
// }
// }
// }
// public void SendDevice(Device device)
// {
// Task.Run(() =>
// {
// try
// {
// Console.WriteLine("send device to server");
// this.ClientToServer("UpdateDevice", device.ToJson());
// }
// catch (Exception ex)
// {
// ex.PrintStack();
// }
// });
// }
// public void SendDeviceInfo(DeviceInfo deviceInfo)
// {
// Task.Run(() =>
// {
// try
// {
// Console.WriteLine("send device to server");
// this.ClientToServer("UpdateDeviceInfo", deviceInfo.ToJson());
// }
// catch (Exception ex)
// {
// ex.PrintStack();
// }
// });
// }
// }
//}

@ -1,34 +0,0 @@
namespace FBeeService
{
public static class Keys
{
public const string DeviceId = "DeviceId";
public const string Address = "Address";
public const string EndPoint = "EndPoint";
public const string Version = "Version";
public const string Electricity = "Electricity";
public const string KeyPress = "KeyPress";
public const string State = "State";
public const string L1State = "L1State";
public const string L2State = "L2State";
public const string L3State = "L3State";
public const string Battery = "Battery";
public const string EndPointCount = "EndPointCount";
public const string Data = "Data";
public const string ZoneType = "ZoneType";
public const string Brightness = "Brightness";
public const string Hue = "Hue";
public const string Saturation = "Saturation";
public const string ColorTemperature = "ColorTemperature";
public const string Light = "Light";
public const string Warning = "Warning";
public const string UnderVoltage = "UnderVoltage";
public const string PM25 = "PM25";
public const string PM100 = "PM100";
public const string PM10 = "PM10";
public const string Temperature = "Temperature";
public const string Humidity = "Humidity";
public const string Voltage = "Voltage";
public const string DeviceCount = "DeviceCount";
}
}

@ -1,41 +0,0 @@
using System;
using System.Collections.Generic;
using Infrastructure.Application;
using Infrastructure.Configuration;
using Infrastructure.Extensions;
using Infrastructure.Web.Hosting;
using Microsoft.AspNetCore;
namespace FBeeService
{
public class Program
{
public static void Main(string[] args)
{
var host = "localhost";
WebHost.CreateDefaultBuilder(args)
.Run<Startup>(new List<EFConfigurationValue> {
new EFConfigurationValue { Id = "openapi.name", Value= "v1" },
new EFConfigurationValue { Id = "openapi.title", Value= "fbee api" },
new EFConfigurationValue { Id = "openapi.version", Value= "1.0" },
new EFConfigurationValue { Id = "security:key", Value= "111111111111111111111111"},
new EFConfigurationValue { Id = "security:iv", Value= "11111111"},
new EFConfigurationValue { Id = "email:host", Value= "nbaxp.com"},
new EFConfigurationValue { Id = "email:port", Value= "25"},
new EFConfigurationValue { Id = "email:user", Value= "admin@nbaxp.com"},
new EFConfigurationValue { Id = "email:password", Value= "aA123456"},
new EFConfigurationValue { Id = "server.ip", Value= "" },
new EFConfigurationValue { Id = "server.urls", Value= "http://*:8009" },
new EFConfigurationValue { Id = "notify:enabled", Value= "false"},
new EFConfigurationValue { Id = "notify:host", Value= $"{host}:8001"},
new EFConfigurationValue { Id = "timer.seconds", Value="600"},
new EFConfigurationValue { Id = "connectId", Value= Guid.NewGuid().ToBase62() },
new EFConfigurationValue { Id = "node.number", Value= "所属节点编号" },
//
new EFConfigurationValue { Id = "name", Value= "FBeeService服务"},
new EFConfigurationValue { Id = "logo", Value= "/images/logo.png",Type= InputType.ImageUrl},
new EFConfigurationValue { Id = "copyright", Value= "Copyright © {now} Company. All rights reserved",Type= InputType.Html}
});
}
}
}

@ -1,27 +0,0 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:8009/",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"OnvifService": {
"commandName": "Project",
"launchBrowser": true,
"applicationUrl": "http://127.0.0.1:8009/",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

@ -1,31 +0,0 @@
using IoT.Shared.Infrastructure;
using IoT.UI.Shard;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
namespace FBeeService
{
public class Startup : IoTServiceStartup
{
public Startup(IConfiguration configuration, IHostingEnvironment env) : base(configuration, env)
{
}
public override void ConfigureServices(IServiceCollection services)
{
services.AddSingleton<ClientService>();
services.AddSingleton<DeviceService>();
base.ConfigureServices(services);
}
public override void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
base.Configure(app, env, loggerFactory);
app.ApplicationServices.GetService<DeviceService>().Start();
app.ApplicationServices.GetService<ClientService>().Start();
}
}
}

@ -1,222 +0,0 @@
@model List<Device>
@{
this.HtmlTitle = "设备列表";
var index = 0;
}
<div class="box">
<table class="table table-bordered">
<tr>
<th></th>
<th>编号</th>
<th>名称</th>
<th>类别</th>
<th>地址</th>
<th>电量</th>
<th>在线状态</th>
<th>设备状态</th>
<th>连接Id</th>
<th>操作</th>
<th>删除</th>
</tr>
@foreach (var item in Model)
{
var deviceId = Convert.ToInt32(item.Data.FirstOrDefault(o => o.Key == "DeviceId").Value);
var address = item.Data.FirstOrDefault(o => o.Key == "Address").Value;
var voltage = item.Data.FirstOrDefault(o => o.Key == "Voltage")?.Value;
var state = item.Data.FirstOrDefault(o => o.Key == "State")?.Value;
var battery = item.Data.FirstOrDefault(o => o.Key == "Battery")?.Value;
<tr>
<th>@(++index)</th>
<td>@item.Number</td>
<td>@item.Name</td>
<td>@deviceId</td>
<td>@address</td>
<td>@voltage/@battery</td>
<td>@Html.DisplayFor(o => item.IsOnline)</td>
<td>
@if (new int[] { 0x0002, 0x0009, 0x0081, 0x0202, 0x0220, 0x0051 }.Contains(deviceId))
{
<text>@state</text>
}
@if (deviceId == 0x0106)
{
<text>@item.Data.FirstOrDefault(o => o.Key == "Light")?.Value</text>
}
else if (deviceId == 0x0402)
{
<text>@item.Data.FirstOrDefault(o => o.Key == "Warning")?.Value</text>
}
else if (deviceId == 0x0309)
{
<span>温度:@item.Data.FirstOrDefault(o => o.Key == "Temperature")?.Value</span>
<span>湿度:@item.Data.FirstOrDefault(o => o.Key == "Humidity")?.Value</span>
<br />
<span>PM 1.0@item.Data.FirstOrDefault(o => o.Key == "PM10")?.Value</span>
<span>PM 2.5@item.Data.FirstOrDefault(o => o.Key == "PM25")?.Value</span>
<span>PM 10@item.Data.FirstOrDefault(o => o.Key == "PM100")?.Value</span>
}
else if (deviceId == 0x0302)
{
<span>温度:@item.Data.FirstOrDefault(o => o.Key == "Temperature")?.Value</span>
<span>湿度:@item.Data.FirstOrDefault(o => o.Key == "Humidity")?.Value</span>
}
else if (deviceId == 0x0220)
{
<span>亮度:@item.Data.FirstOrDefault(o => o.Key == "Brightness")?.Value</span>
<br />
<span>色调: @item.Data.FirstOrDefault(o => o.Key == "Hue")?.Value</span>
<span>饱和度: @item.Data.FirstOrDefault(o => o.Key == "Saturation")?.Value</span>
<br />
<span>色温:@item.Data.FirstOrDefault(o => o.Key == "ColorTemperature")?.Value</span>
}
else if (deviceId == 0x0163)
{
var version = item.Data.FirstOrDefault(o => o.Key == "Version")?.Value;
if (!string.IsNullOrEmpty(version))
{
<span>版本:@version</span>
}
}
else if (deviceId == 0x0051)
{
var electricity = item.Data.FirstOrDefault(o => o.Key == "Electricity")?.Value;
if (!string.IsNullOrEmpty(electricity))
{
<span>电量:@electricity</span>
}
}
</td>
<td>@item.ConnectId</td>
<td>
@if (new int[] { 0x0002, 0x0009, 0x0081, 0x0202, 0x0220, 0x0051 }.Contains(deviceId))
{
<a class="btn btn-primary cmd" href="/api/x82?sn=@item.GatewayNumber&ieee=@item.Number&status=1">开</a>
<a class="btn btn-primary cmd" href="/api/x82?sn=@item.GatewayNumber&ieee=@item.Number&status=0">关</a>
}
@if (deviceId == 0x0202)
{
<a class="btn btn-primary cmd" href="/api/x82?sn=@item.GatewayNumber&ieee=@item.Number&status=2">停</a>
}
@if (deviceId == 0x0163)
{
<a class="btn btn-primary cmd" href="/ir/version?sn=@item.GatewayNumber&id=@item.Number">版本</a>
}
@if (deviceId == 0x0220)
{
<form action="/colorlight/23setbrightness">
<input type="hidden" name="sn" value="@item.GatewayNumber" />
<input type="hidden" name="id" value="@item.Number" />
<label>亮度:<input name="Brightness" type="range" step="1" min="0" max="255" value="@item.Data.FirstOrDefault(o => o.Key == "Brightness")?.Value" class="ajax" /></label>
</form>
<form action="/colorlight/24setcolor">
<input type="hidden" name="sn" value="@item.GatewayNumber" />
<input type="hidden" name="id" value="@item.Number" />
<label>色度:<input name="Hue" type="range" step="1" min="0" max="255" value="@item.Data.FirstOrDefault(o => o.Key == "Hue")?.Value" class="ajax" /></label>
<label>饱和度:<input name="Saturation" type="range" step="1" min="0" max="255" value="@item.Data.FirstOrDefault(o => o.Key == "Saturation")?.Value" class="ajax" /></label>
</form>
<form action="/colorlight/25setcolortemperature">
<input type="hidden" name="sn" value="@item.GatewayNumber" />
<input type="hidden" name="id" value="@item.Number" />
<label>色温:<input name="ColorTemperature" type="range" step="1" min="2700" max="6500" value="@item.Data.FirstOrDefault(o => o.Key == "ColorTemperature")?.Value" class="ajax" /></label>
</form>
}
@if (deviceId == 0x0163)
{
<h2>发射:</h2>
<form action="/ir/test">
<input type="hidden" name="sn" value="@item.GatewayNumber" />
<input type="hidden" name="id" value="@item.Number" />
<label>设备类型:</label><select name="type">
<option value="1">空调</option>
<option value="2">电视</option>
<option value="3">机顶盒</option>
<option value="4">DVD</option>
<option value="5">其他</option>
</select>
<label>按键值:</label><input type="text" name="code" class="ajax" />
</form>
<h2>空调:</h2>
<form action="/ir/control">
<input type="hidden" name="sn" value="@item.GatewayNumber" />
<input type="hidden" name="id" value="@item.Number" />
<fieldset>
<legend>开关:</legend>
<label>开:<input name="power" type="radio" value="2" class="ajax" /></label>
<label>关:<input name="power" type="radio" value="1" class="ajax" /></label>
</fieldset>
<fieldset>
<legend>模式</legend>
<label>制冷:<input name="pattern" type="radio" value="0" class="ajax" /></label>
<label>自动:<input name="pattern" type="radio" value="120" class="ajax" /></label>
<label>制热:<input name="pattern" type="radio" value="240" class="ajax" /></label>
<label>抽湿:<input name="pattern" type="radio" value="360" class="ajax" /></label>
<label>送风:<input name="pattern" type="radio" value="480" class="ajax" /></label>
</fieldset>
<fieldset>
<label>温度:<input name="temperature" type="range" step="1" min="1" max="15" value="1" class="ajax" /></label>
</fieldset>
<fieldset>
<legend>风向</legend>
<label>任意:<input name="direction" type="radio" value="0" class="ajax" /></label>
<label>手动:<input name="direction" type="radio" value="60" class="ajax" /></label>
<label>自动:<input name="direction" type="radio" value="75" class="ajax" /></label>
</fieldset>
<fieldset>
<legend>风量</legend>
<label>自动:<input name="wind" type="radio" value="0" class="ajax" /></label>
<label>高:<input name="wind" type="radio" value="15" class="ajax" /></label>
<label>中:<input name="wind" type="radio" value="30" class="ajax" /></label>
<label>低:<input name="wind" type="radio" value="45" class="ajax" /></label>
</fieldset>
</form>
<h2>电视:</h2>
<form action="/ir/test">
<input type="hidden" name="sn" value="@item.GatewayNumber" />
<input type="hidden" name="id" value="@item.Number" />
<input type="hidden" name="type" value="2" />
@{
var tvKeys = new string[] { "POWR","AV","1","2","3","4","5","6","7","8","9","0",
"返回","退出","静音","菜单","音量+","音量-","上","下","左","右",
"OK","CH+>>|","CH-|<<","快退","快进","录像","暂停","停止","红","绿","黄","蓝",
"自定义","自定义","自定义","自定义","自定义","自定义","自定义","自定义"};
}
@for (int i = 0; i < tvKeys.Length; i++)
{
<label>@tvKeys[i]:@(i + 1)<input name="code" type="radio" value="@(i+1)" class="ajax" /></label>
@if (i % 5 == 0)
{
<br />
}
}
</form>
<h2>学习:</h2>
<form action="/ir/study">
<input type="hidden" name="sn" value="@item.GatewayNumber" />
<input type="hidden" name="id" value="@item.Number" />
<input type="hidden" name="type" value="5" />
<label>按键值:</label><input min="511" max="610" type="text" name="code" class="ajax" />
</form>
}
</td>
<td><a class="btn btn-primary cmd" href="/api/x95?sn=@item.GatewayNumber&ieee=@item.Number">删除设备</a></td>
</tr>
}
</table>
</div>
@section scripts{
<script>
$('body').on('change', '.ajax', function () {
var form = $(this).parents('form');
var url = form.attr('action') + '?' + form.serialize();
$.getJSON(url, function (response) {
console.log(response);
}).fail(function (jqxhr, textStatus, error) {
var err = textStatus + ", " + error;
alert(err);
});
return false;
});
</script>
}

@ -1,33 +0,0 @@
@model List<Device>
@{
ViewBag.HideBread = true;
}
<div class="box">
<a class="btn btn-primary cmd" href="/Gateway/Refresh">查询所有网关</a>
</div>
<div class="box">
<table class="table table-bordered">
<tr>
<th>编号</th>
<th>Ip地址</th>
<th>启用</th>
<th>用户名</th>
<th>密码</th>
<th>查询网关设备</th>
<th>查看</th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>@item.Number</td>
<td>@item.Ip</td>
<td>@Html.DisplayFor(o => item.Enable)</td>
<td>@item.UserName</td>
<td>@item.Password</td>
<td><a class="btn btn-primary cmd" href="/Gateway/X9d?gateway=@item.Number">查询网关信息</a></td>
<td><a class="btn btn-primary cmd" href="/Gateway/X81?gateway=@item.Number">查询网关设备</a></td>
<td><a href="/Home/Gateway?sn=@item.Number">查看设备</a></td>
</tr>
}
</table>
</div>

@ -1,26 +0,0 @@
<ul class="nav navbar-nav">
<li class="@GetClass("Home")">
<a href="@Url.Action("Index","Home")">
首页
</a>
</li>
<li>
<a href="/swagger/index.html">
Open API
</a>
</li>
</ul>
@functions{
public string GetClass(params string[] controllers)
{
if (controllers.Select(o => o.ToLower()).Contains(this.ViewContext.RouteData.Values["controller"].ToString().ToLower()))
{
if (controllers.Length > 1)
{
return "active open";
}
return "active";
}
return "";
}
}

@ -1,11 +0,0 @@
@inherits Infrastructure.Web.Mvc.Razor.MyRazorPage<TModel>
@using Microsoft.Extensions.Configuration
@using System.ComponentModel.DataAnnotations
@using Infrastructure.Application
@using Infrastructure.Web
@using Infrastructure.Web.DataAnnotations
@using Infrastructure.Extensions
@using Infrastructure.Data
@using Application.Domain.Entities
@using Application.Models
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

@ -1,10 +0,0 @@
{
"Logging": {
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
},
"UseMiniProfiler": false
}.

@ -1,17 +0,0 @@
{
"version": "1.0.0-beta.108",
"Logging": {
"LogLevel": {
"Default": "Information"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"database.mysql.connection": "Server=127.0.0.1;Port=3306;Database=data;Uid=root;Pwd=root;",
"database.sqlite.connection": "Data Source=data.db"
},
"AppSettings": {
"database": "sqlite",
"UseCookieSessionStore": false
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

@ -1,16 +0,0 @@
*.bak
*.suo
*.db
*.user
.vs
obj
Obj
bin
Bin
debug
Debug
release
Release
Logs
logs
node_modules

@ -1,70 +0,0 @@
using Infrastructure.Application;
using System.ComponentModel.DataAnnotations;
namespace ONVIFService.Applicaiton.Models
{
[Display(Name = "摄像头")]
public class EditCameraModel : EditModel
{
[Required]
[Display(Name = "编号")]
public string Number { get; set; }
[Required]
[Display(Name = "设备地址")]
public string DeviceUrl { get; set; }
[Required]
[Display(Name = "码流")]
public string Profiles { get; set; }
[Display(Name = "流地址")]
public string StreamUri { get; set; }
[Display(Name = "截图地址")]
public string SnapshotUri { get; set; }
[Display(Name = "控制台地址")]
public string PtzAddress { get; set; }
[Display(Name = "缩放支持")]
public bool Ptz3DZoomSupport { get; set; }
[Display(Name = "需验证")]
public bool NeedAuth { get; set; }
[Display(Name = "已验证")]
public bool HasAuth { get; set; }
[Display(Name = "用户名")]
public string UserName { get; set; }
[Display(Name = "密码")]
public string Password { get; set; }
public string Rtmp1 { get; set; }
public string Flv1 { get; set; }
public string Hls1 { get; set; }
public string Rtmp2 { get; set; }
public string Flv2 { get; set; }
public string Hls2 { get; set; }
[Display(Name = "启用")]
public bool Enabled { get; set; }
[Display(Name = "推流")]
public bool Publish { get; set; }
[Display(Name = "自定义参数")]
public bool UseCustomArguments { get; set; }
[Display(Name = "自定义参数")]
public string Arguments { get; set; }
[Display(Name = "自定义ffmpeg")]
public bool UseCustomFile { get; set; }
[Display(Name = "ffmpeg")]
public string File { get; set; }
}
}

@ -1,33 +0,0 @@
using System.Linq;
using Application.Domain.Entities;
using Application.Models;
using Infrastructure.Data;
using Infrastructure.Extensions;
using Infrastructure.Web.Mvc;
using IoTShared.Controllers;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace IoTCenter.Areas.Admin.Controllers
{
[Authorize]
[Area(nameof(Admin))]
public class DataController : CrudController<Data, DataSearchModel, EditDataModel, EditDataModel>
{
private readonly AjaxController _ajax;
public DataController(IRepository<Data> repo, AjaxController ajax) : base(repo)
{
this._ajax = ajax;
}
public override IQueryable<Data> Query(DataSearchModel model, IQueryable<Data> query)
{
ViewData.SelectList(o => model.NodeId, () => this._ajax.GetNodeSelectList(model.NodeId));
ViewData.SelectList(o => model.DeviceId, () => this._ajax.GetDeviceSelectList(model.NodeId.Value, model.DeviceId), model.NodeId.HasValue);
return query.WhereIf(model.NodeId.HasValue, o => o.Device.NodeId == model.NodeId.Value)
.WhereIf(model.DeviceId.HasValue, o => o.DeviceId == model.DeviceId.Value)
.WhereIf(!string.IsNullOrEmpty(model.Keyword), o => o.Name.Contains(model.Keyword));
}
}
}

@ -1,18 +0,0 @@
using Application.Domain.Entities;
using Application.Models;
using Infrastructure.Data;
using Infrastructure.Web.Mvc;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace IoTCenter.Areas.Admin.Controllers
{
[Authorize]
[Area(nameof(Admin))]
public class DeviceController : CrudController<Device, DeviceSearchMode, EditDeviceModel, EditDeviceModel>
{
public DeviceController(IRepository<Device> repo) : base(repo)
{
}
}
}

@ -1,19 +0,0 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace UserCenter.Areas.Admin.Controllers
{
[Authorize]
[Area(nameof(Admin))]
public class HomeController : Controller
{
public HomeController()
{
}
public IActionResult Index()
{
return View();
}
}
}

@ -1,4 +0,0 @@
@{
ViewData["IsHomePage"] = true;
}
<h1>首页</h1>

@ -1,52 +0,0 @@
<section class="sidebar" style="height: auto;">
<ul class="sidebar-menu" data-widget="tree">
<li class="@GetClass("Home")"><a href="@Url.Action("Index","Home")"><i class="fa fa-circle-o"></i><span>首页</span></a></li>
<li class="@GetClass("Configuration")"><a href="@Url.Action("Index","Configuration")"><i class="fa fa-circle-o"></i><span>网站配置</span></a></li>
<li class="treeview @GetClass("User","Role","Permission")">
<a href="javascript:;" class="dropdown-toggle">
<i class="fa fa-list"></i>
<span>权限管理</span>
<span class="pull-right-container">
<i class="fa fa-angle-left pull-right"></i>
</span>
</a>
<ul class="treeview-menu">
<li class="@GetClass("User")"><a href="@Url.Action("Index","User")"><i class="fa fa-circle-o"></i><span>用户管理</span></a></li>
<li class="@GetClass("Role")"><a href="@Url.Action("Index","Role")"><i class="fa fa-circle-o"></i><span>角色管理</span></a></li>
<li class="@GetClass("Permission")"><a href="@Url.Action("Index","Permission")"><i class="fa fa-circle-o"></i><span>权限管理</span></a></li>
</ul>
</li>
<li class="treeview @GetClass("Node","Device","Data","Api","Parameter","Sence","Command")">
<a href="javascript:;" class="dropdown-toggle">
<i class="fa fa-list"></i>
<span>设备管理</span>
<span class="pull-right-container">
<i class="fa fa-angle-left pull-right"></i>
</span>
</a>
<ul class="treeview-menu">
<li class="@GetClass("Node")"><a href="@Url.Action("Index","Node")"><i class="fa fa-circle-o"></i><span>节点管理</span></a></li>
<li class="@GetClass("Device")"><a href="@Url.Action("Index","Device")"><i class="fa fa-circle-o"></i><span>设备管理</span></a></li>
<li class="@GetClass("Data")"><a href="@Url.Action("Index","Data")"><i class="fa fa-circle-o"></i><span>数据管理</span></a></li>
<li class="@GetClass("Api")"><a href="@Url.Action("Index","Api")"><i class="fa fa-circle-o"></i><span>接口管理</span></a></li>
<li class="@GetClass("Parameter")"><a href="@Url.Action("Index","Parameter")"><i class="fa fa-circle-o"></i><span>参数管理</span></a></li>
<li class="@GetClass("Sence")"><a href="@Url.Action("Index","Sence")"><i class="fa fa-circle-o"></i><span>场景管理</span></a></li>
<li class="@GetClass("Command")"><a href="@Url.Action("Index","Command")"><i class="fa fa-circle-o"></i><span>命令管理</span></a></li>
</ul>
</li>
</ul>
</section>
@functions{
public string GetClass(params string[] controllers)
{
if (controllers.Select(o => o.ToLower()).Contains(this.ViewContext.RouteData.Values["controller"].ToString().ToLower()))
{
if (controllers.Length > 1)
{
return "active open";
}
return "active";
}
return "";
}
}

@ -1,24 +0,0 @@
<script>
function clear() {
for (var i = 0; i < arguments.length; i++) {
$(arguments[i]).find('option').not('[value=""]').remove();
}
}
function update(url, id) {
$.getJSON(url, function (data) {
$.each(data, function (i, v) {
$(id).append('<option value="' + v.Value + '">' + v.Text + '</option>');
});
});
}
$(function () {
$('#NodeId').change(function () {
var id = $(this).find(':selected').val();
clear('#DeviceId');
if (id) {
var url = '@Url.Action("GetDeviceJson", "Ajax")?parentId=' + encodeURI(id);
update(url,'#DeviceId');
}
});
});
</script>

@ -1,7 +0,0 @@
@inherits Infrastructure.Web.Mvc.Razor.MyRazorPage<TModel>
@using Infrastructure.Application
@using Infrastructure.Extensions
@using Infrastructure.Data
@using Application.Domain.Entities
@using Application.Models
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

@ -1,22 +0,0 @@
using Application.Domain.Entities;
using Infrastructure.Data;
using Infrastructure.Email;
using Infrastructure.Resources;
using Infrastructure.Security;
using IoT.UI.Shard.Controllers;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Localization;
namespace ONVIFService.Controllers
{
public class AccountController : BaseAccountController
{
public AccountController(IConfiguration configuration,
IRepository<User> userRepo,
IEncryptionService encryptionService,
IStringLocalizer<Resource> localizer,
IEmailSender emaliSender) : base(configuration, userRepo, encryptionService, localizer, emaliSender)
{
}
}
}

@ -1,91 +0,0 @@
using Application.Models;
using IoT.Shared.Controllers;
using Microsoft.AspNetCore.Mvc;
using Swashbuckle.AspNetCore.Annotations;
using System;
namespace ONVIFService.Controllers
{
[SwaggerTag("摄像头")]
public class CameraController : BaseDeviceController
{
private readonly DeviceService _deviceService;
public CameraController(IServiceProvider applicationServices, DeviceService deviceService) : base(applicationServices)
{
this._deviceService = deviceService;
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse ScreenShot([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number)
{
return this.AsyncAction(() =>
{
this._deviceService.ScreenShot(number);
});
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse Up([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number)
{
return this.AsyncAction(() =>
{
this._deviceService.Up(number, 0.5f);
});
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse Down([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number)
{
return this.AsyncAction(() =>
{
this._deviceService.Down(number, 0.5f);
});
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse Left([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number)
{
return this.AsyncAction(() =>
{
this._deviceService.Left(number, 0.5f);
});
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse Right([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number)
{
return this.AsyncAction(() =>
{
this._deviceService.Right(number, 0.5f);
});
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse Zoomin([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number)
{
return this.AsyncAction(() =>
{
this._deviceService.ZoomIn(number, 0.5f);
});
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse Zoomout([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number)
{
return this.AsyncAction(() =>
{
this._deviceService.ZoomOut(number, 0.5f);
});
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse Stop([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number)
{
return this.AsyncAction(() =>
{
this._deviceService.Stop(number);
});
}
}
}

@ -1,26 +0,0 @@
using Application.Domain.Entities;
using Infrastructure.Data;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using System.Linq;
namespace ONVIFService.Controllers
{
public class HomeController : Controller
{
private readonly IRepository<Device> _cameraRepo;
private readonly DeviceService _onvifService;
public HomeController(DeviceService onvifService, IRepository<Device> cameraRepo)
{
this._cameraRepo = cameraRepo;
this._onvifService = onvifService;
}
public IActionResult Index()
{
var model = this._cameraRepo.ReadOnlyTable().Include(o => o.Data).ToList();
return View(model);
}
}
}

@ -1,518 +0,0 @@
using Application.Domain.Entities;
using Infrastructure.Data;
using Infrastructure.Extensions;
using Infrastructure.Models;
using IoT.Shared.Infrastructure;
using Microsoft.AspNetCore.Hosting;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Concurrent;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
namespace ONVIFService
{
public class DeviceService : BaseDeviceService
{
private readonly ConcurrentDictionary<string, (Device camera, Process local, Process remote)> _list = new ConcurrentDictionary<string, (Device camera, Process local, Process remote)>();
private readonly IHostingEnvironment _env;
private readonly IHttpClientFactory _httpClientFactory;
private readonly IOnvifDeviceManagement _onvifDeviceManagement;
public DeviceService(IServiceProvider applicationServices, IConfiguration configuration, IHostingEnvironment env, IHttpClientFactory httpClientFactory)
: base(applicationServices, configuration)
{
this._env = env;
this._httpClientFactory = httpClientFactory;
this._onvifDeviceManagement = new OnvifDeviceManagement(httpClientFactory);
}
#region impl interface
public override void Execute()
{
Refresh();
}
public override void Stop()
{
try
{
this._tokenSource.Cancel();
foreach (var item in this._list.Keys.ToList())
{
this.Remove(item);
}
}
catch (Exception ex)
{
ex.PrintStack();
}
}
#endregion impl interface
private void Refresh()
{
try
{
Search();
Notify();
}
catch (Exception ex)
{
ex.PrintStack();
}
}
public void Search()
{
try
{
var list = this._onvifDeviceManagement.Discovery();
foreach (var ipCamera in list)
{
if (string.IsNullOrEmpty(ipCamera.Id) || string.IsNullOrEmpty(ipCamera.DeviceUrl))
{
continue;
}
Console.WriteLine(ipCamera.DeviceUrl);
using (var scope = _applicationServices.CreateScope())
{
var deviceInfoNumber = "onvifcamera";
var deviceInfoRepo = scope.ServiceProvider.GetService<IRepository<DeviceInfo>>();
var deviceInfo = deviceInfoRepo.Table().FirstOrDefault(o => o.Number == deviceInfoNumber);
if (deviceInfo == null)
{
deviceInfo = new DeviceInfo
{
Number = deviceInfoNumber,
Name = "ONVIF摄像头",
DeviceType = DeviceType.Gateway,
ApiJson = this.GetApiJson("/Camera/")
};
deviceInfoRepo.Add(deviceInfo);
deviceInfoRepo.SaveChanges();
this.SendDeviceInfo(deviceInfo);
}
var deviceRepo = scope.ServiceProvider.GetService<IRepository<Device>>();
var device = deviceRepo.Table().Include(o => o.Data).FirstOrDefault(o => o.Number == ipCamera.Id);
if (device == null)
{
device = new Device
{
Name = "摄像头",
Number = ipCamera.Id,
Icon = "camera",
CategoryNumber = "10",
InfoNumber = deviceInfoNumber,
InfoId = deviceInfo.Id
};
device.AddorUpdateData("mainrtmp", $"rtmp://{this._configuration["stream.rtmp"]}/live/main{ipCamera.Id}", DeviceDataType.String, "主码流rtmp");
device.AddorUpdateData("mainflv", $"http://{this._configuration["stream.flv"]}/live/main{ipCamera.Id}.flv", DeviceDataType.String, "主码流flv");
device.AddorUpdateData("mainhls", $"http://{this._configuration["stream.hls"]}/live/main{ipCamera.Id}.m3u8", DeviceDataType.String, "主码流hls");
device.AddorUpdateData("subrtmp", $"rtmp://{this._configuration["stream.rtmp"]}/live/sub{ipCamera.Id}", DeviceDataType.String, "子码流rtmp");
device.AddorUpdateData("subflv", $"http://{this._configuration["stream.flv"]}/live/sub{ipCamera.Id}.flv", DeviceDataType.String, "子码流flv");
device.AddorUpdateData("subhls", $"http://{this._configuration["stream.hls"]}/live/sub{ipCamera.Id}.m3u8", DeviceDataType.String, "子码流hls");
device.AddorUpdateData("ffmpeg.file", this._configuration["ffmpeg.file"], DeviceDataType.String, "ffmpeg.file", hidden: true);
device.AddorUpdateData("ffmpeg.args", this._configuration["ffmpeg.args"], DeviceDataType.String, "ffmpeg.args", hidden: true);
device.AddorUpdateData("CustomFile", "", DeviceDataType.String, "自定义ffmpeg路径", hidden: true);
device.ConnectId = this._configuration["connectId"];
device.NodeNumber = this._configuration["node.number"];
deviceRepo.Add(device);
deviceRepo.SaveChanges();
this.SendDevice(device);
}
var profiles = this._onvifDeviceManagement.GetProfiles(ipCamera.DeviceUrl, ipCamera.MediaUrl);
var needAuth = false;
var hasAuth = false;
if (profiles == "")
{
needAuth = true;
device.UserName = device.UserName ?? this._configuration["camera.usr"];
device.Password = device.Password ?? this._configuration["camera.pwd"];
profiles = this._onvifDeviceManagement.GetProfiles(ipCamera.DeviceUrl, ipCamera.MediaUrl, device.UserName, device.Password);
if (profiles == "")
{
hasAuth = false;
}
else
{
hasAuth = true;
ipCamera.GetProfilesXml = profiles;
}
}
else
{
ipCamera.GetProfilesXml = profiles;
}
ipCamera.ParseProfiles();
if (needAuth)
{
ipCamera.MainStreamUriXml = this._onvifDeviceManagement.GetStreamUri(ipCamera.DeviceUrl, ipCamera.MediaUrl, device.UserName, device.Password, ipCamera.Profiles.First().Token);
ipCamera.MainSnapshotUriXml = this._onvifDeviceManagement.GetSnapshotUri(ipCamera.DeviceUrl, ipCamera.MediaUrl, device.UserName, device.Password, ipCamera.Profiles.First().Token);
ipCamera.SubStreamUriXml = this._onvifDeviceManagement.GetStreamUri(ipCamera.DeviceUrl, ipCamera.MediaUrl, device.UserName, device.Password, ipCamera.Profiles.Last().Token);
ipCamera.SubSnapshotUriXml = this._onvifDeviceManagement.GetSnapshotUri(ipCamera.DeviceUrl, ipCamera.MediaUrl, device.UserName, device.Password, ipCamera.Profiles.Last().Token);
}
else
{
ipCamera.MainStreamUriXml = this._onvifDeviceManagement.GetStreamUri(ipCamera.DeviceUrl, ipCamera.MediaUrl, ipCamera.Profiles.First().Token);
ipCamera.MainSnapshotUriXml = this._onvifDeviceManagement.GetSnapshotUri(ipCamera.DeviceUrl, ipCamera.MediaUrl, ipCamera.Profiles.First().Token);
ipCamera.SubStreamUriXml = this._onvifDeviceManagement.GetStreamUri(ipCamera.DeviceUrl, ipCamera.MediaUrl, ipCamera.Profiles.Last().Token);
ipCamera.SubSnapshotUriXml = this._onvifDeviceManagement.GetSnapshotUri(ipCamera.DeviceUrl, ipCamera.MediaUrl, ipCamera.Profiles.Last().Token);
}
ipCamera.ParseStreamUri();
ipCamera.ParseSnapshotUri();
device.AddorUpdateData("NeedAuth", needAuth ? "是" : "否", DeviceDataType.String, "需认证");
device.AddorUpdateData("HasAuth", hasAuth ? "是" : "否", DeviceDataType.String, "已认证");
device.AddorUpdateData("DeviceUrl", ipCamera.DeviceUrl, DeviceDataType.String, "设备地址");
device.AddorUpdateData("PtzAddress", ipCamera.PTZAddress, DeviceDataType.String, "云台地址");
device.AddorUpdateData("Ptz3DZoomSupport", ipCamera.Ptz3DZoomSupport ? "是" : "否", DeviceDataType.String, "缩放支持");
device.AddorUpdateData("MainToken", ipCamera.Profiles.First().Token, DeviceDataType.String, "主码流Token");
device.AddorUpdateData("SubToken", ipCamera.Profiles.Last().Token, DeviceDataType.String, "子码流Token");
device.AddorUpdateData("MainStreamUri", ipCamera.MainStreamUri, DeviceDataType.String, "主码流地址");
device.AddorUpdateData("MainSnapshotUri", ipCamera.MainSnapshotUri, DeviceDataType.String, "主码流截图地址");
device.AddorUpdateData("SubStreamUri", ipCamera.SubStreamUri, DeviceDataType.String, "子码流地址");
device.AddorUpdateData("SubSnapshotUri", ipCamera.SubSnapshotUri, DeviceDataType.String, "子码流截图地址");
deviceRepo.SaveChanges();
this.SendDevice(device);
}
}
}
catch (Exception ex)
{
ex.PrintStack();
}
}
public void Notify()
{
using (var scope = _applicationServices.CreateScope())
{
var repo = scope.ServiceProvider.GetService<IRepository<Device>>();
var cameras = repo.ReadOnlyTable().Include(o => o.Data).Where(o => o.Enable).ToList();
foreach (var key in this._list.Keys)
{
var camera = cameras.FirstOrDefault(o => o.Number == key);
var remove = false;
if (!camera.Enable)
{
remove = true;
}
if (camera.Data.FirstOrDefault(o => o.Key == "NeedAuth").Value == "是" && camera.Data.FirstOrDefault(o => o.Key == "HasAuth").Value == "否")
{
remove = true;
}
if (remove)
{
this.Remove(key);
}
}
foreach (var camera in cameras)
{
try
{
if (camera.Enable)
{
if (camera.Data.FirstOrDefault(o => o.Key == "NeedAuth").Value == "否" || camera.Data.FirstOrDefault(o => o.Key == "HasAuth").Value == "是")
{
this.Publish(camera);
}
}
}
catch (Exception ex)
{
ex.PrintStack();
}
}
}
}
private void Publish(Device camera)
{
try
{
if (!this._list.Any(o => o.Key == camera.Number))
{
this.Add(camera);
}
}
catch (Exception ex)
{
ex.PrintStack();
}
}
public void Add(string key)
{
using (var scope = _applicationServices.CreateScope())
{
var repo = scope.ServiceProvider.GetService<IRepository<Device>>();
var camera = repo.ReadOnlyTable().Include(o => o.Data).FirstOrDefault(o => o.Number == key);
if (camera != null && camera.Enable)// && camera.Publish && (!camera.NeedAuth || (camera.NeedAuth && camera.HasAuth)))
{
if (camera.Data.FirstOrDefault(o => o.Key == "NeedAuth").Value == "否" || camera.Data.FirstOrDefault(o => o.Key == "HasAuth").Value == "是")
{
this.Add(camera);
}
}
}
}
public void Add(Device camera)
{
if (this._list.Any(o => o.Key == camera.Number))
{
return;
}
var needAuth = camera.Data.FirstOrDefault(o => o.Key == "NeedAuth").Value == "是";
var hasAuth = camera.Data.FirstOrDefault(o => o.Key == "HasAuth").Value == "是";
var mainStreamUri = camera.Data.FirstOrDefault(o => o.Key == "MainStreamUri").Value;
var mainRtspUrl = $"rtsp://{(needAuth ? $"{camera.UserName}:{camera.Password}@" : "")}{mainStreamUri.Substring(7)}";
var subStreamUri = camera.Data.FirstOrDefault(o => o.Key == "SubStreamUri").Value;
var subRtspUrl = $"rtsp://{(needAuth ? $"{camera.UserName}:{camera.Password}@" : "")}{subStreamUri.Substring(7)}";
var fileName = $"ffmpeg-{Helper.Instance.GetRunTime()}{(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ".exe" : "")}";
var file = Path.Combine(this._env.WebRootPath, fileName);
var mainRtmp = camera.Data.FirstOrDefault(o => o.Key == "mainrtmp").Value;
var subRtmp = camera.Data.FirstOrDefault(o => o.Key == "subrtmp").Value;
var customFile = camera.GetData("CustomFile")?.Value;
if (!string.IsNullOrEmpty(customFile))
{
file = customFile;
}
Console.WriteLine(file);
var arguments = camera.Data.FirstOrDefault(o => o.Key == "ffmpeg.args").Value;
Process main = null, sub = null;
if (!string.IsNullOrEmpty(mainStreamUri))
{
if (!string.IsNullOrEmpty(mainRtmp))
{
main = this.SetProcess(file, string.Format(arguments, Environment.ProcessorCount, mainRtspUrl, mainRtmp));
}
if (!string.IsNullOrEmpty(subRtmp))
{
sub = this.SetProcess(file, string.Format(arguments, Environment.ProcessorCount, subRtspUrl, subRtmp));
}
}
if (this._list.TryAdd(camera.Number, (camera, main, sub)))
{
Console.WriteLine($"add {camera.Number} to list");
}
else
{
if (main != null)
{
this.CloseProcess(main);
this.CloseProcess(sub);
}
}
}
public void Remove(string key)
{
var item = this._list[key];
this.CloseProcess(item.local);
this.CloseProcess(item.remote);
if (this._list.TryRemove(key, out item))
{
Console.WriteLine($"remove {key} from list");
}
}
private Process SetProcess(string file, string arguments)
{
Console.WriteLine(file);
var process = new Process
{
StartInfo = new ProcessStartInfo
{
WorkingDirectory = this._env.WebRootPath,
FileName = file,
Arguments = arguments,
UseShellExecute = false,
CreateNoWindow = true,
RedirectStandardError = true
},
EnableRaisingEvents = true
};
process.Exited += (s, e) =>
{
var _process = s as Process;
Console.WriteLine($"list:{_list.Count},exit:{_process.ExitCode},args:{arguments}");
if (_process != null)
{
Thread.Sleep(10 * 1000);
_process.CancelErrorRead();
_process.Start();
_process.BeginErrorReadLine();
}
};
process.ErrorDataReceived += (s, e) =>
{
if (!string.IsNullOrEmpty(e.Data))
{
//Console.WriteLine(e.Data);
if (e.Data.IndexOf("forcing output") > -1)
{
process.Kill();
}
}
};
Console.WriteLine(arguments);
process.Start();
process.BeginErrorReadLine();
return process;
}
private void CloseProcess(Process process)
{
if (process != null)
{
process.EnableRaisingEvents = false;
try
{
process.Kill();
process.WaitForExit();
}
catch (Exception ex)
{
ex.PrintStack();
}
}
}
private string GetOnoce(string deviceUrl)
{
var message = @"<s:Envelope xmlns:s=""http://www.w3.org/2003/05/soap-envelope"">
<s:Body xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">
<GetDeviceInformation xmlns=""http://www.onvif.org/ver10/device/wsdl""></GetDeviceInformation>
</s:Body>
</s:Envelope>";
var hc = this._httpClientFactory.CreateClient();
hc.DefaultRequestHeaders.Add("ContentType", $"application/soap+xml; charset=utf-8; action=\"{Template.GetDeviceInformationAction}\"");
var task = hc.PostAsync(deviceUrl, new StringContent(message));
var result = task.Result.Headers.WwwAuthenticate;
return Regex.Match(result.ToString(), "nonce=\"([^\"]+)\"").Groups[1].Value;
}
private string RequestXml(string url, string action, string body, string userName, string password, string onoce)
{
var nonce_b = Convert.FromBase64String(onoce);
var now = DateTime.Now.ToUniversalTime().ToString("yyyy-MM-ddThh:mm:ss.fffZ");
var creationtime_b = Encoding.ASCII.GetBytes(now);
var password_b = Encoding.ASCII.GetBytes(password);
var concatenation_b = new byte[nonce_b.Length + creationtime_b.Length + password_b.Length];
Buffer.BlockCopy(nonce_b, 0, concatenation_b, 0, nonce_b.Length);
Buffer.BlockCopy(creationtime_b, 0, concatenation_b, nonce_b.Length, creationtime_b.Length);
Buffer.BlockCopy(password_b, 0, concatenation_b, nonce_b.Length + creationtime_b.Length, password_b.Length);
var sha = new SHA1CryptoServiceProvider();
var pdresult = sha.ComputeHash(concatenation_b);
var passworddigest = Convert.ToBase64String(pdresult);
var message = string.Format(Template.AuthTemplate, userName, passworddigest, Convert.ToBase64String(nonce_b), now, body);
var result = SoapRequest(url, action, message);
return result;
}
private string SoapRequest(string url, string action, string message)
{
var hc = this._httpClientFactory.CreateClient();
hc.DefaultRequestHeaders.Add("ContentType", $"application/soap+xml; charset=utf-8; action=\"{action}\"");
var task = hc.PostAsync(url, new StringContent(message));
var result = task.Result.Content.ReadAsStringAsync().Result;
return result;
}
public void ZoomIn(string id, float speed)
{
this.Move(id, speed, 0, 0);
}
public void ZoomOut(string id, float speed)
{
this.Move(id, -speed, 0, 0);
}
public void Up(string id, float speed)
{
this.Move(id, 0, 0, speed);
}
public void Right(string id, float speed)
{
this.Move(id, 0, speed, 0);
}
public void Down(string id, float speed)
{
this.Move(id, 0, 0, -speed);
}
public void Left(string id, float speed)
{
this.Move(id, 0, -speed, 0);
}
public void Stop(string id)
{
var camera = this.GetCamera(id);
if (camera != null)
{
var ptzAddress = camera.GetDataValue("PtzAddress");
if (!string.IsNullOrEmpty(ptzAddress))
{
var deviceUrl = camera.GetDataValue("DeviceUrl");
RequestXml(ptzAddress, Template.StopAction, String.Format(Template.StopMessage, camera.GetDataValue("MainToken"), true, true), camera.UserName, camera.Password, GetOnoce(deviceUrl));
}
}
}
public void Move(string id, float zx, float px, float py)
{
var camera = this.GetCamera(id);
if (camera != null)
{
var ptzAddress = camera.GetDataValue("PtzAddress");
if (!string.IsNullOrEmpty(ptzAddress))
{
var deviceUrl = camera.GetDataValue("DeviceUrl");
RequestXml(ptzAddress, Template.ContinuousMoveAction, String.Format(Template.ContinuousMoveMessage, camera.GetDataValue("MainToken"), zx, px, py), camera.UserName, camera.Password, GetOnoce(deviceUrl));
}
}
}
public byte[] ScreenShot(string id)
{
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") == "否")
{
return hc.GetByteArrayAsync(url).Result;
}
return hc.GetByteDigest(url, camera.UserName, camera.Password);
}
private Device GetCamera(string number)
{
using (var scope = _applicationServices.CreateScope())
{
var repo = scope.ServiceProvider.GetService<IRepository<Device>>();
return repo.ReadOnlyTable().Include(o => o.Data).FirstOrDefault(o => o.Number == number);
}
}
}
}

@ -1,23 +0,0 @@
using System.Collections.Generic;
namespace ONVIFService
{
public interface IOnvifDeviceManagement
{
List<IPCamera> Discovery();
string GetCapabilities(string deviceUrl);
string GetProfiles(string deviceUrl, string mediaUrl);
string GetProfiles(string deviceUrl, string mediaUrl, string userName, string password);
string GetStreamUri(string deviceUrl, string mediaUrl, string token);
string GetStreamUri(string deviceUrl, string mediaUrl, string userName, string password, string token);
string GetSnapshotUri(string deviceUrl, string mediaUrl, string token);
string GetSnapshotUri(string deviceUrl, string mediaUrl, string userName, string password, string token);
}
}

@ -1,85 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text.RegularExpressions;
using System.Xml.Linq;
namespace ONVIFService
{
public class IPCamera
{
public string DiscoveryXml { get; set; }
public string GetCapabilitiesXml { get; set; }
public string DeviceUrl { get; set; }
public string Id { get; set; }
public string MediaUrl { get; set; }
public string GetProfilesXml { get; set; }
public string UserName { get; set; }
public string Password { get; set; }
public string PTZAddress { get; set; }
public bool Ptz3DZoomSupport { get; set; }
public List<Profile> Profiles { get; set; } = new List<Profile>();
public string MainStreamUriXml { get; set; }
public string MainSnapshotUriXml { get; set; }
public string SubStreamUriXml { get; set; }
public string SubSnapshotUriXml { get; set; }
public string MainStreamUri { get; set; }
public string SubStreamUri { get; set; }
public string MainSnapshotUri { get; set; }
public string SubSnapshotUri { get; set; }
public void ParseDiscovery()
{
var doc = XDocument.Parse(this.DiscoveryXml);
this.DeviceUrl = doc.Descendants().FirstOrDefault(o => o.Name.LocalName == "XAddrs").Value.Split(' ')[0];
this.Id = doc.Descendants()
.FirstOrDefault(o => o.Name.LocalName == "EndpointReference").Elements()
.FirstOrDefault(o => o.Name.LocalName == "Address").Value.Replace("urn:uuid:", "").Replace("-", "");
}
public void ParseCapabilities()
{
var doc = XDocument.Parse(this.GetCapabilitiesXml);
this.MediaUrl = doc.Descendants().FirstOrDefault(o => o.Name.LocalName == "Media").Elements().FirstOrDefault(o => o.Name.LocalName == "XAddr").Value;
this.PTZAddress = doc.Descendants().FirstOrDefault(o => o.Name.LocalName == "PTZ")?.Elements().FirstOrDefault(o => o.Name.LocalName == "XAddr")?.Value;
this.Ptz3DZoomSupport = string.IsNullOrWhiteSpace(this.PTZAddress) ? false : true;
}
public void ParseProfiles()
{
var doc = XDocument.Parse(this.GetProfilesXml);
foreach (var item in doc.Descendants().Where(o => o.Name.LocalName == "Profiles"))
{
var profile = new Profile
{
Token = item.Attribute("token").Value,
Name = item.Elements().FirstOrDefault(o => o.Name.LocalName == "Name").Value
};
var videoEncoderConfiguration = item.Elements().FirstOrDefault(o => o.Name.LocalName == "VideoEncoderConfiguration");
profile.Encoding = videoEncoderConfiguration.Elements().FirstOrDefault(o => o.Name.LocalName == "Encoding").Value;
var resolution = videoEncoderConfiguration.Elements().FirstOrDefault(o => o.Name.LocalName == "Resolution");
profile.Width = Convert.ToInt32(resolution.Elements().FirstOrDefault(o => o.Name.LocalName == "Width").Value);
profile.Height = Convert.ToInt32(resolution.Elements().FirstOrDefault(o => o.Name.LocalName == "Height").Value);
this.Profiles.Add(profile);
}
}
public void ParseStreamUri()
{
this.MainStreamUri = WebUtility.HtmlDecode(this.RegexMatch(this.MainStreamUriXml, @"[^<>]*", @"<tt:Uri>", @"</tt:Uri>"));
this.SubStreamUri = WebUtility.HtmlDecode(this.RegexMatch(this.SubStreamUriXml, @"[^<>]*", @"<tt:Uri>", @"</tt:Uri>"));
}
public void ParseSnapshotUri()
{
this.MainSnapshotUri = WebUtility.HtmlDecode(this.RegexMatch(this.MainSnapshotUriXml, @"[^<>]*", @"<tt:Uri>", @"</tt:Uri>"));
this.SubSnapshotUri = WebUtility.HtmlDecode(this.RegexMatch(this.SubSnapshotUriXml, @"[^<>]*", @"<tt:Uri>", @"</tt:Uri>"));
}
private string RegexMatch(string input, string pattern, string prefix, string suffix)
{
return Regex.Match(input, $"(?<={prefix}){pattern}(?={suffix})").Value;
}
}
}

@ -1,181 +0,0 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.NetworkInformation;
using System.Net.Sockets;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using Infrastructure.Extensions;
namespace ONVIFService
{
public class OnvifDeviceManagement : IOnvifDeviceManagement
{
private readonly IHttpClientFactory _httpClientFactory;
private readonly object thisLock = new object();
public OnvifDeviceManagement(IHttpClientFactory httpClientFactory)
{
this._httpClientFactory = httpClientFactory;
}
public List<IPCamera> Discovery()
{
Console.WriteLine("search onvif devices...");
var list = new ConcurrentBag<string>();
var ips = NetworkInterface.GetAllNetworkInterfaces()
.Where(nic => nic.OperationalStatus == OperationalStatus.Up && nic.NetworkInterfaceType != NetworkInterfaceType.Loopback)
.Select(nic => nic.GetIPProperties().UnicastAddresses)
.SelectMany(o => o.ToList())
.Select(o => o.Address)
.Where(o => o.AddressFamily == AddressFamily.InterNetwork)
.ToList();
foreach (var ip in ips)
{
Console.WriteLine($"search:{ip}");
lock (thisLock)
{
try
{
var tokenSource = new CancellationTokenSource();
using (var client = new UdpClient(new IPEndPoint(ip, 0)))
{
var probeMessage = string.Format(Template.GetServiceRequestTemplage, Guid.NewGuid());
var message = Encoding.UTF8.GetBytes(probeMessage);
client.Send(message, message.Length, new IPEndPoint(IPAddress.Parse("239.255.255.250"), 3702));
Task.Run(() =>
{
try
{
var ep = new IPEndPoint(IPAddress.Any, 3702);
while (!tokenSource.IsCancellationRequested)
{
if (client.Available > 0)
{
var buffer = client.Receive(ref ep);
var result = Encoding.UTF8.GetString(buffer);
if (!list.Any(o => o == result))
{
list.Add(result);
}
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}, tokenSource.Token);
Thread.Sleep(1000);
tokenSource.Cancel();
}
}
catch (Exception ex)
{
ex.PrintStack();
}
}
}
var cameras = new List<IPCamera>();
foreach (var item in list)
{
var camera = new IPCamera { DiscoveryXml = item };
try
{
camera.ParseDiscovery();
camera.GetCapabilitiesXml = GetCapabilities(camera.DeviceUrl);
camera.ParseCapabilities();
cameras.Add(camera);
}
catch (Exception ex)
{
ex.PrintStack();
}
}
return cameras;
}
public string GetCapabilities(string deviceUrl)
{
return SoapRequest(deviceUrl, Template.GetCapabilitiesAction, Template.GetCapabilitiesMessage);
}
public string GetProfiles(string deviceUrl, string mediaUrl)
{
return SoapRequest(mediaUrl, Template.GetProfilesAction, string.Format(Template.Templage, Template.GetProfilesMessageBody));
}
public string GetProfiles(string deviceUrl, string mediaUrl, string userName, string password)
{
return RequestXml(mediaUrl, Template.GetProfilesAction, Template.GetProfilesMessageBody, userName, password, GetOnoce(deviceUrl));
}
public string GetStreamUri(string deviceUrl, string mediaUrl, string token)
{
return SoapRequest(mediaUrl, Template.GetStreamUriAction, string.Format(Template.Templage, String.Format(Template.GetStreamUriMessage, token)));
}
public string GetStreamUri(string deviceUrl, string mediaUrl, string userName, string password, string token)
{
return RequestXml(mediaUrl, Template.GetStreamUriAction, String.Format(Template.GetStreamUriMessage, token), userName, password, GetOnoce(deviceUrl));
}
public string GetSnapshotUri(string deviceUrl, string mediaUrl, string token)
{
return SoapRequest(mediaUrl, Template.GetSnapshotUriAction, string.Format(Template.Templage, String.Format(Template.GetSnapshotUriMessage, token)));
}
public string GetSnapshotUri(string deviceUrl, string mediaUrl, string userName, string password, string token)
{
return RequestXml(mediaUrl, Template.GetSnapshotUriAction, String.Format(Template.GetSnapshotUriMessage, token), userName, password, GetOnoce(deviceUrl));
}
private string SoapRequest(string url, string action, string message)
{
var hc = this._httpClientFactory.CreateClient();
hc.DefaultRequestHeaders.Add("ContentType", $"application/soap+xml; charset=utf-8; action=\"{action}\"");
var task = hc.PostAsync(url, new StringContent(message));
var result = task.Result;
var content = result.Content.ReadAsStringAsync().Result;
return result.StatusCode == HttpStatusCode.OK ? content : "";
}
private string RequestXml(string url, string action, string body, string userName, string password, string onoce)
{
var nonce_b = Convert.FromBase64String(onoce);
var now = DateTime.Now.ToUniversalTime().ToString("yyyy-MM-ddThh:mm:ss.fffZ");
var creationtime_b = Encoding.ASCII.GetBytes(now);
var password_b = Encoding.ASCII.GetBytes(password);
var concatenation_b = new byte[nonce_b.Length + creationtime_b.Length + password_b.Length];
Buffer.BlockCopy(nonce_b, 0, concatenation_b, 0, nonce_b.Length);
Buffer.BlockCopy(creationtime_b, 0, concatenation_b, nonce_b.Length, creationtime_b.Length);
Buffer.BlockCopy(password_b, 0, concatenation_b, nonce_b.Length + creationtime_b.Length, password_b.Length);
var sha = new SHA1CryptoServiceProvider();
var pdresult = sha.ComputeHash(concatenation_b);
var passworddigest = Convert.ToBase64String(pdresult);
var message = string.Format(Template.AuthTemplate, userName, passworddigest, Convert.ToBase64String(nonce_b), now, body);
var result = SoapRequest(url, action, message);
return result;
}
private string GetOnoce(string deviceUrl)
{
var message = @"<s:Envelope xmlns:s=""http://www.w3.org/2003/05/soap-envelope"">
<s:Body xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">
<GetDeviceInformation xmlns=""http://www.onvif.org/ver10/device/wsdl""></GetDeviceInformation>
</s:Body>
</s:Envelope>";
var hc = this._httpClientFactory.CreateClient();
hc.DefaultRequestHeaders.Add("ContentType", $"application/soap+xml; charset=utf-8; action=\"{Template.GetDeviceInformationAction}\"");
var task = hc.PostAsync(deviceUrl, new StringContent(message));
var result = task.Result.Headers.WwwAuthenticate;
return Regex.Match(result.ToString(), "nonce=\"([^\"]+)\"").Groups[1].Value;
}
}
}

@ -1,13 +0,0 @@
using System.Xml.Linq;
namespace ONVIFService
{
public class Profile
{
public string Token { get; set; }
public string Name { get; set; }
public string Encoding { get; set; }
public int Width { get; set; }
public int Height { get; set; }
}
}

@ -1,95 +0,0 @@
namespace ONVIFService
{
public class Template
{
public const string GetServiceRequestTemplage = @"<s:Envelope
xmlns:s=""http://www.w3.org/2003/05/soap-envelope""
xmlns:a=""http://schemas.xmlsoap.org/ws/2004/08/addressing"">
<s:Header>
<a:Action s:mustUnderstand=""1"">http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe</a:Action>
<a:MessageID>urn:uuid:{0}</a:MessageID>
<a:ReplyTo>
<a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address>
</a:ReplyTo>
<a:To s:mustUnderstand=""1"">urn:schemas-xmlsoap-org:ws:2005:04:discovery</a:To>
</s:Header>
<s:Body>
<Probe
xmlns=""http://schemas.xmlsoap.org/ws/2005/04/discovery"">
<d:Types
xmlns:d=""http://schemas.xmlsoap.org/ws/2005/04/discovery""
xmlns:dp0=""http://www.onvif.org/ver10/device/wsdl"">dp0:Device
</d:Types>
</Probe>
</s:Body>
</s:Envelope>";
public const string GetCapabilitiesAction = "http://www.onvif.org/ver10/device/wsdl/GetCapabilities";
public const string GetCapabilitiesMessage = @"<s:Envelope xmlns:s=""http://www.w3.org/2003/05/soap-envelope"">
<s:Body xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">
<GetCapabilities xmlns=""http://www.onvif.org/ver10/device/wsdl"">
<Category>All</Category>
</GetCapabilities>
</s:Body>
</s:Envelope>";
public const string GetProfilesAction = "http://www.onvif.org/ver10/media/wsdlGetProfiles/";
public const string GetProfilesMessageBody = @"<GetProfiles xmlns=""http://www.onvif.org/ver10/media/wsdl""></GetProfiles>";
public const string GetStreamUriAction = "http://www.onvif.org/ver10/media/wsdl/GetStreamUri";
public const string GetStreamUriMessage = @"<GetStreamUri xmlns=""http://www.onvif.org/ver10/media/wsdl"">
<StreamSetup>
<Stream xmlns=""http://www.onvif.org/ver10/schema"">RTP-Unicast</Stream>
<Transport xmlns=""http://www.onvif.org/ver10/schema"">
<Protocol>RTSP</Protocol>
</Transport>
</StreamSetup>
<ProfileToken>{0}</ProfileToken>
</GetStreamUri>";
public const string GetDeviceInformationAction = "http://www.onvif.org/ver10/device/wsdl/GetDeviceInformation";
public const string Templage = @"<s:Envelope xmlns:s=""http://www.w3.org/2003/05/soap-envelope"">
<s:Body xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">
{0}
</s:Body>
</s:Envelope>";
public const string AuthTemplate = @"<s:Envelope xmlns:s=""http://www.w3.org/2003/05/soap-envelope"">
<s:Header>
<Security xmlns=""http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"" s:mustUnderstand=""1"">
<UsernameToken>
<Username>{0}</Username>
<Password Type=""http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest"">{1}</Password>
<Nonce EncodingType=""http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary"">{2}</Nonce>
<Created xmlns=""http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"">{3}</Created>
</UsernameToken>
</Security>
</s:Header>
<s:Body xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">
{4}
</s:Body>
</s:Envelope>";
public const string GetSnapshotUriAction = "http://www.onvif.org/ver10/media/wsdl/GetSnapshotUri";
public const string GetSnapshotUriMessage = @"<GetSnapshotUri xmlns=""http://www.onvif.org/ver10/media/wsdl"">
<ProfileToken>{0}</ProfileToken>
</GetSnapshotUri>";
public const string ContinuousMoveAction = "http://www.onvif.org/ver20/ptz/wsdl/ContinuousMove";
public const string ContinuousMoveMessage = @"<ContinuousMove xmlns=""http://www.onvif.org/ver20/ptz/wsdl"">
<ProfileToken>{0}</ProfileToken>
<Velocity>
<Zoom xmlns=""http://www.onvif.org/ver10/schema"" x=""{1}""></Zoom>
<PanTilt x=""{2}"" y=""{3}"" xmlns=""http://www.onvif.org/ver10/schema""></PanTilt>
</Velocity>
</ContinuousMove>";
public const string StopAction = "http://www.onvif.org/ver20/ptz/wsdl/Stop";
public const string StopMessage = @"<Stop xmlns=""http://www.onvif.org/ver20/ptz/wsdl""><ProfileToken>{0}</ProfileToken><PanTilt>true</PanTilt><Zoom>true</Zoom></Stop>";
}
}

@ -1,18 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="4.0.1" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="4.0.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Infrastructure\Infrastructure.csproj" />
<ProjectReference Include="..\..\IoT.Shared\IoT.Shared.csproj" />
</ItemGroup>
</Project>

@ -1,43 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28010.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ONVIFService", "ONVIFService.csproj", "{E25B755D-0074-481F-847B-8D45B33C65A7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Infrastructure", "..\..\..\..\Infrastructure\Infrastructure\src\Infrastructure\Infrastructure.csproj", "{6DC05FAD-C2E7-4C7F-B376-3BEFE56439B9}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IoT.Shared", "..\..\Libraries\src\IoT.Shared\IoT.Shared.csproj", "{8572A0E0-E4E3-466D-8116-5F686040C66D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IoT.UI.Shard", "..\..\Libraries\src\IoT.UI.Shard\IoT.UI.Shard.csproj", "{4D947053-F0FF-4F5B-8E33-CE474BDF0621}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E25B755D-0074-481F-847B-8D45B33C65A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E25B755D-0074-481F-847B-8D45B33C65A7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E25B755D-0074-481F-847B-8D45B33C65A7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E25B755D-0074-481F-847B-8D45B33C65A7}.Release|Any CPU.Build.0 = Release|Any CPU
{6DC05FAD-C2E7-4C7F-B376-3BEFE56439B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6DC05FAD-C2E7-4C7F-B376-3BEFE56439B9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6DC05FAD-C2E7-4C7F-B376-3BEFE56439B9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6DC05FAD-C2E7-4C7F-B376-3BEFE56439B9}.Release|Any CPU.Build.0 = Release|Any CPU
{8572A0E0-E4E3-466D-8116-5F686040C66D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8572A0E0-E4E3-466D-8116-5F686040C66D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8572A0E0-E4E3-466D-8116-5F686040C66D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8572A0E0-E4E3-466D-8116-5F686040C66D}.Release|Any CPU.Build.0 = Release|Any CPU
{4D947053-F0FF-4F5B-8E33-CE474BDF0621}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4D947053-F0FF-4F5B-8E33-CE474BDF0621}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4D947053-F0FF-4F5B-8E33-CE474BDF0621}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4D947053-F0FF-4F5B-8E33-CE474BDF0621}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B5A82048-F0E0-4FA7-9954-E5983781CAAC}
EndGlobalSection
EndGlobal

@ -1,48 +0,0 @@
using Infrastructure.Application;
using Infrastructure.Configuration;
using Infrastructure.Extensions;
using Infrastructure.Web.Hosting;
using Microsoft.AspNetCore;
using System;
using System.Collections.Generic;
namespace ONVIFService
{
public class Program
{
public static void Main(string[] args)
{
var host = "localhost";
WebHost.CreateDefaultBuilder(args)
.Run<Startup>(new List<EFConfigurationValue> {
new EFConfigurationValue { Id = "openapi.title", Value= "web api" },
new EFConfigurationValue { Id = "openapi.version", Value= "1.0" },
new EFConfigurationValue { Id = "security:key", Value= "111111111111111111111111"},
new EFConfigurationValue { Id = "security:iv", Value= "11111111"},
new EFConfigurationValue { Id = "email:host", Value= "nbaxp.com"},
new EFConfigurationValue { Id = "email:port", Value= "25"},
new EFConfigurationValue { Id = "email:user", Value= "admin@nbaxp.com"},
new EFConfigurationValue { Id = "email:password", Value= "aA123456"},
new EFConfigurationValue { Id = "server.urls", Value= "http://*:8004" },
new EFConfigurationValue { Id = "notify:enabled", Value= "false"},
new EFConfigurationValue { Id = "notify:host", Value= $"{host}:8001"},
new EFConfigurationValue { Id = "timer.seconds", Value="600"},
new EFConfigurationValue { Id = "connectId", Value= Guid.NewGuid().ToBase62() },
new EFConfigurationValue { Id = "node.number", Value= "所属节点编号" },
new EFConfigurationValue { Id = "onvif.timer", Value="1"},
new EFConfigurationValue { Id = "onvif.speed", Value="0.2"},
new EFConfigurationValue { Id = "camera.usr", Value="admin"},
new EFConfigurationValue { Id = "camera.pwd", Value="lg123456"},
new EFConfigurationValue { Id = "stream.rtmp", Value=host},
new EFConfigurationValue { Id = "stream.flv", Value=$"{host}:8080"},
new EFConfigurationValue { Id = "stream.hls", Value=$"{host}:8080"},
new EFConfigurationValue { Id = "ffmpeg.args", Value=" -y -threads {0} -rtsp_transport tcp -use_wallclock_as_timestamps 1 -stimeout 3000000 -i \"{1}\" -fflags +genpts -c copy -f flv \"{2}\""},
new EFConfigurationValue { Id = "ffmpeg.file", Value="/usr/ffmpeg-rkmp/bin/ffmpeg"},
//
new EFConfigurationValue { Id = "name", Value= "ONVIF服务"},
new EFConfigurationValue { Id = "logo", Value= "/images/logo.png",Type= InputType.ImageUrl},
new EFConfigurationValue { Id = "copyright", Value= "Copyright © {now} Company. All rights reserved",Type= InputType.Html}
});
}
}
}

@ -1,27 +0,0 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:8004/",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"OnvifService": {
"commandName": "Project",
"launchBrowser": true,
"applicationUrl": "http://127.0.0.1:8004/",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

@ -1,31 +0,0 @@
using IoT.Shared.Infrastructure;
using IoT.UI.Shard;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
namespace ONVIFService
{
public class Startup : IoTServiceStartup
{
public Startup(IConfiguration configuration, IHostingEnvironment env) : base(configuration, env)
{
}
public override void ConfigureServices(IServiceCollection services)
{
services.AddSingleton<ClientService>();
services.AddSingleton<DeviceService>();
base.ConfigureServices(services);
}
public override void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
base.Configure(app, env, loggerFactory);
app.ApplicationServices.GetService<DeviceService>().Start();
app.ApplicationServices.GetService<ClientService>().Start();
}
}
}

@ -1,263 +0,0 @@
@model List<Device>
@section styles{
<style>
.video {
max-width: 100%;
margin: 0 auto;
display: block;
}
.modal-dialog {
width: 670px;
}
</style>
}
@if (Model != null && Model.Count > 0)
{
<div class="row">
@foreach (var item in Model)
{
var url = "/images/empty.png";
var needAuth = item.GetDataValue("NeedAuth") == "是";
var hasAuth = item.GetDataValue("hasAuth") == "是";
if (!needAuth || hasAuth)
{
url = Url.Action("Image", "Home", new { id = item.Number });
}
<div class="col-lg-3">
<div class="row camera">
<div class="box-header">
<p style="white-space:nowrap; text-overflow:ellipsis;overflow:hidden;" title="@item.GetDataValue("StreamUri")">@item.GetDataValue("StreamUri")</p>
</div>
<div class="box-body">
<a class="fancybox" href="@url"><img style="width:100%;height:100%;" src="@url" /></a>
</div>
<div class="box-body">
<span>PTZ支持@item.GetDataValue("SubPtz3DZoomSupport")</span>
<span>需认证:@Html.DisplayFor(o => needAuth)</span>
@if (needAuth)
{
<span>已认证:@Html.DisplayFor(o => hasAuth)</span>
}
</div>
<div class="box-body">
<a class="btn btn-default btn-sm rtmp" href="@item.GetDataValue("mainrtmp")">mainrtmp</a>
<a class="btn btn-default btn-sm flv" href="@item.GetDataValue("mainflv")">mainflv</a>
<a class="btn btn-default btn-sm hls" href="@item.GetDataValue("mainhls")">mainhls</a>
<br />
<a class="btn btn-default btn-sm rtmp" href="@item.GetDataValue("subrtmp")">subrtmp</a>
<a class="btn btn-default btn-sm flv" href="@item.GetDataValue("subflv")">subflv</a>
<a class="btn btn-default btn-sm hls" href="@item.GetDataValue("subhls")">subhls</a>
<br />
<a class="btn btn-default btn-sm api" href="/Home/Restart/@item.Number">重启推流</a>
<a class="btn btn-default btn-sm" target="_blank" href="/Home/Image/@item.Number">截图</a>
</div>
<div class="ptz" style="display:none;">
@if (item.GetDataValue("Ptz3DZoomSupport") == "是")
{
<div class="box-body" style="text-align:center;">
<a class="btn btn-default btn-sm cmd" href="/camera/21zoomin/?id=@item.Number">放大</a>
<a class="btn btn-default btn-sm cmd" href="/camera/22zoomout/?id=@item.Number">缩小</a>
<a class="btn btn-default btn-sm cmd" href="/camera/23stop/?id=@item.Number">停止</a>
<a class="btn btn-default btn-sm cmd" href="/camera/24left/?id=@item.Number">左</a>
<a class="btn btn-default btn-sm cmd" href="/camera/25right/?id=@item.Number">右</a>
<a class="btn btn-default btn-sm cmd" href="/camera/26up/?id=@item.Number">上</a>
<a class="btn btn-default btn-sm cmd" href="/camera/27down/?id=@item.Number">下</a>
</div>
}
</div>
</div>
</div>
}
</div>
}
<div class="modal fade" id="modal-default">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title">
网页播放器
</h4>
</div>
<div class="modal-body">
</div>
</div>
</div>
</div>
@section scripts{
<script src="~/lib/clappr/clappr.min.js"></script>
<script src="~/lib/clappr/clappr-rtmp-plugin/rtmp.min.js"></script>
<script src="~/lib/flv.js/flv.min.js"></script>
<script src="~/lib/hls.js/hls.min.js"></script>
<script>
var rtmpPlayer;
var flvPlayer;
var hlsPlayer;
var timer;
var decodedFrames;
$('.rtmp').click(function () {
var id = 'rtmpPlayer';
var url = $(this).attr('href');
if (!navigator.plugins['Shockwave Flash']) {
$('.modal-body').html('<a href="http://www.adobe.com/go/getflashplayer" rel="nofollow" target="_blank" title="启用Flash" class="btn btn-default btn-sm flash">启用Flash</a>');
}
else {
$('.modal-body').html('<div id="rtmpPlayer" class="video"></div>');
var videoElement = document.getElementById(id);
if (rtmpPlayer != null) {
closePlayer();
}
rtmpPlayer = new Clappr.Player({
source: url,
autoPlay: true,
mute: true,
parentId: "#" + id,
plugins: { 'playback': [RTMP] },
rtmpConfig: {
swfPath: '/lib/clappr/clappr-rtmp-plugin/assets/RTMP.swf',
scaling: 'stretch',
playbackType: 'live',
bufferTime: 1,
startLevel: 0
},
});
}
$('#modal-default').modal('show');
return false;
});
$('.flv').click(function () {
$('.modal-body').html('<video id="flvPlayer" class="video" muted controls autoplay></video>');
$('.modal-body').append($(this).parents('.camera').find('.ptz').html());
try {
if (flvPlayer != null) {
closePlayer();
}
var url = $(this).attr('href');
playFlv(url);
} catch (e) {
console.log('error:');
console.log(e);
}
$('#modal-default').modal('show');
return false;
});
function playFlv(url) {
var id = 'flvPlayer';
var videoElement = document.getElementById(id);
flvPlayer = flvjs.createPlayer({
type: 'flv',
url: url,
isLive: true,
cors: true
}, {
enableWorker: true,
enableStashBuffer: false,
stashInitialSize: 1,
fixAudioTimestampGap: false,
//lazyLoad: false
});
flvPlayer.attachMediaElement(videoElement);
flvPlayer.load();
timer = setInterval(function () {
console.log('.');
if (flvPlayer.statisticsInfo.speed == 0) {
console.log('reload1');
closePlayer();
playFlv(url);
}
else if (decodedFrames && flvPlayer.statisticsInfo.decodedFrames <= decodedFrames) {
console.log('reload2');
closePlayer();
playFlv(url);
}
else if (flvPlayer.buffered.end(0) - flvPlayer.currentTime > 1) {
console.log('reset currentTime');
flvPlayer.currentTime = flvPlayer.buffered.end(0) - 0.001;
}
decodedFrames = flvPlayer.statisticsInfo.decodedFrames;
}, 10 * 1000);
}
$('.hls').click(function () {
try {
var id = 'hlsPlayer';
var url = $(this).attr('href');
$('.modal-body').html('<video id="hlsPlayer" class="video" muted controls autoplay></video>');
$('.modal-body').append($(this).parents('.camera').find('.ptz').html());
if (hlsPlayer != null) {
closePlayer();
}
var video = document.getElementById(id);
hlsPlayer = new Hls();
hlsPlayer.loadSource(url);
hlsPlayer.attachMedia(video);
hlsPlayer.on(Hls.Events.MANIFEST_PARSED, function () {
video.play();
});
$('#modal-default').modal('show');
} catch (e) {
console.log(e);
}
return false;
});
$('.ios').click(function () {
try {
var id = 'hlsPlayer';
$('.modal-body').html('<video id="hlsPlayer" class="video" muted controls autoplay></video>');
$('.modal-body').append($(this).parents('.camera').find('.ptz').html());
var video = document.getElementById(id).src = $(this).attr('href');
$('#modal-default').modal('show');
} catch (e) {
console.log(e);
}
return false;
});
$('.close').click(function () {
closePlayer();
});
function closePlayer() {
console.log('close player');
if (timer) {
clearInterval(timer);
timer = null;
}
if (rtmpPlayer != null) {
rtmpPlayer.destroy();
rtmpPlayer = null;
}
if (flvPlayer != null) {
flvPlayer.pause();
flvPlayer.unload();
flvPlayer.detachMediaElement();
flvPlayer.destroy();
flvPlayer = null;
}
if (hlsPlayer != null) {
hlsPlayer.destroy();
}
$('#callback .page-content .block').html('');
}
$('.api').click(function () {
$.getJSON($(this).attr('href'), function (response) {
alert(response);
}).fail(function (jqxhr, textStatus, error) {
var err = textStatus + ", " + error;
alert(err);
});
return false;
});
$('body').on('click', '.cmd', function () {
$.getJSON($(this).attr('href'), function (response) {
console.log(response);
}).fail(function (jqxhr, textStatus, error) {
var err = textStatus + ", " + error;
alert(err);
});
return false;
});
</script>
}

@ -1,26 +0,0 @@
<ul class="nav navbar-nav">
<li class="@GetClass("Home")">
<a href="@Url.Action("Index","Home")">
首页
</a>
</li>
<li>
<a href="/swagger/index.html">
Open API
</a>
</li>
</ul>
@functions{
public string GetClass(params string[] controllers)
{
if (controllers.Select(o => o.ToLower()).Contains(this.ViewContext.RouteData.Values["controller"].ToString().ToLower()))
{
if (controllers.Length > 1)
{
return "active open";
}
return "active";
}
return "";
}
}

@ -1,11 +0,0 @@
@inherits Infrastructure.Web.Mvc.Razor.MyRazorPage<TModel>
@using Microsoft.Extensions.Configuration
@using System.ComponentModel.DataAnnotations
@using Infrastructure.Application
@using Infrastructure.Web
@using Infrastructure.Web.DataAnnotations
@using Infrastructure.Extensions
@using Infrastructure.Data
@using Application.Domain.Entities
@using Application.Models
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

@ -1,9 +0,0 @@
{
"Logging": {
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
}
}

@ -1,17 +0,0 @@
{
"version": "1.0.0-beta.108",
"Logging": {
"LogLevel": {
"Default": "Information"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"database.mysql.connection": "Server=127.0.0.1;Port=3306;Database=iotnode;Uid=root;Pwd=root;",
"database.sqlite.connection": "Data Source=data.db"
},
"AppSettings": {
"database": "sqlite",
"UseCookieSessionStore": false
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

@ -1,52 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>flvjsdemo</title>
</head>
<body>
<div>
<input id="url" type="text" value="http://192.168.3.2:8080/live/b57e867ae29d11b483864cbd8fd0f747.flv" placeholder="url" style="width:80%;" /><button id="btn">播放</button>
</div>
<video id="videoElement" muted controls autoplay> style="width:80%;"></video>
<script>
var flvPlayer;
document.getElementById('btn').addEventListener('click', function () {
if (flvjs.isSupported()) {
var videoElement = document.getElementById('videoElement');
if (flvPlayer) {
flvPlayer.unload();
flvPlayer.detachMediaElement();
flvPlayer.destroy();
flvPlayer = null;
}
flvPlayer = flvjs.createPlayer({
type: 'flv',
url: document.getElementById('url').value,
isLive: true,
cors: true
}, {
isLive: true,
fixAudioTimestampGap: false,
enableWorker: true,
enableStashBuffer: false,
stashInitialSize: 1,
//lazyLoad: false,
//lazyLoadMaxDuration: 1,
//lazyLoadRecoverDuration: 1,
deferLoadAfterSourceOpen: false,
//autoCleanupMaxBackwardDuration: 1,
//autoCleanupMinBackwardDuration: 1,
//statisticsInfoReportInterval: 1,
});
flvPlayer.attachMediaElement(videoElement);
flvPlayer.load();
}
else {
alert('不支持flv格式');
}
});
</script>
<script src="/lib/flv.js/flv.min.js"></script>
</body>
</html>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

@ -1,16 +0,0 @@
*.bak
*.suo
*.db
*.user
.vs/
obj
Obj
bin
Bin
debug
Debug
release
Release
Logs
logs
node_modules

@ -1,15 +0,0 @@
using Infrastructure.Domain;
namespace Application.Domain.Entities
{
public class Button : BaseEntity
{
public string Name { get; set; }
public string Message { get; set; }
public string SerialPort { get; set; }
public int Baud { get; set; }
public int Data { get; set; }
public int Partity { get; set; }
public int StopBits { get; set; }
}
}

@ -1,37 +0,0 @@
using System.ComponentModel.DataAnnotations;
using Infrastructure.Application;
namespace SPService.Applicaiton.Models
{
[Display(Name = "指令")]
public class EditButtonModel : EditModel
{
[Required]
[Display(Name = "名称")]
public string Name { get; set; }
[Required]
[Display(Name = "消息")]
public string Message { get; set; }
[Required]
[Display(Name = "串口")]
public string SerialPort { get; set; }
[Required]
[Display(Name = "波特率")]
public int Baud { get; set; } = 9600;
[Required]
[Display(Name = "数据位")]
public int Data { get; set; } = 8;
[Required]
[Display(Name = "停止位")]
public int StopBits { get; set; } = 0;
[Required]
[Display(Name = "校验位")]
public int Partity { get; set; } = 0;
}
}

@ -1,11 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace SerialPortService.Application.Models
{
public class EditSerialPortDeviceModel
{
}
}

@ -1,33 +0,0 @@
using System.Linq;
using Application.Domain.Entities;
using Application.Models;
using Infrastructure.Data;
using Infrastructure.Extensions;
using Infrastructure.Web.Mvc;
using IoTShared.Controllers;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace IoTCenter.Areas.Admin.Controllers
{
[Authorize]
[Area(nameof(Admin))]
public class DataController : CrudController<Data, DataSearchModel, EditDataModel, EditDataModel>
{
private readonly AjaxController _ajax;
public DataController(IRepository<Data> repo, AjaxController ajax) : base(repo)
{
this._ajax = ajax;
}
public override IQueryable<Data> Query(DataSearchModel model, IQueryable<Data> query)
{
ViewData.SelectList(o => model.NodeId, () => this._ajax.GetNodeSelectList(model.NodeId));
ViewData.SelectList(o => model.DeviceId, () => this._ajax.GetDeviceSelectList(model.NodeId.Value, model.DeviceId), model.NodeId.HasValue);
return query.WhereIf(model.NodeId.HasValue, o => o.Device.NodeId == model.NodeId.Value)
.WhereIf(model.DeviceId.HasValue, o => o.DeviceId == model.DeviceId.Value)
.WhereIf(!string.IsNullOrEmpty(model.Keyword), o => o.Name.Contains(model.Keyword));
}
}
}

@ -1,55 +0,0 @@
using Application.Domain.Entities;
using Application.Models;
using Infrastructure.Data;
using Infrastructure.Extensions;
using Infrastructure.Web.Mvc;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.Linq;
namespace IoTCenter.Areas.Admin.Controllers
{
[Authorize]
[Area(nameof(Admin))]
public class DeviceController : CrudController<Device, DeviceSearchMode, EditDeviceModel, EditDeviceModel>
{
private readonly IConfiguration _cfg;
private readonly IRepository<product> _productRepo;
public DeviceController(IConfiguration cfg, IRepository<product> productRepo, IRepository<Device> repo) : base(repo)
{
this._cfg = cfg;
this._productRepo = productRepo;
}
public override IActionResult Add()
{
var model = new EditDeviceModel
{
CategoryNumber = "20",
InfoNumber = "serialport",
ConnectId = this._cfg["ConnectId"],
Number = Guid.NewGuid().ToBase62(),
NodeNumber = this._cfg["node.number"]
};
return View(model);
}
public override void ToEntity(EditDeviceModel model, Device entity)
{
if (!this.repo.ReadOnlyTable().Any(o => o.Id == model.Id))
{
entity.ProductId = this._productRepo.ReadOnlyTable().First().Id;
entity.AddorUpdateData("SerialPort", "", DeviceDataType.String, "串口", hidden: true);
entity.AddorUpdateData("Baud", "9600", DeviceDataType.Int, "波特率", hidden: true);
entity.AddorUpdateData("Partity", "0", DeviceDataType.Int, "校验位", hidden: true);
entity.AddorUpdateData("DataBits", "8", DeviceDataType.Int, "数据位", hidden: true);
entity.AddorUpdateData("StopBits", "1", DeviceDataType.Int, "停止位", hidden: true);
entity.AddorUpdateData("Buttons", new List<KeyValuePair<string, string>> { new KeyValuePair<string, string>("测试按键", "11111111") }.ToJson(), DeviceDataType.SelectList, "按键");
}
}
}
}

@ -1,19 +0,0 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace UserCenter.Areas.Admin.Controllers
{
[Authorize]
[Area(nameof(Admin))]
public class HomeController : Controller
{
public HomeController()
{
}
public IActionResult Index()
{
return View();
}
}
}

@ -1,4 +0,0 @@
@{
ViewData["IsHomePage"] = true;
}
<h1>首页</h1>

@ -1,52 +0,0 @@
<section class="sidebar" style="height: auto;">
<ul class="sidebar-menu" data-widget="tree">
<li class="@GetClass("Home")"><a href="@Url.Action("Index","Home")"><i class="fa fa-circle-o"></i><span>首页</span></a></li>
<li class="@GetClass("Configuration")"><a href="@Url.Action("Index","Configuration")"><i class="fa fa-circle-o"></i><span>网站配置</span></a></li>
<li class="treeview @GetClass("User","Role","Permission")">
<a href="javascript:;" class="dropdown-toggle">
<i class="fa fa-list"></i>
<span>权限管理</span>
<span class="pull-right-container">
<i class="fa fa-angle-left pull-right"></i>
</span>
</a>
<ul class="treeview-menu">
<li class="@GetClass("User")"><a href="@Url.Action("Index","User")"><i class="fa fa-circle-o"></i><span>用户管理</span></a></li>
<li class="@GetClass("Role")"><a href="@Url.Action("Index","Role")"><i class="fa fa-circle-o"></i><span>角色管理</span></a></li>
<li class="@GetClass("Permission")"><a href="@Url.Action("Index","Permission")"><i class="fa fa-circle-o"></i><span>权限管理</span></a></li>
</ul>
</li>
<li class="treeview @GetClass("Node","Device","Data","Api","Parameter","Scene","Command")">
<a href="javascript:;" class="dropdown-toggle">
<i class="fa fa-list"></i>
<span>设备管理</span>
<span class="pull-right-container">
<i class="fa fa-angle-left pull-right"></i>
</span>
</a>
<ul class="treeview-menu">
<li class="@GetClass("Node")"><a href="@Url.Action("Index","Node")"><i class="fa fa-circle-o"></i><span>节点管理</span></a></li>
<li class="@GetClass("Device")"><a href="@Url.Action("Index","Device")"><i class="fa fa-circle-o"></i><span>设备管理</span></a></li>
<li class="@GetClass("Data")"><a href="@Url.Action("Index","Data")"><i class="fa fa-circle-o"></i><span>数据管理</span></a></li>
<li class="@GetClass("Api")"><a href="@Url.Action("Index","Api")"><i class="fa fa-circle-o"></i><span>接口管理</span></a></li>
<li class="@GetClass("Parameter")"><a href="@Url.Action("Index","Parameter")"><i class="fa fa-circle-o"></i><span>参数管理</span></a></li>
<li class="@GetClass("Scene")"><a href="@Url.Action("Index","Scene")"><i class="fa fa-circle-o"></i><span>场景管理</span></a></li>
<li class="@GetClass("Command")"><a href="@Url.Action("Index","Command")"><i class="fa fa-circle-o"></i><span>命令管理</span></a></li>
</ul>
</li>
</ul>
</section>
@functions{
public string GetClass(params string[] controllers)
{
if (controllers.Select(o => o.ToLower()).Contains(this.ViewContext.RouteData.Values["controller"].ToString().ToLower()))
{
if (controllers.Length > 1)
{
return "active open";
}
return "active";
}
return "";
}
}

@ -1,24 +0,0 @@
<script>
function clear() {
for (var i = 0; i < arguments.length; i++) {
$(arguments[i]).find('option').not('[value=""]').remove();
}
}
function update(url, id) {
$.getJSON(url, function (data) {
$.each(data, function (i, v) {
$(id).append('<option value="' + v.Value + '">' + v.Text + '</option>');
});
});
}
$(function () {
$('#NodeId').change(function () {
var id = $(this).find(':selected').val();
clear('#DeviceId');
if (id) {
var url = '@Url.Action("GetDeviceJson", "Ajax")?parentId=' + encodeURI(id);
update(url,'#DeviceId');
}
});
});
</script>

@ -1,7 +0,0 @@
@inherits Infrastructure.Web.Mvc.Razor.MyRazorPage<TModel>
@using Infrastructure.Application
@using Infrastructure.Extensions
@using Infrastructure.Data
@using Application.Domain.Entities
@using Application.Models
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

@ -1,22 +0,0 @@
using Application.Domain.Entities;
using Infrastructure.Data;
using Infrastructure.Email;
using Infrastructure.Resources;
using Infrastructure.Security;
using IoT.UI.Shard.Controllers;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Localization;
namespace ONVIFService.Controllers
{
public class AccountController : BaseAccountController
{
public AccountController(IConfiguration configuration,
IRepository<User> userRepo,
IEncryptionService encryptionService,
IStringLocalizer<Resource> localizer,
IEmailSender emaliSender) : base(configuration, userRepo, encryptionService, localizer, emaliSender)
{
}
}
}

@ -1,49 +0,0 @@
using Application.Domain.Entities;
using Infrastructure.Data;
using Infrastructure.Extensions;
using Microsoft.AspNetCore.Mvc;
using SPService.Applicaiton.Models;
using System;
using System.Net.Http;
namespace SerialPortService.Controllers
{
public class HomeController : Controller
{
private readonly IRepository<Button> _cameraRepo;
private readonly IHttpClientFactory _httpClientFactory;
private readonly DeviceService _spService;
public HomeController(IHttpClientFactory httpClientFactory, DeviceService spService, IRepository<Button> cameraRepo)
{
this._cameraRepo = cameraRepo;
this._httpClientFactory = httpClientFactory;
this._spService = spService;
}
public IActionResult Index()
{
return View(new EditButtonModel { Name = "test" });
}
[HttpPost]
public IActionResult Index(EditButtonModel model)
{
if (ModelState.IsValid)
{
try
{
var button = new Button().From(model);
this._spService.ExecInternal(button.SerialPort, button.Baud, button.Data, button.Partity, button.StopBits, button.Message);
ViewBag.Result = "success";
}
catch (Exception ex)
{
ex.PrintStack();
ModelState.AddModelError("", ex.Message);
}
}
return View(model);
}
}
}

@ -1,55 +0,0 @@
using Application.Models;
using IoT.Shared.Controllers;
using Microsoft.AspNetCore.Mvc;
using Swashbuckle.AspNetCore.Annotations;
using System;
namespace SerialPortService.Controllers
{
[SwaggerTag("串口")]
public class SerialPortController : BaseDeviceController
{
private readonly DeviceService _deviceService;
public SerialPortController(IServiceProvider applicationServices, DeviceService deviceService) : base(applicationServices)
{
this._deviceService = deviceService;
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse AddButton([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number, [SwaggerParameter("名称")]string key, [SwaggerParameter("消息")]string value)
{
return this.AsyncAction(() =>
{
//this._deviceService.UpdateButtons(number, buttons);
});
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse EditButton([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number, [SwaggerParameter("名称")]string key, [SwaggerParameter("消息")]string value)
{
return this.AsyncAction(() =>
{
//this._deviceService.UpdateButtons(number, buttons);
});
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse DeleteButton([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number, [SwaggerParameter("名称")]string key)
{
return this.AsyncAction(() =>
{
//this._deviceService.UpdateButtons(number, buttons);
});
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse PressButton([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number, [SwaggerParameter("按键码")]string key)
{
return this.AsyncAction(() =>
{
this._deviceService.Exec(number, key);
});
}
}
}

@ -1,128 +0,0 @@
using Application.Domain.Entities;
using Application.Models;
using Infrastructure.Data;
using Infrastructure.Extensions;
using IoT.Shared.Infrastructure;
using IoT.Shared.Services;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using RJCP.IO.Ports;
using System;
using System.Collections.Generic;
using System.IO.Ports;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
namespace SerialPortService
{
public class DeviceService : BaseDeviceService
{
public DeviceService(IServiceProvider applicationServices, IConfiguration configuration)
: base(applicationServices, configuration)
{
}
#region impl interface
public override void Start()
{
Task.Run(() =>
{
using (var scope = _applicationServices.CreateScope())
{
var productNumber = "serialport";
var productRepo = scope.ServiceProvider.GetService<IRepository<Product>>();
var product = productRepo.Table().FirstOrDefault(o => o.Number == productNumber);
if (product == null)
{
product = new Product
{
Number = productNumber,
Name = "串口",
ApiJson = this.GetApiJson("/SerialPort/")
};
OpenApiService.UpdateApi(product);
productRepo.Add(product);
productRepo.SaveChanges();
}
}
});
base.Start();
}
public override void Execute()
{
Notify();
}
#endregion impl interface
public void Exec(string id, string code)
{
using (var scope = _applicationServices.CreateScope())
{
var repo = scope.ServiceProvider.GetService<IRepository<Device>>();
var device = repo.ReadOnlyTable().Include(o => o.Data).FirstOrDefault(o => o.Number == id);
var port = device.GetDataValue("SerialPort");
var baud = Convert.ToInt32(device.GetDataValue("Baud"));
var dataBits = Convert.ToInt32(device.GetDataValue("DataBits"));
var partity = Convert.ToInt32(device.GetDataValue("Partity"));
var stopBits = Convert.ToInt32(device.GetDataValue("StopBits"));
var buttonsValue = device.Data.FirstOrDefault(o => o.Key == "Buttons").Value;
var buttons = buttonsValue.FromJson<List<KeyValuePair<string, string>>>();
var message = buttons.FirstOrDefault(o => o.Key == code).Value;
this.ExecInternal(port, baud, dataBits, partity, stopBits, message);
}
}
public void ExecInternal(string port, int baud, int dataBits, int partity, int stopBits, string message)
{
try
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
using (var sp = new SerialPortStream(port, baud, dataBits, (RJCP.IO.Ports.Parity)partity, (RJCP.IO.Ports.StopBits)stopBits))
{
sp.Open();
var bytes = message.HexToBytes();
sp.Write(bytes, 0, bytes.Length);
sp.Flush();
sp.Close();
}
}
else
{
using (var sp = new SerialDevice(port, (BaudRate)baud, (System.IO.Ports.Parity)partity, dataBits, (System.IO.Ports.StopBits)stopBits))
{
sp.Open();
var bytes = message.HexToBytes();
sp.Write(bytes);
sp.Close();
}
}
}
catch (Exception ex)
{
ex.PrintStack();
}
}
public void Notify()
{
using (var scope = _applicationServices.CreateScope())
{
var repo = scope.ServiceProvider.GetService<IRepository<Device>>();
var devices = repo.ReadOnlyTable().Include(o => o.Product).Include(o => o.Node).ToList();
foreach (var device in devices)
{
var deviceDto = device.To<EditDeviceModel>();
deviceDto.ProductNumber = device.Product.Number;
deviceDto.NodeNumber = device.Node.Number;
this.SendToServer(Methods.EditDeviceResponse, deviceDto);
}
}
}
}
}

@ -1,41 +0,0 @@
using System;
using System.Collections.Generic;
using Infrastructure.Application;
using Infrastructure.Configuration;
using Infrastructure.Extensions;
using Infrastructure.Web.Hosting;
using Microsoft.AspNetCore;
namespace SerialPortService
{
public class Program
{
public static void Main(string[] args)
{
var host = "localhost";
WebHost.CreateDefaultBuilder(args)
.Run<Startup>(new List<EFConfigurationValue> {
new EFConfigurationValue { Id = "openapi.name", Value= "v1" },
new EFConfigurationValue { Id = "openapi.title", Value= "web api" },
new EFConfigurationValue { Id = "openapi.version", Value= "1.0" },
new EFConfigurationValue { Id = "security:key", Value= "111111111111111111111111"},
new EFConfigurationValue { Id = "security:iv", Value= "11111111"},
new EFConfigurationValue { Id = "email:host", Value= "nbaxp.com"},
new EFConfigurationValue { Id = "email:port", Value= "25"},
new EFConfigurationValue { Id = "email:user", Value= "admin@nbaxp.com"},
new EFConfigurationValue { Id = "email:password", Value= "aA123456"},
new EFConfigurationValue { Id = "server.ip", Value= "" },
new EFConfigurationValue { Id = "server.urls", Value= "http://*:8007" },
new EFConfigurationValue { Id = "notify:enabled", Value= "false"},
new EFConfigurationValue { Id = "notify:host", Value= $"{host}:8001"},
new EFConfigurationValue { Id = "timer.seconds", Value="600"},
new EFConfigurationValue { Id = "connectId", Value= Guid.NewGuid().ToBase62() },
new EFConfigurationValue { Id = "node.number", Value= "节点编号" },
//
new EFConfigurationValue { Id = "name", Value= "SerialPort服务"},
new EFConfigurationValue { Id = "logo", Value= "/images/logo.png",Type= InputType.ImageUrl},
new EFConfigurationValue { Id = "copyright", Value= "Copyright © {now} Company. All rights reserved",Type= InputType.Html}
});
}
}
}

@ -1,27 +0,0 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:8007/",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"OnvifService": {
"commandName": "Project",
"launchBrowser": true,
"applicationUrl": "http://127.0.0.1:8007/",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

@ -1,27 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="crozone.LinuxSerialPort" Version="1.2.0" />
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="NetCoreSerial" Version="1.3.1" />
<PackageReference Include="SerialPortStream" Version="2.2.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="4.0.1" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="4.0.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Infrastructure\Infrastructure.csproj" />
<ProjectReference Include="..\..\IoT.Shared\IoT.Shared.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="libnserial.so.1">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save