Sito molto utile, non agiungo altro.
Link
Divertitevi a girarlo un pò!
lunedì 22 agosto 2011
Linq To Object in sharepoint 2007
Il codice sarà sicuramente molto semplificato in Sharepoint 2010.
Un esempio di come usare Linq to Object per manipolare i dati di una lista:
// Get all the Site Collections (Urls) in the "departments" Managed Path
var sites = from site in SPContext.Current.Site.WebApplication.Sites.Names
where site.ToLower().StartsWith("departments")
orderby site
select site;
// A List that will contain all the non-expired rolled up announcements
List announcementsRollup = new List();
foreach (string siteName in sites)
{
using (SPSite spSite = new SPSite("http://intranet/" + siteName))
{
using (SPWeb web = spSite.RootWeb)
{
// Select the "top 2" announcements in each web
// where the announcement is not expired
var top2 =
(from all in
web.Lists["Announcements"].Items.GetDataTable().AsEnumerable()
orderby all.Field("Created") descending
where all.IsNull("Expires") == true ||
all.Field("Expires") > DateTime.Today
select all).Take(2);
// Add those 2 announcements to multi Site Collection rollup
foreach (DataRow announcement in top2)
announcementsRollup.Add(announcement);
}
}
}
// Sort all the announcments across all the sites by created date
var sorted = from s in announcementsRollup
orderby s.Field("Created") descending
select s;
// Print all the announcements
foreach (DataRow announcement in sorted)
this.Controls.Add(new LiteralControl(announcement["Title"].ToString() + "
"));
End.
Un esempio di come usare Linq to Object per manipolare i dati di una lista:
// Get all the Site Collections (Urls) in the "departments" Managed Path
var sites = from site in SPContext.Current.Site.WebApplication.Sites.Names
where site.ToLower().StartsWith("departments")
orderby site
select site;
// A List that will contain all the non-expired rolled up announcements
List
foreach (string siteName in sites)
{
using (SPSite spSite = new SPSite("http://intranet/" + siteName))
{
using (SPWeb web = spSite.RootWeb)
{
// Select the "top 2" announcements in each web
// where the announcement is not expired
var top2 =
(from all in
web.Lists["Announcements"].Items.GetDataTable().AsEnumerable()
orderby all.Field
where all.IsNull("Expires") == true ||
all.Field
select all).Take(2);
// Add those 2 announcements to multi Site Collection rollup
foreach (DataRow announcement in top2)
announcementsRollup.Add(announcement);
}
}
}
// Sort all the announcments across all the sites by created date
var sorted = from s in announcementsRollup
orderby s.Field
select s;
// Print all the announcements
foreach (DataRow announcement in sorted)
this.Controls.Add(new LiteralControl(announcement["Title"].ToString() + "
"));
End.
SPSiteCollection - Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)).
Si verifica quando proviamo ad eseguire delle istruzioni senza i permessi,
per superare questo problema:
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite(SPContext.Current.Site.Url))
{
site.AllowUnsafeUpdates = true;
//Code .....
site.AllowUnsafeUpdates = false;
}
}
;)
per superare questo problema:
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite(SPContext.Current.Site.Url))
{
site.AllowUnsafeUpdates = true;
//Code .....
site.AllowUnsafeUpdates = false;
}
}
;)
Installare sharepoint 2010 su macchina vindows 7 x64
Introduzione
Ora, si può semplicemente installare SharePoint Server 2010 nel sistema operativo client semplicemente modificando un file di configurazione.
Requisiti
- Process Explorer (Download)
- SharePoint Server 2010 Beta installer (en_sharepoint_server_2010_beta_x64_x16-19249.exe)
- Windows 7 x64 come sistema operativo client
Installazione
Quando si tenta di installare sharepoint si ha il seguente errore:
Sembra che SharePoint Server 2010 è compatibile solo con Windows Server 2008 x64. Ma non lo è.
Ok, start up Process Explorer, mentre la schermata di avvio di installazione è in esecuzione e vedrete il seguente:
Così sembra che il programma di installazione è stato decompresso in C: \ Program Files (x86) \ MSECache \ oserver2010. È possibile passare alla directory che ora.
- Vai a C: \ Program Files (x86) \ MSECache \ oserver2010
- Vai alla cartella File
- Vai alla cartella di installazione
- Aprire il file config.xml
- Aggiungere la seguente riga prima della chiusura
< / configuration >tag
<Id = Impostazione "AllowWindowsClientInstall" value = "true" /> Una volta modificato il file di configurazione, siamo in grado di installare SharePoint Server 2010 su Windows 7!
Catch error for castom page in sharepoint
Può capitare di dover castomizzare un messaggio, generato da sharepoint, in seguito a un errore particolare.

