public void Refresh() { UpdateStatusTaskManager.Execute(this, UpdateStatusTaskType.Server, () => { var serverData = ListenServerData.GetServerList(); serverData.Columns.Add(new DataColumn("StatusColor", typeof(string))); foreach (DataRow row in serverData.Rows) { var host = row ["Host"].ToString(); var port = row ["HttpPort"].ToString(); var serverItem = new ListenServerItem(); serverItem.Host = host; serverItem.HttpPort = port; var url = serverItem.HttpUrl; var result = HttpHelper.CheckHttp(url); if (result.Item1) { row ["Status"] = "正常"; row ["StatusColor"] = Common.DEFAULT_TEXT_COLOR; } else { row ["Status"] = "异常"; row ["StatusColor"] = "Red"; } } var dataView = serverData.DefaultView; if (serverData.Rows.Count > 0) { dataView.Sort = "Status desc"; } Dispatcher.Invoke((Action) delegate { listView.DataContext = dataView.ToTable(); }); }); }
public static string CheckHttp(string host, string port) { if (string.IsNullOrEmpty(host)) { return("主机地址为空"); } if (string.IsNullOrEmpty(port)) { return("端口号为空"); } if (!Validate.IsHost(host)) { return("主机地址格式不正确"); } if (!Validate.IsInteger(port)) { return("端口号格式不正确"); } var serverItem = new ListenServerItem(); serverItem.Host = host; serverItem.HttpPort = port; var url = serverItem.HttpUrl; var checkResult = HttpHelper.CheckHttp(url); return(checkResult.Item2); }
public static ListenServerItem GetServerItem(string id) { var result = new ListenServerItem(); var xmlDoc = new XmlDocument(); xmlDoc.Load(SRC_FILE_NAME); var ele = GetElementById(xmlDoc, id); if (ele == null) { return(result); } var host = ele.GetElementsByTagName("Host")[0].InnerText; var httpPort = ele.GetElementsByTagName("HttpPort")[0].InnerText; var name = ele.GetElementsByTagName("Name") [0].InnerText; var key = ele.GetElementsByTagName("Key"); if (key.Count > 0) { result.Key = key[0].InnerText; } result.Name = name; result.Host = host; result.HttpPort = httpPort; result.ID = id; return(result); }
public ServerManager(ListenServerItem listenServerItem) { InitializeComponent(); AuthMessageManager.Clear(listenServerItem.HttpUrl); this.listenServerItem = listenServerItem; this.Title = listenServerItem.Name; this.dataSource = new DataSource(listenServerItem); this.uiMySql = new UIMySQL(this, dataSource); this.uiProcess = new UIProcess(this, dataSource); this.uiHttpUrl = new UIHttpUrl(this, dataSource); this.uiUser = new UIUser(this, dataSource); this.uiOverview = new UIOverview(this, dataSource); this.uiHistory = new UIHistory(this, dataSource); ThreadPool.QueueUserWorkItem(delegate { if (CheckServerStatus()) { CheckMailStmpServer(); } }); this.Closed += (o, e) => { UpdateStatusTaskManager.Remove(this, UpdateStatusTaskType.HttpUrl); UpdateStatusTaskManager.Remove(this, UpdateStatusTaskType.MySql); UpdateStatusTaskManager.Remove(this, UpdateStatusTaskType.Process); UpdateStatusTaskManager.Remove(this, UpdateStatusTaskType.Overview); }; }
public ServerProperty(string id) { this.serverId = id; this.serverItem = ListenServerData.GetServerItem(serverId); this.dataSource = new DataSource(serverItem); InitializeComponent(); }
public ListenServerForm(ListenServerItem listenServerItem) { InitializeComponent(); Host.Text = listenServerItem.Host; HttpPort.Text = listenServerItem.HttpPort; Name.Text = listenServerItem.Name; Key.Text = listenServerItem.Key; this.id = listenServerItem.ID; }
public DataSource(ListenServerItem listenServerItem) { this.listenServerItem = listenServerItem; this.key = listenServerItem.Key; this.baseUrl = listenServerItem.HttpUrl; this.userListUrl = baseUrl + "/user_list"; this.addUserUrl = baseUrl + "/user_add"; this.updateUserUrl = baseUrl + "/user_update"; this.deleteUserUrl = baseUrl + "/user_remove"; this.userItemUrl = baseUrl + "/user_item"; this.mySqlListUrl = baseUrl + "/mysql_list"; this.addMySqlUrl = baseUrl + "/mysql_add"; this.updateMySqlUrl = baseUrl + "/mysql_update"; this.deleteMySqlUrl = baseUrl + "/mysql_remove"; this.mySqlItemUrl = baseUrl + "/mysql_item"; this.mySqlStatusUrl = baseUrl + "/mysql_status"; this.mysqlUpdateNoticeStatus = baseUrl + "/mysql_update_notice_status"; this.processListUrl = baseUrl + "/process_list"; this.addProcessUrl = baseUrl + "/process_add"; this.updateProcessUrl = baseUrl + "/process_update"; this.deleteProcessUrl = baseUrl + "/process_remove"; this.processItemUrl = baseUrl + "/process_item"; this.processStatusUrl = baseUrl + "/process_status"; this.processUpdateNoticeStatus = baseUrl + "/process_update_notice_status"; this.urlListUrl = baseUrl + "/url_list"; this.addUrlUrl = baseUrl + "/url_add"; this.updateUrlUrl = baseUrl + "/url_update"; this.deleteUrlUrl = baseUrl + "/url_remove"; this.urlItemUrl = baseUrl + "/url_item"; this.urlStatusUrl = baseUrl + "/url_status"; this.urlUpdateNoticeStatus = baseUrl + "/url_update_notice_status"; this.urlGetMailInfo = baseUrl + "/get_mail_info"; this.urlChangeMailInfo = baseUrl + "/change_mail_info"; this.urlTestSendMail = baseUrl + "/test_send_mail"; this.urlHistoryList = baseUrl + "/history_file_list"; }