Ejemplo n.º 1
0
    public MDLogData GetLogDataByLogID(string LogID)
    {
        MDLogData  oMDLog = new MDLogData();
        DataTable  dTable = new DataTable();
        SqlCommand sql    = new SqlCommand();

        sql.CommandText  = "SELECT LogID,username,ComputerName,IPAddress,Action,PageUrl,LogDate FROM LogData";
        sql.CommandText += " WHERE LogID=@LogID";
        sql.Parameters.Add(new SqlParameter("@LogID", LogID));

        dTable = oConn.Query(sql);
        if (dTable.Rows.Count > 0)
        {
            foreach (DataRow row in dTable.Rows)
            {
                MDLogData.CMDLogData oMD = new MDLogData.CMDLogData();
                oMD.LogID        = row["LogID"].ToString();
                oMD.username     = row["username"].ToString();
                oMD.ComputerName = row["ComputerName"].ToString();
                oMD.IPAddress    = row["IPAddress"].ToString();
                oMD.Action       = row["Action"].ToString();
                oMD.PageUrl      = row["PageUrl"].ToString();
                oMD.LogDate      = row["LogDate"].ToString();
                oMDLog.ListOfLog.Add(oMD);
            }
        }

        return(oMDLog);
    }
Ejemplo n.º 2
0
    public MDLogData GetLogData(string inSearch, string LogDate)
    {
        inSearch = "%" + inSearch + "%";
        MDLogData  oMDLog = new MDLogData();
        DataTable  dTable = new DataTable();
        SqlCommand sql    = new SqlCommand();

        sql.CommandText  = "SELECT TOP 200 LogID,username,ComputerName,IPAddress,Action,PageUrl,LogDate FROM LogData";
        sql.CommandText += " WHERE ISNULL(LogID,'')+ISNULL(username,'')+ISNULL(ComputerName,'')+ISNULL(IPAddress,'')+ISNULL(PageUrl,'')+ISNULL(Action,'') like @inSearch";
        if (LogDate != "")
        {
            sql.CommandText += " AND Convert(date,LogDate)=@LogDate";
            sql.Parameters.Add(new SqlParameter("@LogDate", LogDate));
        }
        sql.CommandText += " ORDER BY LogDate DESC";
        sql.Parameters.Add(new SqlParameter("@inSearch", inSearch));

        dTable = oConn.Query(sql);
        if (dTable.Rows.Count > 0)
        {
            foreach (DataRow row in dTable.Rows)
            {
                MDLogData.CMDLogData oMD = new MDLogData.CMDLogData();
                oMD.LogID        = row["LogID"].ToString();
                oMD.username     = row["username"].ToString();
                oMD.ComputerName = row["ComputerName"].ToString();
                oMD.IPAddress    = row["IPAddress"].ToString();
                oMD.Action       = row["Action"].ToString();
                oMD.PageUrl      = row["PageUrl"].ToString();
                oMD.LogDate      = row["LogDate"].ToString();
                oMDLog.ListOfLog.Add(oMD);
            }
        }

        return(oMDLog);
    }