/// <Summary>
/// Convert the Sharepoint list into a able
/// </Summary>
/// <Returns> </returns>
Private datatable listtodatatable ()
{
// Create a table Header
Datatable _ sourcedatatable;
_ Sourcedatatable = This. columnnamedatatable ();
// Splist sourcelist = psourcespweb. Lists [This. _ sourcesplistname];
// Splistitemcollection caseitems = sourcelist. items;
Spsite site = new spsite (siteurl );
Spweb web = site. openweb ();
Splist treelist = web. Lists [sourcetreelist];
Datatable dt = new datatable ();
Splistitemcollection caseitems = treelist. items;
Foreach (splistitem caseitem in caseitems)
{
Try
{
Datarow rownew = _ sourcedatatable. newrow ();
For (INT Inti = 0; Inti <this. psourcesplistfields. length; Inti ++)
{
If (caseitem [psourcesplistfields [Inti]! = NULL)
{
If (treelist. Fields [This. psourcesplistfields [Inti]. fieldvaluetype. tostring () = "Microsoft. Sharepoint. spfielduservalue ")
{
String createrusername = caseitem [This. psourcesplistfields [Inti]. tostring ();
Int Index = createrusername. indexof (';');
Int createruserid = convert. toint32 (createrusername. substring (0, index ));
Spuser createruser = web. allusers. getbyid (createruserid );
Rownew [psourcesplistfields [Inti] = createruser. Name;
}
Else
{
Object columntype = _ sourcedatatable. Columns [This. psourcesplistfields [Inti]. datatype;
Rownew [psourcesplistfields [Inti] = caseitem [psourcesplistfields [Inti];
}
}
}
_ Sourcedatatable. Rows. Add (rownew );
}
Catch
{
}
}
Return _ sourcedatatable;
}
/// <Summary>
/// Create a able field based on the Sharepoint list
/// </Summary>
/// <Returns> </returns>
Public datatable columnnamedatatable ()
{
Spsite site = new spsite (siteurl );
Spweb web = site. openweb ();
Splist treelist = web. Lists [sourcetreelist];
Datatable dt = new datatable ();
Splistitemcollection caseitems = treelist. items;
For (INT Inti = 0; Inti <psourcesplistfields. length; Inti ++)
{
Datacolumn columnnew = new datacolumn ();
Columnnew. columnname = psourcesplistfields [Inti];
DT. Columns. Add (columnnew );
}
Return DT;
}