初始化
This commit is contained in:
13
BLWLogProduce/.config/dotnet-tools.json
Normal file
13
BLWLogProduce/.config/dotnet-tools.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"version": 1,
|
||||
"isRoot": true,
|
||||
"tools": {
|
||||
"dotnet-ef": {
|
||||
"version": "9.0.7",
|
||||
"commands": [
|
||||
"dotnet-ef"
|
||||
],
|
||||
"rollForward": false
|
||||
}
|
||||
}
|
||||
}
|
||||
55
BLWLogProduce/2.txt
Normal file
55
BLWLogProduce/2.txt
Normal file
@@ -0,0 +1,55 @@
|
||||
# HELP UDP_Upload Total bytes uploaded via UDP.
|
||||
# TYPE UDP_Upload gauge
|
||||
UDP_Upload 333
|
||||
|
||||
# HELP UDP_Sent Total UDP packets sent.
|
||||
# TYPE UDP_Sent gauge
|
||||
UDP_Sent 0
|
||||
|
||||
# HELP RCU_Online Current number of online RCU units.
|
||||
# TYPE RCU_Online gauge
|
||||
RCU_Online 0
|
||||
|
||||
# HELP RCU_TakeCard Total number of card take operations performed by RCU units.
|
||||
# TYPE RCU_TakeCard gauge
|
||||
RCU_TakeCard 0
|
||||
|
||||
# HELP RCU_Heart Total number of heartbeats received from RCU units.
|
||||
# TYPE RCU_Heart gauge
|
||||
RCU_Heart 0
|
||||
|
||||
# HELP RCU_SearchHost Total number of host search operations performed by RCU units.
|
||||
# TYPE RCU_SearchHost gauge
|
||||
RCU_SearchHost 0
|
||||
|
||||
# HELP Intercept Number of intercept operations or intercepted items.
|
||||
# TYPE Intercept gauge
|
||||
Intercept 0
|
||||
|
||||
# HELP WebUser Number of active web users currently connected.
|
||||
# TYPE WebUser gauge
|
||||
WebUser 0
|
||||
|
||||
# HELP Energy Current energy consumption or energy level.
|
||||
# TYPE Energy gauge
|
||||
Energy 0
|
||||
|
||||
# HELP RCU_0E Number of RCU units with type 0E status.
|
||||
# TYPE RCU_0E gauge
|
||||
RCU_OE 0
|
||||
|
||||
# HELP TCL_Ctr Control counter or status for TCL devices.
|
||||
# TYPE TCL_Ctr gauge
|
||||
TCL_Ctr 0
|
||||
|
||||
# HELP TM_Ctr Control counter or status for TM devices.
|
||||
# TYPE TM_Ctr gauge
|
||||
TM_Ctr 0
|
||||
|
||||
# HELP XD_Ctr Control counter or status for XD devices.
|
||||
# TYPE XD_Ctr gauge
|
||||
XD_Ctr 0
|
||||
|
||||
# HELP Hivi_Ctr Control counter or status for Hivi devices.
|
||||
# TYPE Hivi_Ctr gauge
|
||||
Hivi_Ctr 0
|
||||
30
BLWLogProduce/BLWLogProduce.csproj
Normal file
30
BLWLogProduce/BLWLogProduce.csproj
Normal file
@@ -0,0 +1,30 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Confluent.Kafka" Version="2.11.0" />
|
||||
<PackageReference Include="Google.Protobuf" Version="3.32.0" />
|
||||
<PackageReference Include="MessagePack" Version="3.1.4" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="NLog" Version="6.0.2" />
|
||||
<PackageReference Include="NLog.Schema" Version="6.0.2" />
|
||||
<PackageReference Include="RestSharp" Version="112.1.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\CommonEntity\CommonEntity.csproj" />
|
||||
<ProjectReference Include="..\CommonTools\CommonTools.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="Para_copy.yaml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
12
BLWLogProduce/BLWLogProduce.csproj.user
Normal file
12
BLWLogProduce/BLWLogProduce.csproj.user
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ActiveDebugProfile>http</ActiveDebugProfile>
|
||||
<Controller_SelectedScaffolderID>ApiControllerEmptyScaffolder</Controller_SelectedScaffolderID>
|
||||
<Controller_SelectedScaffolderCategoryPath>root/Common/Api</Controller_SelectedScaffolderCategoryPath>
|
||||
<NameOfLastUsedPublishProfile>E:\tian\BLS\BLWLogServer\BLWLogProduce\Properties\PublishProfiles\FolderProfile.pubxml</NameOfLastUsedPublishProfile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<DebuggerFlavor>ProjectDebugger</DebuggerFlavor>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
6
BLWLogProduce/BLWLogProduce.http
Normal file
6
BLWLogProduce/BLWLogProduce.http
Normal file
@@ -0,0 +1,6 @@
|
||||
@BLWLogProduce_HostAddress = http://localhost:5092
|
||||
|
||||
GET {{BLWLogProduce_HostAddress}}/weatherforecast/
|
||||
Accept: application/json
|
||||
|
||||
###
|
||||
23
BLWLogProduce/Controllers/HeartBeatController.cs
Normal file
23
BLWLogProduce/Controllers/HeartBeatController.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using BLWLogProduce.Services;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace BLWLogProduce.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class HeartBeatController : ControllerBase
|
||||
{
|
||||
[HttpPost()]
|
||||
public string Heart()
|
||||
{
|
||||
return "hello";
|
||||
}
|
||||
|
||||
[HttpPost()]
|
||||
public string getlocation(string ip)
|
||||
{
|
||||
return KafkaProduce.GetBaiduIp(ip);
|
||||
}
|
||||
}
|
||||
}
|
||||
33
BLWLogProduce/Controllers/WeatherForecastController.cs
Normal file
33
BLWLogProduce/Controllers/WeatherForecastController.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace BLWLogProduce.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class WeatherForecastController : ControllerBase
|
||||
{
|
||||
private static readonly string[] Summaries = new[]
|
||||
{
|
||||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
||||
};
|
||||
|
||||
private readonly ILogger<WeatherForecastController> _logger;
|
||||
|
||||
public WeatherForecastController(ILogger<WeatherForecastController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IEnumerable<WeatherForecast> Get()
|
||||
{
|
||||
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
|
||||
{
|
||||
Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
|
||||
TemperatureC = Random.Shared.Next(-20, 55),
|
||||
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
|
||||
})
|
||||
.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
1332
BLWLogProduce/EnergyConsumption.cs
Normal file
1332
BLWLogProduce/EnergyConsumption.cs
Normal file
File diff suppressed because it is too large
Load Diff
21
BLWLogProduce/EnergyConsumption.proto
Normal file
21
BLWLogProduce/EnergyConsumption.proto
Normal file
@@ -0,0 +1,21 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package BLWData.Entity;
|
||||
|
||||
// 定义一个Person消息类型
|
||||
message EnergyConsumption {
|
||||
int64 HotelCode = 1;
|
||||
string HostNumber = 2;
|
||||
string Mac = 3;
|
||||
string EndPoint = 4;
|
||||
string Version = 5;
|
||||
bool IsTakeCard = 6;
|
||||
double V = 7;
|
||||
double A = 8;
|
||||
double P = 9;
|
||||
double Energy_Consumption = 10;
|
||||
double Sum_Energy_Consumption = 11;
|
||||
int64 CreateTime=12;
|
||||
string RoomNumber=13;
|
||||
int32 CarbonVIP=14;
|
||||
}
|
||||
61
BLWLogProduce/Models/WaiBuJianKong.cs
Normal file
61
BLWLogProduce/Models/WaiBuJianKong.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
|
||||
namespace BLWLogProduce.Models
|
||||
{
|
||||
public class WaiBuJianKong
|
||||
{
|
||||
public static string WaiBuJianKongSourceFileName = "Para_copy.yaml";
|
||||
public static string WaiBuJianKongTargetFileName = "C:\\Program Files\\windows_exporter\\textfile_inputs\\Para.prom";
|
||||
public static string Data = "";
|
||||
|
||||
static WaiBuJianKong()
|
||||
{
|
||||
string getdata = File.ReadAllText(WaiBuJianKongSourceFileName, Encoding.UTF8);
|
||||
Data = getdata;
|
||||
}
|
||||
public static grafana_data data = new grafana_data();
|
||||
|
||||
public static string UDPPackage_TotalRecvPackage = "UDPPackage_TotalRecvPackage";
|
||||
public static string UDPPackage_TotalSendPackage = "UDPPackage_TotalSendPackage";
|
||||
public static string RCU_Online = "RCUOnLine";
|
||||
public static string TakeCardIn = "TakeCardIn";
|
||||
public static string UDPPackage_Heart = "UDPPackage_Heart";
|
||||
public static string UDPPackage_SearchHost = "UDPPackage_SearchHost";
|
||||
public static string UDPPackage_Intercept = "UDPPackage_Intercept";
|
||||
public static string 在线用户 = "在线用户";
|
||||
public static string UDPPackage_能耗 = "UDPPackage_能耗";
|
||||
public static string UDPPackage_StatusPass = "UDPPackage_StatusPass";
|
||||
|
||||
|
||||
public static string UDPPackage_TCL电视Discovery = "UDPPackage_TCL电视Discovery";
|
||||
public static string UDPPackage_TCL电视Control = "UDPPackage_TCL电视Control";
|
||||
|
||||
public static string UDPPackage_小度音箱Discovery = "UDPPackage_小度音箱Discovery";
|
||||
public static string UDPPackage_小度音箱Control = "UDPPackage_小度音箱Control";
|
||||
|
||||
public static string UDPPackage_TianMaoQueryAll = "UDPPackage_TianMaoQueryAll";
|
||||
public static string UDPPackage_TianMaoCONTROL = "UDPPackage_TianMaoCONTROL";
|
||||
}
|
||||
public class grafana_data
|
||||
{
|
||||
public string? WireShark_UDPCapCount { get; set; } = "0";
|
||||
public string? UDP_Upload { get; set; } = "0";
|
||||
public string? UDP_Sent { get; set; } = "0";
|
||||
public string? RCU_Online { get; set; } = "0";
|
||||
public string? RCU_TakeCard { get; set; } = "0";
|
||||
public string? RCU_Heart { get; set; } = "0";
|
||||
public string? RCU_SearchHost { get; set; } = "0";
|
||||
public string? Intercept { get; set; } = "0";
|
||||
public string? WebUser { get; set; } = "0";
|
||||
public string? Energy { get; set; } = "0";
|
||||
public string? RCU_OE { get; set; } = "0";
|
||||
public string? TCL_Ctr_D { get; set; } = "0";
|
||||
public string? TCL_Ctr_C { get; set; } = "0";
|
||||
public string? TM_Ctr_D { get; set; } = "0";
|
||||
public string? TM_Ctr_C { get; set; } = "0";
|
||||
public string? XD_Ctr_D { get; set; } = "0";
|
||||
public string? XD_Ctr_C { get; set; } = "0";
|
||||
public string? Hivi_Ctr { get; set; } = "0";
|
||||
}
|
||||
}
|
||||
5069
BLWLogProduce/NLog.xsd
Normal file
5069
BLWLogProduce/NLog.xsd
Normal file
File diff suppressed because it is too large
Load Diff
693
BLWLogProduce/NewActionChangeDataPush.cs
Normal file
693
BLWLogProduce/NewActionChangeDataPush.cs
Normal file
@@ -0,0 +1,693 @@
|
||||
// <auto-generated>
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: NewActionChangeDataPush.proto
|
||||
// </auto-generated>
|
||||
#pragma warning disable 1591, 0612, 3021, 8981
|
||||
#region Designer generated code
|
||||
|
||||
using pb = global::Google.Protobuf;
|
||||
using pbc = global::Google.Protobuf.Collections;
|
||||
using pbr = global::Google.Protobuf.Reflection;
|
||||
using scg = global::System.Collections.Generic;
|
||||
namespace BLWData.Entity {
|
||||
|
||||
/// <summary>Holder for reflection information generated from NewActionChangeDataPush.proto</summary>
|
||||
public static partial class NewActionChangeDataPushReflection {
|
||||
|
||||
#region Descriptor
|
||||
/// <summary>File descriptor for NewActionChangeDataPush.proto</summary>
|
||||
public static pbr::FileDescriptor Descriptor {
|
||||
get { return descriptor; }
|
||||
}
|
||||
private static pbr::FileDescriptor descriptor;
|
||||
|
||||
static NewActionChangeDataPushReflection() {
|
||||
byte[] descriptorData = global::System.Convert.FromBase64String(
|
||||
string.Concat(
|
||||
"Ch1OZXdBY3Rpb25DaGFuZ2VEYXRhUHVzaC5wcm90bxIOQkxXRGF0YS5FbnRp",
|
||||
"dHki/wEKF05ld0FjdGlvbkNoYW5nZURhdGFQdXNoEgwKBGNvZGUYASABKAMS",
|
||||
"EgoKcm9vbU51bWJlchgCIAEoCRISCgpob3N0TnVtYmVyGAMgASgJEg8KB2Fk",
|
||||
"ZHJlc3MYBCABKAkSDAoEbmFtZRgFIAEoCRIOCgZzdGF0dXMYBiABKAUSEgoK",
|
||||
"YnJpZ2h0bmVzcxgHIAEoBRITCgtjdXJyZW50VGVtcBgIIAEoBRITCgtzZXR0",
|
||||
"aW5nVGVtcBgJIAEoBRIQCghmYW5TcGVlZBgKIAEoBRIMCgRtb2RlGAsgASgF",
|
||||
"Eg0KBXZhbHZlGAwgASgFEhIKCmNyZWF0ZXRpbWUYDSABKANiBnByb3RvMw=="));
|
||||
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
|
||||
new pbr::FileDescriptor[] { },
|
||||
new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] {
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::BLWData.Entity.NewActionChangeDataPush), global::BLWData.Entity.NewActionChangeDataPush.Parser, new[]{ "Code", "RoomNumber", "HostNumber", "Address", "Name", "Status", "Brightness", "CurrentTemp", "SettingTemp", "FanSpeed", "Mode", "Valve", "Createtime" }, null, null, null, null)
|
||||
}));
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
#region Messages
|
||||
/// <summary>
|
||||
/// 定义一个Person消息类型
|
||||
/// </summary>
|
||||
[global::System.Diagnostics.DebuggerDisplayAttribute("{ToString(),nq}")]
|
||||
public sealed partial class NewActionChangeDataPush : pb::IMessage<NewActionChangeDataPush>
|
||||
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
||||
, pb::IBufferMessage
|
||||
#endif
|
||||
{
|
||||
private static readonly pb::MessageParser<NewActionChangeDataPush> _parser = new pb::MessageParser<NewActionChangeDataPush>(() => new NewActionChangeDataPush());
|
||||
private pb::UnknownFieldSet _unknownFields;
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public static pb::MessageParser<NewActionChangeDataPush> Parser { get { return _parser; } }
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public static pbr::MessageDescriptor Descriptor {
|
||||
get { return global::BLWData.Entity.NewActionChangeDataPushReflection.Descriptor.MessageTypes[0]; }
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
pbr::MessageDescriptor pb::IMessage.Descriptor {
|
||||
get { return Descriptor; }
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public NewActionChangeDataPush() {
|
||||
OnConstruction();
|
||||
}
|
||||
|
||||
partial void OnConstruction();
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public NewActionChangeDataPush(NewActionChangeDataPush other) : this() {
|
||||
code_ = other.code_;
|
||||
roomNumber_ = other.roomNumber_;
|
||||
hostNumber_ = other.hostNumber_;
|
||||
address_ = other.address_;
|
||||
name_ = other.name_;
|
||||
status_ = other.status_;
|
||||
brightness_ = other.brightness_;
|
||||
currentTemp_ = other.currentTemp_;
|
||||
settingTemp_ = other.settingTemp_;
|
||||
fanSpeed_ = other.fanSpeed_;
|
||||
mode_ = other.mode_;
|
||||
valve_ = other.valve_;
|
||||
createtime_ = other.createtime_;
|
||||
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public NewActionChangeDataPush Clone() {
|
||||
return new NewActionChangeDataPush(this);
|
||||
}
|
||||
|
||||
/// <summary>Field number for the "code" field.</summary>
|
||||
public const int CodeFieldNumber = 1;
|
||||
private long code_;
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public long Code {
|
||||
get { return code_; }
|
||||
set {
|
||||
code_ = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Field number for the "roomNumber" field.</summary>
|
||||
public const int RoomNumberFieldNumber = 2;
|
||||
private string roomNumber_ = "";
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public string RoomNumber {
|
||||
get { return roomNumber_; }
|
||||
set {
|
||||
roomNumber_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Field number for the "hostNumber" field.</summary>
|
||||
public const int HostNumberFieldNumber = 3;
|
||||
private string hostNumber_ = "";
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public string HostNumber {
|
||||
get { return hostNumber_; }
|
||||
set {
|
||||
hostNumber_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Field number for the "address" field.</summary>
|
||||
public const int AddressFieldNumber = 4;
|
||||
private string address_ = "";
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public string Address {
|
||||
get { return address_; }
|
||||
set {
|
||||
address_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Field number for the "name" field.</summary>
|
||||
public const int NameFieldNumber = 5;
|
||||
private string name_ = "";
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public string Name {
|
||||
get { return name_; }
|
||||
set {
|
||||
name_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Field number for the "status" field.</summary>
|
||||
public const int StatusFieldNumber = 6;
|
||||
private int status_;
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public int Status {
|
||||
get { return status_; }
|
||||
set {
|
||||
status_ = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Field number for the "brightness" field.</summary>
|
||||
public const int BrightnessFieldNumber = 7;
|
||||
private int brightness_;
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public int Brightness {
|
||||
get { return brightness_; }
|
||||
set {
|
||||
brightness_ = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Field number for the "currentTemp" field.</summary>
|
||||
public const int CurrentTempFieldNumber = 8;
|
||||
private int currentTemp_;
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public int CurrentTemp {
|
||||
get { return currentTemp_; }
|
||||
set {
|
||||
currentTemp_ = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Field number for the "settingTemp" field.</summary>
|
||||
public const int SettingTempFieldNumber = 9;
|
||||
private int settingTemp_;
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public int SettingTemp {
|
||||
get { return settingTemp_; }
|
||||
set {
|
||||
settingTemp_ = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Field number for the "fanSpeed" field.</summary>
|
||||
public const int FanSpeedFieldNumber = 10;
|
||||
private int fanSpeed_;
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public int FanSpeed {
|
||||
get { return fanSpeed_; }
|
||||
set {
|
||||
fanSpeed_ = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Field number for the "mode" field.</summary>
|
||||
public const int ModeFieldNumber = 11;
|
||||
private int mode_;
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public int Mode {
|
||||
get { return mode_; }
|
||||
set {
|
||||
mode_ = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Field number for the "valve" field.</summary>
|
||||
public const int ValveFieldNumber = 12;
|
||||
private int valve_;
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public int Valve {
|
||||
get { return valve_; }
|
||||
set {
|
||||
valve_ = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Field number for the "createtime" field.</summary>
|
||||
public const int CreatetimeFieldNumber = 13;
|
||||
private long createtime_;
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public long Createtime {
|
||||
get { return createtime_; }
|
||||
set {
|
||||
createtime_ = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public override bool Equals(object other) {
|
||||
return Equals(other as NewActionChangeDataPush);
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public bool Equals(NewActionChangeDataPush other) {
|
||||
if (ReferenceEquals(other, null)) {
|
||||
return false;
|
||||
}
|
||||
if (ReferenceEquals(other, this)) {
|
||||
return true;
|
||||
}
|
||||
if (Code != other.Code) return false;
|
||||
if (RoomNumber != other.RoomNumber) return false;
|
||||
if (HostNumber != other.HostNumber) return false;
|
||||
if (Address != other.Address) return false;
|
||||
if (Name != other.Name) return false;
|
||||
if (Status != other.Status) return false;
|
||||
if (Brightness != other.Brightness) return false;
|
||||
if (CurrentTemp != other.CurrentTemp) return false;
|
||||
if (SettingTemp != other.SettingTemp) return false;
|
||||
if (FanSpeed != other.FanSpeed) return false;
|
||||
if (Mode != other.Mode) return false;
|
||||
if (Valve != other.Valve) return false;
|
||||
if (Createtime != other.Createtime) return false;
|
||||
return Equals(_unknownFields, other._unknownFields);
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public override int GetHashCode() {
|
||||
int hash = 1;
|
||||
if (Code != 0L) hash ^= Code.GetHashCode();
|
||||
if (RoomNumber.Length != 0) hash ^= RoomNumber.GetHashCode();
|
||||
if (HostNumber.Length != 0) hash ^= HostNumber.GetHashCode();
|
||||
if (Address.Length != 0) hash ^= Address.GetHashCode();
|
||||
if (Name.Length != 0) hash ^= Name.GetHashCode();
|
||||
if (Status != 0) hash ^= Status.GetHashCode();
|
||||
if (Brightness != 0) hash ^= Brightness.GetHashCode();
|
||||
if (CurrentTemp != 0) hash ^= CurrentTemp.GetHashCode();
|
||||
if (SettingTemp != 0) hash ^= SettingTemp.GetHashCode();
|
||||
if (FanSpeed != 0) hash ^= FanSpeed.GetHashCode();
|
||||
if (Mode != 0) hash ^= Mode.GetHashCode();
|
||||
if (Valve != 0) hash ^= Valve.GetHashCode();
|
||||
if (Createtime != 0L) hash ^= Createtime.GetHashCode();
|
||||
if (_unknownFields != null) {
|
||||
hash ^= _unknownFields.GetHashCode();
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public override string ToString() {
|
||||
return pb::JsonFormatter.ToDiagnosticString(this);
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public void WriteTo(pb::CodedOutputStream output) {
|
||||
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
||||
output.WriteRawMessage(this);
|
||||
#else
|
||||
if (Code != 0L) {
|
||||
output.WriteRawTag(8);
|
||||
output.WriteInt64(Code);
|
||||
}
|
||||
if (RoomNumber.Length != 0) {
|
||||
output.WriteRawTag(18);
|
||||
output.WriteString(RoomNumber);
|
||||
}
|
||||
if (HostNumber.Length != 0) {
|
||||
output.WriteRawTag(26);
|
||||
output.WriteString(HostNumber);
|
||||
}
|
||||
if (Address.Length != 0) {
|
||||
output.WriteRawTag(34);
|
||||
output.WriteString(Address);
|
||||
}
|
||||
if (Name.Length != 0) {
|
||||
output.WriteRawTag(42);
|
||||
output.WriteString(Name);
|
||||
}
|
||||
if (Status != 0) {
|
||||
output.WriteRawTag(48);
|
||||
output.WriteInt32(Status);
|
||||
}
|
||||
if (Brightness != 0) {
|
||||
output.WriteRawTag(56);
|
||||
output.WriteInt32(Brightness);
|
||||
}
|
||||
if (CurrentTemp != 0) {
|
||||
output.WriteRawTag(64);
|
||||
output.WriteInt32(CurrentTemp);
|
||||
}
|
||||
if (SettingTemp != 0) {
|
||||
output.WriteRawTag(72);
|
||||
output.WriteInt32(SettingTemp);
|
||||
}
|
||||
if (FanSpeed != 0) {
|
||||
output.WriteRawTag(80);
|
||||
output.WriteInt32(FanSpeed);
|
||||
}
|
||||
if (Mode != 0) {
|
||||
output.WriteRawTag(88);
|
||||
output.WriteInt32(Mode);
|
||||
}
|
||||
if (Valve != 0) {
|
||||
output.WriteRawTag(96);
|
||||
output.WriteInt32(Valve);
|
||||
}
|
||||
if (Createtime != 0L) {
|
||||
output.WriteRawTag(104);
|
||||
output.WriteInt64(Createtime);
|
||||
}
|
||||
if (_unknownFields != null) {
|
||||
_unknownFields.WriteTo(output);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) {
|
||||
if (Code != 0L) {
|
||||
output.WriteRawTag(8);
|
||||
output.WriteInt64(Code);
|
||||
}
|
||||
if (RoomNumber.Length != 0) {
|
||||
output.WriteRawTag(18);
|
||||
output.WriteString(RoomNumber);
|
||||
}
|
||||
if (HostNumber.Length != 0) {
|
||||
output.WriteRawTag(26);
|
||||
output.WriteString(HostNumber);
|
||||
}
|
||||
if (Address.Length != 0) {
|
||||
output.WriteRawTag(34);
|
||||
output.WriteString(Address);
|
||||
}
|
||||
if (Name.Length != 0) {
|
||||
output.WriteRawTag(42);
|
||||
output.WriteString(Name);
|
||||
}
|
||||
if (Status != 0) {
|
||||
output.WriteRawTag(48);
|
||||
output.WriteInt32(Status);
|
||||
}
|
||||
if (Brightness != 0) {
|
||||
output.WriteRawTag(56);
|
||||
output.WriteInt32(Brightness);
|
||||
}
|
||||
if (CurrentTemp != 0) {
|
||||
output.WriteRawTag(64);
|
||||
output.WriteInt32(CurrentTemp);
|
||||
}
|
||||
if (SettingTemp != 0) {
|
||||
output.WriteRawTag(72);
|
||||
output.WriteInt32(SettingTemp);
|
||||
}
|
||||
if (FanSpeed != 0) {
|
||||
output.WriteRawTag(80);
|
||||
output.WriteInt32(FanSpeed);
|
||||
}
|
||||
if (Mode != 0) {
|
||||
output.WriteRawTag(88);
|
||||
output.WriteInt32(Mode);
|
||||
}
|
||||
if (Valve != 0) {
|
||||
output.WriteRawTag(96);
|
||||
output.WriteInt32(Valve);
|
||||
}
|
||||
if (Createtime != 0L) {
|
||||
output.WriteRawTag(104);
|
||||
output.WriteInt64(Createtime);
|
||||
}
|
||||
if (_unknownFields != null) {
|
||||
_unknownFields.WriteTo(ref output);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public int CalculateSize() {
|
||||
int size = 0;
|
||||
if (Code != 0L) {
|
||||
size += 1 + pb::CodedOutputStream.ComputeInt64Size(Code);
|
||||
}
|
||||
if (RoomNumber.Length != 0) {
|
||||
size += 1 + pb::CodedOutputStream.ComputeStringSize(RoomNumber);
|
||||
}
|
||||
if (HostNumber.Length != 0) {
|
||||
size += 1 + pb::CodedOutputStream.ComputeStringSize(HostNumber);
|
||||
}
|
||||
if (Address.Length != 0) {
|
||||
size += 1 + pb::CodedOutputStream.ComputeStringSize(Address);
|
||||
}
|
||||
if (Name.Length != 0) {
|
||||
size += 1 + pb::CodedOutputStream.ComputeStringSize(Name);
|
||||
}
|
||||
if (Status != 0) {
|
||||
size += 1 + pb::CodedOutputStream.ComputeInt32Size(Status);
|
||||
}
|
||||
if (Brightness != 0) {
|
||||
size += 1 + pb::CodedOutputStream.ComputeInt32Size(Brightness);
|
||||
}
|
||||
if (CurrentTemp != 0) {
|
||||
size += 1 + pb::CodedOutputStream.ComputeInt32Size(CurrentTemp);
|
||||
}
|
||||
if (SettingTemp != 0) {
|
||||
size += 1 + pb::CodedOutputStream.ComputeInt32Size(SettingTemp);
|
||||
}
|
||||
if (FanSpeed != 0) {
|
||||
size += 1 + pb::CodedOutputStream.ComputeInt32Size(FanSpeed);
|
||||
}
|
||||
if (Mode != 0) {
|
||||
size += 1 + pb::CodedOutputStream.ComputeInt32Size(Mode);
|
||||
}
|
||||
if (Valve != 0) {
|
||||
size += 1 + pb::CodedOutputStream.ComputeInt32Size(Valve);
|
||||
}
|
||||
if (Createtime != 0L) {
|
||||
size += 1 + pb::CodedOutputStream.ComputeInt64Size(Createtime);
|
||||
}
|
||||
if (_unknownFields != null) {
|
||||
size += _unknownFields.CalculateSize();
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public void MergeFrom(NewActionChangeDataPush other) {
|
||||
if (other == null) {
|
||||
return;
|
||||
}
|
||||
if (other.Code != 0L) {
|
||||
Code = other.Code;
|
||||
}
|
||||
if (other.RoomNumber.Length != 0) {
|
||||
RoomNumber = other.RoomNumber;
|
||||
}
|
||||
if (other.HostNumber.Length != 0) {
|
||||
HostNumber = other.HostNumber;
|
||||
}
|
||||
if (other.Address.Length != 0) {
|
||||
Address = other.Address;
|
||||
}
|
||||
if (other.Name.Length != 0) {
|
||||
Name = other.Name;
|
||||
}
|
||||
if (other.Status != 0) {
|
||||
Status = other.Status;
|
||||
}
|
||||
if (other.Brightness != 0) {
|
||||
Brightness = other.Brightness;
|
||||
}
|
||||
if (other.CurrentTemp != 0) {
|
||||
CurrentTemp = other.CurrentTemp;
|
||||
}
|
||||
if (other.SettingTemp != 0) {
|
||||
SettingTemp = other.SettingTemp;
|
||||
}
|
||||
if (other.FanSpeed != 0) {
|
||||
FanSpeed = other.FanSpeed;
|
||||
}
|
||||
if (other.Mode != 0) {
|
||||
Mode = other.Mode;
|
||||
}
|
||||
if (other.Valve != 0) {
|
||||
Valve = other.Valve;
|
||||
}
|
||||
if (other.Createtime != 0L) {
|
||||
Createtime = other.Createtime;
|
||||
}
|
||||
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public void MergeFrom(pb::CodedInputStream input) {
|
||||
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
||||
input.ReadRawMessage(this);
|
||||
#else
|
||||
uint tag;
|
||||
while ((tag = input.ReadTag()) != 0) {
|
||||
if ((tag & 7) == 4) {
|
||||
// Abort on any end group tag.
|
||||
return;
|
||||
}
|
||||
switch(tag) {
|
||||
default:
|
||||
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
|
||||
break;
|
||||
case 8: {
|
||||
Code = input.ReadInt64();
|
||||
break;
|
||||
}
|
||||
case 18: {
|
||||
RoomNumber = input.ReadString();
|
||||
break;
|
||||
}
|
||||
case 26: {
|
||||
HostNumber = input.ReadString();
|
||||
break;
|
||||
}
|
||||
case 34: {
|
||||
Address = input.ReadString();
|
||||
break;
|
||||
}
|
||||
case 42: {
|
||||
Name = input.ReadString();
|
||||
break;
|
||||
}
|
||||
case 48: {
|
||||
Status = input.ReadInt32();
|
||||
break;
|
||||
}
|
||||
case 56: {
|
||||
Brightness = input.ReadInt32();
|
||||
break;
|
||||
}
|
||||
case 64: {
|
||||
CurrentTemp = input.ReadInt32();
|
||||
break;
|
||||
}
|
||||
case 72: {
|
||||
SettingTemp = input.ReadInt32();
|
||||
break;
|
||||
}
|
||||
case 80: {
|
||||
FanSpeed = input.ReadInt32();
|
||||
break;
|
||||
}
|
||||
case 88: {
|
||||
Mode = input.ReadInt32();
|
||||
break;
|
||||
}
|
||||
case 96: {
|
||||
Valve = input.ReadInt32();
|
||||
break;
|
||||
}
|
||||
case 104: {
|
||||
Createtime = input.ReadInt64();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) {
|
||||
uint tag;
|
||||
while ((tag = input.ReadTag()) != 0) {
|
||||
if ((tag & 7) == 4) {
|
||||
// Abort on any end group tag.
|
||||
return;
|
||||
}
|
||||
switch(tag) {
|
||||
default:
|
||||
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input);
|
||||
break;
|
||||
case 8: {
|
||||
Code = input.ReadInt64();
|
||||
break;
|
||||
}
|
||||
case 18: {
|
||||
RoomNumber = input.ReadString();
|
||||
break;
|
||||
}
|
||||
case 26: {
|
||||
HostNumber = input.ReadString();
|
||||
break;
|
||||
}
|
||||
case 34: {
|
||||
Address = input.ReadString();
|
||||
break;
|
||||
}
|
||||
case 42: {
|
||||
Name = input.ReadString();
|
||||
break;
|
||||
}
|
||||
case 48: {
|
||||
Status = input.ReadInt32();
|
||||
break;
|
||||
}
|
||||
case 56: {
|
||||
Brightness = input.ReadInt32();
|
||||
break;
|
||||
}
|
||||
case 64: {
|
||||
CurrentTemp = input.ReadInt32();
|
||||
break;
|
||||
}
|
||||
case 72: {
|
||||
SettingTemp = input.ReadInt32();
|
||||
break;
|
||||
}
|
||||
case 80: {
|
||||
FanSpeed = input.ReadInt32();
|
||||
break;
|
||||
}
|
||||
case 88: {
|
||||
Mode = input.ReadInt32();
|
||||
break;
|
||||
}
|
||||
case 96: {
|
||||
Valve = input.ReadInt32();
|
||||
break;
|
||||
}
|
||||
case 104: {
|
||||
Createtime = input.ReadInt64();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
#endregion Designer generated code
|
||||
60
BLWLogProduce/Para_copy.yaml
Normal file
60
BLWLogProduce/Para_copy.yaml
Normal file
@@ -0,0 +1,60 @@
|
||||
# HELP UDP_Upload Total bytes uploaded via UDP.
|
||||
# TYPE UDP_Upload gauge
|
||||
UDP_Upload {1}
|
||||
|
||||
# HELP UDP_Sent Total UDP packets sent.
|
||||
# TYPE UDP_Sent gauge
|
||||
UDP_Sent {2}
|
||||
|
||||
# HELP RCU_Online Current number of online RCU units.
|
||||
# TYPE RCU_Online gauge
|
||||
RCU_Online {3}
|
||||
|
||||
# HELP RCU_TakeCard Total number of card take operations performed by RCU units.
|
||||
# TYPE RCU_TakeCard gauge
|
||||
RCU_TakeCard {4}
|
||||
|
||||
# HELP RCU_Heart Total number of heartbeats received from RCU units.
|
||||
# TYPE RCU_Heart gauge
|
||||
RCU_Heart {5}
|
||||
|
||||
# HELP RCU_SearchHost Total number of host search operations performed by RCU units.
|
||||
# TYPE RCU_SearchHost gauge
|
||||
RCU_SearchHost {6}
|
||||
|
||||
# HELP Intercept Number of intercept operations or intercepted items.
|
||||
# TYPE Intercept gauge
|
||||
Intercept {7}
|
||||
|
||||
# HELP WebUser Number of active web users currently connected.
|
||||
# TYPE WebUser gauge
|
||||
WebUser {8}
|
||||
|
||||
# HELP Energy Current energy consumption or energy level.
|
||||
# TYPE Energy gauge
|
||||
Energy {9}
|
||||
|
||||
# HELP RCU_0E Number of RCU units with type 0E status.
|
||||
# TYPE RCU_0E gauge
|
||||
RCU_OE {10}
|
||||
|
||||
# HELP TCL_Ctr Control counter or status for TCL devices.
|
||||
# TYPE TCL_Ctr gauge
|
||||
TCL_Ctr {11}
|
||||
|
||||
# HELP TM_Ctr Control counter or status for TM devices.
|
||||
# TYPE TM_Ctr gauge
|
||||
TM_Ctr {12}
|
||||
|
||||
# HELP XD_Ctr Control counter or status for XD devices.
|
||||
# TYPE XD_Ctr gauge
|
||||
XD_Ctr {13}
|
||||
|
||||
# HELP Hivi_Ctr Control counter or status for Hivi devices.
|
||||
# TYPE Hivi_Ctr gauge
|
||||
Hivi_Ctr {14}
|
||||
|
||||
|
||||
# HELP UDP_Cnt_Wireshark Total UDP packets captured and analyzed by Wireshark.
|
||||
# TYPE UDP_Cnt_Wireshark gauge
|
||||
UDP_Cnt_Wireshark {15}
|
||||
32
BLWLogProduce/Program.cs
Normal file
32
BLWLogProduce/Program.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using BLWLogProduce.Services;
|
||||
|
||||
namespace BLWLogProduce
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
|
||||
builder.Services.AddControllers();
|
||||
builder.Services.AddHostedService<KafkaProduce>();
|
||||
builder.Services.AddHostedService<MyTimer>();
|
||||
|
||||
builder.Services.AddMemoryCache();
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
app.UseAuthorization();
|
||||
|
||||
|
||||
app.MapControllers();
|
||||
|
||||
app.Run();
|
||||
}
|
||||
}
|
||||
}
|
||||
41
BLWLogProduce/Properties/launchSettings.json
Normal file
41
BLWLogProduce/Properties/launchSettings.json
Normal file
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:37373",
|
||||
"sslPort": 44392
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "weatherforecast",
|
||||
"applicationUrl": "http://localhost:5092",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"https": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "weatherforecast",
|
||||
"applicationUrl": "https://localhost:7078;http://localhost:5092",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "weatherforecast",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
27
BLWLogProduce/Services/CPUDataCollect.cs
Normal file
27
BLWLogProduce/Services/CPUDataCollect.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
|
||||
using System.Collections.Concurrent;
|
||||
using CommonTools;
|
||||
|
||||
namespace BLWLogProduce.Services
|
||||
{
|
||||
public class CPUDataCollect : BackgroundService
|
||||
{
|
||||
public static ConcurrentBag<double> CPU_Data = new ConcurrentBag<double>();
|
||||
protected override Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
return Task.Factory.StartNew(async () =>
|
||||
{
|
||||
var timer = new PeriodicTimer(TimeSpan.FromSeconds(1));
|
||||
while (await timer.WaitForNextTickAsync(stoppingToken))
|
||||
{
|
||||
Console.WriteLine("HostServiceTest_A is doing work.");
|
||||
double d = CPUData.GetCPU();
|
||||
CPUDataCollect.CPU_Data.Add(d);
|
||||
}
|
||||
|
||||
Console.WriteLine("HostServiceTest_A task done.");
|
||||
|
||||
}, TaskCreationOptions.LongRunning);
|
||||
}
|
||||
}
|
||||
}
|
||||
53
BLWLogProduce/Services/CRICS_P_C.cs
Normal file
53
BLWLogProduce/Services/CRICS_P_C.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
|
||||
using System.Threading.Channels;
|
||||
using Common;
|
||||
using static CSRedis.CSRedisClient;
|
||||
|
||||
namespace BLWLogProduce.Services
|
||||
{
|
||||
public class CRICS_P_C : BackgroundService
|
||||
{
|
||||
private static Channel<string> _messageChannel;
|
||||
|
||||
public CRICS_P_C()
|
||||
{
|
||||
|
||||
}
|
||||
public static async Task ConsumeMessagesAsync()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
if (_messageChannel.Reader.TryRead(out var nnn))
|
||||
{
|
||||
//CSRedisCacheHelper.redis3.Subscribe(wireshark);
|
||||
}
|
||||
}
|
||||
}
|
||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 创建无界Channel
|
||||
_messageChannel = Channel.CreateUnbounded<string>();
|
||||
await ConsumeMessagesAsync();
|
||||
var wireshark = ("crics-udp-package", new Action<SubscribeMessageEventArgs>(async (args) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
await _messageChannel.Writer.WriteAsync("");
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
}
|
||||
}));
|
||||
|
||||
CSRedisCacheHelper.redis3.Subscribe(wireshark);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
729
BLWLogProduce/Services/KafkaProduce.cs
Normal file
729
BLWLogProduce/Services/KafkaProduce.cs
Normal file
@@ -0,0 +1,729 @@
|
||||
|
||||
using System.Diagnostics.Metrics;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Channels;
|
||||
using BLWData.Entity;
|
||||
using BLWLogProduce.Models;
|
||||
using Common;
|
||||
using CommonEntity;
|
||||
using CommonTools;
|
||||
using Confluent.Kafka;
|
||||
using Google.Protobuf;
|
||||
using MessagePack;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NLog;
|
||||
using RestSharp;
|
||||
using static CSRedis.CSRedisClient;
|
||||
|
||||
namespace BLWLogProduce.Services
|
||||
{
|
||||
public class KafkaProduce : BackgroundService
|
||||
{
|
||||
public IConfiguration Configuration { get; set; }
|
||||
public IMemoryCache _Cache { get; set; }
|
||||
|
||||
public KafkaProduce(IConfiguration configuration, IMemoryCache cache)
|
||||
{
|
||||
this.Configuration = configuration;
|
||||
_Cache = cache;
|
||||
}
|
||||
|
||||
|
||||
public static Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
|
||||
// 消费者方法
|
||||
|
||||
protected async override Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
|
||||
await Task.Factory.StartNew((state) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
string? ipport = Configuration["Kafka:EndPoint"];
|
||||
string? user = Configuration["Kafka:UserName"];
|
||||
string? pwd = Configuration["Kafka:PassWord"];
|
||||
var config = new ProducerConfig
|
||||
{
|
||||
BootstrapServers = ipport,
|
||||
SecurityProtocol = SecurityProtocol.SaslPlaintext,
|
||||
SaslMechanism = SaslMechanism.Plain,
|
||||
SaslUsername = user,
|
||||
SaslPassword = pwd
|
||||
};
|
||||
var p = new ProducerBuilder<string, byte[]>(config).Build();
|
||||
//var p = new ProducerBuilder<string, byte[]>(config).Build();
|
||||
|
||||
///udp 采集数据
|
||||
var wireshark = ("wireshark-cap-udp-totalcount", new Action<SubscribeMessageEventArgs>(async (args) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
WaiBuJianKong.data.WireShark_UDPCapCount = args.Body;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
}
|
||||
}));
|
||||
///udp 采集数据
|
||||
var DingYue = ("redis-udppackage", new Action<SubscribeMessageEventArgs>(async (args) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
string body = args.Body;
|
||||
//Console.WriteLine("UDPData:"+body);
|
||||
UDPPackage? usa = System.Text.Json.JsonSerializer.Deserialize<UDPPackage>(body);
|
||||
if (usa != null)
|
||||
{
|
||||
string countsa = usa.TotalCount.ToString();
|
||||
if (usa.CommandType.Equals(WaiBuJianKong.UDPPackage_TotalRecvPackage))
|
||||
{
|
||||
WaiBuJianKong.data.UDP_Upload = countsa;
|
||||
}
|
||||
else if (usa.CommandType.Equals(WaiBuJianKong.UDPPackage_TotalSendPackage))
|
||||
{
|
||||
WaiBuJianKong.data.UDP_Sent = countsa;
|
||||
}
|
||||
else if (usa.CommandType.Equals(WaiBuJianKong.RCU_Online))
|
||||
{
|
||||
WaiBuJianKong.data.RCU_Online = countsa;
|
||||
}
|
||||
else if (usa.CommandType.Equals(WaiBuJianKong.TakeCardIn))
|
||||
{
|
||||
WaiBuJianKong.data.RCU_TakeCard = countsa;
|
||||
}
|
||||
|
||||
else if (usa.CommandType.Equals(WaiBuJianKong.UDPPackage_Heart))
|
||||
{
|
||||
WaiBuJianKong.data.RCU_Heart = countsa;
|
||||
}
|
||||
else if (usa.CommandType.Equals(WaiBuJianKong.UDPPackage_SearchHost))
|
||||
{
|
||||
WaiBuJianKong.data.RCU_SearchHost = countsa;
|
||||
}
|
||||
else if (usa.CommandType.Equals(WaiBuJianKong.UDPPackage_Intercept))
|
||||
{
|
||||
WaiBuJianKong.data.Intercept = countsa;
|
||||
}
|
||||
else if (usa.CommandType.Equals(WaiBuJianKong.在线用户))
|
||||
{
|
||||
WaiBuJianKong.data.WebUser = countsa;
|
||||
}
|
||||
else if (usa.CommandType.Equals(WaiBuJianKong.UDPPackage_能耗))
|
||||
{
|
||||
WaiBuJianKong.data.Energy = countsa;
|
||||
}
|
||||
else if (usa.CommandType.Equals(WaiBuJianKong.UDPPackage_StatusPass))
|
||||
{
|
||||
WaiBuJianKong.data.RCU_OE = countsa;
|
||||
}
|
||||
|
||||
else if (usa.CommandType.Equals(WaiBuJianKong.UDPPackage_TCL电视Discovery))
|
||||
{
|
||||
WaiBuJianKong.data.TCL_Ctr_D = countsa;
|
||||
}
|
||||
else if (usa.CommandType.Equals(WaiBuJianKong.UDPPackage_TCL电视Control))
|
||||
{
|
||||
WaiBuJianKong.data.TCL_Ctr_C = countsa;
|
||||
}
|
||||
|
||||
|
||||
else if (usa.CommandType.Equals(WaiBuJianKong.UDPPackage_小度音箱Discovery))
|
||||
{
|
||||
WaiBuJianKong.data.XD_Ctr_D = countsa;
|
||||
}
|
||||
else if (usa.CommandType.Equals(WaiBuJianKong.UDPPackage_小度音箱Control))
|
||||
{
|
||||
WaiBuJianKong.data.XD_Ctr_C = countsa;
|
||||
}
|
||||
|
||||
|
||||
else if (usa.CommandType.Equals(WaiBuJianKong.UDPPackage_TianMaoQueryAll))
|
||||
{
|
||||
WaiBuJianKong.data.TM_Ctr_D = countsa;
|
||||
}
|
||||
else if (usa.CommandType.Equals(WaiBuJianKong.UDPPackage_TianMaoCONTROL))
|
||||
{
|
||||
WaiBuJianKong.data.TM_Ctr_C = countsa;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
var QQQ = usa.ExtraData;
|
||||
if (QQQ != null && QQQ.Count > 0)
|
||||
{
|
||||
foreach (var item in QQQ)
|
||||
{
|
||||
string Location = "";
|
||||
if (_Cache.TryGetValue(item.Key, out Location))
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Location = GetBaiduIp(item.Key);
|
||||
_Cache.Set<string>(item.Key, Location, DateTimeOffset.Now.AddHours(1));
|
||||
}
|
||||
QQQ[item.Key] = Location;
|
||||
}
|
||||
}
|
||||
byte[] bytes = MyMessagePacker.FastSerialize(usa);
|
||||
|
||||
//byte[] bytes = MessagePackSerializer.Serialize<UDPPackage>(usa);
|
||||
|
||||
string TopicKey = KafkaKey.BLWLog_RCU_Topic;
|
||||
string DetailKey = KafkaKey.UDPPackageKey;
|
||||
|
||||
|
||||
|
||||
//var partition = new Partition(0); // 指定分区号
|
||||
//var topicPartition = new TopicPartition(TopicKey, partition);
|
||||
//Console.WriteLine("产生了数据:"+body);
|
||||
//var dr = await p.ProduceAsync(TopicKey, new Message<string, byte[]> { Key = DetailKey, Value = Encoding.UTF8.GetBytes(body) });
|
||||
var dr = await p.ProduceAsync(TopicKey, new Message<string, byte[]> { Key = DetailKey, Value = bytes });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("redis-udppackage");
|
||||
Console.WriteLine(ex.Message);
|
||||
Console.WriteLine(ex.StackTrace);
|
||||
}
|
||||
}));
|
||||
|
||||
var DingYue1 = ("redis-roomstatus-monitor", new Action<SubscribeMessageEventArgs>(async (args) =>
|
||||
{
|
||||
string body = args.Body;
|
||||
|
||||
StepInfo? usa = System.Text.Json.JsonSerializer.Deserialize<StepInfo>(body);
|
||||
byte[] bytes = MyMessagePacker.FastSerialize(usa);
|
||||
|
||||
string TopicKey = KafkaKey.BLWLog_RCU_Topic;
|
||||
string DetailKey = KafkaKey.UDPPackageStepMonitor;
|
||||
|
||||
|
||||
|
||||
//var partition = new Partition(0); // 指定分区号
|
||||
//var topicPartition = new TopicPartition(TopicKey, partition);
|
||||
await p.ProduceAsync(TopicKey, new Message<string, byte[]> { Key = DetailKey, Value = bytes });
|
||||
|
||||
|
||||
//await _messageChannel.Writer.WriteAsync("");
|
||||
}));
|
||||
|
||||
//旁路系统
|
||||
var DingYue2 = ("redis-forksystemdata", new Action<SubscribeMessageEventArgs>(async (args) =>
|
||||
{
|
||||
string body = args.Body;
|
||||
|
||||
ForkSystem? forkSystem = System.Text.Json.JsonSerializer.Deserialize<ForkSystem>(body);
|
||||
byte[] qf = MyMessagePacker.FastSerialize(forkSystem);
|
||||
|
||||
string TopicKey = KafkaKey.BLWLog_RCU_Topic;
|
||||
string DetailKey = KafkaKey.UDPPackageForkSystemKey;
|
||||
|
||||
|
||||
//var partition = new Partition(0); // 指定分区号
|
||||
//var topicPartition = new TopicPartition(TopicKey, partition);
|
||||
await p.ProduceAsync(TopicKey, new Message<string, byte[]> { Key = DetailKey, Value = qf });
|
||||
|
||||
|
||||
//await Task.Factory.StartNew(async () =>
|
||||
// {
|
||||
// await ConsumeMessagesAsync();
|
||||
// }, TaskCreationOptions.LongRunning);
|
||||
}));
|
||||
|
||||
///能耗
|
||||
var DingYue3 = ("redis-power", new Action<SubscribeMessageEventArgs>(async (args) =>
|
||||
{
|
||||
string body = args.Body;
|
||||
|
||||
try
|
||||
{
|
||||
NengHao? poo = System.Text.Json.JsonSerializer.Deserialize<NengHao>(body);
|
||||
//string str= Newtonsoft.Json.JsonConvert.SerializeObject(poo);
|
||||
//Console.WriteLine("收到了"+str);
|
||||
byte[] qf = MyMessagePacker.FastSerialize(poo);
|
||||
|
||||
string TopicKey = KafkaKey.BLWLog_RCU_Topic;
|
||||
string DetailKey = KafkaKey.UDPPackagePowerMonitor;
|
||||
await p.ProduceAsync(TopicKey, new Message<string, byte[]> { Key = DetailKey, Value = qf });
|
||||
|
||||
|
||||
List<DeviceData> la = new List<DeviceData>();
|
||||
foreach (var item in poo.AllDeviceData)
|
||||
{
|
||||
DeviceData dd = new DeviceData();
|
||||
dd.HostID = item.HostID;
|
||||
dd.DeviceType = item.DeviceType;
|
||||
dd.Address = item.Address;
|
||||
dd.Brightness = item.Brightness;
|
||||
dd.Status = item.Status;
|
||||
dd.CurrentTemp = item.CurrentTemp;
|
||||
dd.SettingTemp = item.SettingTemp;
|
||||
dd.Mode = item.Mode;
|
||||
dd.FanSpeed = item.FanSpeed;
|
||||
dd.Valve = item.Valve;
|
||||
la.Add(dd);
|
||||
}
|
||||
|
||||
//宝镜系统使用
|
||||
EnergyConsumption ese = new EnergyConsumption();
|
||||
ese.HotelCode = poo.HotelCode;
|
||||
ese.HostNumber = poo.HostNumber;
|
||||
ese.Mac = poo.Mac;
|
||||
ese.EndPoint = poo.EndPoint;
|
||||
ese.V = poo.V;
|
||||
ese.A = poo.A;
|
||||
ese.P = poo.P;
|
||||
ese.EnergyConsumption_ = poo.Energy_Consumption;
|
||||
ese.SumEnergyConsumption = poo.Sum_Energy_Consumption;
|
||||
ese.CreateTime = poo.CreateTime;
|
||||
ese.RoomNumber = poo.RoomNumber ?? "";
|
||||
ese.IsTakeCard = poo.IsTakeCard;
|
||||
ese.CarbonVIP = poo.CarbonVIP;
|
||||
ese.DeviceStatusList.AddRange(la);
|
||||
ese.IdentityInfo = poo.IdentityInfo;
|
||||
|
||||
|
||||
byte[] data = ese.ToByteArray();
|
||||
string TopicKey1 = KafkaKey.BLWLog4BaoJing_RCU_Topic;
|
||||
string DetailKey1 = KafkaKey.UDPPackagePowerMonitor;
|
||||
|
||||
await p.ProduceAsync(TopicKey1, new Message<string, byte[]> { Key = DetailKey1, Value = data });
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
Console.WriteLine(ex.StackTrace);
|
||||
}
|
||||
}));
|
||||
|
||||
var DingYue3_1 = ("redis-action-data", new Action<SubscribeMessageEventArgs>(async (args) =>
|
||||
{
|
||||
string body = args.Body;
|
||||
|
||||
try
|
||||
{
|
||||
NewRoomtusPush? poo = System.Text.Json.JsonSerializer.Deserialize<NewRoomtusPush>(body);
|
||||
//byte[] qf = MyMessagePacker.FastSerialize(poo);
|
||||
//string TopicKey = KafkaKey.BLWLog_RCU_Topic;
|
||||
//string DetailKey = KafkaKey.UDPPackagePowerMonitor;
|
||||
//await p.ProduceAsync(TopicKey, new Message<string, byte[]> { Key = DetailKey, Value = qf });
|
||||
|
||||
|
||||
//宝镜系统使用
|
||||
NewActionChangeDataPush ese = new NewActionChangeDataPush();
|
||||
ese.Code = poo.code;
|
||||
ese.RoomNumber = poo.roomNumber;
|
||||
ese.HostNumber = poo.hostnumber;
|
||||
ese.Address = poo.address;
|
||||
ese.Brightness = poo.brightness;
|
||||
ese.Status = poo.status;
|
||||
ese.Name = poo.name;
|
||||
ese.CurrentTemp = poo.currentTemp;
|
||||
ese.SettingTemp = poo.settingTemp;
|
||||
ese.FanSpeed = poo.fanSpeed;
|
||||
ese.Mode = poo.mode;
|
||||
ese.Valve = poo.valve;
|
||||
ese.Createtime = poo.createtime;
|
||||
|
||||
|
||||
byte[] data = ese.ToByteArray();
|
||||
string TopicKey1 = KafkaKey.BLWLog4BaoJing_RCU_Topic;
|
||||
string DetailKey1 = KafkaKey.UDPPackage_ActionData;
|
||||
|
||||
await p.ProduceAsync(TopicKey1, new Message<string, byte[]> { Key = DetailKey1, Value = data });
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
Console.WriteLine(ex.StackTrace);
|
||||
}
|
||||
}));
|
||||
|
||||
|
||||
#region 碳达人
|
||||
//var DingYue3_1 = ("redis-carbon_trigger", new Action<SubscribeMessageEventArgs>(async (args) =>
|
||||
//{
|
||||
// string body = args.Body;
|
||||
|
||||
// NengHao? poo = System.Text.Json.JsonSerializer.Deserialize<NengHao>(body);
|
||||
// //poo.ReportTime = DateTime.Now;
|
||||
// byte[] qf = MyMessagePacker.FastSerialize(poo);
|
||||
|
||||
// string TopicKey = KafkaKey.BLWLog_RCU_Topic;
|
||||
// string DetailKey = KafkaKey.UDPPackagePowerMonitor;
|
||||
// await p.ProduceAsync(TopicKey, new Message<string, byte[]> { Key = DetailKey, Value = qf });
|
||||
|
||||
|
||||
// //宝镜系统使用
|
||||
// EnergyConsumption ese = new EnergyConsumption();
|
||||
// ese.HotelCode = poo.HotelCode;
|
||||
// ese.HostNumber = poo.HostNumber;
|
||||
// ese.Mac = poo.Mac;
|
||||
// ese.EndPoint = poo.EndPoint;
|
||||
// ese.V = poo.V;
|
||||
// ese.A = poo.A;
|
||||
// ese.P = poo.P;
|
||||
// ese.KWH = poo.KW_H;
|
||||
// ese.SumKWH = poo.Sum_KW_H;
|
||||
// ese.CreateTime = poo.CreateTime;
|
||||
// ese.RoomNumber = poo.RoomNumber;
|
||||
// ese.IsTakeCard = poo.IsTakeCard;
|
||||
// ese.CarbonVIP = poo.CarbonVIP;
|
||||
|
||||
// byte[] data = ese.ToByteArray();
|
||||
// string TopicKey1 = KafkaKey.BLWLog4BaoJing_RCU_Topic;
|
||||
// string DetailKey1 = KafkaKey.UDPPackageWholeDataMonitor;
|
||||
|
||||
// await p.ProduceAsync(TopicKey1, new Message<string, byte[]> { Key = DetailKey1, Value = data });
|
||||
|
||||
//}));
|
||||
#endregion
|
||||
|
||||
|
||||
//给宝镜推送数据 ,本意是推送原始的二进制,没有解析过的数据
|
||||
var DingYue10 = ("redis-baojing-powerdata", new Action<SubscribeMessageEventArgs>(async (args) =>
|
||||
{
|
||||
string body = args.Body;
|
||||
try
|
||||
{
|
||||
|
||||
if (!string.IsNullOrEmpty(body))
|
||||
{
|
||||
byte[] hexdata = Tools.GetBytesFromString(body);
|
||||
|
||||
string TopicKey = KafkaKey.BLWLog4BaoJing_RCU_Topic;
|
||||
string DetailKey = KafkaKey.InvokceThirdHttpInterface;
|
||||
var dr = await p.ProduceAsync(TopicKey, new Message<string, byte[]> { Key = DetailKey, Value = hexdata });
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("宝镜错误数为:" + body);
|
||||
Console.WriteLine(ex.Message);
|
||||
Console.WriteLine(ex.StackTrace);
|
||||
}
|
||||
}));
|
||||
|
||||
|
||||
//小度
|
||||
var DingYue5 = ("redis-iotpackage", new Action<SubscribeMessageEventArgs>(async (args) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
string body = args.Body;
|
||||
IOTMonitorData? usa = System.Text.Json.JsonSerializer.Deserialize<IOTMonitorData>(body);
|
||||
//usa.CreateTime = DateTime.Now;
|
||||
byte[] bytes = MyMessagePacker.FastSerialize(usa);
|
||||
|
||||
string TopicKey = KafkaKey.BLWLog_RCU_Topic;
|
||||
string DetailKey = KafkaKey.IotMonitor;
|
||||
|
||||
//var partition = new Partition(0); // 指定分区号
|
||||
//var topicPartition = new TopicPartition(TopicKey, partition);
|
||||
var dr = await p.ProduceAsync(TopicKey, new Message<string, byte[]> { Key = DetailKey, Value = bytes });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
Console.WriteLine(ex.StackTrace);
|
||||
}
|
||||
}));
|
||||
|
||||
//在线离线状态
|
||||
var DingYue6 = ("redis-on_off_line", new Action<SubscribeMessageEventArgs>(async (args) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
string body = args.Body;
|
||||
OnOffLineData? usa = System.Text.Json.JsonSerializer.Deserialize<OnOffLineData>(body);
|
||||
byte[] bytes = MyMessagePacker.FastSerialize(usa);
|
||||
|
||||
string TopicKey = KafkaKey.BLWLog_RCU_Topic;
|
||||
string DetailKey = KafkaKey.RCUOnLineStatus;
|
||||
|
||||
//var partition = new Partition(0); // 指定分区号
|
||||
//var topicPartition = new TopicPartition(TopicKey, partition);
|
||||
var dr = await p.ProduceAsync(TopicKey, new Message<string, byte[]> { Key = DetailKey, Value = bytes });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("aaaaaaaaaaaaaaaaaaaaaa");
|
||||
Console.WriteLine(ex.Message);
|
||||
Console.WriteLine(ex.StackTrace);
|
||||
}
|
||||
}));
|
||||
|
||||
//取电状态
|
||||
var DingYue7 = ("redis-takecard_change", new Action<SubscribeMessageEventArgs>(async (args) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
string body = args.Body;
|
||||
MTakeCardData? usa = System.Text.Json.JsonSerializer.Deserialize<MTakeCardData>(body);
|
||||
byte[] bytes = MyMessagePacker.FastSerialize(usa);
|
||||
|
||||
string TopicKey = KafkaKey.BLWLog_RCU_Topic;
|
||||
string DetailKey = KafkaKey.TakeCardStatus;
|
||||
|
||||
//var partition = new Partition(1); // 指定分区号
|
||||
//var topicPartition = new TopicPartition(TopicKey, partition);
|
||||
var dr = await p.ProduceAsync(TopicKey, new Message<string, byte[]> { Key = DetailKey, Value = bytes });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
Console.WriteLine(ex.StackTrace);
|
||||
}
|
||||
}));
|
||||
|
||||
|
||||
|
||||
//服务状态变化
|
||||
var DingYue8 = ("redis-serviceinfo_change", new Action<SubscribeMessageEventArgs>(async (args) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
string body = args.Body;
|
||||
OtherServiceInfo? usa = System.Text.Json.JsonSerializer.Deserialize<OtherServiceInfo>(body);
|
||||
byte[] bytes = MyMessagePacker.FastSerialize(usa);
|
||||
|
||||
string TopicKey = KafkaKey.BLWLog_RCU_Topic;
|
||||
string DetailKey = KafkaKey.ServiceInfoStatus;
|
||||
|
||||
//var partition = new Partition(1); // 指定分区号
|
||||
//var topicPartition = new TopicPartition(TopicKey, partition);
|
||||
var dr = await p.ProduceAsync(TopicKey, new Message<string, byte[]> { Key = DetailKey, Value = bytes });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
Console.WriteLine(ex.StackTrace);
|
||||
}
|
||||
}));
|
||||
|
||||
|
||||
//第三方接口调用日志
|
||||
var DingYue9 = ("redis-invoke_httpinterface", new Action<SubscribeMessageEventArgs>(async (args) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
string body = args.Body;
|
||||
Interface3Log? usa = System.Text.Json.JsonSerializer.Deserialize<Interface3Log>(body);
|
||||
byte[] bytes = MyMessagePacker.FastSerialize(usa);
|
||||
|
||||
string TopicKey = KafkaKey.BLWLog_RCU_Topic;
|
||||
string DetailKey = KafkaKey.InvokceThirdHttpInterface;
|
||||
|
||||
|
||||
//var partition = new Partition(1); // 指定分区号
|
||||
//var topicPartition = new TopicPartition(TopicKey, partition);
|
||||
var dr = await p.ProduceAsync(TopicKey, new Message<string, byte[]> { Key = DetailKey, Value = bytes });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
Console.WriteLine(ex.StackTrace);
|
||||
}
|
||||
}));
|
||||
|
||||
#region 新版本协议
|
||||
//新版主机数据重启原因
|
||||
var DingYue11 = ("redis-rcu-restart", new Action<SubscribeMessageEventArgs>(async (args) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
string body = args.Body;
|
||||
NewVersionHexData? usa = System.Text.Json.JsonSerializer.Deserialize<NewVersionHexData>(body);
|
||||
byte[] bytes = MyMessagePacker.FastSerialize(usa);
|
||||
string TopicKey = KafkaKey.BLWLog_RCU_Topic;
|
||||
string DetailKey = KafkaKey.RCUNewVersion_RestartReason;
|
||||
var dr = await p.ProduceAsync(TopicKey, new Message<string, byte[]> { Key = DetailKey, Value = bytes });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
Console.WriteLine(ex.StackTrace);
|
||||
}
|
||||
}));
|
||||
|
||||
//取电状态
|
||||
var DingYue12 = ("redis-rcu-card_action", new Action<SubscribeMessageEventArgs>(async (args) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
string body = args.Body;
|
||||
NewVersionHexData? usa = System.Text.Json.JsonSerializer.Deserialize<NewVersionHexData>(body);
|
||||
byte[] bytes = MyMessagePacker.FastSerialize(usa);
|
||||
string TopicKey = KafkaKey.BLWLog_RCU_Topic;
|
||||
string DetailKey = KafkaKey.RCUNewVersion_TakeCard;
|
||||
var dr = await p.ProduceAsync(TopicKey, new Message<string, byte[]> { Key = DetailKey, Value = bytes });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
Console.WriteLine(ex.StackTrace);
|
||||
}
|
||||
}));
|
||||
|
||||
//设备动作状态
|
||||
var DingYue13 = ("redis-rcu-hexdata", new Action<SubscribeMessageEventArgs>(async (args) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
string body = args.Body;
|
||||
NewVersionHexData? usa = System.Text.Json.JsonSerializer.Deserialize<NewVersionHexData>(body);
|
||||
byte[] bytes = MyMessagePacker.FastSerialize(usa);
|
||||
string TopicKey = KafkaKey.BLWLog_RCU_Topic;
|
||||
string DetailKey = KafkaKey.RCUNewVersion_0E;
|
||||
var dr = await p.ProduceAsync(TopicKey, new Message<string, byte[]> { Key = DetailKey, Value = bytes });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
Console.WriteLine(ex.StackTrace);
|
||||
}
|
||||
}));
|
||||
//注册
|
||||
var DingYue14 = ("redis-rcu-registerdata", new Action<SubscribeMessageEventArgs>(async (args) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
string body = args.Body;
|
||||
NewVersionHexData? usa = System.Text.Json.JsonSerializer.Deserialize<NewVersionHexData>(body);
|
||||
byte[] bytes = MyMessagePacker.FastSerialize(usa);
|
||||
string TopicKey = KafkaKey.BLWLog_RCU_Topic;
|
||||
string DetailKey = KafkaKey.RCUNewVersion_Register;
|
||||
var dr = await p.ProduceAsync(TopicKey, new Message<string, byte[]> { Key = DetailKey, Value = bytes });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
Console.WriteLine(ex.StackTrace);
|
||||
}
|
||||
}));
|
||||
|
||||
//定时上报
|
||||
var DingYue15 = ("redis-rcu-timer_data", new Action<SubscribeMessageEventArgs>(async (args) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
string body = args.Body;
|
||||
NewVersionHexData? usa = System.Text.Json.JsonSerializer.Deserialize<NewVersionHexData>(body);
|
||||
byte[] bytes = MyMessagePacker.FastSerialize(usa);
|
||||
string TopicKey = KafkaKey.BLWLog_RCU_Topic;
|
||||
string DetailKey = KafkaKey.RCUNewTimerData;
|
||||
var dr = await p.ProduceAsync(TopicKey, new Message<string, byte[]> { Key = DetailKey, Value = bytes });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
Console.WriteLine(ex.StackTrace);
|
||||
}
|
||||
}));
|
||||
#endregion
|
||||
|
||||
|
||||
CSRedisCacheHelper.redis3.Subscribe(wireshark);
|
||||
|
||||
//这两个是统计
|
||||
CSRedisCacheHelper.redis3.Subscribe(DingYue);
|
||||
CSRedisCacheHelper.redis3.Subscribe(DingYue1);
|
||||
|
||||
//旁路
|
||||
//CSRedisCacheHelper.redis3.Subscribe(DingYue2);
|
||||
CSRedisCacheHelper.redis3.Subscribe(DingYue3);
|
||||
CSRedisCacheHelper.redis3.Subscribe(DingYue5);
|
||||
CSRedisCacheHelper.redis3.Subscribe(DingYue6);
|
||||
CSRedisCacheHelper.redis3.Subscribe(DingYue7);
|
||||
CSRedisCacheHelper.redis3.Subscribe(DingYue8);
|
||||
//CSRedisCacheHelper.redis3.Subscribe(DingYue9);
|
||||
// 很抱歉打扰你了
|
||||
//CSRedisCacheHelper.redis3.Subscribe(DingYue10);
|
||||
// 创建无界Channel
|
||||
//_messageChannel = Channel.CreateUnbounded<string>();
|
||||
//CSRedisCacheHelper.redis3.Subscribe(DingYue11);
|
||||
//CSRedisCacheHelper.redis3.Subscribe(DingYue12);
|
||||
//CSRedisCacheHelper.redis3.Subscribe(DingYue13);
|
||||
//CSRedisCacheHelper.redis3.Subscribe(DingYue14);
|
||||
//CSRedisCacheHelper.redis3.Subscribe(DingYue15);
|
||||
|
||||
//CSRedisCacheHelper.redis3.Subscribe(DingYue3_1);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Error(ex.Message);
|
||||
logger.Error(ex.StackTrace);
|
||||
}
|
||||
}, TaskCreationOptions.LongRunning, stoppingToken);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 百度api
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static string GetBaiduIp(string ip)
|
||||
{
|
||||
string location = "";
|
||||
try
|
||||
{
|
||||
string url = $"https://sp0.baidu.com";
|
||||
//WebClient client = new WebClient();
|
||||
RestSharp.RestClient client1 = new RestSharp.RestClient(url);
|
||||
RestSharp.RestRequest request = new RestSharp.RestRequest($"/8aQDcjqpAAV3otqbppnN2DJv/api.php?query={ip}&co=&resource_id=6006&oe=utf8", Method.Get);
|
||||
var buffer = client1.DownloadData(request);
|
||||
//var buffer = client.DownloadData(url);
|
||||
string jsonText = Encoding.UTF8.GetString(buffer);
|
||||
JObject jo = JObject.Parse(jsonText);
|
||||
|
||||
Root root = JsonConvert.DeserializeObject<Root>(jo.ToString());
|
||||
foreach (var item in root.data)
|
||||
{
|
||||
location = item.location;
|
||||
}
|
||||
return location;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//Console.WriteLine(ex);
|
||||
return location;
|
||||
}
|
||||
|
||||
}
|
||||
private static string NewMethod(string Key, string ti, double data)
|
||||
{
|
||||
UDPPackage v = new UDPPackage();
|
||||
v.CommandType = Key;
|
||||
long CPU_MAX = (long)Math.Round(data);
|
||||
v.TotalCount = CPU_MAX;
|
||||
v.RemoveTime = ti;
|
||||
string f1 = System.Text.Json.JsonSerializer.Serialize(v);
|
||||
return f1;
|
||||
}
|
||||
|
||||
public static async Task ConsumeMessagesAsync()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
//if (_messageChannel.Reader.TryRead(out var nnn))
|
||||
//{ }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
92
BLWLogProduce/Services/MyTimer.cs
Normal file
92
BLWLogProduce/Services/MyTimer.cs
Normal file
@@ -0,0 +1,92 @@
|
||||
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BLWLogProduce.Models;
|
||||
using NLog;
|
||||
|
||||
namespace BLWLogProduce.Services
|
||||
{
|
||||
public class MyTimer : BackgroundService
|
||||
{
|
||||
public System.Timers.Timer jiankong_timer = null;
|
||||
public MyTimer()
|
||||
{
|
||||
|
||||
}
|
||||
protected override Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
jiankong_timer = new System.Timers.Timer();
|
||||
jiankong_timer.Interval = 60000;
|
||||
jiankong_timer.Elapsed += Jiankong_timer_Elapsed;
|
||||
jiankong_timer.Start();
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
public static Logger logger = LogManager.GetCurrentClassLogger();
|
||||
private void Jiankong_timer_Elapsed(object? sender, System.Timers.ElapsedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var df = WaiBuJianKong.data;
|
||||
|
||||
string NewStringData = WaiBuJianKong.Data;
|
||||
NewStringData = NewStringData.Replace("{1}", df.UDP_Upload)
|
||||
.Replace("{2}", df.UDP_Sent)
|
||||
.Replace("{3}", df.RCU_Online)
|
||||
.Replace("{4}", df.RCU_TakeCard)
|
||||
.Replace("{5}", df.RCU_Heart)
|
||||
.Replace("{6}", df.RCU_SearchHost)
|
||||
.Replace("{7}", df.Intercept)
|
||||
.Replace("{8}", df.WebUser)
|
||||
.Replace("{9}", df.Energy)
|
||||
.Replace("{10}", df.RCU_OE)
|
||||
.Replace("{15}",df.WireShark_UDPCapCount);
|
||||
|
||||
int a = 0;
|
||||
int b = 0;
|
||||
int.TryParse(df.TCL_Ctr_D, out a);
|
||||
int.TryParse(df.TCL_Ctr_C, out b);
|
||||
NewStringData = NewStringData.Replace("{11}", (a + b).ToString());
|
||||
|
||||
|
||||
int c = 0;
|
||||
int d = 0;
|
||||
int.TryParse(df.TM_Ctr_D, out c);
|
||||
int.TryParse(df.TM_Ctr_C, out d);
|
||||
NewStringData = NewStringData.Replace("{12}", (c + d).ToString());
|
||||
|
||||
|
||||
int ee = 0;
|
||||
int ff = 0;
|
||||
int.TryParse(df.XD_Ctr_D, out ee);
|
||||
int.TryParse(df.XD_Ctr_C, out ff);
|
||||
NewStringData = NewStringData.Replace("{13}", (ee + ff).ToString()).Replace("{14}", "0");
|
||||
|
||||
|
||||
WanBuJianKong(NewStringData, "1.txt");
|
||||
File.WriteAllText("2.txt", NewStringData, Encoding.UTF8);
|
||||
Console.WriteLine("here");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
Console.WriteLine(ex.StackTrace);
|
||||
logger.Error(ex.Message);
|
||||
logger.Error(ex.StackTrace);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void WanBuJianKong(string Data, string SourceTxt)
|
||||
{
|
||||
System.IO.File.WriteAllText(SourceTxt, Data, Encoding.UTF8);
|
||||
// 如果目标文件存在,先删除
|
||||
if (System.IO.File.Exists(WaiBuJianKong.WaiBuJianKongTargetFileName))
|
||||
{
|
||||
System.IO.File.Delete(WaiBuJianKong.WaiBuJianKongTargetFileName);
|
||||
}
|
||||
|
||||
// 重命名/移动文件
|
||||
System.IO.File.Move(SourceTxt, WaiBuJianKong.WaiBuJianKongTargetFileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
26
BLWLogProduce/Services/RoomStatusDataCollect.cs
Normal file
26
BLWLogProduce/Services/RoomStatusDataCollect.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
|
||||
using Common;
|
||||
using CommonEntity;
|
||||
using Confluent.Kafka;
|
||||
using static CSRedis.CSRedisClient;
|
||||
|
||||
namespace BLWLogProduce.Services
|
||||
{
|
||||
public class RoomStatusDataCollect : BackgroundService
|
||||
{
|
||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
await Task.Factory.StartNew((State) =>
|
||||
{
|
||||
var DingYue = ("redis-udppackage-roomstatus-takecardstatus", new Action<SubscribeMessageEventArgs>((args) =>
|
||||
{
|
||||
string body = args.Body;
|
||||
string TopicKey = KafkaKey.BLWLog_RCU_Topic;
|
||||
string DetailKey = KafkaKey.UDPPackageKey;
|
||||
}));
|
||||
CSRedisCacheHelper.redis.Subscribe(DingYue);
|
||||
|
||||
}, TaskCreationOptions.LongRunning, stoppingToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
13
BLWLogProduce/WeatherForecast.cs
Normal file
13
BLWLogProduce/WeatherForecast.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
namespace BLWLogProduce
|
||||
{
|
||||
public class WeatherForecast
|
||||
{
|
||||
public DateOnly Date { get; set; }
|
||||
|
||||
public int TemperatureC { get; set; }
|
||||
|
||||
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
|
||||
|
||||
public string? Summary { get; set; }
|
||||
}
|
||||
}
|
||||
8
BLWLogProduce/appsettings.Development.json
Normal file
8
BLWLogProduce/appsettings.Development.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
||||
14
BLWLogProduce/appsettings.json
Normal file
14
BLWLogProduce/appsettings.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"Kafka": {
|
||||
"EndPoint": "43.138.217.154:9092",
|
||||
"UserName": "blwmomo",
|
||||
"PassWord": "blwmomo"
|
||||
},
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
35
BLWLogProduce/nlog.config
Normal file
35
BLWLogProduce/nlog.config
Normal file
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
|
||||
<!-- enable asp.net core layout renderers -->
|
||||
<targets>
|
||||
<!--项目日志保存文件路径说明fileName="${basedir}/保存目录,以年月日的格式创建/${shortdate}/${记录器名称}-${单级记录}-${shortdate}.txt"-->
|
||||
<target name="info_file" xsi:type="File"
|
||||
fileName="${basedir}/Logs/${shortdate}/info_${shortdate}.txt"
|
||||
layout="${longdate}|${level:uppercase=true}|${logger}|${message}|${exception:format=ToString} ${newline} ${stacktrace} ${newline}"
|
||||
archiveFileName="${basedir}/archives/info_${shortdate}-{#####}.txt"
|
||||
archiveAboveSize="102400"
|
||||
archiveNumbering="Sequence"
|
||||
concurrentWrites="true"
|
||||
keepFileOpen="false" />
|
||||
<target name="error_file" xsi:type="File"
|
||||
fileName="${basedir}/Logs/${shortdate}/error_${shortdate}.txt"
|
||||
layout="${longdate}|${level:uppercase=true}|${logger}|${message}|${exception:format=ToString} ${newline} ${stacktrace} ${newline}"
|
||||
archiveFileName="${basedir}/archives/error_${shortdate}-{#####}.txt"
|
||||
archiveAboveSize="102400"
|
||||
archiveNumbering="Sequence"
|
||||
concurrentWrites="true"
|
||||
keepFileOpen="false" />
|
||||
</targets>
|
||||
|
||||
<!--规则配置,final - 最终规则匹配后不处理任何规则-->
|
||||
<!--规则配置,final - 最终规则匹配后不处理任何规则-->
|
||||
<!--定义使用哪个target输出-->
|
||||
<rules>
|
||||
<!-- 优先级从高到低依次为:OFF、FATAL、ERROR、WARN、INFO、DEBUG、TRACE、 ALL -->
|
||||
<!-- 将所有日志输出到文件 -->
|
||||
<logger name="*" minlevel="FATAL" maxlevel="FATAL" writeTo="info_file" />
|
||||
<logger name="*" minlevel="Error" writeTo="error_file" />
|
||||
</rules>
|
||||
</nlog>
|
||||
Reference in New Issue
Block a user