Per poter ottenere questo dato bisogna far riferimento al UserProfileValueCollection.
Le user properties potete trovarle da Central Administration andato a controllare le proprietà del servizio User Profile:
Quella utile per ricavare i dati OSC è la proprietà WorkEmail (di default in Sharepoint inglese è chiamata così).
Innanzitutto allora dichiariamo l’html per l’immagine (trovato in giro per il web)
const string PRESENCEPAWN = @""0"" height=""20"" width=""20"" src=""_layouts/images/imnhdr.gif"" onload=""IMNRC('{0}')"" ShowOfflinePawn=""1"" id=""{0}"" />";IMRC è una funzione Javascript, è possibile trovarla in /_layouts/1033/owsbrows.js
Utilizzando l’istanza di UserProfile che ci interessa otteniamo un metodo del tipo:
private static string GetPropValue(UserProfile p) { if (p[PropertyConstants.WorkEmail] != null && p[PropertyConstants.WorkEmail].Value != null) { return p[PropertyConstants.WorkEmail].Value.ToString(); } return string.Empty; }
E conludiamo costruendo la stringa html corretta in questa maniera:
string imgPawn = string.Format(PRESENCEPAWN, emailStr);
adesso abbiamo l’html necessario per ottenere lo staus di ocs del nostro utente
No comments:
Post a Comment