59 lines
1.6 KiB
C#
59 lines
1.6 KiB
C#
using AutoMapper;
|
|
using Microsoft.Extensions.Caching.Memory;
|
|
using SqlSugar;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using UIStandardWebApi.Entity;
|
|
using UIStandardWebApi.IService;
|
|
|
|
namespace UIStandardWebApi.Service
|
|
{
|
|
/// <summary>
|
|
/// Socket通信连接服务层
|
|
/// </summary>
|
|
public class SocketConnectionService : BaseService, ISocketConnectionService
|
|
{
|
|
private readonly IMapper _IMapper;
|
|
private readonly IMemoryCache _IMemoryCache;
|
|
|
|
public SocketConnectionService(ISqlSugarClient client, IMapper mapper, IMemoryCache iMemoryCache) : base(client)
|
|
{
|
|
_IMapper = mapper;
|
|
_IMemoryCache = iMemoryCache;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取通信连接的ip及端口号
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public Sys_Socket ObtainAddress()
|
|
{
|
|
Sys_Socket socket = _Client.Queryable<Sys_Socket>() .OrderBy(c => c.Id, OrderByType.Desc).First();
|
|
return socket;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 新增通信信息
|
|
/// </summary>
|
|
/// <param name="ip"></param>
|
|
/// <param name="port"></param>
|
|
/// <returns></returns>
|
|
public int InserAddress(string ip, string port)
|
|
{
|
|
int inItSocketId = 0;
|
|
inItSocketId = _Client.Insertable<Sys_Socket>(new Sys_Socket()
|
|
{
|
|
IP = ip,
|
|
Port = port,
|
|
}).ExecuteReturnIdentity();
|
|
|
|
return inItSocketId;
|
|
}
|
|
|
|
|
|
}
|
|
}
|