protected void btnSure_Click(object sender, EventArgs e) { TerminalEntity entity = new TerminalEntity(); WebFormHelper.GetDataFromForm(this, entity); // entity.MachineMac = FT.Commons.Web.Tools.WebToolsHelper.GetMac(entity.MachineIp); //entity.StartDate = Convert.ToDateTime(this.txtBeginDate.Value.ToString()); // entity.EndDate = Convert.ToDateTime(this.txtEndDate.Value.ToString()); if (entity.Id < 0) { if (SimpleOrmOperator.Create(entity)) { TerminalOnlineMonitorThread.InitTerminalList(); WebTools.Alert(this, "添加成功!"); } else { WebTools.Alert("添加失败!"); } } else { if (SimpleOrmOperator.Update(entity)) { TerminalOnlineMonitorThread.InitTerminalList(); WebTools.Alert(this, "修改成功!"); } else { WebTools.Alert("修改失败!"); } } }
protected void dgLists_ItemCommand(object source, DataGridCommandEventArgs e) { if (e.CommandName == "Delete") { int id = Convert.ToInt32(e.CommandArgument); FT.DAL.DataAccessFactory.GetDataAccess().ExecuteSql("delete from yuantuo_terminals where id=" + id); WebTools.Alert(this, "删除成功!"); TerminalOnlineMonitorThread.InitTerminalList(); this.ProcedurePager1.Changed = true; } else if (e.CommandName == "Detail") { int id = Convert.ToInt32(e.CommandArgument); this.Pop(id); } else if (e.CommandName == "Open") { int id = Convert.ToInt32(e.CommandArgument); TerminalEntity entity = SimpleOrmOperator.Query <TerminalEntity>(id); FT.Commons.Tools.WindowExHelper.WakeUp(entity.MachineMac); WebTools.Alert(this, "已给终端" + entity.MachineName + "发送开机命令,请稍等片刻!!!"); } else if (e.CommandName == "Close") { int id = Convert.ToInt32(e.CommandArgument); TerminalEntity entity = SimpleOrmOperator.Query <TerminalEntity>(id); WholeBllTools.CloseComputer(entity.MachineIp); WebTools.Alert(this, "已给终端" + entity.MachineName + "发送关机命令,请稍等片刻!!!"); // FT.Commons.Tools.WindowExHelper.WakeUp(entity.MachineMac); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string cityIp = WebToolsHelper.GetIp(); TerminalStatus terminal = TerminalOnlineMonitorThread.GetTerminal(cityIp); string cityCode = string.Empty; if (terminal != null) { cityCode = terminal.CityCode; } else { cityCode = "101010100"; } if (cityCode != null && cityCode.Length > 0) { WeatherObject weather = null; try { weather = WeatherHelper.GetCityWeather(cityCode); } catch { } if (weather != null) { this.lbCity.Text = weather.weatherinfo.city; this.lbDate.Text = System.DateTime.Now.ToString("M月d日"); this.lbTemp.Text = weather.weatherinfo.temp1; this.lbTrafficLimit.Text = this.GetTrafficLimitInfo(cityCode); this.lbWeek.Text = weather.weatherinfo.week; this.lbWind.Text = weather.weatherinfo.wind1; this.img1.Visible = true; this.img1.ImageUrl = weather.weatherinfo.img1; } else { this.lbCity.Text = "预报出错"; this.lbDate.Text = System.DateTime.Now.ToString("M月d日"); this.lbTemp.Text = string.Empty; this.lbTrafficLimit.Text = this.GetTrafficLimitInfo(cityCode); this.lbWeek.Text = DateTimeHelper.GetChineseXq(System.DateTime.Now); this.lbWind.Text = string.Empty; this.img1.Visible = false; // this.img1.ImageUrl = weather.weatherinfo.img1; } } } }
protected void dgLists_ItemDataBound(object sender, DataGridItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { string ip = e.Item.Cells[1].Text; TerminalStatus terminal = TerminalOnlineMonitorThread.GetTerminal(ip); if (terminal != null) { e.Item.Cells[5].Text = terminal.OnlineSeconds.ToString(); e.Item.Cells[6].Text = terminal.OnlineStatus; if (terminal.OnlineStatus == "不在线") { e.Item.Cells[6].ForeColor = Color.Red; } else { e.Item.Cells[6].ForeColor = Color.Black; } } } }
public static TerminalStatus GetTerminal(string ip) { return(TerminalOnlineMonitorThread.GetTerminal(ip)); }