Skip to content

Commit

Permalink
增加默认上报系统目录项,页面暂未支持目录
Browse files Browse the repository at this point in the history
  • Loading branch information
vanjoge committed Jul 24, 2024
1 parent 1595fc3 commit f39c2cb
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 17 deletions.
32 changes: 20 additions & 12 deletions SipServer/Cascade/CascadeClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -272,24 +272,28 @@ protected internal void AddChannel(SuperiorChannel item)
Model = item.Model,
Owner = item.Owner,
CivilCode = item.CivilCode,
Block = item.Block,
Block = Empty2Null(item.Block),
Address = item.Address,
Parental = item.Parental ? 1 : 0,
ParentID = item.ParentId,
BusinessGroupID = item.BusinessGroupId,
SafetyWay = item.SafetyWay,
BusinessGroupID = Empty2Null(item.BusinessGroupId),
RegisterWay = item.RegisterWay,
CertNum = item.CertNum,
Certifiable = item.Certifiable ? 1 : 0,
ErrCode = item.ErrCode,
EndTime = item.EndTime?.ToTStr(),
Secrecy = item.Secrecy ? 1 : 0,
IPAddress = item.Ipaddress,
Password = item.Password,
IPAddress = Empty2Null(item.Ipaddress),
Password = Empty2Null(item.Password),
Status = item.Status,
Longitude = item.Longitude,
Latitude = item.Latitude,
};
if (item.IsDevice)
{
ci.Parental = item.Parental ? 1 : 0;
ci.SafetyWay = item.SafetyWay;
}
if (item.EndTime.HasValue)
{
ci.CertNum = item.CertNum;
ci.Certifiable = item.Certifiable ? 1 : 0;
ci.ErrCode = item.ErrCode;
ci.EndTime = item.EndTime.Value.ToTStr();
}
if (item.Port > 0)
ci.Port = (ushort)item.Port;
if (item.Longitude > 0)
Expand All @@ -304,5 +308,9 @@ protected internal void RemoveChannel(string ChannelId)
ditChild.TryRemove(ChannelId, out var citem);
}

private static string Empty2Null(string val)
{
return string.IsNullOrEmpty(val) ? null : val;
}
}
}
34 changes: 31 additions & 3 deletions SipServer/Cascade/CascadeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,43 @@ public async Task<bool> Remove(params string[] ids)
}
async Task<bool> AddClient(TSuperiorInfo sinfo)
{
var channels = await sipServer.DB.GetSuperiorChannels(sinfo.Id);
var tmp = await sipServer.DB.GetSuperiorChannels(sinfo.Id);
var id = sinfo.ClientId;
var ClientName = string.IsNullOrEmpty(sinfo.ClientName) ? sinfo.Name : sinfo.ClientName;
var root = new SuperiorChannel(new TCatalog
{
ChannelId = id,
DeviceId = id,
Name = ClientName,
Manufacturer = "RTVS",
Model = "gbsip",
Owner = "Owner",
CivilCode = id.Substring(0, 6),
Address = "Address",
RegisterWay = 1,
Secrecy = false,
},
null,
false
);
var channels = new List<SuperiorChannel>
{
//添加系统目录项
root
};
foreach (var channel in tmp)
{
channel.ParentId = id;
channels.Add(channel);
}
CascadeClient client = new CascadeClient(this, sinfo.Id, SuperiorInfoEx.GetServerSipStr(sinfo), sinfo.ServerId, new GB28181.XML.DeviceInfo
{
DeviceID = sinfo.ClientId,
DeviceName = string.IsNullOrEmpty(sinfo.ClientName) ? sinfo.Name : sinfo.ClientName,
DeviceName = ClientName,
Manufacturer = "RTVS",
Model = "gbsip",
Result = "OK",
Firmware = "v0.1"
Firmware = "v0.2"

}, channels, authUsername: sinfo.Sipusername, password: sinfo.Sippassword, expiry: sinfo.Expiry, UserAgent: sipServer.UserAgent, EnableTraceLogs: sipServer.Settings.EnableSipLog, heartSec: sinfo.HeartSec, timeOutSec: sinfo.HeartTimeoutTimes * sinfo.HeartSec
, localPort: sinfo.ClientPort);
Expand Down
2 changes: 1 addition & 1 deletion SipServer/GBClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ async Task MessageProcess(SIPEndPoint localSipEndPoint, SIPEndPoint remoteEndPoi
RegisterWay = item.RegisterWay.HasValue ? item.RegisterWay.Value : 1,
SafetyWay = item.SafetyWay.HasValue ? item.SafetyWay.Value : 0,
Secrecy = item.Secrecy == 1,
Status = item.Status,
Status = item.Status ?? "",
Online = "ON".IgnoreEquals(item.Status),
};
if (string.IsNullOrWhiteSpace(citem.ParentId) || citem.ParentId == ServerID)
Expand Down
11 changes: 10 additions & 1 deletion SipServer/Models/SuperiorChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ namespace SipServer.Models
{
public class SuperiorChannel : TCatalog
{
public SuperiorChannel(TCatalog item, TSuperiorChannel channel)
public SuperiorChannel(TCatalog item, TSuperiorChannel channel) : this(item, channel, true)
{

}
public SuperiorChannel(TCatalog item, TSuperiorChannel channel, bool isDevice)
{
ChannelId = item.ChannelId;
DeviceId = item.DeviceId;
Expand Down Expand Up @@ -50,6 +54,7 @@ public SuperiorChannel(TCatalog item, TSuperiorChannel channel)
Enable = channel.Enable;
CustomChannelId = channel.CustomChannelId;
}
IsDevice = isDevice;
}
public ulong RowId { get; set; }
/// <summary>
Expand All @@ -64,6 +69,10 @@ public SuperiorChannel(TCatalog item, TSuperiorChannel channel)
/// 自定义通道ID
/// </summary>
public string CustomChannelId { get; set; }
/// <summary>
/// 设备/目录
/// </summary>
public bool IsDevice { get; set; }

public string GetChannelId()
{
Expand Down

0 comments on commit f39c2cb

Please sign in to comment.