Consider a system that must process multiple files simultaneously.
We want to improve system performance but also we want to monitor the process in real time.

To achieve this goal, we suggest to build a distributed architecture consisting of a REST web server ( ASP.NET WEB API, SIGNALR), a WEB client (ASP.NET MVC and Angular JS ) and a web service that processes files ( WCF or Other).

But for this tutorial we will use a single project for easier reading.

To follow this tutorial, you must undertand ASP.NET WEB API , SIGNALR and TPL Dataflow.

TECHNOLOGY ARCHITECTURE

HUB Server : ASP.NET WEB API and SIGNALR

Monitoring Client : ASP.NET MVC and AngularJS

Processing Server : TPL DataFlow, FileWatcher System

HUB SERVER.

To Build our Hub Server, we will use ASP.NET Web API because clients must connect to the hub by uploading json data

.

We will also use SignalR as it allows bi-directional communication between server and client. Servers can now push content to connected clients instantly as it becomes available and supports Web Sockets.

When Server is invoked, Hub.Clients.All.LoadBalance(item) ( where item is Processor), data is pushed to Hub and be available for clients as follow

Monitor Controller MonitorCtrl use MonitorSvc

2.MONITORING CLIENTS

Clients connect to LoadBalance function of the Hub as follow:

Client use MonitorCtrl and iterate through processor to display items in real time. this is possible because MonitorCtrl push item into an array named Processor

$scope.Processor = new Array();

var addProcessor = function (data) {
$scope.Processor.push(data);
};

3.PROCESSING SERVER

We can avoid bottlenecks in performance and improve overall responsiveness of our application using the asynchronous programming. However, traditional techniques for writing asynchronous applications can be complex and difficult to write, debug and update applications.

There exist différent technics to build asynchronous systems :

THREAD

We can Start, Stop, Abort and Coordinating Threads (Join)

TASK

A task Represents an asynchronous operation that can return a value

ASYNC and AWAIT

PARALLEL PROGRAMMING

TPL DATAFLOW

we want to just write the code, and the way we structure it results in no synchronization issues. So we don’t have to think about synchronization. In this world each object has its own private thread of execution, and only ever manipulates its own internal state.

Instead of one single thread executing through many objects by calling object methods, objects send asynchronous messages to each other.

If the object is busy processing a previous message, the message is queued. When the object is no longer busy it then processes the next message.
Fundamentally, if each object only has one thread of execution, then updating its own internal state is perfectly safe.

TPL Dataflow enable us to achieve this goal by building blocks. Blocks are
essentially a message source, target, or both. In addition to receiving and sending messages, a block represents an element of concurrency for processing the messages it receives.

Multiple blocks are linked together to produce networks of blocks. Messages are then posted asynchronously into the network for processing.

Consider the following use case. Several files are sent to a server (in a directory), The data contained in each file need to be transformed into a
data object ready to be sent to the web service. For network efficiency the web service receives multiple data objects as part of a single request, up to a defined maximum.

The following process could be broken down into a series of blocks, where each block is responsible for doing some part of the overall processing.

_bufferBlock has the responsibility to fetch files from directory as they arrive

_receptorBlockOne , _receptorBlockTwo and _receptorBlockThree has the responsibility to load balance fetched files

For better performance , we want to load balance our process. So our next step is to create 3 load balanced receptors, if _receptorBlockOne is busy, _receptorBlockTwo or _receptorBlockThee will process the item,… ReceptorBlockOne, ReceptorBlockTwo and ReceptorBlockThree are blocks. So, if a message is refused by one block, the next linked block will be
offered the message. If all blocks refuse the message, the first block to become available to process the message will do so. To achieve this goal, we have to make a block non-greedy, simply set the queue length to 1.

_transformBlockToManyFiles has responsability transfrom a FileOrderEntity to as List<FileOrderEntity>. large files must be split to many small files.

_printingBlock has responsability to print outputs

Now we are going to build our Dataflow network by linking blocks.

To visualize the TPL Dataflow network , launch debugger and then click the search icon

The schema below represent our DataFlow network, the workflow that will execute at runtime.

Finally, let us use FileSystemWatcher to listen file system change notifications and raises events when a directory receives some files.

Press F5 to run application, so you can see that the behaviour is different between windows Phone and Surface tablet.Our sample is finish but in a real world application, we must reference our portable class library in both windows Phone client, surface client, XBOX client and sower. and implement business logic for each client,

