jeudi 16 mai 2013

SharePoint 2013 Managed Meta data .csv and Setting site navigation to use taxonomy using PowerShell and Custom Property

You can import .csv file using the following powershell function, you can after launch the function with the following parameters:

webApplication URL
CSV file path
Group Term Name

In order to set the managed metadata Navigation you have to set the option in "Navigation" menu.

Param(
 [Parameter(Mandatory=$True,Position=1)]
 [string]$WebAppUrl,
 [Parameter(Mandatory=$True,Position=2)]
 [string]$CSVFilePath,
 [Parameter(Mandatory=$True,Position=3)]
 [string]$TermGroupName
)

Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue

function ImportTermSet([Microsoft.SharePoint.Taxonomy.TermStore]$store, [string]$groupName, [PSCustomObject]$termSet) { 
   function ImportTerm([Microsoft.SharePoint.Taxonomy.Group]$group,
                       [Microsoft.SharePoint.Taxonomy.TermSet]$set,
                       [Microsoft.SharePoint.Taxonomy.Term]$parent,
                       [string[]]$path) {       
     if ($path.Length -eq 0) {
       return
     }
      elseif ($group -eq $null)
       {
       $group = $store.Groups | where { $_.Name -eq $path[0] }
       if ($group -eq $null)
       {
         $group = $store.CreateGroup($path[0])
       }
      }
      elseif ($set -eq $null)
       {
       $set = $group.TermSets | where { $_.Name -eq $path[0] }
       if ($set -eq $null)
        {
         $set = $group.CreateTermSet($path[0])
        }
        $set.SetCustomProperty("_Sys_Nav_IsNavigationTermSet", "True")
     }
      else
       {
       $node = if ($parent -eq $null) { $set } else { $parent }
       $parent = $node.Terms | where { $_.Name -eq $path[0] }      
       if ($parent -eq $null -and $path -ne $null -and $path[0] -ne $null) {
         $parent = $node.CreateTerm($path[0], 1036)
        #Debut Menu
        if($_.MenuID -ne "" -and $parent  -ne $null )
        {
            $parent.SetLocalCustomProperty("Menu ID", $_.MenuID)
        }
        if($_.Menu_Particulier -ne "" -and $parent  -ne $null )
        {
            $parent.SetLocalCustomProperty("Menu Particulier", $_.Menu_Particulier)
        }
        if($_.Menu_Professionnel -ne "" -and $parent  -ne $null )
        {
            $parent.SetLocalCustomProperty("Menu Professionnel", $_.Menu_Professionnel)
        }
        if($_.SousTitre -ne "" -and $parent  -ne $null )
        {
            $parent.SetLocalCustomProperty("Sous Titre", $_.SousTitre)
        }
        if($_.TitreAccueil -ne "" -and $parent  -ne $null )
        {
            $parent.SetLocalCustomProperty("Titre accueil", $_.TitreAccueil)
        }
        if($_.SousTitreAccueil -ne "" -and $parent  -ne $null )
        {
            $parent.SetLocalCustomProperty("Sous titre accueil", $_.SousTitreAccueil)
        }
        if($_.Picto -ne "" -and $parent  -ne $null )
        {
            $parent.SetLocalCustomProperty("Picto", $_.Picto)
        }
        #Fin Menu
        #Debut colonne
        if($_.ColonneID -ne "" -and $parent  -ne $null )
        {
            $parent.SetLocalCustomProperty("Colonne ID", $_.ColonneID)
        }
        if($_.ClasseTitreColonne -ne "" -and $parent  -ne $null )
        {
            $parent.SetLocalCustomProperty("Classe titre colonne", $_.ClasseTitreColonne)
        }
        if($_.TitreColonne -ne "" -and $parent  -ne $null )
        {
            $parent.SetLocalCustomProperty("Titre colonne", $_.TitreColonne)
        }
        #Fin colonne
        #Debut lien
        if($_.LienID -ne "" -and $parent  -ne $null )
        {
            $parent.SetLocalCustomProperty("Lien ID", $_.LienID)
        }
        if($_.SousTitreLien -ne "" -and $parent  -ne $null )
        {
            $parent.SetLocalCustomProperty("Sous titre lien", $_.SousTitreLien)
        }
        #Fin lien
        #Debut rubrique
        if($_.RubriqueID -ne "" -and $parent  -ne $null )
        {
            $parent.SetLocalCustomProperty("Rubrique ID", $_.RubriqueID)
        }
        if($_.BaliseRubriqueIcon -ne "" -and $parent  -ne $null )
        {
            $parent.SetLocalCustomProperty("Balise rubrique icone", $_.BaliseRubriqueIcon)
        }
        if($_.ClasseIconRubrique -ne "" -and $parent  -ne $null )
        {
            $parent.SetLocalCustomProperty("Classe icone rubrique", $_.ClasseIconRubrique)
        }
        if($_.TitreIcon -ne "" -and $parent  -ne $null )
        {
            $parent.SetLocalCustomProperty("Titre icone", $_.TitreIcon)
        }
        if($_.SousTitreIcon -ne "" -and $parent  -ne $null )
        {
            $parent.SetLocalCustomProperty("Sous titre icone", $_.SousTitreIcon)
        }
        if($_.ClasseLien -ne "" -and $parent  -ne $null )
        {
            $parent.SetLocalCustomProperty("Classe lien", $_.ClasseLien)
        }
        if($_.TitreLien -ne "" -and $parent  -ne $null )
        {
            $parent.SetLocalCustomProperty("Titre lien", $_.TitreLien)
        }
        if($_.EmphaseTitre -ne "" -and $parent  -ne $null )
        {
            $parent.SetLocalCustomProperty("Emphase titre", $_.EmphaseTitre)
        }
        if($_.ParentRubriqueID -ne "" -and $parent  -ne $null )
        {
            $parent.SetLocalCustomProperty("Parent rubrique ID", $_.ParentRubriqueID)
        }
        if($_.ClasseSousTitre -ne "" -and $parent  -ne $null )
        {
            $parent.SetLocalCustomProperty("Classe sous titre", $_.ClasseSousTitre)
        }
        if($_.ClasseParagrapheEnglobantLien -ne "" -and $parent  -ne $null )
        {
            $parent.SetLocalCustomProperty("Classe paragraphe englobant lien", $_.ClasseParagrapheEnglobantLien)
        }
        #Fin rubrique
        if($_.Ordre -ne "" -and $parent  -ne $null )
        {
            $parent.SetLocalCustomProperty("Ordre", $_.Ordre)
        }
        if($_.ClasseCSS -ne "" -and $parent  -ne $null )
        {
            $parent.SetLocalCustomProperty("Classe CSS", $_.ClasseCSS)
        }
        if($_.Visible -ne "" -and $parent  -ne $null )
        {
            $parent.SetLocalCustomProperty("Visible", $_.Visible)
        }
        if($_.Type -ne "" -and $parent  -ne $null )
        {
            $parent.SetLocalCustomProperty("Type", $_.Type)
        }
        if($_.PlanSite -ne "" -and $parent  -ne $null )
        {
            $parent.SetLocalCustomProperty("PlanSite", $_.PlanSite)
        }
       }
     }

     ImportTerm $group $set $parent $path[1..($path.Length)]
         Commit $store 2>&1 | out-null
   }

   function RemoveTermGroup([Microsoft.SharePoint.Taxonomy.TermStore]$store, [string]$groupName) {
     $group = $store.Groups | where { $_.Name -eq $groupName }
     if ($group -ne $null) {
       $group.TermSets | foreach { $_.Delete() }
       $group.Delete()
       $store.CommitAll()
     }
   }
   function Commit($store) {
     $store.CommitAll()
   }

   $termSetName = $termSet[0]."Term Set Name"
   $termSet | where { $_."Level 1 Term" -ne "" } | foreach {
     $path = @($groupName, $termSetName) + @(for ($i = 1; $i -le 5; $i++) {
       $term = $_."Level $i Term"
         if ($term -eq "") {
           break
         } else {
           $term
         }
       }
     )
     ImportTerm -path $path
     $ErrorActionPreference = "Continue";
   }
   }

