Yyt.Abp.HkSdk.Grpc.Server
1.0.0
dotnet add package Yyt.Abp.HkSdk.Grpc.Server --version 1.0.0
NuGet\Install-Package Yyt.Abp.HkSdk.Grpc.Server -Version 1.0.0
<PackageReference Include="Yyt.Abp.HkSdk.Grpc.Server" Version="1.0.0" />
<PackageVersion Include="Yyt.Abp.HkSdk.Grpc.Server" Version="1.0.0" />
<PackageReference Include="Yyt.Abp.HkSdk.Grpc.Server" />
paket add Yyt.Abp.HkSdk.Grpc.Server --version 1.0.0
#r "nuget: Yyt.Abp.HkSdk.Grpc.Server, 1.0.0"
#:package Yyt.Abp.HkSdk.Grpc.Server@1.0.0
#addin nuget:?package=Yyt.Abp.HkSdk.Grpc.Server&version=1.0.0
#tool nuget:?package=Yyt.Abp.HkSdk.Grpc.Server&version=1.0.0
Yyt.Abp.HkSdk.Grpc.Server
English Version
Overview
Yyt.Abp.HkSdk.Grpc.Server is a library that provides the functionality to encapsulate the Hikvision SDK (hksdk) protocol as a gRPC server service for .NET applications. Built with a modular architecture, it enables seamless integration into your existing projects. Maintained and supported by Patrick.Z, it streamlines routine development configurations in .NET applications and takes over heavy, tedious workloads for you.
Why Choose Yyt.Abp.HkSdk.Grpc.Server?
- Minimal Dependencies: Lightweight design with few external dependencies, keeps your project lean and efficient.
- Secure by Design: Security is prioritized from the design phase to reduce potential vulnerabilities.
- Highly Extensible: Easy to extend and customize to meet your specific business requirements.
- Battle-Tested: Proven stable and reliable through validation in multiple production projects.
Core Features
- gRPC Server Encapsulation: Encapsulates Hikvision SDK protocol as gRPC server services
- Device Management: Device list query, offline device list query
- Video File Operations: Video file download by time/range, download by file name, download progress query, stop download
- Video Record Query: Video retrieval, monthly calendar query for recorded videos
- File Task Management: Delete file task query
Code Integration Example
Note: This library references the Yyt.Abp.HkSdk package. Please add the relevant configuration settings to your configuration file before using this service.
namespace Demo.HttpApi.Host
{
[DependsOn(
typeof(HKSdkGrpcModule)
)]
public class DemoHttpApiHostModule : AbpModule
{
// config service & other
}
}
Client gRPC Service Usage Example
Step 1: Create a new Protos directory and place the proto files in it.
Step 2: Add proto protocol files in csproj:
<ItemGroup>
<Protobuf Include="Protos\*.proto" GrpcServices="Client" Link="Protos\%(RecursiveDir)%(Filename)%(Extension)" />
<Content Include="@(Protobuf)" />
<None Remove="@(Protobuf)" />
</ItemGroup>
Step 3: Code Usage
public void QueryFileRecod(QueryFileRecodInput input)
{
var channel = GrpcChannel.ForAddress("grpc server url");
var client = new VideoRecord.VideoRecordClient(channel);
var reply = client.GetVideoMonthlyCalendar(new VideoMonthlyCalendarRequest()
{
DeviceIp = deviceIP,
DevicePort = Convert.ToInt32(devicePort),
DateTime = queryTime,
ChannelID = channelID,
UserName = userName,
Password = password,
});
foreach (var item in reply.CalendarList)
{
Console.WriteLine(item.DateTime + " " + (item.IsHaveFile == 1 ? "有" : "无"));
}
}
Configuration Example
appsettings.json:
{
"Kestrel": {
"Endpoints": {
"gRPC": {
"Url": "http://***:**",
"Protocols": "Http2"
}
}
}
}
Proto Files Appendix
greet.proto
syntax = "proto3";
option csharp_namespace = "Yyt.Abp.Grpc";
import "google/protobuf/empty.proto";
package greet;
service Greeter {
rpc SayHello (HelloRequest) returns (HelloReply);
rpc GetDvrList(GetDvrListRequest) returns(GetDvrListReply);
rpc GetDownDvrList(google.protobuf.Empty) returns(GetDownDvrListReply);
rpc GetDeleteFileTask(google.protobuf.Empty) returns(GetDeleteFileTaskReply);
}
message HelloRequest {
string name = 1;
}
message GetDvrListRequest {
string DeviceIps = 1;
bool IsShowChannle=2;
}
message HelloReply {
string message = 1;
}
message GetDvrListReply{
int32 code=1;
string message=2;
repeated DeviceInfo devices = 3;
}
message GetDownDvrListReply{
int32 code=1;
string message=2;
repeated DeviceInfo devices = 3;
}
message GetDeleteFileTaskReply{
int32 code=1;
string message=2;
}
message DeviceInfo{
string deviceTitel=1;
repeated ChannelInfo channels=2;
string fileName=3;
}
message ChannelInfo{
string channelCn=3;
}
VideoFile.proto
syntax = "proto3";
option csharp_namespace = "Yyt.Abp.Grpc";
service VideoFile{
rpc DownloadByTime(DowFileRequest) returns(DowFileReply);
rpc GetDownloadPos(GetDownloadPosRequest) returns(GetDownloadPosReply);
rpc StopDownload(GetDownloadPosRequest) returns(GetDownloadPosReply);
rpc DownloadByName(DowFileByNameRequest) returns(DowFileReply);
}
message DowFileRequest{
string deviceIp=1;
int32 devicePort=2;
string userName=3;
string password=4;
string beginTime=5;
string endTime=6;
string channelID=7;
string platUserName=8;
string platUserId=9;
string fileName=10;
}
message DowFileByNameRequest{
string deviceIp=1;
int32 devicePort=2;
string userName=3;
string password=4;
string channelID=5;
string platUserName=6;
string platUserId=7;
string fileName=8;
}
message GetDownloadPosRequest{
string deviceIp=1;
string platUserName=2;
string platUserId=3;
string fileName=4;
int32 downHandle=6;
}
message DowFileReply{
int32 code=1;
string message=2;
string fileName=4;
string filePath=5;
int32 downHandle=6;
}
message GetDownloadPosReply{
int32 code=1;
string message=2;
int32 pos = 3;
}
message DelFileReply{
int32 code=1;
string message=2;
bool isRun=3;
float periodHour=4;
}
VideoRecord.proto
syntax = "proto3";
option csharp_namespace = "Yyt.Abp.Grpc";
package videorecord;
service VideoRecord{
rpc GetVideoRetrieva(VideoFileRequest) returns(VideoFileReply);
rpc GetVideoMonthlyCalendar(VideoMonthlyCalendarRequest) returns(VideoMonthlyCalendarReply);
}
message VideoFileRequest{
string deviceIp=1;
int32 devicePort=2;
string userName=3;
string password=4;
string beginTime=5;
string endTime=6;
string channelID=7;
}
message VideoMonthlyCalendarRequest{
string deviceIp=1;
int32 devicePort=2;
string userName=3;
string password=4;
string dateTime=5;
string channelID=6;
}
message VideoFileReply{
int32 code=1;
string message=2;
repeated FileInfo files = 3;
}
message VideoMonthlyCalendarReply{
int32 code=1;
string message=2;
repeated VideoCalendar calendarList = 3;
}
message FileInfo{
string fileName=1;
string beginTime=2;
string endTime=3;
int32 fileSize=4;
}
message VideoCalendar{
string dateTime=1;
int32 isHaveFile=2;
}
Chinese Version
概述
Yyt.Abp.HkSdk.Grpc.Server 提供了 .Net 程序封装 hksdk 协议为 gRPC server 服务功能。代码采用了 Module 模块化设计,能无缝集成到项目中。该库由 Patrick.Z 提供支持,简化了 .Net 应用程序中的日常开发配置工作,为您分担繁重的工作。
为什么选择 Yyt.Abp.HkSdk.Grpc.Server?
- 极少依赖:轻量级设计,外部依赖少,保持项目精简高效
- 设计安全:从设计阶段就优先考虑安全性,减少潜在漏洞
- 可扩展定制:易于扩展和定制,满足特定业务需求
- 久经沙场:经过多个生产项目验证,稳定可靠
核心功能
- gRPC 服务封装:将海康 SDK 协议封装为 gRPC 服务
- 设备管理:设备列表查询、离线设备列表查询
- 视频文件操作:按时间/范围下载、按文件名下载、下载进度查询、停止下载
- 录像查询:录像检索、录像月度日历查询
- 文件任务管理:删除文件任务查询
代码模块集成示例
注意: 本库引用了 Yyt.Abp.HkSdk 包。请在使用该服务前,配置文件先增加包相关配置信息。
namespace Demo.HttpApi.Host
{
[DependsOn(
typeof(HKSdkGrpcModule)
)]
public class DemoHttpApiHostModule : AbpModule
{
// config service & other
}
}
客户端 gRPC 服务调用示例
步骤 1:新建 Protos 文件目录并将 proto 文件放入。
步骤 2:在 csproj 中添加 proto 协议文件:
<ItemGroup>
<Protobuf Include="Protos\*.proto" GrpcServices="Client" Link="Protos\%(RecursiveDir)%(Filename)%(Extension)" />
<Content Include="@(Protobuf)" />
<None Remove="@(Protobuf)" />
</ItemGroup>
步骤 3:代码调用
public void QueryFileRecod(QueryFileRecodInput input)
{
var channel = GrpcChannel.ForAddress("grpc server url");
var client = new VideoRecord.VideoRecordClient(channel);
var reply = client.GetVideoMonthlyCalendar(new VideoMonthlyCalendarRequest()
{
DeviceIp = deviceIP,
DevicePort = Convert.ToInt32(devicePort),
DateTime = queryTime,
ChannelID = channelID,
UserName = userName,
Password = password,
});
foreach (var item in reply.CalendarList)
{
Console.WriteLine(item.DateTime + " " + (item.IsHaveFile == 1 ? "有" : "无"));
}
}
配置示例
appsettings.json:
{
"Kestrel": {
"Endpoints": {
"gRPC": {
"Url": "http://***:**",
"Protocols": "Http2"
}
}
}
}
Proto 文件附录
greet.proto
syntax = "proto3";
option csharp_namespace = "Yyt.Abp.Grpc";
import "google/protobuf/empty.proto";
package greet;
service Greeter {
rpc SayHello (HelloRequest) returns (HelloReply);
rpc GetDvrList(GetDvrListRequest) returns(GetDvrListReply);
rpc GetDownDvrList(google.protobuf.Empty) returns(GetDownDvrListReply);
rpc GetDeleteFileTask(google.protobuf.Empty) returns(GetDeleteFileTaskReply);
}
message HelloRequest {
string name = 1;
}
message GetDvrListRequest {
string DeviceIps = 1;
bool IsShowChannle=2;
}
message HelloReply {
string message = 1;
}
message GetDvrListReply{
int32 code=1;
string message=2;
repeated DeviceInfo devices = 3;
}
message GetDownDvrListReply{
int32 code=1;
string message=2;
repeated DeviceInfo devices = 3;
}
message GetDeleteFileTaskReply{
int32 code=1;
string message=2;
}
message DeviceInfo{
string deviceTitel=1;
repeated ChannelInfo channels=2;
string fileName=3;
}
message ChannelInfo{
string channelCn=3;
}
VideoFile.proto
syntax = "proto3";
option csharp_namespace = "Yyt.Abp.Grpc";
service VideoFile{
rpc DownloadByTime(DowFileRequest) returns(DowFileReply);
rpc GetDownloadPos(GetDownloadPosRequest) returns(GetDownloadPosReply);
rpc StopDownload(GetDownloadPosRequest) returns(GetDownloadPosReply);
rpc DownloadByName(DowFileByNameRequest) returns(DowFileReply);
}
message DowFileRequest{
string deviceIp=1;
int32 devicePort=2;
string userName=3;
string password=4;
string beginTime=5;
string endTime=6;
string channelID=7;
string platUserName=8;
string platUserId=9;
string fileName=10;
}
message DowFileByNameRequest{
string deviceIp=1;
int32 devicePort=2;
string userName=3;
string password=4;
string channelID=5;
string platUserName=6;
string platUserId=7;
string fileName=8;
}
message GetDownloadPosRequest{
string deviceIp=1;
string platUserName=2;
string platUserId=3;
string fileName=4;
int32 downHandle=6;
}
message DowFileReply{
int32 code=1;
string message=2;
string fileName=4;
string filePath=5;
int32 downHandle=6;
}
message GetDownloadPosReply{
int32 code=1;
string message=2;
int32 pos = 3;
}
message DelFileReply{
int32 code=1;
string message=2;
bool isRun=3;
float periodHour=4;
}
VideoRecord.proto
syntax = "proto3";
option csharp_namespace = "Yyt.Abp.Grpc";
package videorecord;
service VideoRecord{
rpc GetVideoRetrieva(VideoFileRequest) returns(VideoFileReply);
rpc GetVideoMonthlyCalendar(VideoMonthlyCalendarRequest) returns(VideoMonthlyCalendarReply);
}
message VideoFileRequest{
string deviceIp=1;
int32 devicePort=2;
string userName=3;
string password=4;
string beginTime=5;
string endTime=6;
string channelID=7;
}
message VideoMonthlyCalendarRequest{
string deviceIp=1;
int32 devicePort=2;
string userName=3;
string password=4;
string dateTime=5;
string channelID=6;
}
message VideoFileReply{
int32 code=1;
string message=2;
repeated FileInfo files = 3;
}
message VideoMonthlyCalendarReply{
int32 code=1;
string message=2;
repeated VideoCalendar calendarList = 3;
}
message FileInfo{
string fileName=1;
string beginTime=2;
string endTime=3;
int32 fileSize=4;
}
message VideoCalendar{
string dateTime=1;
int32 isHaveFile=2;
}
Document Version: v1.0
Created Date: July 2026
Author: Patrick.Z
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net6.0
- Google.Protobuf (>= 3.35.1)
- Grpc.AspNetCore.Server (>= 2.54.0)
- Grpc.AspNetCore.Web (>= 2.51.0)
- Grpc.Core (>= 2.46.6)
- Microsoft.AspNetCore.Grpc.HttpApi (>= 0.1.0-alpha.21317.5)
- protobuf-net.Grpc.AspNetCore (>= 1.1.1)
- Volo.Abp.AspNetCore (>= 6.0.2)
- Yyt.Abp.HkSdk (>= 1.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 57 | 7/10/2026 |