In this tutorial, we are going to show how to track user activity and how to log runtime errors.We can use filter attributes to mark any action method or controller. If the attribute marks a controller, the filter applies to all action methods in that controller.

Typically, we create an action or response filter by creating an attribute class that inherits from the abstract ActionFilterAttribute class.

Some built-in action filters, such as AuthorizeAttribute and HandleErrorAttribute, inherit from the FilterAttribute class.

Other action filters, such as OutputCacheAttribute, inherit from the abstract ActionFilterAttribute class, which enables the action filter to run either before or after the action method runs.

The following tutorial shows how to create a simple action filter that logs trace messages before and after an action method is called.

So Lets Create an ASP.NET MVC internet application project

Add a class TraceFilterAttribute that inherit from ActionFilterAttribute

ASP.NET membership is designed to enable you to easily use a number of different membership providers for your ASP.NET applications. You can use the supplied membership providers that are included with the .NET Framework, or you can implement your own providers.

There are two primary reasons for creating a custom membership provider.

You need to store membership information in a data source that is not supported by the membership providers included with the .NET Framework, such as a MysQL database, an Oracle database, or other data sources.

You need to manage membership information using a database schema that is different from the database schema used by the providers that ship with the .NET Framework. A common example of this would be membership data that already exists in a SQL Server database for a company or Web site.

In tis tutorial, we are going to implement and configure a custom Membership Provider using ASP.NET MVC4

Visual Studio Application Lifecycle Management (ALM) solution enables businesses to manage the entire life of the application development, reduce cycle times and eliminate waste in order to provide a continuous stream of business value.

When effectively implemented, ALM practices break down barriers between teams, enabling organizations to meet the challenges and to provide high quality software at a faster pace Companies using ALM also benefit from a greater reduction of waste, faster cycle times and greater agility.

During application development , it essential to answer the following questions:

What is the probability of my application to crach ?

Will my Infrastructure be able to stand in front of a large amount of users?

When integrating a new software component , is it possible to have negative impact on the existing one? .

In this tutorial, we are going to walk through 3 steps:

Validate and maintain the quality of our application through the unit tests. Next, we switch to using a test driven development (TDD) approach in which we write unit tests before writing the production code.

Simulate user load on a web application

Validate and maintain the quality of our application through the unit tests

We have different types of tests :

C. Web Performance Testing

D. Load Testing

E. Code Coverage

F. Ordered tests

G. Testing and Team Foundation Server

A. Getting Started

There are actually many profiles of potential testers : all project developers will not have to perform load tests or web tests, this task is delegated to a small group of people.

We are using visual studio 2012 so as to be able to cover a large number of test case.

In contrast, people who perform unit tests will be more numerous..

It is therefore imperative to conduct a battery of tests to different aspects of the application. To identify gaps in earlier and be able to work their corrections cost, this exercise should take place throughout the development process.

B. Unit tests

Unit tests verify that every part of our application responds correctly to the functional requirements that have been expressed and it has no bug. Throughout the development of the application, re-running the tests automatically (when generating build as seen in the previous chapter) or when editing the corresponding module, we can ensure that we non-regression system.
Since Visual Studio 2005, Microsoft proposes using MSTest, its own testing framework, fully integrated into the IDE. The principle is simple: the attributes are used to decorate classes and methods and have written assertions. This is the conclusion of the latter indicate that if our test is passed or not.
In the following example, we will use the Authenticate class below. We will add it in a Project Class Library in the solution:

Create a project class Library and add our class Authenticate as a sample for testing.

ASP.NET membership is designed to enable you to easily use a number of different membership providers for your ASP.NET applications. You can use the supplied membership providers that are included with the .NET Framework, or you can implement your own providers.

There are two primary reasons for creating a custom membership provider.

You need to store membership information in a data source that is not supported by the membership providers included with the .NET Framework, such as a MysQL database, an Oracle database, or other data sources.

You need to manage membership information using a database schema that is different from the database schema used by the providers that ship with the .NET Framework. A common example of this would be membership data that already exists in a SQL Server database for a company or Web site.

In tis tutorial, we are going to implement and configure a custom Membership Provider using ASP.NET MVC4 that enable external login like facebook, yahoo , google or other relying party accounts.

To authenticate users with credentials from an external provider, you must register your web site with the provider. When you register your site, you will receive the parameters (such as key or id, and secret) to include when registering the client. You must have an account with the providers you wish to use.

To successfully register your site, follow the instructions provided on this sites :