$session = [Microsoft.SharePoint.Publishing.Navigation.TaxonomyNavigation]::CreateTaxonomySessionForEdit($web)
$store = $session.TermStores[0]
$termSet = Import-csv $CSVFilePath
ImportTermSet $store $TermGroupName $termSet

$store.CommitAll()

lundi 13 mai 2013

Change SPWeb Properties, CreateFriendlyUrlsForNewPages and CreateFriendlyUrlsForNewPages for SharePoint 2013 Navigation

Use the following Powershell in order to change the behavior of the managed navigation when you create a new page. Replace whether by true or false in order to fit the needs.


Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue
$site = Get-SPSite $siteUrl;

$site.AllWebs | foreach {

$webNav = $_.Properties["_webnavigationsettings"];
$webNav ;

#Replace  AddNewPagesToNavigation="True"  and  CreateFriendlyUrlsForNewPages="True" 


$webNav = $webNav.Replace('AddNewPagesToNavigation="True"','AddNewPagesToNavigation="False"');
$webNav = $webNav.Replace('CreateFriendlyUrlsForNewPages="True"','CreateFriendlyUrlsForNewPages="False"');
$_.Properties["_webnavigationsettings"] = $webNav;
$_.Properties.Update();
$_.Update();
}



lundi 29 avril 2013

