Pages

Thursday, December 13, 2012

Hello World App Using ASP.NET SignalR


Introduction

ASP.NET SignalR is an async signaling library for .NET to help build real-time, multi-user interactive web applications. In this article we will see, how do create a basic application using ASP.NET SignalR.

Previously SignalR was a standalone entity, now it's integrated as part of ASP.NET framework. You can check the following fall update.

http://www.microsoft.com/en-us/download/details.aspx?id=35493

Procedure

We can check the following documentation to understand the basics about SignalR.

https://github.com/SignalR/SignalR/wiki

We will create a simple application that the user can drag and drop the Div/Box and the same position of the box will be updated to all clients. First we need to add a reference for the SignalR dlls; we can use the Nuget package also to add the references.

http://nuget.org/packages/microsoft.aspnet.signalr

ASP.NET-SignalR.jpg

The same Nuget Package can also install the required JavaScript files and we added the "Jquery.UI" plug-in for the demo application.

Nuget-Package.jpg

We will create a simple "Hub" to broadcast the required actions (method) from the server as explained below. Please note that we need to add the "Microsoft.AspNet.SignalR.Hubs" namespace and the application namespace should be unique across the application files.

Microsoft.AspNet.SignalR.Hubs.jpg

We will prepare the client, just added a HTML page and the following JavaScript references and div tag.

JavaScript-references-and-div-tag.jpg

We don't have the manual reference for "signalR/hubs" js, it'll automatically be created at runtime and does the all magic. We'll add the following JavaScript to complete our functionalities.

manual-reference-for-signalR-hubs.jpg

In the preceding script we have three parts:

  1. We need to create a connection to the server and the same "Hub" name should be used in this connection statement.
  2. We can define the client side event called "shapemoved" and do the actions at the client side. Here we set the CSS property to the "shape" div. If we notice the "Hub" code we are calling this client side event from the server.
  3. The final one to do is we need to call a server side method "action" which is a "Hub" method. We called the "action" method in the client side "drag" function.
That's all, now we will see the result in action, if we drag the box in one browser and it's automatically updated in other clients.
result-in-action-Nuget-Package.jpg

Summary

ASP.NET SignalR is a new library for ASP.NET developers that make it incredibly simple to add real-time web functionality to your applications. What is "real-time web" functionality? It's the ability to have your server-side code push content to the connected clients as it happens, in real-time.
 

Hello World App Using Client Web Part in SharePoint 2013

Introduction

In this article we will see how to create and use a "Client Web Part" using the Office Napa Tool. In the previous article, we covered the basic App development using Napa Tool.
Steps

First we will navigate to the "Napa office 365 Development Tools" and select any existing App or create a new one.

Image1.jpg


Image2.jpg

Image3.jpg

Once your application opens, select the "ClientWebPart.aspx".

Image4.jpg

Add the following code to develop a simple application that will just list the latest 10 tweets.

Image5.jpg

Add the "JS" event to populate the tweets.

Image6.jpg

Create a new site page (wiki page) in our SharePoint 2013 site and edit the page.

In Edit mode navigate to the Ribbon ->Insert -> click App part

Image7.jpg

Select the SharePoint App and add it to our page.

Image8.jpg

Image9.jpg

We will ensure that the web part will work fine. Now it will load the tweets.

Image10.jpg

Summary

Using "Client Web Part" we easily add any "App Functionality" to our pages.
 

Tuesday, November 27, 2012

Site Access Request and Invitations in SharePoint 2013

Introduction

In this article we will see how the end-user requests site access invitations and how the site owner will manage the requests in SharePoint 2013.

Steps

We will first allow the end user to send an access request, if they don't have access to the SharePoint sites. The Site Owner/Administrator goes to the Site Settings -> Site Permissions page; see:

Image1.jpg

In the permissions page click the "Access Request Settings" link from the Ribbon.

Image2.jpg

Check the "Allow access requests" check box and enter the email id.

Image3.jpg

Image4.jpg

If the user doesn't have the access to the site then they will get a message like "Sorry you don't have access to this site" and if enabled for the site access request, the user is able to send a request as shown below.

Image5.jpg

Once user has sent the request, they will see the following status and confirmation message:

Image5.5.jpg

Now the site Owner/Administrator navigates to Site Settings-> Access requests and invitations.

Image6.jpg

We are able to view all the pending requests with conversation messages and we provide appropriate access and approve the request.

Image7.jpg

If there are any issues while attempting to approve the request, then we check the "configure outgoing e-mail settings".

