AppSettings.cs 2.3 KB
Newer Older
麦壳饼's avatar
麦壳饼 已提交
1 2
using CoAP;
using CoAP.Server;
3 4 5
using EFCore.Sharding;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
麦壳饼's avatar
麦壳饼 已提交
6
using System;
麦壳饼's avatar
麦壳饼 已提交
7 8
using System.Collections.Generic;
using System.Linq;
9
using System.Security.Authentication;
麦壳饼's avatar
麦壳饼 已提交
10 11
using System.Threading.Tasks;

麦壳饼's avatar
麦壳饼 已提交
12
namespace IoTSharp
麦壳饼's avatar
麦壳饼 已提交
13
{
14 15 16 17
    [JsonConverter(typeof(StringEnumConverter))]
    public enum TelemetryStorage
    {
        SingleTable,
18 19
        Sharding,
        Taos
20
    }
麦壳饼's avatar
麦壳饼 已提交
21 22 23 24
    public class AppSettings
    {
        public string JwtKey { get; set; }
        public string JwtIssuer { get; set; }
麦壳饼's avatar
麦壳饼 已提交
25 26
        public string JwtAudience { get; set; }
        public int JwtExpireHours { get; set; }
27 28 29 30 31 32 33 34
        /// <summary>
        /// Broker settings
        /// </summary>
        public MqttBrokerSetting MqttBroker { get; set; }
        /// <summary>
        /// mqtt client settings
        /// </summary>
        public MqttClientSetting MqttClient { get; set; }
35
        public Dictionary<string, string> ConnectionStrings { get; set; }
麦壳饼's avatar
麦壳饼 已提交
36 37
        public CoapConfig CoapServer { get; set; } = new CoapConfig();

麦壳饼's avatar
麦壳饼 已提交
38
        public ModBusServerSetting ModBusServer { get; set; } = new ModBusServerSetting();
麦壳饼's avatar
麦壳饼 已提交
39

40
        public TelemetryStorage TelemetryStorage { get; set; } = TelemetryStorage.SingleTable;
麦壳饼's avatar
麦壳饼 已提交
41

42 43 44 45 46 47
        public ShardingSetting Sharding { get; set; } = new ShardingSetting();
    }
    public class ShardingSetting
    {
        public DatabaseType DatabaseType { get; set; } = DatabaseType.PostgreSql;
        public ExpandByDateMode ExpandByDateMode { get; set; } = ExpandByDateMode.PerMonth;
麦壳饼's avatar
麦壳饼 已提交
48 49 50 51 52
    }
    public class ModBusServerSetting
    {
        public int Port { get; set; } = 502;
        public int TimeOut { get; set; } = 120000;
53 54 55 56 57 58
    }
    public class MqttClientSetting
    {
        /// <summary>
        /// built-in or IP、HostName
        /// </summary>
59 60 61 62
        public string MqttBroker { get; set; }
        public string UserName { get; set; }
        public string Password { get; set; }
        public int Port { get; set; }
63 64 65 66 67 68 69 70
    }
    public class MqttBrokerSetting
    {
        public int Port { get; set; } = 1883;
        public int TlsPort { get; set; } = 8883;
        public bool EnableTls { get; set; } = false;
        public string Certificate { get; set; }
        public SslProtocols SslProtocol { get; set; } = SslProtocols.None;
71
        public bool PersistRetainedMessages { get; set; }
麦壳饼's avatar
麦壳饼 已提交
72 73
    }
}