Cache et perfomances SharePoint 2013

Plan for caching and performance in SharePoint Server 2013

Learn about the BLOB cache, Bit Rate Throttling, and other SharePoint features that can improve browser performance.

For a publishing site for which most of the visitors are anonymous or where most of the files are static content, enable the BLOB cache for as many file types as possible.

Using BLOB cache in a high traffic environment, and if you will use ULS logging, consider placing the BLOB cache on a separate physical drive from the ULS log — not on a separate partition. Storing the BLOB cache and the ULS log on the same drive can result in poor server performance.

Each front-end web server has its own local copy of the BLOB cache that is built as requests for files are received. If you use load balancing with multiple front-end web servers, each server contains its own cache.

By default, the BLOB cache is set to 10 gigabytes (GB). Allow at least 20 percent more space on the drive than the size of the cache. For example, if you have 100 GB of content, set the size of the cache to 120 GB on a drive that has at least 150 GB of space. If the BLOB cache is too small, serving files to users slows, reducing the performance of your site.

http://technet.microsoft.com/en-us/library/ee424404.aspx

Cache settings operations in SharePoint Server 2013

Learn about the available caches and the settings that can be configured for the BLOB cache, cache profiles and object cache settings.

http://technet.microsoft.com/en-us/library/cc261797.aspx

Monitor cache performance in SharePoint 2013

Learn how to monitor the SharePoint BLOB cache, the ASP.NET output cache, and the SharePoint object cache.

http://technet.microsoft.com/en-us/library/ff934623.aspx

Configure cache settings for a web application in SharePoint Server 2013

Learn how to configure the BLOB cache, page output cache profiles, and the object cache for a web application.

http://technet.microsoft.com/en-us/library/cc770229.aspx

Create a Data Collector Set to Monitor Performance Counters

You can create a custom Data Collector Set containing performance counters and configure alert activities based on the performance counters exceeding or dropping below limits you define.

http://technet.microsoft.com/en-us/library/cc722414.aspx

mardi 23 avril 2013

Premiers pas sur Office 365 et SharePoint 2013 Online

Création de votre site

Une offre d'essai permet de créer un compte sur Office 365 pendant 30 jours, tout ce qu'il vous suffit c'est une adresse mail Microsoft (hotmail /outlook /live).

http://msdn.microsoft.com/fr-fr/library/fp179924.aspx#o365_signup



Une fois votre compte créé il ne reste plus qu'à vous rendre sur votre portail avec le compte créé ( @onmicrosoft.com)



Votre première application

Commençons par nous rendre sur l'administration SharePoint


Rendez-vous ensuite sur la première collection de sites SharePoint 2013 online créée par défaut dont l'URL est https://angama.sharepoint.com dans mon cas puisque mon domaine est 'angama'

Vous voici donc sur votre site SharePoint 2013 dédié au développement d'application.

Nous allons nous intéresser en premier lieu à l'ajout d'application à votre portail et plus particulièrement aux liste de tâches.
Dans la partie paramètres située en haut à droite de votre site cliquez sur "Ajouter une application".


Une fois dans la galerie des applications, cliquez sur le modèle de liste "Tâches" et nommez votre liste "Planning".


Une fois la liste créée vous vous retrouvez sur la page "Contenu de site" avec la liste "Planning" correctement créée.
La prochaine étape consistera à populer cette liste et modifier l'affichage de celle-ci.

