Archive for April 29, 2013

Introduction to System Status Notifications in SharePoint 2013

SharePoint 2013 implements new System Status Notifications designed to provide site users information about lifecycle events to include availability of upgrade, maintenance, and read-only states.

System Status Notifications present important information about a SharePoint deployment and its availability, whether during upgrades, routine maintenance,  or conversion to read-only. Users are kept “in the know” as they receive a prominent banner on their sites that provides insight into the activity being performed—helping reduce calls to the help desk and subsequent burden on IT.

Farm administrators and developers can configure System Status Notifications to provide additional information to users and adjust upgrade delays.

SPWebApplication Properties

UpgradeReminderDelay

The UpgradeReminderDelay property is used to enable users to suppress the upgrade availability System Status Notification for a specified period of time.  Farm administrators can configure theUpgradeReminderDelay to allow users to suppress the UpgradeAvailable reminder for a period of time or alternatively set the value to 0 which shows users an UpgradeRequired reminder.  The default value is 30 (days).

image

Figure 1 above illustrates the System Status Notification when the UpgradeReminderDelay is set to a value greater than 0.

image

Figure 2 above illustrates the System Status Notification when the UpgradeReminderDelay is set to 0.

Configuring the UpgradeReminderDelay SPWebApplication property:

C#

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 
using Microsoft.SharePoint; 
using Microsoft.SharePoint.Administration;

namespace Sample_Maintenance_Link_Code 
{ 
    class Program 
    { 
        static void Main(string[] args) 
        { 
            SPWebApplication webApp = SPWebApplication.Lookup(new Uri(“http://sharepoint.contoso.com”)); 
            webApp.UpgradeReminderDelay = 90; 
            webApp.Update(); 
        } 
    } 
}

Windows PowerShell

$webApp = Get-SPWebApplication http://sharepoint.contoso.com

$webApp.UpgradeReminderDelay = 90

$weApp.Update()

UpgradeMaintenanceLink

The UpgradeMaintenanceLink property is used to provide users additional information during the site collection upgrade process.  Farm administrators can use the UpgradeMaintenanceLink property to enable a More Information link in the System Status Notification during the upgrade process directing users to a location where more information is available related to the upgrade process.  The default value for theUpgradeMaintenanceLink property is null therefore no More Information link is displayed to users.

image

Figure 3 Illustrates the System Status Notification when the UpgradeMaintenanceLink is not null.

Configuring the UpgradeMaintenanceLink SPWebApplication property:

C#

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 
using Microsoft.SharePoint; 
using Microsoft.SharePoint.Administration;

namespace Sample_Maintenance_Link_Code 
{ 
     class Program 
     { 
         static void Main(string[] args) 
         { 
             SPWebApplication webApp = SPWebApplication.Lookup(new Uri(“http://sharepoint.contoso.com”)); 
             webApp.UpgradeMaintenanceLink = “http://office.microsoft.com/en-us/sharepoint-help/training-courses-for-sharepoint-2013-HA104030990.aspx“; 
             webApp.Update(); 
         } 
     } 
}

Windows PowerShell

$webApp = Get-SPWebApplication http://sharepoint.contoso.com

$webApp.UpgradeMaintenanceLink =  “http://office.microsoft.com/en-us/sharepoint-help/training-courses-for-sharepoint-2013-HA104030990.aspx”

$webApp.Update()

ReadOnlyMaintenanceLink

The ReadOnlyMaintenanceLink property is used to provide users additional information when a site collection is set to read-only or a content database is configured to read-only in Microsoft SQL Server.  Farm administrators can use the ReadOnlyMaintenanceLink property to enable a More information link in the System Status Notification while a site collection or content database is in a read-only state.  The default value for the ReadOnlyMaintenanceLink is null therefore no More Information link is displayed to users.  For example, if a farm administrator would like to provide additional information on the read-only experience for users, the ReadOnlyMaintenanceLink can be configured with a More information link that directs users tohttp://technet.microsoft.com/en-us/library/dd793608.aspx#proc1.

image

Figure 4 Illustrates the System Status Notification when the ReadOnly property for a SPSite is set to $true.

image

Figure 5 Illustrates the System Status Notification when the content database for a SPSite is set to read-only.

Configuring the ReadOnlyMaintenanceLink SPWebApplication property:

C#

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 
using Microsoft.SharePoint; 
using Microsoft.SharePoint.Administration;

namespace Sample_Maintenance_Link_Code 
{ 
    class Program 
     { 
         static void Main(string[] args) 
         { 
             SPWebApplication webApp = SPWebApplication.Lookup(new Uri(“http://sharepoint.contoso.com”)); 
             webApp.ReadOnlyMaintenanceLink = “http://technet.microsoft.com/en-us/library/dd793608.aspx#proc1“; 
             webApp.Update(); 
         } 
     } 
}

Windows PowerShell

$webApp = Get-SPWebApplication http://sharepoint.contoso.com

$webApp.ReadOnlyMaintenanceLink = “http://technet.microsoft.com/en-us/library/dd793608.aspx#proc1”;

$webApp.Update()

NOTE

If a site collection or content database is set to read-only, the read-only message is displayed, upgrade status notifications are not displayed.  If ReadOnlyMaintenanceLink is not empty, a More Information link will be displayed.

If a site collection or content database is not read-only, and an upgrade is processing, “the site is currently being upgraded” is displayed.  If UpgradeMaintenanceLink is not empty, a More Information link will be displayed.

If a site collection or content database is not read-only, not upgrading, and the site is in 2010 mode, and current user is site collection admin:

