Wednesday 19 October 2016

Sample MVC UI

.CSHTML


@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_MainLayout.cshtml";
}

<div class="PageTitle">
    Eligibility Config - Main
</div>
<div class="BreadCrumb">Eligibility Configuration >> Main</div>
<hr />
<div>
    <p>
        Eligibility Configuration sample text Eligibility Configuration sample text Eligibility Configuration sample text Eligibility Configuration sample text Eligibility Configuration sample text Eligibility Configuration sample text Eligibility Configuration sample text Eligibility Configuration sample text Eligibility Configuration sample text Eligibility Configuration sample text Eligibility Configuration sample text Eligibility Configuration sample text Eligibility Configuration sample text Eligibility Configuration sample text
    Eligibility Configuration sample text Eligibility Configuration sample text Eligibility Configuration sample text Eligibility Configuration sample text Eligibility Configuration sample text Eligibility Configuration sample text Eligibility Configuration sample text Eligibility Configuration sample text Eligibility Configuration sample text Eligibility Configuration sample text Eligibility Configuration sample text
    Eligibility Configuration sample text Eligibility Configuration sample text Eligibility Configuration sample text Eligibility Configuration sample text Eligibility Configuration sample text Eligibility Configuration sample text
    </p>
    <br />
    <div class="lable">What is your name ?</div>
    <div class="control">
        <input type="text" style="width: 200px" />
    </div>
    <div style="clear: both"></div>
    <div class="lable">What is your name ?</div>
    <div class="control">
        <input type="text" style="width: 200px" />
    </div>
    <div style="clear: both"></div>
    <div class="lable">What is your name ?</div>
    <div class="control">
        <input type="text" style="width: 200px" />
    </div>
    <div style="clear: both"></div>
    <div class="lable">What is your name ?</div>
    <div class="control">
        <input type="text" style="width: 200px" />
    </div>
    <div style="clear: both"></div>
    <div class="lable">What is your name ?</div>
    <div class="control">
        <input type="text" style="width: 200px" />
    </div>
    <div style="clear: both"></div>
    <div class="lable">What is your name ?</div>
    <div class="control">
        <input type="text" style="width: 200px" />
    </div>
    <div style="clear: both"></div>
    <div class="lable">What is your name ?</div>
    <div class="control">
        <input type="text" style="width: 200px" />
    </div>
    <div style="clear: both"></div>
    <div class="lable">Do you wish to Subscribe ?</div>
    <div class="control">
        <input type="checkbox" checked="checked" />
        <input type="checkbox" checked="checked" />
    </div>
    <div style="clear: both"></div>
 
</div>


<table>
    <tr>
        <td>Lable 1</td>
        <td><input type="text" /></td>
        <td style="width:10px"></td>
        <td>Lable 1</td>
        <td><input type="text" /></td>
    </tr>
    <tr>
        <td>Lable 1</td>
        <td><input type="text" /></td>
        <td style="width:10px"></td>
        <td>Lable 1</td>
        <td><input type="text" /></td>
    </tr>
    <tr>
       <td>Lable 1</td>
        <td><input type="number" /></td>
        <td style="width:10px"></td>
        <td>Lable 1</td>
        <td><input type="email" /></td>
    </tr>
    <tr>
         <td>Lable 1</td>
        <td><input type="text" /></td>
        <td style="width:10px"></td>
        <td>Lable 1</td>
        <td><input type="date" /></td>
    </tr>
</table>
<table>
    <tr>
        <th>S.No</th>
        <th>Heading 1</th>
        <th>Heading 2</th>
        <th>Heading 3</th>
        <th>Heading 4</th>
    </tr>
    <tr>
        <td>1</td>
        <td>Column Text</td>
        <td>Column Text</td>
        <td>Column Text</td>
        <td>Column Text</td>
    </tr>
    <tr>
        <td>2</td>
        <td>Column Text</td>
        <td>Column Text</td>
        <td>Column Text</td>
        <td>Column Text</td>
    </tr>
    <tr>
        <td>3</td>
        <td>Column Text</td>
        <td>Column Text</td>
        <td>Column Text</td>
        <td>Column Text</td>
    </tr>
    <tr>
        <td>4</td>
        <td>Column Text</td>
        <td>Column Text</td>
        <td>Column Text</td>
        <td>Column Text</td>
    </tr>
