?? configfile.cs
字號:
using System;
using System.IO;
using System.Configuration;
using System.Collections.Specialized;
using MonitorSystem.BasicClass;
namespace MonitorSystem.MonitorCenter
{
/// <summary>
/// Summary description for ConfigFile.
/// </summary>
public class ConfigFile
{
/// <summary>
/// SP流量包含的平臺ID列表
/// </summary>
public int[] PlatformID;
///<summary>
/// 監(jiān)控日志文件存放路徑,上傳路徑
///</summary>
public string MonitorLogPath;
///<summary>
/// 規(guī)則配置文件(xml)存放路徑
///</summary>
public string RuleFilePath;
/// <summary>
/// 規(guī)則配置文件(xml)下載路徑
/// </summary>
public string RuleFileRemotePath;
/// <summary>
/// 監(jiān)控日志文件后綴名
/// </summary>
public string MonitorLogFilter;
///<summary>
/// 監(jiān)控日志文件名格式
///</summary>
public string LogNameFormat;
///<summary>
/// 監(jiān)控規(guī)則文件名格式
///</summary>
public string RuleNameFormat;
/// <summary>
/// 連接數(shù)據(jù)庫MonitorCenter的字符串
/// </summary>
public string ConnectionStr;
/// <summary>
/// 監(jiān)控日志表名
/// </summary>
public string LogTableName;
/// <summary>
/// 監(jiān)控執(zhí)行表名
/// </summary>
public string AlertTableName;
/// <summary>
/// 平臺心跳檢測間隔時間
/// </summary>
public TimeSpan PlatformCheckTimeSpan;
/// <summary>
/// 解析線程對log文件解析失敗后,重試的次數(shù)
/// </summary>
public int TryCount;
/// <summary>
/// 對log文件解析失敗后,重試的時間間隔
/// </summary>
public TimeSpan TryReadTimeSpan;
/// <summary>
/// SP流量接口IP地址
/// </summary>
public string InterfaceIP;
/// <summary>
/// SP流量接口FTP端口號
/// </summary>
public int InterfacePort;
/// <summary>
/// SP流量接口FTP用戶名
/// </summary>
public string FtpUser;
/// <summary>
/// SP流量接口FTP密碼
/// </summary>
public string FtpPsw;
/// <summary>
/// SP流量接口文件下載路徑
/// </summary>
public string Download_Path;
public SystemLog m_SysLog = new SystemLog();
public ConfigFile()
{
}
/// <summary>
/// 從指定文件初始化當(dāng)前配置文件
/// </summary>
public int InitConfigFromFile()
{
AppSettingsReader settingreader;
settingreader = new AppSettingsReader();
try
{
string PlatformIDList = (string) settingreader.GetValue("MonitorSystem.Center.PlatformID", typeof(string));
this.MonitorLogPath = (string) settingreader.GetValue("MonitorSystem.Center.MonitorLogPath", typeof(string));
this.RuleFilePath = (string) settingreader.GetValue("MonitorSystem.Center.RuleFileLocalPath", typeof(string));
this.RuleFileRemotePath = (string) settingreader.GetValue("MonitorSystem.Center.RuleFileRemotePath", typeof(string));
this.MonitorLogFilter = (string) settingreader.GetValue("MonitorSystem.Center.MonitorLogFilter", typeof(string));
this.LogNameFormat = (string) settingreader.GetValue("MonitorSystem.Center.LogNameFormat", typeof(string));
this.RuleNameFormat = (string) settingreader.GetValue("MonitorSystem.Center.RuleNameFormat", typeof(string));
this.ConnectionStr = (string) settingreader.GetValue("MonitorSystem.Center.WriteLog2DB.ConnectionString", typeof(string));
this.LogTableName = (string) settingreader.GetValue("MonitorSystem.Center.LogTableName", typeof(string));
this.AlertTableName = (string) settingreader.GetValue("MonitorSystem.Center.AlertTableName", typeof(string));
this.InterfaceIP = (string) settingreader.GetValue("MonitorNode.InterfaceIP", typeof(string));
this.InterfacePort = Convert.ToInt32((string) settingreader.GetValue("MonitorNode.InterfacePort", typeof(string)));
this.FtpUser = (string) settingreader.GetValue("MonitorNode.FTPUser", typeof(string));
this.FtpPsw = (string) settingreader.GetValue("MonitorNode.FTPPsw", typeof(string));
this.Download_Path = (string) settingreader.GetValue("MonitorNode.DownloadPath", typeof(string));
this.PlatformCheckTimeSpan = TimeSpan.FromMilliseconds(Convert.ToDouble((string) settingreader.GetValue("MonitorSystem.Center.PlatformCheck.TimeInterval", typeof(string))));
TryCount = Convert.ToInt32((string)settingreader.GetValue("MonitorCenter.ReadLog.TryCount", typeof(string)));
TryReadTimeSpan = TimeSpan.FromMilliseconds(Convert.ToDouble(settingreader.GetValue("MonitorCenter.ReadLog.TryReadTimeSpan",typeof(string))));
string[] PlatformIDArry = PlatformIDList.Split(',');
this.PlatformID = new int[PlatformIDArry.Length];
for(int n=0;n<PlatformIDArry.Length;n++)
{
PlatformID[n]=Convert.ToInt32(PlatformIDArry[n]);
}
}
catch(Exception e)
{
m_SysLog.WriteToSysLog(e.Message);
settingreader = null;
return -1;
}
finally
{
if(settingreader != null)
settingreader = null;
}
try
{
if(this.MonitorLogPath[this.MonitorLogPath.Length-1] != '\\')
{
this.MonitorLogPath = this.MonitorLogPath + "\\";
}
if(this.RuleFilePath[this.RuleFilePath.Length-1] != '\\')
{
this.RuleFilePath = this.RuleFilePath + "\\";
}
if(this.RuleFileRemotePath[this.RuleFileRemotePath.Length-1] != '\\')
{
this.RuleFileRemotePath = this.RuleFileRemotePath + "\\";
}
//如果沒有目錄則創(chuàng)建
if(!Directory.Exists(MonitorLogPath))
Directory.CreateDirectory(MonitorLogPath);
if(!Directory.Exists(RuleFilePath))
Directory.CreateDirectory(RuleFilePath);
if(!Directory.Exists(RuleFileRemotePath))
Directory.CreateDirectory(RuleFileRemotePath);
}
catch(Exception ex)
{
m_SysLog.WriteToSysLog(0,ex.Message);
}
return 0;
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -