protected void Page_Load(object sender, EventArgs e) { if (this.Session["hyuid"] != null) { if (this.Session["hyuid"].ToString() == "") this.Response.Redirect("/login.aspx?url=" + this.Request.RawUrl); } else { this.Response.Redirect("/login.aspx?url=" + this.Request.RawUrl); } HyLonginLog hyLongin = new HyLonginLog(); DataTable dt = hyLongin.GetDataTableOneByUid(this.Session["hyuid"].ToString()); if (dt.Rows.Count > 0) { hyLongin.id = dt.Rows[0]["id"].ToString(); hyLongin.hyUpateTime = DateTime.Now.ToString(); hyLongin.UpdateTime(); } else { hyLongin.id = System.Guid.NewGuid().ToString(); hyLongin.hyLoginTime = DateTime.Now.ToString(); hyLongin.hyLoginIp = getIp(); hyLongin.hyLoginType = "0"; hyLongin.hyuDeptid = Session["hydeptid"].ToString(); hyLongin.hyuDeptName = Session["hydeptname"].ToString(); hyLongin.hyuId = Session["hyuid"].ToString(); hyLongin.hyuName = Session["hyuname"].ToString(); hyLongin.Insert(); } }
protected void Page_Load(object sender, EventArgs e) { HyLonginLog hyLonginLog = new HyLonginLog(); DataTable dt = hyLonginLog.GetDataTableAllOnLine(); if (dt.Rows.Count > 0) { DateTime t1 = new DateTime(); DateTime t2 = DateTime.Now; DateTime t3 = new DateTime(); double diff = 0; double onlineTimeTotal = 0; for (int i = 0; i < dt.Rows.Count; i++) { t1 = Convert.ToDateTime(dt.Rows[i]["hyUpateTime"].ToString()); t3 = Convert.ToDateTime(dt.Rows[i]["hyLoginTime"].ToString()); TimeSpan tt1 = new TimeSpan(t1.Ticks); TimeSpan tt2 = new TimeSpan(t2.Ticks); TimeSpan tt3 = new TimeSpan(t3.Ticks); diff = Convert.ToDouble(tt2.Subtract(tt1).TotalMinutes.ToString()); onlineTimeTotal = Convert.ToDouble(tt2.Subtract(tt3).TotalMinutes.ToString()); if (diff >= 10) { hyLonginLog.id = dt.Rows[i]["id"].ToString(); hyLonginLog.hyLogoutTime = DateTime.Now.ToString(); hyLonginLog.hyNotOnLine = "1"; hyLonginLog.hyonlineTimeTotal = onlineTimeTotal.ToString("0.00"); hyLonginLog.UpdateLogOutTime(); } } } }
//删除 protected void btndelinfo_Click(object sender, EventArgs e) { HyCommon HyCommon = new HyCommon(); string pageUrl = HyCommon.CombUrlTxt(ls_url, "page={0}&rnd={1}", page.ToString(), System.Guid.NewGuid().ToString()); string ls_tip = "删除成功!"; String[] v_uids = this.txtuids.Value.Split(','); for (int i = 0; i < v_uids.Length; i++) { HyLonginLog HyLonginLog = new HyLonginLog(); HyLonginLog.id = v_uids[i]; HyLonginLog.delete(); } //写系统日志 Response.Write("<script>alert('" + ls_tip + "');window.location='" + pageUrl + "';</script>"); }
// 数据绑定 private void RptBind() { HyLonginLog hyLongin = new HyLonginLog(); string test = ""; DataTable dt = hyLongin.GetGroupByUidAndDeptid(this.ddl_user.SelectedValue, this.ddl_dept.SelectedValue, this.operateTime_s.Value, this.operateTime_e.Value, out test); if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { this.lb_show.Text += " <tr height=\"22\" onmouseover=\"this.className='tr_over'\" onmouseout=\"this.className='tr_out'\" class=\"tr_out\">"; this.lb_show.Text += "<td align=\"center\" >" + dt.Rows[i]["hyuName"].ToString() + "</td>"; string[] strTime = hyLongin.getTimeOnLine(dt.Rows[i]["hyuId"].ToString()); if (strTime.Length > 0) { this.lb_show.Text += "<td align=\"center\" >" + strTime[0] + "</td>"; this.lb_show.Text += "<td align=\"center\" >" + strTime[1] + "分钟</td>"; this.lb_show.Text += "<td align=\"center\" >" + strTime[2] + "</td>"; this.lb_show.Text += "</tr>"; } else { this.lb_show.Text += "<td align=\"center\" >0</td>"; this.lb_show.Text += "<td align=\"center\" >0</td>"; this.lb_show.Text += "<td align=\"center\" ></td>"; this.lb_show.Text += "</tr>"; } } } else { this.lb_show.Text += " <tr height=\"22\" onmouseover=\"this.className='tr_over'\" onmouseout=\"this.className='tr_out'\" class=\"tr_out\">"; this.lb_show.Text += "<td colspan=\"4\" align=\"center\" >暂无数据</td><tr></tr>"; } }