</table>
  <div class="control-buttons">
        <input type="button" class="CommandButton" value="Save" />
        <input type="button" class="CommandButton" value="Cancel" />
        <input type="button" class="CommandButton"value="Reset" />
        <input type="button" class="CommandButton" value="<< Previous" />
        <input type="button" class="CommandButton" value="Next >>" />
    </div>

_Layout

@{
    ViewBag.Title = "_MainLayout";
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>@ViewBag.Title - My ASP.NET MVC Application</title>
    <link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
    <meta name="viewport" content="width=device-width" />
    <link href="~/Content/website.css" rel="stylesheet" />
    @Styles.Render("~/Content/css")
    @Scripts.Render("~/bundles/modernizr")
</head>
<body>  
    <div class="Wrapper">
        <div class="PageHeader">
            <div class="Menu">
                <nav>
                    <ul id="menu">
                        <li>@Html.ActionLink("Home", "Index", "Home")</li>
                        <li>@Html.ActionLink("About", "About", "Home")</li>
                        <li>@Html.ActionLink("Contact", "Contact", "Home")</li>
                    </ul>
                </nav>
            </div>          
        </div>
        <div class="Content">
            @RenderBody()
        </div>
        <hr />
        <div class="PageFooter">
            <p>&copy; @DateTime.Now.Year - Eligibility Configuration</p>
        </div>
    </div>
</body>

</html>


.CSS

.Wrapper {
    background-color: #fff;
    padding:10px;
}

.PageHeader {
    color: #000;
    font-size: 25px;
    text-align: left;
    vertical-align: middle;
    width: 100%;
}

.Menu {
    color: #000;
    font-size: 15px;
    text-align: right;
    vertical-align: middle;
    width: 100%;
}

.PageTitle {
    color: #056af6;
    font-size: 20px;
    text-align: left;
    vertical-align: middle;
    width: 100%;
}

.BreadCrumb {
    color: #0a84fa;
    font-size: 10px;
    text-align: left;
    vertical-align: middle;
    width: 100%;
    padding-right:50px;
}

.Content {
    background-color: #fff;
    width: 100%;
 
}

.PageFooter {
    width: 100%;
    background-color: #000;
    height: 25px;
    color: #fff;
    font-size: 10px;
    text-align: center;
    vertical-align: middle;
}
.lable {
    width:200px;
   word-wrap:normal;
   float:left;
   text-align:left;
   vertical-align:middle;
   height:31px;
 
}.control {
   width:200px;
   float:left;
   text-align:left;
   vertical-align:middle;
 
}
.control-buttons {
    width:98%;
    text-align:right;

}
.CommandButton {
    background-color:#b2b2b2;
    color:black;
}
.CommandButton:hover {
    background-color:#f1ecec;
    color:black;
}


Wednesday 5 March 2014

Developer Guide - SCRUM Process

What is agile scrum (sprint) process?
Scrum is a software development process. In today’s rapid world stakeholders want immediate return on their investments. They don’t want to wait for longer periods to get full featured product. As a result, nowadays new software development and testing framework are catching momentum i.e. Scrum approaches.

In scrum, projects are divided in small features to be developed and tested in specific time-frames called as sprint (small cycles). Features should get developed and tested in specified small time-frames.  This agile scrum team is handled by scrum master.

Scrum is an iterative, incremental framework for projects and products or application development. Scrum has become more and more popular software development and testing framework among organizations. Many small to large sized IT companies have started to embrace Scrum framework, as this can create excellent quality products in less time than other traditional methodologies. This framework can save companies both time and money.


Source: ScrumAlliance



Soft Skills for a Scrum Team:
What Soft Skills are required to be a Successful Scrum Team?

When we start our regular (Agile) sprints (Cycles of work), we usually find some of the challenges with our team members. These challenges are not part of technical difficulties.  It usually occurs with team member’s mindset or their soft skills.  Many successful Scrum projects taught us that the success of scrum depends on how team members support whole heartedly towards the Sprint.
Let us discuss some of the pre-requisite soft skills for a Scrum Team.

Cross functional Team work is at the heart of Scrum.  There is no “my work”, “I have finished my work” and “your work”. On a Scrum team we find only “Our work”, “we have completed our Sprint”.  Individuals will have helping tendency for sharing technical knowledge. Scrum Members are always available to team members rather than locked away behind closed doors.  Scrum Master will always motivate the teams and create a Supporting learning environment. Team will always be sprint-oriented and often discuss smooth run of the sprint. A scrum team’s job is to self-organize around the challenges and management’s job is to remove impediments to self-organization.
Good communication must exist among team members of development team, testing team, business analysts and stake holders. There must be highly collaborative interaction between client and the delivery teams. More client involvement implies more suggestions or changes from the client.  It implies more bandwidth for communication.
Commitment
Agile Teams needs periodic re-energizing to renew their commitments to their purpose and to each other.  Scrum Masters can help by ensuring that the team embraces the concept of whole-team responsibility and whole-team commitment to deliver working software at the end of each sprint. With the whole-team commitment, the team member who has completed his tasks will help the one who has not completed so that hopefully each finishes on time.
Problem Solving
Scrum does not simply focus on developing just any type of end product.  Instead, the Scrum method allows the team to focus on creating a product that fulfils the customer’s highest value priorities which are defined by product owners.
Transparency
Transparency among team members and management gives a real momentum to the scrum team. Scrum Master encourages people to ask for help, surface roadblocks, and give public recognition for those brave enough to do so. At the same time, Scrum Master also understands the time wasted and impact on the team when individuals sit on or ignore problems.
Scrum Result
If scrum team follows some of above said soft skills, team velocity will increase significantly.  In turn, customers will appreciate the results or updates – and also can react quickly to any potential problems. Team can deliver high value software features in a short time period keeps everyone on top of changing business conditions.


Thursday 20 February 2014

AJAX

Getting Started With AJAX

This is the first installment of a new online column for Visual Studio Magazine. The column will focus on several key .NET technologies, including ASP.NET AJAX, Silverlight, XML and Web services. It'll provide short to-the-point articles from which you can quickly and easily glean information.
In this article, I'll introduce AJAX, walking you through the concepts behind it, demonstrating how it works, and explaining why you may want to use it in your ASP.NET Web sites.

What Is AJAX?

AJAX, or Asynchronous JavaScript and XML, is an acronym for many technologies, rather than a single technology. It has been around for many years. Back in the old days, you could implement AJAX principles by using remote scripting (which relied on a Java Applet), the Internet Explorer 5 Web Service Behavior (which relied on JavaScript and the XMLHttpRequest object), or IFrames.


Today, most Web applications send data to a server by performing postback operations that reload the entire page. For example, if you click on a button or select an item from a drop-down list, you will see the page reload, even though you may have only requested a small amount of new information.

When Internet Explorer 5 was released, it enabled you to build Web applications that sent requests to the server without requiring full postback operations and page reloads. Instead, you could use it for "partial page updates" or updates to specific parts of a page. Partial page updates offered better performance times and created happier end users.

All modern browsers (including Internet Explorer, FireFox, Safari and Opera) provide partial page updates by supporting AJAX capabilities. AJAX describes the process during which Web pages leverage JavaScript, the XMLHttpRequest and Dynamic HTML (DHTML) to make asynchronous calls to a server and update parts of a page when a response is received. Asynchronous AJAX calls are one or more calls made to a server while a user interacts with a browser that is performing other actions. Making these calls results in richer applications that look and feel more like desktop applications.

While AJAX sounds good in principle, it can be problematic to implement across multiple browsers. Internet Explorer 5 and Internet Explorer 6 rely on built-in ActiveX controls to make AJAX calls, whereas FireFox, Safari, Opera and Internet Explorer 7 use a built-in JavaScript XMLHttpRequest object. To write cross-browser AJAX code, you must understand JavaScript and the different ways browsers can call a server asynchronously.

Listing 1 shows a simple example of how you can make a cross-browser AJAX call to add two numbers and show the result. As you look through the code in Listing 1, you'll see that the GetXmlHttp() function performs several checks to determine how to properly create the XMLHttpRequest object and use it based upon the browser. You can write this code several ways, including using try/catch blocks to load a particular XMLHttpRequest object.

XMLHttpRequest Object in Different Browsers
Listing 1. Accounting for differences in how browsers use the XMLHttpRequest object can be painful. This listing shows a simple cross-browser example of how you can make AJAX requests using the XMLHttpRequest object. The complete code for this example is available in the article's code download.

<script type="text/javascript">
    var xmlHttp = null;
    function Add()
    {
       var x = document.getElementById("txtX").value;
       var y = document.getElementById("txtY").value;
       
       //Create params string to be posted to server
       var params  = encodeURI("x=" + x + "&y=" + y);
       
       xmlHttp = GetXmlHttp("POST","XmlHttpHandler.ashx");
       xmlHttp.onreadystatechange = OnStateChange;
       xmlHttp.send(params);
    }
    
    function OnStateChange()
    {
       if (xmlHttp.readyState == 4)
       {   
           if (xmlHttp.status == 200)
           {
              document.getElementById("lblResult").innerHTML = 
                xmlHttp.responseText;
           }
       }
    }
    
    function GetXmlHttp(verb,url)
    {
       var request = null;
       //Create XmlHttpxmlHttp object
       var ua = navigator.userAgent.toLowerCase();
       if (window.XMLHttpRequest) //IE7, Safari, Mozilla
       {
           request = new XMLHttpRequest();
       }
       else //IE5, IE6
       {
           if (ua.indexOf('msie 5') == -1)
             request = new ActiveXObject("Msxml2.XMLHTTP");
           else
             request = new ActiveXObject("Microsoft.XMLHTTP");
       }
       request.open(verb.toUpperCase(),url,true);
       if (verb.toUpperCase() == "POST") 
           request.setRequestHeader("Content-type", 
             "application/x-www-form-urlencoded");
       return request;
    }
</script>

Fortunately, you can rely on one of many AJAX frameworks to avoid the complexities of writing AJAX code. Microsoft's recently released ASP.NET AJAX Extensions is a very useful framework. It can greatly simplify the amount of work you have to complete to AJAX-enable a Web page.

ASP.NET AJAX Options

Microsoft has three options for adding AJAX functionality into new or existing Web sites, all of which can be downloaded for free at http://ajax.asp.net. These options include ASP.NET AJAX Extensions, ASP.NET AJAX Control Toolkit and ASP.NET AJAX Futures.


ASP.NET AJAX Extensions provides a complete framework for working with AJAX technologies. It includes a client-side script library as well as several server-side ASP.NET controls. This framework extends existing ASP.NET functionality and provides a familiar development environment for existing ASP.NET application developers. By using the framework, you can AJAX-enable new or existing Web sites with limited understanding of JavaScript and the XMLHttpRequest object.

With the ASP.NET AJAX Control Toolkit, Microsoft released over 30 AJAX-enabled ASP.NET server controls. These controls can perform a variety of AJAX functions, including showing specialized modal pop-ups, reordering lists using drag-and-drop functionality, adding watermarks to textboxes, providing hover menus and more. The toolkit controls are available in a single assembly that can be dropped into your ASP.NET application's bin folder.

Finally, for those of you who like to stay on the cutting edge, Microsoft has also released ASP.NET AJAX Futures. This download contains future AJAX technologies that aren't officially supported in production environments yet. If you're interested in seeing what may be coming, then you can try out this release, but keep in mind that its documentation is limited at this point.


While AJAX is only an acronym, the technologies it references provide a great way to enhance new or existing Web sites, making them more rich, user-friendly and efficient. AJAX can be difficult to implement across different browsers, but AJAX frameworks, such as ASP.NET AJAX, are available to ease the development process. In the next column, I'll show you how to get started using the ASP.NET AJAX Extensions. 

Glossary for WCF

Address
The location at which a WCF service can be found. The address incorporates a protocol and URI.

Not dependent on timing. Each application or command runs in the specified order, but the specified item does not wait for any previously started processes to finish before an application or command runs.

A method call that returns to the caller immediately regardless of whether processing has completed. The results of processing are returned through another call on another thread. Asynchronous methods free the caller from having to wait until processing has finished.

In .NET Framework security, the process of discovering and verifying the identity of a principal by examining the user's credentials against some authority.

In .NET Framework security, the process of limiting access rights by granting or denying specific permissions to an authenticated identity or principal.
B
Behavior
In WCF, a way of customizing the behavior of a client or service.

In WCF, the transport-level details that define how a client interacts with a service.
C
Claim
In security, claims are pieces of information held within a credential.

The behavior and state that a class provides, which is matched with what a client of that class can expect to hold. A contract is expressed partly by the signatures for all public fields, methods, properties, and events of that class. This is augmented by a description (usually in simple descriptive text) of what each field or property represents, together with what each method does.

In security, a credential carries information about a caller, and is used for authentication.
D
Duplex
When applied to a WCF contract, indicates independent two-way communication between client and service.
E
Encoder
A class that converts a message into bytes for transmission.

A combination of address, binding and contract.
N
NAT
Network Address Translator. Hardware or software that hides local network addresses behind a single IP address, translating incoming and outgoing packets as necessary.
S
SAML
Security Access Markup Language provides a way to attach credentials to a message.

In WCF, the way in which a message is secured. Transport mode uses the security of the transport, while message mode secures the message itself.

Applications that expose services through interfaces and contracts. Service oriented applications benefit from being loosely coupled.

A simple, XML-based protocol for exchanging structured and type information on the Web. The protocol contains no application or transport semantics, which makes it highly modular and extensible.
T
Transport

The underlying communication protocol. WCF supports three transports: HTTP, TCP and Named Pipes.

Introduction to WCF Security

How to Configure Message-Based Security

In this demo, we will see how to secure a Windows Communication Foundation Service.
We will also see how to use the service trace utility provided by the Windows SDK to inspect service messages.

Now, what we have here is a very simple application for applying customer credits. This application makes a call to a WCF service for performing the transaction.

And if we look at the application, we can see in the btnApplyCredit_Click event handler, that we are creating a request object which contains account, amount, and transaction ID information.

We then invoke the service and receive a response as to whether or not the transaction was approved.
Let’s run the application. Now we will enter an account number, an amount to be credited, hit apply, and we see that the transaction was successful.

Now let’s take a quick look at the service.

Our service utilizes data contracts for the request and response objects.

As to the service itself, we see that we have an ICredit that defines a credit account method.

Now, our credit service implements the ICredit interface, credit account simply takes the request passed in and creates a response that approves the transaction.

Let’s go enable encryption for our service and also view our service messages in the service trace viewer.
We will go to the binding, we will go to the security tab, and we will specify message level security.

Now, because we are working within a windows domain, we can leave the MessageClientCredentialType set to Windows, and allow Windows to handle the encryption scheme for us.

We will save the config, and now we will go set the security on our client.

We will go to the security tab, we will set the mode to message, just as we did for the service, and now we will enable MessageLogging under Diagnostics.

Once we have enabled message logging it will automatically create a diagnostic source and listener.
If we want to change the location of the output files, we can click on the listener link and change the name.
In this case, we will change it now to c:\wcf logs\credit_service.svclog.

Also, we are going to set message logging to log the entire message so that we can see both the header and the message content.

Now we can save our configuration changes, compile, and run the application.

Now we can see that the application runs successfully without throwing an exception and that our transaction was approved.

Now let’s take a look at our log file in the service trace utility.

When we look at the messages now, we can see that the data for our request and our response is no longer being passed in clear text, but is now encrypted.

So now we have taken care of encrypting our message. However, anyone can access our service, so let’s use WCF to secure the service so only authorised users can invoke it.

So what I am going to do now is add a using statement, for System.Security.Permissions, and now what I am going to do is set permissions on my credit account method, so that only those who are members of the service users group can access it.

And I will do this by using a principal permission attribute setting the security action to demand, and the role equal to service users.

Now because we are not a member of the service users group, the call to this method should fail at runtime.
I will save my application, recompile, then I will run my application; perform my transaction for one final time.
So now you see we have received a security exception because we did not have the proper permissions to invoke this method on the service.

Customizing WCF with Behaviors

How to Configure WCF Behaviors

In this demonstration, you will see how to apply the instancing attributes to your behaviors for your Windows Communication Foundation service. For this demonstration we have an existing application that consists of a service and a client.

The service is hosted on Internet Information Server as a web service.

We have two contracts, or two interfaces in our service, one is a calculator, which has the four standard mathematical methods, add, subtract, multiply, and divide.

We also have an ICalculator instance which implements the ICalculator and this will be responsible for providing us with our ContextMode InstanceId and operationCount values.

Notice that each one of these two contracts of the interfaces in our service have the SessionMode equals SessionMode.Required.

We specify this so that when a client accesses it, we indicate the necessary type of session mode that we wish in our service, and the client will then see that behavior from our service as it is executed.

So very quickly we will take a look at our CalculatorService class which implements our ICalculator instance interface, and we see that we have a static instanceCount variable, and we will see how that plays into our client application as we execute it and we will see those values increment accordingly.

The CalculatorService in the constructor will simply implement our instanceCount and sets the InstanceId equal to the instanceCount and then we have our four methods add, subtract, multiply, and divide, and then for our ICalculator instance, we implement the GetInstanceContextMode method here, our GetInstanceId method, and our GetOperationCount method in here.

So, one of the first things that we need to do is to make sure that we have the appropriate attribute uncommented in our code.

The first one we will make use of is the PerSession attribute, where the PerSession will create an instance per channel session.

So, if we take a look at our client application, it is a console based application, we create an instance of our calculator instance client.

We then get the instance mode from the GetInstanceContextMode, write that value out to our screen, and then start calling the methods and new calculations.

Notice in the first one, that we are using a client called client, so this is our first instance, and for the second instance we will have a client called client2.

We will call the new calculations with client1 and then client2, closing outer clients here, and writing out the necessary information to terminate the client information.

And the new calculations simply call each one of our operations, add service, subtract service, multiply service, we pass in the necessary values, we call the add method, or we call the subtract method as appropriate.

In our output we will write out values that we are going to be adding, subtracting, multiplying or dividing, the result. We will grab the client.InstanceId and GetOperationCount.

So, let’s go ahead and run our client application, and we will see what our first generated output results in.
So here we have used PerSession, as you can see, InstanceContextMode indicates PerSession, we see that we have called the add method, passed in the two values, got a result back, notice our InstanceId is one, and our operationCount is one.

So we have called add, subtract, multiply, and divide, all from instance one and we can see that with the instance IDs.

For each one of these same instances that we have called, we see that our operationCount increments.
Then we went ahead and used client2 to call the same methods again, notice that our instance ID has now changed to two, and that each of our operationCounts has been incremented again within that instance.
So you can see that we have really established two sessions here, and each one of the sessions maintained its own operationCount.

Let’s go ahead and terminate that client, we will come back to our service, and we will comment out the PerSession call and we will now change our attribute to a PerCall InstanceContextMode.
Note that when we change these because we have made changes in the actual attribute that is applied to the service, we need to rebuild that service one more time, and now we can go ahead and run our client application on a PerCall basis.

Notice that our InstanceContextMode indicates that we have executed a PerCall, and you will also note as we take a look at the InstanceId for each method call, regardless of the client that called it, the InstanceId has changed.

So each time we have made a call with a client, regardless of which client it was, we have actually generated a new InstanceId for each and every call.

Also take note, that because the instance changes for every call, the operationCount never gets incremented and always remains at zero. So, once again this is the client using the PerCall method.

Let’s go ahead and terminate that client. And for the final part, comment out our PerCall attribute, uncomment the Single, rebuild our service one more time, and we will start the client application again.
So our InstanceContextMode now, has been changed to Single, again we are still calling the same operations, but you will notice that regardless of the client that is making the call, and regardless of the method that is being called, our InstanceID remains at one, so this is a single instance that is servicing all clients, and you will also notice that the operationCount increments from beginning to end regardless of the number of clients that are actually calling it.

So if we were to add client3, and have client3 call one of these methods again, our InstanceID will still remain as one, but we would also notice the values of nine, ten, eleven, and twelve in our operationsCounts incremented.


So in this demonstration, you have seen how to apply the three different attributes to a service behaviour for your Windows Communication Foundation service.