domingo, 18 de enero de 2015

Hacer Load testing para Sharepoint 2013 con Visual Studio 2013

Primero verifico que esté habilitado “Enable 3rd party extensions” en las propiedades avanzadas del IE.

image

Creo un proyecto

image

Selecciono el Botón “Add Recording”

image

Me abrirá el IE, donde selecciono “Record”. Después ingreso al portal de Sharepoint, y genero un poco de workload para tener test reales

image

image

Una vez detenido, me genera los parámetros dinámicos

image

image

image

Después agrego un Load Test

image

image

Agrego como carga, 50 usuarios concurrentes

image

image

image

image

image

image

El resumen del Load test es:

image

Puedes agregar contadores de performance

image

image

Y lanzo el test de stress load.

image

image

Si le haces doble click en el item, ves más información:

image

Si cambias la vista a Tales, puedes ver el estado actual de los test

image

Una vez finalizado los test, reviso los resultados

image

image

image

Remover Event Receiver mediante PowerShell

En este post expliqué cómo agregar Event Receivers mediante client object, ahora les voy a mostrar cómo sacarlos con PowerShell

Add-PSSnapin Microsoft.SharePoint.PowerShell –erroraction SilentlyContinue
$web=Get-SPWeb "http://url_WEBSITE"
$lista = $web.Lists["NombreListaOLibreria"]
$tipoEvent = "ItemAdding" #pueden ser ItemAdding, ItemUpdating, ItemDeleted, etc
$cantEventReceivers = $lista.EventReceivers.Count
if ($cantEventReceivers -gt 0)
{
   for( $index = $cantEventReceivers -1; $index -gt -1; $index–-)
   {
      $receiver = $lista.EventReceivers[$index] ;
      $name = $receiver.Name
      $typ = $receiver.type ;
 
      if ($typ -eq $tipoEvent) 
      {
         $receiver.Delete()
         Write-Host "se borro el event receiver " $name
      }
   }
}
else
{
   Write-Host "No hay EventReceivers de este tipo " $tipoEvent " registrados para la lista"
}
 
$web.Dispose()

Event Receiver remoto – Sharepoint 2013 (remote event receiver) – Parte 1

En este post voy a crear un event receiver remoto (deployado sobre un Azure WebSite) para un Sharepoint 2013 on-premise. En una segunda parte voy a utilizar algunos servicios de Azure (Table, Services Bus, Push Notifications, etc) para ver el uso que se puede hacer con estos eventos-

Hay muchos ejemplos con Auto-hosted Apps: http://blogs.technet.com/b/sharepointdevelopersupport/archive/2013/03/13/how-to-create-a-remote-event-receiver-for-a-sharepoint-hosted-app.aspx

La idea es utilizar client object para configurar los remote event receiver, esto nos permite configurarlos sin deployar nada en los ambientes, y afectar su funcionamiento.

image

Primero creo una librería con dos campos:

ValorAnteriorDocNum = representa el valor anterior que tenia DocNum, solo lo actualizo en el eventoItemUpdating
DocNum = String (visible)      

imageimage

image

Creo una aplicación ASP.NET Empty

image

Elijo que se va a deployar en Windows Azure (host in the cloud)

image

Agrego mi subscripción

image

Una vez configurada la subscripción se crea el website en Azure

image

Agrego las referencias de “Microsoft.Sharepoint.Client.dll” y “Microsoft.Sharepoint.Client.Runtime.dll”

En general las dll´s están en : C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI

image

image

Recuerda marca la opción “Copy Local” a true

image

Agrego un WCF Service llamado “EventSynchronous.svc”

image

En el archivo “EventSynchronous.svc.cs” edito el archivo y le agrego lo siguiente.

Agrego referencias mediante using:

  • using Microsoft.SharePoint.Client;
  • using Microsoft.SharePoint.Client.EventReceivers;
  • using System.ServiceModel.Activation;

Después hago que la clase EventSynchronous herede de IRemoteEventService

image

Agrego dos métodos para satisfacer la Interface.

image

El método ProcessOneWayEvent se deja vacio, porque se usa para eventos Asyncrónicos. Definición de los métodos:

1. ProcessEvent(): This is a synchronous event that handles events that occur before an action occurs.  Such as when a user adds or deletes a list item.  Two way event that can handle current events (“-ing”) that can callback to SharePoint.

2. ProcessOneWayEvent(): This is a asynchronous event that handles events that occur after an action occurs.  Such as after a user adds an item to a list or deletes an item from a list.  This is one-way event that can handle past events (“-ed”).

En cambio el método “ProcessEvent”, tiene el siguiente contenido

image

Dependiendo del tipo de evento (ItemDeleted o ItemUpdating) hago una operación diferente, en este caso sólo hago la de ItemUpdating

Deployo la solución en el website de Azure.

image

image

image

Verifico si está andando el servicio WCF:http://eventreceiver5178.azurewebsites.net/EventSynchronous.svc

Ahora creo en el mismo proyecto de Visual Studio, una proyecto de consola

image

Agrego de nuevo las referencias del proyecto anterior

image

En Program.cs, hay 3 variables para completar

