1) Filtrer des items :
datebegin < Today + 60
dateend < Today + 60
2) Chercher :
Chercher :
Entre les doubles-quote :
<View><Query><Where><Or><Gt><FieldRef Name="datebegin"/><Value
Type="Text"><Today/></Value></Gt><And><Gt><FieldRef Name="dateend"/><Value
Type="Text"><Today/></Value></Gt><Eq><FieldRef Name="companyid"/><Value
Type="Text">1</Value></Eq></And></Or></Where><OrderBy><FieldRef Name="aduser"
Ascending="TRUE"/></OrderBy></Query></View>
Remplacer
< par <
> par >
" par "
Résultat :
<View><Query><Where><Or><Gt><FieldRef Name="datebegin"/><Value Type="Text"><Today/></Value></Gt><And><Gt><FieldRef Name="dateend"/><Value
Type="Text"><Today/></Value></Gt><Eq><FieldRef Name="companyid"/><Value Type="Text">1</Value></Eq></And></Or></Where><OrderBy><FieldRef Name="aduser"
Ascending="TRUE"/></OrderBy></Query></View>
3) Dans < Today />, ajouter OffsetDays='60'
Résultat :
<View><Query><Where><Or><Lt><FieldRef Name='datebegin'/><Value Type='Text'><Today OffsetDays='60'/></Value></Lt><And><Lt><FieldRef
Name='dateend'/><Value Type='Text'><Today OffsetDays='60'/></Value></Lt><Eq><FieldRef Name='companyid'/><Value
Type='Text'>1</Value></Eq></And></Or></Where><OrderBy><FieldRef Name='aduser' Ascending='TRUE'/></OrderBy></Query></View>
Avec indentation :
<View>
<Query>
<Where>
<Or>
<Lt>
<FieldRef Name='datebegin'/><Value Type='Text'><Today OffsetDays='60'/></Value>
</Lt>
<And>
<Lt>
<FieldRef Name='dateend'/><Value Type='Text'><Today OffsetDays='60'/></Value>
</Lt>
<Eq>
<FieldRef Name='companyid'/><Value Type='Text'>1</Value>
</Eq>
</And>
</Or>
</Where>
<OrderBy>
<FieldRef Name='aduser' Ascending='TRUE'/>
</OrderBy>
</Query>
</View>
Remplacer par cette requête.
void copyFile(string fileName, string directoryTo)
{
SPSite employeeDirectorySiteCollection = new SPSite("http://philippe-ee2865/personal/administrator/");
SPWeb employeeDirectorySite = employeeDirectorySiteCollection.OpenWeb();
SPList employeeDirectoryListTo = employeeDirectorySite.Lists["Devel"];
SPList employeeDirectoryListFrom = employeeDirectorySite.Lists["Devel"];
SPFile spFileName = employeeDirectorySite.GetFile(fileName);
SPListItem itemFile = spFileName.Item;
byte[] fileBytes = itemFile.File.OpenBinary();
string destUrl = employeeDirectoryListFrom.RootFolder.Url + "/"+ directoryTo + "/" + itemFile.File.Name;
SPFile destFile = employeeDirectoryListFrom.RootFolder.Files.Add(destUrl, fileBytes, true);
}
void createDirectory(string directoryName)
{
SPSite employeeDirectorySiteCollection = new SPSite("http://philippe-ee2865/personal/administrator/");
SPWeb employeeDirectorySite = employeeDirectorySiteCollection.OpenWeb();
SPList employeeDirectoryList = employeeDirectorySite.Lists["Devel"];
employeeDirectorySite.AllowUnsafeUpdates = true;
SPListItem employeeDirectoryListItem = employeeDirectoryList.Items.Add("", SPFileSystemObjectType.Folder, directoryName);
employeeDirectoryListItem.Update();
}
<%@ Page Language="C#" Debug="true" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="MySql.Data.MySqlClient" %>
<%@ import Namespace="System.Drawing" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<script runat="server">
/*
Usage :
http://philippe-ee2865/personal/administrator/Devel/UpdateAllItem2List.aspx
*/
protected void Page_Load(Object sender, EventArgs e)
{
string dateAujourdhui = DateTime.Now.ToString("MM/dd/yyyy");
string strDashListRoot = "http://philippe-ee2865/personal/administrator/Lists/";
SPSite oSiteCollection = new SPSite(strDashListRoot);
SPWeb oWebsiteRoot = oSiteCollection.OpenWeb();
oWebsiteRoot.AllowUnsafeUpdates = true;
SPList oList = oWebsiteRoot.Lists["astreintes"];
SPListItemCollection listItemCOll;
SPQuery query = new SPQuery();
query.Query="";
//Fetch item from the User List by passing query to the User List
listItemCOll = oList.GetItems(query);
if (listItemCOll.Count > 0)
{
//If record found in the list
for(int icount=0; icount< listItemCOll.Count;icount++)
{
//Take the reference of that item
SPListItem listItem = listItemCOll[icount];
listItem["dateaujourdhui"] = dateAujourdhui;
//Update the Item
listItem.Update();
}
}
}
void updatedOkay( )
{
Response.Write("astreintes has been updated with date today<br>");
}
</script>
<html>
<head>
<META name="WebPartPageExpansion" content="full">
<title>Update Item 2 List </title>
</head>
<body>
<%
updatedOkay();
%>
</body>
</html>
<%@ Page Language="C#" Debug="true" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="MySql.Data.MySqlClient" %>
<%@ import Namespace="System.Drawing" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<script runat="server">
/*
Usage :
http://philippe-ee2865/personal/administrator/Devel/UpdateItem2List.aspx?Title=tv&field=country&value=TUVALU
Link:
http://www.codegain.com/index.php?option=com_content&view=article&id=258
*/
public String title;
public String field;
public String value;
protected void Page_Load(Object sender, EventArgs e)
{
title = Request.QueryString["Title"];
field = Request.QueryString["field"];
value = Request.QueryString["value"];
string strDashListRoot = "http://philippe-ee2865/personal/administrator/Lists/";
SPSite oSiteCollection = new SPSite(strDashListRoot);
SPWeb oWebsiteRoot = oSiteCollection.OpenWeb();
oWebsiteRoot.AllowUnsafeUpdates = true;
SPList oList = oWebsiteRoot.Lists["Tld"];
SPListItemCollection listItemCOll;
SPQuery query = new SPQuery();
query.Query="<Where><Eq><FieldRef Name='Title'/><Value Type='Text'>" + title + "</Value></Eq></Where>";
//Fetch item from the User List by passing query to the User List
listItemCOll = oList.GetItems(query);
if (listItemCOll.Count > 0)
{
//If record found in the list
for(int icount=0; icount< listItemCOll.Count;icount++)
{
//Take the reference of that item
SPListItem listItem = listItemCOll[icount];
listItem[field] = value;
//Update the Item
listItem.Update();
}
}
}
void updatedOkay(string title, string field, string value)
{
Response.Write("TDL "+ title + " has been updated<br>");
Response.Write("This field : "+ field + " with this value : " + value + "<br>");
}
</script>
<html>
<head>
<META name="WebPartPageExpansion" content="full">
<title>Update Item 2 List </title>
</head>
<body>
<%
updatedOkay(title, field, value);
%>
</body>
</html>
<%@ Page Language="C#" Debug="true" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="MySql.Data.MySqlClient" %>
<%@ import Namespace="System.Drawing" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<script runat="server">
/*
Usage :
http://philippe-ee2865/personal/administrator/Devel/deleteAllItem2List.aspx?Title=ae
Link:
http://www.codegain.com/index.php?option=com_content&view=article&id=258
http://www.functionx.com/aspnet/Lesson07.htm
*/
public String title;
protected void Page_Load(Object sender, EventArgs e)
{
title = Request.QueryString["Title"];
string strDashListRoot = "http://philippe-ee2865/personal/administrator/Lists/";
SPSite oSiteCollection = new SPSite(strDashListRoot);
SPWeb oWebsiteRoot = oSiteCollection.OpenWeb();
oWebsiteRoot.AllowUnsafeUpdates = true;
SPList oList = oWebsiteRoot.Lists["Tld"];
SPListItemCollection listItemCOll;
SPQuery query = new SPQuery();
query.Query="<Where><Eq><FieldRef Name='Title'/><Value Type='Text'>" + title + "</Value></Eq></Where>";
//Check items exist in the User List or not
if (oList.Items.Count > 0)
{
//Fetch item from the User List by passing query to the User List
listItemCOll = oList.GetItems(query);
if (listItemCOll.Count > 0)
{
//If record found in the list
listItemCOll [0].Delete();
}
}
}
void deletedOkay(string title)
{
Response.Write("TDL "+ title + " has been deleted");
}
</script>
<html>
<head>
<META name="WebPartPageExpansion" content="full">
<title>Delete All Items 2 List </title>
</head>
<body>
<%
deletedOkay(title);
%>
</body>
</html>
1) code :
<script type="text/c#" runat="server">
/*
Usage:
http://philippe-ee2865/personal/administrator/Lists/EuroDNS/CreateListItem.aspx?Title=essai
Link :
http://blog-sharepoint.blogspot.com/2009/04/moss-2007-create-list-item-using-aspx.html
*/
//Declare Variables
public String siteURL;
public String list;
public String title;
protected void Page_Load(object sender, EventArgs e)
{
getQueryStringValues();
InsertEnquiryToSharepoint();
}
public void getQueryStringValues()
{
title = Request.QueryString["Title"];
}
protected void InsertEnquiryToSharepoint()
{
string strDashListRoot = "http://philippe-ee2865/personal/administrator/Lists/";
using(SPSite site = new SPSite(strDashListRoot))
{
using (SPWeb web = site.OpenWeb())
{
web.AllowUnsafeUpdates = true;
SPList list = web.Lists["activedirectoryuser"];
SPListItem item = list.Items.Add();
item["Title"] = title;
item.Update();
}
}
}
</script>
2) Lien :
http://blog-sharepoint.blogspot.com/2009/04/moss-2007-create-list-item-using-aspx.html