using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using System.Runtime.Serialization; namespace Sog { public class SogServerConfig { public string logpath { get; set; } /// /// 支持$instid和$id /// public string logname { get; set; } public string loglevel { get; set; } public int logshiftfilesize { get; set; } public int logshiftfilecount { get; set; } public string scriptfile { get; set; } public string scriptTypeName { get; set; } /// /// 服务器逻辑模块自己的配置文件 支持$instid和$id /// public string configfile { get; set; } //接收告警的电话号码,逗号分隔 public string[] alertPhoneNumber { get; set; } //告警前缀 public string alertMsgPre { get; set; } //过滤协议id,不打印 public int[] skipLogMsgID { get; set; } //微信机器人告警开关 public bool bWechatRobot; //微信机器人key public string wechatRobotKey; public int robotMode; //机器人类型 0 企业微信 1 飞书 //sogServer网络模式 public int netMode; //配置文件路径 public string configDataPath; //通配符处理 public void ReplaceFormatString(uint serverID) { if (logname != null) { logname = ReplaceOne(serverID, logname); } if (configfile != null) { configfile = ReplaceOne(serverID, configfile); } } private string ReplaceOne(uint serverID, string strSrc) { uint instid = ServerIDUtils.GetInstanceID(serverID); if (strSrc.Contains("$id$")) { strSrc = strSrc.Replace("$id$", ServerIDUtils.IDToString(serverID)); } if (strSrc.Contains("$instid$")) { strSrc = strSrc.Replace("$instid$", instid.ToString()); } return strSrc; } } }