c# , get sharepoint list item detail about Author,Editor , assignto with mutiple values , Duedate
// Add reference Microsoft.SharePoint.Client and Microsoft.SharePoint.Client.Runtime
//
using Microsoft.SharePoint.Client;
ClientContext clientContext = new ClientContext("http://sharepointserver");
List list = clientContext.Web.Lists.GetByTitle("testlist");
clientContext.Load(list);
clientContext.ExecuteQuery();
CamlQuery camlQuery = new CamlQuery();
camlQuery.ViewXml = "";
ListItemCollection listItems = list.GetItems(camlQuery);
clientContext.Load(listItems);
clientContext.ExecuteQuery();
int i = 0;
foreach (ListItem listItem in listItems)
{
var SendToList = string.Empty;
var MailSubJect = string.Empty;
var MailBody = string.Empty;
DateTime dt = Convert.ToDateTime(Convert.ToDateTime(listItem["DueDate"]).ToLocalTime().ToString("yyyy/MM/dd"));
DateTime today = Convert.ToDateTime(DateTime.Now.ToLocalTime().ToString("yyyy/MM/dd"));
if ((dt <= today) && (listItem["Status"].ToString().Equals("Finished") == false))
{
Console.WriteLine("Id: {0} Title: {1} Author : {2} Editor : {3}",
listItem.Id, listItem["Title"],
((FieldUserValue)(listItems[i]["Author"])).LookupValue,
((FieldUserValue)(listItems[i]["Editor"])).LookupValue
);
String StartDateStr = Convert.ToDateTime(listItem["StartDate"]).ToLocalTime().ToString("yyyy/MM/dd");
String DueDateStr = Convert.ToDateTime(listItem["DueDate"]).ToLocalTime().ToString("yyyy/MM/dd");
String ModifiedStr = Convert.ToDateTime(listItem["Modified"]).ToLocalTime().ToString("yyyy/MM/dd HH:mm:ss");
double PercentComplete = Convert.ToDouble(listItem["PercentComplete"].ToString());
PercentComplete = PercentComplete * 100;
String PercentCompleteStr = PercentComplete.ToString();
var BodyStr = string.Empty;
if (listItem["Body"]!=null)
BodyStr = listItem["Body"].ToString();
var assigntolist = string.Empty;
Type t = listItems[i]["AssignedTo"].GetType();
if (t.IsArray)
{
foreach (FieldUserValue o in listItems[i]["AssignedTo"] as FieldUserValue[])
Console.WriteLine("AssignedTo: {0}", o.LookupValue);
}
}
i = i + 1;
}
Apr 29, 2011
Sharepoint list items detail about Author,Editor , assignto with mutiple values , Duedate
張貼者: Brian 於 09:06
標籤: Sharepoint 2010
Subscribe to:
Post Comments (Atom)
0 意見:
Post a Comment