forked from fajiao/OnvifServer-CSharp
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.0 KiB
50 lines
1.0 KiB
3 years ago
|
using EC.App.Entity.Onvif;
|
||
|
using EC.App.ThatBLL.Onvif.Impl;
|
||
|
using EC.Onvif;
|
||
|
using System.Threading.Tasks;
|
||
|
|
||
|
namespace EC.App.ThatBLL.Onvif
|
||
|
{
|
||
|
public class CurdBLL : ICurdBLL
|
||
|
{
|
||
|
private readonly OnvifClientService _ocService;
|
||
|
|
||
|
public CurdBLL(OnvifClientService onvifClientService)
|
||
|
{
|
||
|
_ocService = onvifClientService;
|
||
|
}
|
||
|
|
||
|
#region Operate
|
||
|
|
||
|
public async Task<bool> Add(string ip, string username, string password)
|
||
|
{
|
||
|
bool flag = !_ocService.IsExist(ip);
|
||
|
if (!flag) { return false; }
|
||
|
OnvifClient onvifClient = new OnvifClient(ip, username, password);
|
||
|
await onvifClient.InitAsync();
|
||
|
bool ret = _ocService.TryAdd(ip, onvifClient);
|
||
|
return ret;
|
||
|
}
|
||
|
|
||
|
public bool Remove(string ip)
|
||
|
{
|
||
|
bool ret = _ocService.Remove(ip);
|
||
|
return ret;
|
||
|
}
|
||
|
|
||
|
public async Task<bool> Update(string ip, string username, string password)
|
||
|
{
|
||
|
Remove(ip);
|
||
|
bool ret = await Add(ip, username, password);
|
||
|
return ret;
|
||
|
}
|
||
|
|
||
|
public bool IsExist(string ip)
|
||
|
{
|
||
|
bool ret = _ocService.IsExist(ip);
|
||
|
return ret;
|
||
|
}
|
||
|
|
||
|
#endregion Operate
|
||
|
}
|
||
|
}
|