Image8.jpg

Once the requests are approved, we are able to see the request status and confirmation message. Approved requests are moved from "Pending Requests" to "History" section.

Image9.jpg

Now the same user is able to view the site.

Image10.jpg

Internals

Some quick notes about the Access Requests internals. It is all stored in a hidden list called "Access Requests". This list has three views/pages:
  • Guest user invitations (Access Requests/pendinginv.aspx)
  • History (Access Requests/oldreq.aspx)
  • Pending Requests (Access Requests/pendingreq.aspx)
That is good to know if you want to leverage/improve the functionality of access requests in your applications. This list has unique permissions with only Site Owners with Full Control.

Summary

SharePoint 2013 has, with this simple feature, made it so much easier to create and manage community sites; internal or external. It's these little things that make a huge difference!

Wednesday, November 21, 2012

Sequential Work Flow in SP 2010 Using VS 2010


Introduction
In this article we will see how to create a sequential work flow in SharePoint 2010 using VS 2010.

Objective
Let's make the scenario simple. We want to create a simple work flow and if the work flow status is not completed, we need to prevent the user from deleting the document.

Steps
First we need to create a "Status" column with a Choice field type with various status options in our Document library.
Sequenceworkflow1.jpg
Once the "Status" column  was created, the document library will be as shown below:
Sequenceworkflow2.jpg

Open the VS2010 -> Select SharePoint 2010 -> Select the Sequential work flow project type and complete the wizard as shown below.
Sequenceworkflow4.jpgSequenceworkflow4.jpgJust click the OnWorkFlowActivated step and create an event called OnWorkFlowActivated_Invoked:Just click the OnWorkFlowActivated step and create an event called OnWorkFlowActivated_Invoked: Just double-click the onWorkflowActivated step. It will redirect to the code behind file.Drag a while loop step from the Tool Box, below the onWorkflowActivated step:Drag a while loop step from the Tool Box, below the onWorkflowActivated step: 
Sequenceworkflow9.jpg Sequenceworkflow11.jpg



Invoke the "IsWorkFlowPending" method in both the "onWorkflowActivated_Invoked" and the "onWorkflowItemChanged1_Invoked" methods.Invoke the "IsWorkFlowPending" method in both the "onWorkflowActivated_Invoked" and the "onWorkflowItemChanged1_Invoked" methods.Let's deploy the solution and we will check whether or not the workflow is deployed in our document library.Let's deploy the solution and we will check whether or not the workflow is deployed in our document library. 

Upload a document and start the workflow: We will see the workflow status as "InProgress" in the document library. Edit the task and change the status to Approved. Our workflow status will change to "Completed". We can prevent the user from "Deleting" the document, if the "Status" is not completed. Just add an Event Receiver in the same work flow project. 







Sequenceworkflow23.jpgLet's check the code in the UI using a document which is in the InProgress Status and try to delete the document.Let's check the code in the UI using a document which is in the InProgress Status and try to delete the document. If we click ok also the document is still in our repository. Let's make some changes in the code to display a user friendly message: Now when we try to delete the document we will see the following message. Summary                We created a simple work flow in VS 2010 and prevent the users from deleting a document, if its not approved.                We created a simple work flow in VS 2010 and prevent the users from deleting a document, if its not approved.
                
We created a simple work flow in VS 2010 and prevent the users from deleting a document, if its not approved.







Sequenceworkflow3.jpg
By default we have the following simple start page:
Sequenceworkflow5.jpg
Sequenceworkflow6.jpg
Sequenceworkflow7.jpg
Sequenceworkflow8.jpg
Select the while loop step and in the property window configure the "Condition" as "Code Condition" and create an event called "IsWorkFlowPending".
Sequenceworkflow10.jpg
Sequenceworkflow12.jpg
Sequenceworkflow13.jpg
Sequenceworkflow14.jpg
Sequenceworkflow15.jpg
Place the following in the our workflow:
Sequenceworkflow16.jpg
Sequenceworkflow17.jpg
Sequenceworkflow18.jpg
Sequenceworkflow19.jpg
Sequenceworkflow20.jpg
Sequenceworkflow21.jpg
Sequenceworkflow22.jpg
In the code behind file, we will prevent the user from deleting a document if the status is "Pending".
Sequenceworkflow24.jpg
Sequenceworkflow25.jpg
Sequenceworkflow26.jpg
Sequenceworkflow27.jpg
Sequenceworkflow28.jpg


Summary