Possiamo in poche righe di codice creare delle pagine castom in modo da mostrare a video solo i messaggi che noi vogliamo:
Creiamo una classe :
code:
class ExceptionHandler : IHttpModule
{
string _errPage = "/_layouts/DecatecCustomErrorPage.aspx";
public void Dispose()
{
}
public void Init(HttpApplication context)
{
context.Error += new EventHandler(context_Error);
}
void context_Error(object sender, EventArgs e)
{
Exception[] unhandledExceptions = HttpContext.Current.AllErrors;
foreach (Exception ex in unhandledExceptions)
{
//Castomizzo per catturare il survey
if (ex.Message.Equals("You are not allowed to respond again to this survey."))
{
_errPage = "/_layouts/DecatecCustomErrorPageSurvey.aspx?Error="+
ex.Message;
}
}
HttpContext.Current.Server.ClearError();
HttpContext.Current.Response.Clear();
HttpContext.Current.Server.Transfer(_errPage);
}
}
Nel codice uso il query string "Error" che poi uso per stampare nella pagina l'errore che mi arriva.
Dobbiamo poi caricare nel web.config i reguenti tag:
in <HttpModules> ....
<add name="Nome Classe" type="NameSpace.NomeClasse,NameSpace
, Version=1.0.0.0, Culture=neutral, PublicKeyToken=33b75c83e58b885b" />
Ora lavostra pagina castom è pronta a catturare gli errori.
Possiamo in poche righe di codice creare delle pagine castom in modo da mostrare a video solo i messaggi che noi vogliamo:
Creiamo una classe :
code:
class ExceptionHandler : IHttpModule
{
string _errPage = "/_layouts/DecatecCustomErrorPage.aspx";
public void Dispose()
{
}
public void Init(HttpApplication context)
{
context.Error += new EventHandler(context_Error);
}
void context_Error(object sender, EventArgs e)
{
Exception[] unhandledExceptions = HttpContext.Current.AllErrors;
foreach (Exception ex in unhandledExceptions)
{
//Castomizzo per catturare il survey
if (ex.Message.Equals("You are not allowed to respond again to this survey."))
{
_errPage = "/_layouts/DecatecCustomErrorPageSurvey.aspx?Error="+
ex.Message;
}
}
HttpContext.Current.Server.ClearError();
HttpContext.Current.Response.Clear();
HttpContext.Current.Server.Transfer(_errPage);
}
}
Nel codice uso il query string "Error" che poi uso per stampare nella pagina l'errore che mi arriva.
Dobbiamo poi caricare nel web.config i reguenti tag:
in <HttpModules> ....
<add name="Nome Classe" type="NameSpace.NomeClasse,NameSpace
, Version=1.0.0.0, Culture=neutral, PublicKeyToken=33b75c83e58b885b" />
Ora lavostra pagina castom è pronta a catturare gli errori.
Change password FBA - sharepoint (Castom Action)
Ottimo articolo che spiaga come creare un change password:
http://www.codeproject.com/KB/sharepoint/moss_fba_changepassword.aspx
:)
http://www.codeproject.com/KB/
:)
Iscriviti a:
Post (Atom)