image

Después copio lo siguiente.

image

string sharePointUrl = "http://chrissp2013dev/sites/testtheme";
           string remoteWebUrl = "http://eventreceiver5178.azurewebsites.net";
           string listName = "Evento";         
           using (ClientContext clientContext = new ClientContext(sharePointUrl))
           {
               //si estas con un usuario administrador de la farm, no será necesario agregar autenticación.
               //sino usa la siguiente propiedad.
               //NetworkCredential credentials = new NetworkCredential(“username”, “pwd”, “domain”);
               //clientContext.Credentials = credentials;
               clientContext.AuthenticationMode = ClientAuthenticationMode.Default;
               List targetList = clientContext.Web.Lists.GetByTitle(listName);
               clientContext.Load(targetList);
               EventReceiverDefinitionCollection ec = targetList.EventReceivers;
               clientContext.Load(ec);
               //ITEM UPDATING
               EventReceiverDefinitionCreationInformation eventReceiver = new EventReceiverDefinitionCreationInformation();
              eventReceiver.EventType = EventReceiverType.ItemUpdating;
               eventReceiver.ReceiverAssembly = "EventReceiver";
               eventReceiver.ReceiverClass = "EventReceiver.EventSynchronous";
               eventReceiver.ReceiverName = "EventSynchronous";
               eventReceiver.ReceiverUrl = remoteWebUrl + "/EventSynchronous.svc";
               eventReceiver.SequenceNumber = 1000;
               eventReceiver.Synchronization = EventReceiverSynchronization.Synchronous;
               targetList.EventReceivers.Add(eventReceiver);
               clientContext.Web.Context.ExecuteQuery();

               //ITEM DELETING
               eventReceiver = new EventReceiverDefinitionCreationInformation();
              eventReceiver.EventType = EventReceiverType.ItemDeleting;
               eventReceiver.ReceiverAssembly = "EventReceiver";
               eventReceiver.ReceiverClass = "EventReceiver.EventSynchronous";
               eventReceiver.ReceiverName = "EventSynchronous";
               eventReceiver.ReceiverUrl = remoteWebUrl + "/EventSynchronous.svc";
               eventReceiver.SequenceNumber = 1000;
               eventReceiver.Synchronization = EventReceiverSynchronization.Synchronous;
               targetList.EventReceivers.Add(eventReceiver);
               clientContext.Web.Context.ExecuteQuery();
           }

Para verificar el estado de los event receiver, ejecuto el siguiente script powershell

$web=Get-SPWeb "http://chrissp2013dev/sites/testtheme"
$list=$web.Lists["Evento"]
$list.EventReceivers |ForEach-Object {Write-host $_.Type  $_.Name}
$web.Dispose()

image

Después en nuestro ambiente on-premise de Sharepoint, primero verificamos que tengamos acceso al website de azure (habilitar puertos 80 o 443 dependiendo si usaste certificados y el proxy interno para que Sharepoint pueda acceder a contenidos publicados en internet).

Subo un documento y verifico el funcionamiento.

image

Se dispara el evento ItemUpdating y actualiza el campo ValorAnteriorDocNum, ya que las librerías funcionan diferentes a las listas, cuando subes el documento se dispara el evento ItemAdding, y cuando te aparecen las propiedades para actualizarlas se dispara el evento ItemUpdating.

Me queda así el campo ValorAnteriorDocNum

image

Recuerda la siguiente tabla para las listas:

image

Recuerda la siguiente tabla para las librerias:

image

jueves, 8 de enero de 2015

Cambiar la foto de tu perfil con Powershell

Cambien los valores en rojo.

URLMySite: hace referencia al web applicationde MySites

SiglaAD: es la sigla del usuario al cual quieren cambiar la foto

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
$mySiteUrl = "http://URLMySite"
 
#Connect to the User Profile Manager
$site = Get-SPSite $mySiteUrl
$context = Get-SPServiceContext $site
$profileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context)
$up = $profileManager.GetUserProfile("SiglaAD")
$up["PictureURL"].Value = "http://URLMySite/User Photos/Profile Pictures/SiglaAD_MThumb.jpg"
$up.Commit()
write-host $up.DisplayName" --> ", $up["PictureURL"].Value

martes, 6 de enero de 2015

Sharepoint 2013 - User Profile Synchronization Status queda en un estado “Stopping” o “Syncronizing”

Si “Profile Syncronization Status” queda en un estado “Stopping” o “Syncronizing” por más de 1 hora, revisa si el servicio de “Forefront Identity Manager Service” está detenido

image

image

Este servicio es el que gestiona las sincronizaciones.

domingo, 4 de enero de 2015

Obtener todos los websites de un web application mediante powershell

Add-PSSnapin Microsoft.SharePoint.PowerShell –erroraction SilentlyContinue
$webApplication = Get-SPWebApplication http://url_webApplication
$filePath = "C:\AllSites.txt"
$sites = $webApplication.Sites
foreach ($site in $sites)
{
    foreach ($web in $site.AllWebs)
    {      
        $web.Url | Out-File -FilePath $filePath -Append -Width 256        
    }   
}