  • If SPWebApplication.UpgradeReminderDelay is greater than 0, “upgrade is available” notification will be displayed. Clicking on the “remind me later” will update the SPSite.UpgradeReminderDate to be in n days, and dismiss the notification.
  • When SPWebApplication.UpgradeReminderDelay is 0, site admin will see “upgrade is required” notification. There will be no “remind me later” option. The notification will be displayed on every browse, and have to be manually dismissed each time.

 

UpgradeEvalSitesRetentionDays

The UpgradeEvalSitesRetentionDays SPWebApplication property is used to specify the default number days after which upgrade evaluation sites will be deleted. The expiration date for upgrade evaluation sites is set based on their creation date plus this value in days.  For example, in the event a site collection administrator requests an evaluation site collection, and that site collection is created on 4/16/2013, the evaluation site collection will be deleted on 5/16/2013 (the default value is 30 days).

image

Figure 6 Illustrates the System Status Notification when the UpgradeEvalSitesRetentionDays is set.

Configuring the UpgradeEvalSitesRetentionDays SPWebApplication property:

C#

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 
using Microsoft.SharePoint; 
using Microsoft.SharePoint.Administration;

namespace Sample_Maintenance_Link_Code 
{ 
    class Program 
     { 
         static void Main(string[] args) 
         { 
             SPWebApplication webApp = SPWebApplication.Lookup(new Uri(“http://sharepoint.contoso.com”)); 
             webApp.UpgradeEvalSitesRetentionDays = 90; 
             webApp.Update(); 
         } 
     } 
}

Windows PowerShell

$webApp = Get-SPWebApplication http://sharepoint.contoso.com

$webApp.UpgradeEvalSitesRetentionDays = 90;

$webApp.Update()

SPSiteUpgradeThrottleSettings

This class stores the throttle settings for large site upgrade, for example, a farm administrator can throttle the upgrade of site collections with a specified number of sites.

See also SPSiteUpgradeThrottleSettings members (Microsoft.SharePoint.

SPSite Properties

UpgradeReminderDate

The UpgradeReminderDate SPSite property is used to specify a date after which site collection administrators will be reminded to upgrade the site collection.

Configuring the UpgradeReminderDate SPSite property:

C#

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 
using Microsoft.SharePoint; 
using Microsoft.SharePoint.Administration;

namespace Sample_Maintenance_Link_Code 
{ 
    class Program 
    { 
        static void Main(string[] args) 
        { 
            SPSite site = new SPSite(“http://sharepoint.contoso.com”);

            System.DateTime today = System.DateTime.Now; 
            System.TimeSpan duration = new System.TimeSpan(30, 0, 0, 0);

            site.UpgradeReminderDate.Add(duration); 
        } 
    } 
}

Windows PowerShell

$site = Get-SPSite http://sharepoint.contoso.com

$today = Get-Date

$duration = $today.AddDays(30)

$site.UpgradeReminderDate.Add($duration)

ExtendUpgradeReminderDate

The ExtendUpgradeReminderDate SPSite property is used to extend the upgrade reminder date for a site collection by the days specified at UpgradeReminderDate.  When called, it addsSPWebApplication.UpgradeReminderDelay to the current time, stores it in SPSite.UpgradeReminderDelay.

Configuring the ExtendUpgradeReminderDate SPSite property:

C#

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 
using Microsoft.SharePoint; 
using Microsoft.SharePoint.Administration;

namespace Sample_Maintenance_Link_Code 
{ 
    class Program 
    { 
        static void Main(string[] args) 
        { 
            SPSite site = new SPSite(“http://sharepoint.contoso.com”); 
            site.ExtendUpgradeReminderDate(); 
        } 
    } 
}

Windows PowerShell

$site = Get-SPSite http://sharepoint.contoso.com

$site.ExtendUpgradeReminderDate()

More Information 

System Status Notifications are rendered through sending JavaScript to the page head and do not implement server-side controls.  The ExtendUpgradeReminderDate is implemented as an xmlHttp object that sends a REST call to web.Url/_api/Site/ExtendUpgradeReminderDate.

AllowSelfServiceUpgrade

The AllowSelfServiceUpgrade SPSite property is used to specify whether version to version upgrade is allowed on a site collection.  If the AllowSelfServiceUpgrade property is set to false site collection administrators will not be able to upgrade their site collection, if set to true, site collection administrators can perform a self-service (Deferred Site Collection Upgrade).  Farm administrators can control the upgrade process either en masse or selectively by disabling self-service upgrade.

image

Figure 7 illustrates configuring the AllowSelfServiceUpgrade SPSite property to $false.

Configuring the AllowSelfServiceUpgrade SPSite property:

C#

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 
using Microsoft.SharePoint; 
using Microsoft.SharePoint.Administration;

namespace Sample_Maintenance_Link_Code 
{ 
    class Program 
    { 
        static void Main(string[] args) 
        { 
            SPSite site = new SPSite(“http://sharepoint.contoso.com”); 
            site.AllowSelfServiceUpgrade = false; 
        } 
    } 
}

Windows PowerShell

$site = Get-SPSite http://sharepoint.contoso.com

$site.AllowSelfServiceUpgrade = $false;

Summary

A completely revised, backward-compatible upgrade experience is designed to balance the needs of users with those of IT. Because changing software is often difficult, SharePoint Server 2013 enables IT to upgrade SharePoint Server 2010 without having to upgrade users’ sites and content. These upgrades are deferred to the users, allowing them to choose when the time is right.

New evaluation site collections allow users to request an evaluation of the upgrade prior to upgrading production content; if satisfied with the experience, site collection administrators then can upgrade their content. It’s important to note that whether you have deployed SharePoint Server 2010 on-premises or subscribe to SharePoint Online in Office 365, the full upgrade capability is available.

SharePoint 2013: Enabling PDF Previews in Document Libraries with Office Web Apps 2013

Introduction

A couple of weeks back I blogged about the March Update for Office Web Apps 2013 and also how you could use that update to show PDF previews in a SharePoint 2013 Search Center. Since then I’ve received a lot of requests on how to enable PDF Previews in a Document Library, which isn’t there by default. Of course it is not a WAC thing, it’s a SharePoint 2013 thing – but the SharePoint 2013 updates (up until now at least) does not provide this capability either.

In this post I will show you that it can be done. It’s a JavaScript thing and can be done using a Content Editor Web Part added on all pages where you want the PDF previews or as Farm solution which uses a delegate control and a custom JavaScript file.

Build the PDF Preview solution

I assume that you are familiar with SharePoint 2013 development and knows what a delegate control is. What you need to do is create a new empty Farm solution project. In this project we’ll create a new web control that will add a JavaScript (which we will create in just a minute) to the page. The implementation should look like below:

1
2
3
4
5
6
7
8
[MdsCompliant(true)]
public class PdfPreviewControl: WebControl
{
    protected override void OnPreRender(EventArgs e)
    {
        ScriptLink.RegisterScriptAfterUI(this.Page, "wictor.pdfpreviews/previews.js", false);
    }
}

The JavaScript file, added as a Layouts file, is what makes the magic happen. We’re using the Script-On-Demand features in this script to make sure that the scripts aren’t executed before the SharePoint filepreview.js file is loaded. Once that file is loaded two new JavaScript objects are created; the filePreviewManager and theembeddedWACPreview. To enable the PDF previews we only need to add the PDF extension to these objects and specify the previewer objects and the dimensions. In this case I use the same settings as the other Word previewers.

1
2
3
4
5
6
7
8
9
function WictorsPdfPreviews() {
    SP.SOD.executeOrDelayUntilScriptLoaded(function () {
        filePreviewManager.previewers.extensionToPreviewerMap.pdf =
            [embeddedWACPreview, WACImagePreview];
        embeddedWACPreview.dimensions.pdf= { width: 379, height: 252}
    }, "filepreview.js");
    notifyScriptsLoadedAndExecuteWaitingJobs("wictor.pdfpreviews/previews.js");
}
WictorsPdfPreviews();

Now we need to make sure that this control loads the JavaScript on all pages. This is done by adding a new Empty Element SPI and creating a Control element pointing to the web control, like this:

1
2
3
4
5
<Control
  ControlAssembly="$SharePoint.Project.AssemblyFullName$"
  ControlClass="Wictor.PdfPreviews.PdfPreviewControl"
  Id="AdditionalPageHead"
  Sequence="100"/>

As you can see we’re adding this control to the AdditionalPageHead, which means that we will have it on every page. Do not forget to add the web control as a Safe Control in the project!

The final thing we need to do is to modify the Feature that was automatically created when the Empty Element SPI was added to the project. You can scope it to whatever you like, but I want it for all Document Libraries in my farm so I set the scope to Farm. The image below shows all the files in the project.

The Visual Studio 2012 solution

Deploy and Test

Now all we have to do is to deploy the solution. Once the solution is deployed and the Farm feature activated we can navigate to any document library and upload a PDF file. Note that you have to be on at least the March 2013 update of Office Web Apps Server and that you have enabled the WordPDF application (see previous blog post). Once you have the PDF file in the library you can click on the ellipsis button and see the PDF Preview:

PDF Previews in SharePoint 2013

Summary

Enabling PDF Previews are not (yet) a default feature of SharePoint 2013 but can easily be added to your SharePoint farm – if you’re allowed to use Full Trust solutions.  If you don’t feel like you want to do some hacking yourself you can download the WSP here and deploy it yourself to try it out.

New SharePoint 2013 authentication process and Test Lab Guide overview videos

The following new conceptual videos that describe SharePoint 2013 authentication processes are now available:

These videos step you through the details of claims-based authentication for user access to a secure SharePoint resource.

Additionally, the following Test Lab Guide (TLG) overview videos are available:

These videos show you the stack (the set of TLGs that you need to configure) and the lab build-out, correlated with the steps in the TLG. The idea is to give you an idea of what’s involved in building a given test lab in a short, to-the-point, and visually interesting way. You can then decide whether to take the plunge and make it happen in your test lab. For more information about TLGs, see the Test Lab Guides portal page.

If you have any suggestions about to improve these types of videos, please let us know by leaving a comment on this blog post.

For additional videos for SharePoint 2013, see Video demos and training for SharePoint 2013.

SharePoint 2013- Creating App Event handlers

In my last post i have explained how to create remote event receiver. In this post i am talking about how to create app event receivers in share point 2013.
As shown in my last post i have created remote event handler. After adding a remote event receiver to my app, anew web app project got create, Web app project contains web service code files related to remote handlers.
To enable to app events for your app, select the app project, check the properties for app project as shownbelow images. you can see three handlers in the properties related to apps, Handle App Installed, Handle App Uninstalling, Handle App Upgraded. Make the property to True that you need to fire.

Here Iam selecting Handle App Installed event. After changing the value from False to true you can see the new Service file “AppEventReceiver.svc” in Appweb project as shown below image.

In AppManifest.xml file tag, new property  will be updated with the AppeventReceiver service file as shown the below image.

Write the code as per your requirement. Here iam just creating a text file and writing the text in the file when app got installed in my share point site. Code will be

public SPRemoteEventResult ProcessEvent(RemoteEventProperties properties)
      {
            LogAppEvent(properties);
            return new SPRemoteEventResult();
      }

      private void LogAppEvent(RemoteEventProperties properties)
{
            try
            {
                FileStream fileStream = new FileStream(“D:\\AppFile.txt”, FileMode.OpenOrCreate,FileAccess.Write);
                StreamWriter writer = new StreamWriter(fileStream);
                if (properties.EventType == RemoteEventType.AppInstalled)
                {                   
                    writer.Write(“App Installed”);
                    writer.Close();
                }
            }
            catch (Exception ex)
            {  
            }
      }

Here AppEventReceiver class will inherit from IRemoteEventService as shown in the image below. By default there will be two methods ProcessEvent() and ProcessOneWayEvent() as same as Remote event handler. Code file will be 

write the code in ProcessEvent() method. Here code will fire for AppInstalled event. In case if you write the code for AppUnninstalling event, and in the properties value ‘false’, event will not be fired. If you need to disable the event, just make the property value from True to False.

Create Remote Event Receivers in Share Point 2013

Remote event handlers new feature added in share point 2013. I have already published a post regarding event handling in share point 2013. In this post Iam showing how to create a remote event receiver through Visual studio.
here iam considering a requirement that update title of Announcement list, when ever new item added to the Announcement list. So that creating an app that contains Announcement list and adding remote event handler to the app. The process shown as below,
Create New Project–>Select SharePoint App in Visual Studio 2013.

App should be SharePoint-hosted



Check the AppManifest.xml file and tag should be as shown the code.


 

Add New item as list type of announcements , select list Item Type Events , select ItemAdded event as shown below

Add new item as Remote Event Receiver to the solution.

After adding the remote event receiver, you’ll get AppWeb project as shown in the image below. While creating Remote event receiver was selected list Item events and ItemAdded event. 

Visual studio by default add the Appweb to the project, App web contains the service file that to run the web service. A Remote event receiver web service by default inherits from IRemoteEventService.
Remote event structure is different than regular event receivers. In regular event receivers we’ll over ride the existing methods  Here in the Remote event handlers we’ll write the code in two methods, ProceeEvent() and ProcessOneWayEvent(). So the both the methods will handle the Synchronous and Asynchronous events rather than writing every method. Here we can simply called the method by checking SPRemoteEventProperties.EventType enumerator.
ProcessEvent() will return SPRemoteEventResult, shows the status and error message like other server side events. In this method for item event contains dictionaries for before and after properties, list, user information.
Here i took Item Added event. So that i need to add the code in ProcessOneWayEvent. I was added the following code in the method. After item added to the Announcement list title will be updated through my coding.
Here is the code in ProcessOneWayEvent() method.

public void ProcessOneWayEvent(RemoteEventProperties properties)
        {
            Uri myurl = new Uri(properties.ItemEventProperties.WebUrl);
            if (properties.EventType == RemoteEventType.ItemAdded)
            {
                using (ClientContext clientContext = new ClientContext(myurl))
                {
                    if (clientContext != null)
                    {
                        List lstContacts =
                           clientContext.Web.Lists.GetByTitle(properties.ItemEventProperties.ListTitle);
                        clientContext.Load(lstContacts);
                        clientContext.ExecuteQuery();
                        int cnt = lstContacts.ItemCount;
                        ListItem itemContact = lstContacts.GetItemById(cnt);
                        clientContext.Load(itemContact);
                        clientContext.ExecuteQuery();
                        itemContact[“Title”] = itemContact[“Title”] + ”  changed by Remote Event Receiver”;
                        itemContact.Update();
                        clientContext.Load(itemContact);
                        clientContext.ExecuteQuery();
                    }
                }
            }
        }

xml in Elements.xml will be


http://schemas.microsoft.com/sharepoint/“>
 
     
        MyRemoteEventReceiverItemAdded
        ItemAdded
        10000
        ~remoteAppUrl/MyRemoteEventReceiver.svc
     

 

Here Url is the WCF service url to run the event receiver.
Add the following code to default.aspx page, in “PlaceHolderMain” contentplaceholder to view the list in the app home page.

       ID=”full” Title=”loc:full” >
runat=”server” ListUrl=”Lists/Announcements” IsIncluded=”True”
NoDefaultStyle=”TRUE” Title=”Announcements” PageType=”PAGE_NORMALVIEW”
Default=”False” ViewContentTypeId=”0x”>


   

Finally my default.aspx page will be,

Deploy the app and and you’ll be redirected to sharepoint app page that containes Announcement list.
Add new item to the announcement list. Title will be updated with ”  changed by Remote Event Receiver”, in my next post i’ll write about app event handlers.
Provide comments below if you have any issues creating the event receiver.