Ajoutez du contenu à la liste en vous servant du formulaire d'ajout et ajoutez les tâches à la vue chronologique.


Nous allons maintenant ajouter cette vue à la page principale de notre site, revenez à la page d'accueil du site en cliquant sur le logo SharePoint 2013 en haut à gauche de la page.

Cliquez ensuite sur "Page" et enfin sur "Modifer la page".


 Depuis l'onglet "Insérer" cliquez sur "Composant WebPart", il vous suffit maintenant de chercher l'application correspondant à la liste "Planning" et de l'ajouter à la page.

Voici le résultat final en ajoutant à gauche la WebPart Planning et sur la droite cette même WebPart en filtrant les résultats sur "Mes tâches".


Libre à vous de modifier l'affichage de la page notamment en changeant le thème de votre de site et en le renommant.

Le prochain tutoriel portera sur la navigation grâce au magasin des termes, les URL conviviales et le SEO (search engine optimization).

vendredi 1 mars 2013

Modify Site Collection URL SharePoint 2010

In order to rename a Site collection in SharePoint 2010 you need to backup the site first and restore it on an new Site collection.
To do that you can use the following PowerShell :
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue 
  
#Get the Source Site Collection URL
$sourceURL = Read-Host “Enter the Source Site Collection URL:”
  
#Get the Target Site Collection URL
$targetURL = Read-Host “Enter the Destination Site Collection URL”
  
#Location for the backup file 
$backupPath = Read-Host “Enter the Backup File name & location (E.g. c:\temp\Source.bak):”
  
#Backup the source site collection
Backup-SPSite $sourceURL -Path $backupPath -force
  
#Delete source Site Collection 
Remove-SPSite -Identity $sourceURL -Confirm:$false
  
#Restore Site Collection to new URL
Restore-SPSite $targetURL -Path $backupPath -Confirm:$false
  
#Remove backup files
Remove-Item $backupPath
  
write-host "Process Completed!"


vendredi 15 février 2013

Windows 8 : Open a local file and read Xml content

Thanks to this tutorial you will learn how to open an Xml File located in you Solution Explorer and how to retrieve value.

We will use Linq on Xml file so you have to add the following  librairies to your projet :


using System.Xml.Linq;
using Windows.Data.Xml.Dom;
using Windows.Storage;


Add a folder named 'Data' for exemple into you Windows Store solution and add the following Xml content into the file 'Schools.xml':

<?xml version="1.0" encoding="utf-8" ?>
<school>
  <name>IUT Toulouse</name>
  <type>Public</type>
  <location>
    <X>45.1</X>
    <Y>32.5</Y>
  </location>
</school>

And into a EventHandler or in the Page_Load for example add the folowing code :

Windows.Storage.StorageFolder storageFolder =await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFolderAsync("Data"); StorageFile storageFile =await storageFolder.GetFileAsync("Schools.xml"); IAsyncOperation<IRandomAccessStream> stream = await storageFile.OpenAsync(FileAccessMode.Read); XmlDocument xmlDoc = await XmlDocument.LoadFromFileAsync(storageFile); XDocument doc = XDocument.Parse(xmlDoc.GetXml()); string name = from schools in doc.Descendants("name") select schools.Value;string type = from schools in doc.Descendants("type") select schools.Value;

At the end of the code the variables  name and type contains the value retrieve in the xml file.





jeudi 7 février 2013

Windows 8 par où commencer ?

Voici quelques liens qui peuvent vous aidez à prendre en main windows 8 aussi bien niveau usage que développement :


Le top 10 des App :
http://www.pcworld.com/article/2012988/10-windows-8-apps-you-should-download-first.html


Génération App Microsoft avec les offres en cours et les concours:
http://www.generationapp.com/code/#fbid=FcBScBurfJr


Vos ressources de développement avec Microsoft code pour windowsApp:
http://code.msdn.microsoft.com/windowsapps

Comment concevoir vos applications et les rendre #1:
http://msdn.microsoft.com/library/windows/apps/hh779072/


Utilisation de la barre d'application suivant le context:
http://blogs.msdn.com/b/windowsappdev/archive/2012/09/06/embracing-ui-on-demand-with-the-app-bar.aspx