//list the log-in sessions according to the selected criterion private void BuildListBox(int userID, int groupID, DateTime time1, DateTime time2, bool cvs) { string pad = " "; try { DataSet sessionData = InternalAdminDB.SelectSessionHistory(userID, groupID, time1, time2); DataTable sessionHistory = sessionData.Tables[0]; if (sessionHistory.Rows.Count == 0) { lblResponse.Text = Utilities.FormatWarningMessage(" No sessions found for your criteria."); lblResponse.Visible = true; } else { StringBuilder buf = new StringBuilder(); buf.AppendLine(String.Format("{0,-14}{1,-18}{2,-10}{3,-10}{4,-26}{5,-24}", "User Name", "Create Time", "End Time","Modify","Group","Client")); DataTableReader dtr = new DataTableReader(sessionHistory); while(dtr.Read()) { //buf.Append(dtr.GetInt64(0) + pad); buf.Append(String.Format("{0,-12:12}", dtr.GetString(1)) + pad); if(!dtr.IsDBNull(2)) buf.Append(DateUtil.ToUserTime(dtr.GetDateTime(2), CultureInfo.InvariantCulture,userTZ,"g") +pad); else buf.Append(String.Format("{0,-9:9}", "Not Set") + pad); if (!dtr.IsDBNull(3)) buf.Append(DateUtil.ToUserTime(dtr.GetDateTime(3), CultureInfo.InvariantCulture, userTZ, "T") + pad); else buf.Append(String.Format("{0,-8}", "Not Set") + pad); if (!dtr.IsDBNull(4)) buf.Append(DateUtil.ToUserTime(dtr.GetDateTime(4), CultureInfo.InvariantCulture, userTZ, "T") + pad); else buf.Append(String.Format("{0,-8}", "Not Set") + pad); string tmp = dtr.GetString(5); if (tmp != null && tmp.Length > 24) tmp = tmp.Substring(0, 24); buf.Append(String.Format("{0,-24}",tmp) + pad); tmp = dtr.GetString(6); if (tmp != null && tmp.Length > 24) tmp = tmp.Substring(0, 24); buf.Append(String.Format("{0,-24}",tmp)); buf.AppendLine(); } txtLoginDisplay.Text = buf.ToString(); } } catch (Exception ex) { lblResponse.Text = Utilities.FormatErrorMessage(" Cannot retrieve UserSessions. " + ex.GetBaseException()); lblResponse.Visible = true; } }
// ---------------------------------------------- // PRIVATE MEMBERS // ---------------------------------------------- /// <summary> /// [PRIVATE] Fill a static from table reader /// </summary> /// <param name="oDT"></param> /// <returns></returns> private Static _FillStaticFromTableReader(DataTableReader oDT) { Static stc = new Static(); stc.Tag = (oDT.IsDBNull(oDT.GetOrdinal("tag")) ? "" : oDT["tag"].ToString()); stc.Type = (oDT.IsDBNull(oDT.GetOrdinal("type")) ? "" : oDT["type"].ToString()); stc.Content = (oDT.IsDBNull(oDT.GetOrdinal("content")) ? "" : oDT["content"].ToString()); stc.Value = (oDT.IsDBNull(oDT.GetOrdinal("value")) ? "" : oDT["value"].ToString()); stc.Length = oDT.IsDBNull(oDT.GetOrdinal("length")) ? 0 : oDT.GetInt32(oDT.GetOrdinal("length")); return stc; }