jeudi 27 mars 2014

Get élement from Liste sharepoint avec une CAML Query

  public static String LoadDocById(int idDoc)
  {
            String etape = "Debut Methode";
            SPList list = SPContext.Current.Web.Site.RootWeb.Lists["Docs"];
            if (list != null)
            {
                etape = "Litse non null";
string caml = @"<Where><Eq><FieldRef Name='ID' /><Value                     Type='Text'>2428</Value></Eq></Where>";

                SPQuery qry = new SPQuery();
                qry.Query = caml;
                SPListItemCollection items = list.GetItems(qry);
                            

foreach (SPListItem item in items)
                    {
                        String nomFichier = "";
                        if (item2["Nom"] != null)
                        {
                            nomFichier = item["Nom"].ToString();
                        }

                        if (item2["ID"] != null)
                        {
                            nomFichier = item["ID"].ToString();
                        }
                    }
                }

 return etape;

            }

lundi 24 mars 2014

Problème Base de données SQL suspect :


Solution de réparation de la base de données :


EXEC sp_resetstatus Nom_Base;
ALTER DATABASE Nom_BaseSET EMERGENCY
DBCC checkdb(Nom_Base)

ALTER DATABASE Nom_BaseSET ONLINE, SINGLE_USER
DBCC CheckDB (Nom_Base, REPAIR_ALLOW_DATA_LOSS)

ALTER DATABASE Nom_Base SET MULTI_USER

mardi 11 mars 2014

A CAML Query Quick Reference

Single Line of Text

Value TypeText
Example<Query><Where><Eq><FieldRef Name="Title" /><Value Type="Text">Hello World!</Value></Eq></Where></Query>
NotesThis is one of the simplest queries. The example selects items with a title equal to “Hello World!”

Multiple Lines of Text

Value TypeText
Example<Query><Where><Contains><FieldRef Name="Body" /><Value Type="Text"><![CDATA[</a>]]></Value></Contains></Where></Query>
NotesIf this is a Rich Text field, you can use <![CDATA[]]> around the value to prevent parsing errors when passing HTML into the query. Alternatively, you can encode the HTML by replacing < with &lt;, > with &gt;, and " with &quot;. This query uses <Contains> to return any items that contain a hyperlink in the body field by looking for the closing </a> tag.

Person or Group (By Name)

Value TypeText
Example<Query><Where><Eq><FieldRef Name="Author" /><Value Type="Text">Josh McCarty</Value></Eq></Where></Query>
NotesThis will look for items created by any user with “Josh McCarty” in the Name field of the User Information list. If more than one person has the same display name in the user list, it will select items created by all users with that name.

Person or Group (By ID)

Value TypeInteger
Example<Query><Where><Eq><FieldRef Name="Author" LookupId="TRUE" /><Value Type="Integer"><UserID /></Value></Eq></Where></Query>
NotesBy adding LookupId="TRUE" to the <FieldRef /> and using <UserID /> as the value, the query will filter based on the current user. You can also pass the ID of a specific user in place of <UserID /> (e.g. <Value Type="Integer">283</Value>) if you don’t want to filter by the current user. IDs are always unique, so this method ensures that only one user is a valid value.

Lookup (By Text)

Value TypeLookup
Example<Query><Where><Eq><FieldRef Name="State" /><Value Type="Lookup">Arizona</Value></Eq></Where></Query>
NotesThis will look for items with “Arizona” in the State field. If more than one state has the same display name (not likely in this example, but for other lookups it could happen), it will return items from all states with that display name.

Lookup (By ID)

Value TypeLookup
Example<Query><Where><Eq><FieldRef Name="State" LookupId="TRUE" /><Value Type="Lookup">4</Value></Eq></Where></Query>
NotesBy adding LookupId="TRUE" to the <FieldRef />, the query will filter based on the ID of the lookup rather than the text value. IDs are always unique, so this method ensures that only one state is a valid value.

Date (Day Only)

Value TypeDate
Example<Query><Where><Eq><FieldRef Name="Created" /><Value Type="DateTime">2012-01-10</Value></Eq></Where></Query>
NotesThis type of query seems to work whether the value type is set to DateTime or just Date as long as the value is formatted properly (yyyy-mm-dd). It also works if <Today /> is used as the value (you can offset the current date; e.g. use <Today OffsetDays="-7" /> for 7 days ago). <Today />.

lundi 10 mars 2014

Détecter la version du browser

Méthode 1:

<script>function getInternetExplorerVersion()
{
    var rv = -1; // Return value assumes failure.
    if (navigator.appName == 'Microsoft Internet Explorer')
    {
        var ua = navigator.userAgent;
        var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    if (re.exec(ua) != null)
        rv = parseFloat( RegExp.$1 );
    }
    return rv;
}
function checkVersion()
{
    var msg = "Le Portail Internet du Ministère de l’économie et des Finances est optimisé pour les navigateurs Internet explorer 9 , Chrome 33.0 et Firefox 27.0.1. Pour une meilleure navigation, veuillez mettre à jour votre navigateur.";
    var verIE = getInternetExplorerVersion();

    if ( verIE > -1 )
    {
      if (! (verIE > 8.0) )
            alert( msg );
    }

}
checkVersion();</script>


Méthode 2:

<script>navigator.sayswho= (function(){
    var ua= navigator.userAgent, tem,
    M= ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*([\d\.]+)/i) || [];
    if(/trident/i.test(M[1])){
        tem=  /\brv[ :]+(\d+(\.\d+)?)/g.exec(ua) || [];
        return 'IE '+(tem[1] || '');
    }
    M= M[2]? [M[1], M[2]]:[navigator.appName, navigator.appVersion, '-?'];
    if((tem= ua.match(/version\/([\.\d]+)/i))!= null) M[2]= tem[1];
    return M.join(' ');
})();

var navigatorMEF = navigator.sayswho;

if(navigatorMEF == 'MSIE 7.0' || navigatorMEF == 'MSIE 8.0' || navigatorMEF == 'MSIE 6.0' || navigatorMEF == 'FIREFOX 19.0')
{
 var msg = "Message ";
  alert( msg );
}</script>