Logo 
Search:

Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Any body ever worked on AuditLogs

  Asked By: Joshua    Date: Aug 18    Category: Sharepoint    Views: 1047

Please let me know if any of you folks ever worked on SharePoint Audit API's.

I have an issue when i am trying to populate Audit datas from the logged
items.The items are getting duplicated and i dont see anyways to make them
single !.

This is the sample code i have where i am creating an auditentrycollection
object and trying to get the datas.


SPSite sitecoll = SPContext.Current.Site;
//SPWeb site = SPContext.Current.Web;
SPAuditQuery wssquery = new SPAuditQuery(sitecoll);
SPAuditEntryCollection auditcol =
sitecoll.Audit.GetEntries(wssquery);
Table table = new Table();
//DataTable table = new DataTable();
//table.Columns.Add("User", typeof(string));
//table.Columns.Add("DocLocation", typeof(string));
TableRow newRow;
SPGridView SPGridView1 = new SPGridView();


//here i am taking only the 10 items which are available and i am getting 8
duplicates.It is taking values based on each of the click,view etc events.
for (int i = 0; i < 10; i++)
{

newRow = new TableRow();
TableCell col = new TableCell();
Label lbl = new Label();
string name=GetUserNameById(auditcol[i].UserId, site);
lbl.Text = name;
Label lbl1 = new Label();
lbl1.Text = auditcol[i].DocLocation;
col.Controls.Add(lbl);
col.Controls.Add(lbl1);
newRow.Controls.Add(col);
table.Controls.Add(newRow);
}
this.Controls.Add(table);
//newRow = table.Rows.Add();
// newRow["User"] = GetUserNameById(entry.UserId, site);
// newRow["DocLocation"] = entry.DocLocation;
SPBoundField boundField = new SPBoundField();
boundField.HeaderText = "User";
boundField.DataField = "User";
SPGridView1.Columns.Add(boundField);

boundField = new SPBoundField();
boundField.HeaderText = "DocLocation";
boundField.DataField = "DocLocation";
SPGridView1.Columns.Add(boundField);
SPGridView1.AutoGenerateColumns = false;
//SPGridView1.DataSource = table.DefaultView;
SPGridView1.DataBind

Note:In my sharepoint site I have configured the audit policies to 'View' only.

Share: 

 

No Answers Found. Be the First, To Post Answer.

 
Didn't find what you were looking for? Find more on Any body ever worked on AuditLogs Or get search suggestion and latest updates.




Tagged: