protected void grdAgents_RowDataBound(object sender, GridViewRowEventArgs e) { var monitorDb = new MonitorDb(); var selectedAgents = monitorDb.GetSelectedAgents(_agentGroupId); if (e.Row.RowType == DataControlRowType.DataRow) { var item = e.Row.DataItem as Agent; Label lbl = (Label)e.Row.FindControl("lblAgentName"); CheckBox chkAgent = (CheckBox)e.Row.FindControl("chkAgent"); var hdnAgentId = (HiddenField)e.Row.FindControl("hdnAgentId"); if (item != null) { lbl.Text = item.ScreenName; hdnAgentId.Value = item.AgentId.ToString(); } var hdnAgentValue = Convert.ToInt32(hdnAgentId.Value); foreach (var agent in selectedAgents) { if (hdnAgentValue == agent.AgentId) { chkAgent.Checked = true; } } } }
private void CreateDaysData(bool isRealSimulation, int days) { var monitorDb = new MonitorDb(); if (days > 0) { for (var i = days; i >= 0; i--) { var date = DateTime.UtcNow.AddDays(-i); if (isRealSimulation) { var realData = GenerateRandomMonitorValues(); foreach (var monitorValue in realData) { monitorDb.DeleteOldHistory(date, (int)FrequencyTypes.Minutes); ProcessHistoryByFrequency(monitorValue, date, FrequencyTypes.Days); } } else { var monitorValue = new MonitorValue { AgentId = 1, MonitorCommandId = 1, Value = GetRandomNumber(), ErrorMessage = "" }; monitorDb.InsertHistory(monitorValue, date, FrequencyTypes.Days); } } } }
protected void btnSave_Click(object sender, EventArgs e) { var monitorDb = new MonitorDb(); AddAgents(monitorDb); Response.Write("<script>window.close();</" + "script>"); Response.End(); }
private void LoadUserInfo() { var users = new MonitorDb().GetUsers(); foreach (var uInfo in users) { if (uInfo.UserId == 1) { chkEmailOpt.Checked = uInfo.EmailOptout; } } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { MonitorDb monitorDb = new MonitorDb(); if (monitorDb.GetUsers().Count == 0) { Response.Redirect("setup.aspx"); } Msg.Visible = false; } }
protected void Page_Load(object sender, EventArgs e) { var monitorDb = new MonitorDb(); if (Request.QueryString["id"] != string.Empty) { _agentGroupId = Convert.ToInt32(Request.QueryString["id"]); } if (!IsPostBack) { var agentInfo = monitorDb.GetAgents(); grdAgents.DataSource = agentInfo; grdAgents.DataBind(); } }
private void AddAgents(MonitorDb monitorDb) { try { monitorDb.DeleteAgentsGroupsByGroupId(_agentGroupId); foreach (GridViewRow gvr in grdAgents.Rows) { var hdnAgentId = Convert.ToInt32(((HiddenField)gvr.FindControl("hdnAgentId")).Value); if (((CheckBox)gvr.FindControl("chkAgent")).Checked == true) { monitorDb.AddAgentsIntoAgentGroup(_agentGroupId, hdnAgentId); } } } catch (Exception ex) { throw new Exception($"Method AddAgents: {ex.Message}"); } }
public void ProcessHistoryByFrequency( MonitorValue monitorValue, DateTime dateTime, FrequencyTypes frequency) { DateTime dateStart; var monitorDb = new MonitorDb(); monitorDb.ConvertFrequencyToSubtractHrs(dateTime, frequency, out dateStart); bool isEntryPresentinDb = monitorDb.isEntryPresent(monitorValue, dateStart, frequency); if (!isEntryPresentinDb) { int frequencyToAvgEntries; switch (frequency) { case FrequencyTypes.Hours: frequencyToAvgEntries = 0; monitorValue.Value = monitorDb.GetAverageValue( monitorValue, frequencyToAvgEntries); break; case FrequencyTypes.Days : frequencyToAvgEntries = 1; monitorValue.Value = monitorDb.GetAverageValue( monitorValue, frequencyToAvgEntries); break; default: throw new Exception("frequency is not supported"); } monitorDb.InsertHistory(monitorValue, dateStart, frequency); } }
public void DeleteAllHistory() { var monitorDb = new MonitorDb(); monitorDb.DeleteAllHistory(); }