February 12, 2017

Just Overview

.NET is a big umbrella. I see a lot of growth in MVC 4 and 5. Plus with the introduction of C#6 , SignalR 2

Single-Page Applications (SPAs) are Web apps that load a single HTML page and dynamically update that page as the user interacts with the appSPAs use AJAX and HTML5 to create a fluid and responsive Web apps, without constant page reloads. However, this means much of the work happens on the client side, in JavaScript.
Decrease load time and/or weight


Web Farm: When you are hosting your single web site on multiple web servers over load balancer is called “Web Farm”

Application pool is used to separate sets of IIS worker processes and enables a better security, reliability, and availability for any web application.

Web Garden: by default, each and every Application pool contains a single worker process. Application which contains the multiple worker processes is called “Web Garden”

IP Address + Port Number: Here each port number is allocated with particular web application

RTM : Release to Manufacture (old term) 
RTM is a throwback to the days when software was mostly released as CDs. When a project went "Gold", it was released to manufacturing who then burned a bunch of CDs and packaged them up to be put on store shelves. True, this still goes on today believe it or not, but this mode of delivery is on the decline for certain types of software.

RTW: Release to Web
RTW is a related term that stands for "Released to Web" which is more descriptive of how software is actually shipped these days. 


PHONEGAP is the technology which combines best of both the worlds. Means, it will take the frontend codebase (Html5, Css3, Javascript Libraries) and will create a Build based on target operating system. Thus converting the Web based code into Native App
 http://pratapreddypilaka.blogspot.in/2013/03/introduction-to-phonegap.html

Xamarin : Creating Apps in C# for Android,iOS and Mac
A free, full-featured and extensible IDE for Windows users to create Android and iOS apps with Xamarin, as well as Windows apps, web apps, and cloud services.


Web sockets are defined as a two-way communication between the servers and the clients, which mean both the parties, communicate and exchange data at the same time. This protocol defines a full duplex communication from the ground up. Web sockets take a step forward in bringing desktop rich functionalities to the web browsers. It represents an evolution, which was awaited for a long time in client/server web technology.

Awesome link to learn more about web sockets
http://blog.teamtreehouse.com/an-introduction-to-websockets


HTML5 is a markup language used for structuring and presenting content on the World Wide Web. It is the fifth and current version of the HTML standard.It come with many features.
Last version HTML4 came in 1997.


jQuery UI is set of user interface interactions, effects, widgets, and themes built on top of the jQuery JavaScript Library.Whether you're building highly interactive web applications or you just need to add a date picker to a form control



ASP.NET SignalR is a library for ASP.NET developers that simplifies the process of adding real-time web functionality to applications. Real-time web functionality is the ability to have server code push content to connected clients instantly as it becomes available, rather than having the server wait for a client to request new data.


REST : Representational State Transfer
it is an architectural pattern for creating an API that uses HTTP as its underlying communication method.it is primarily used to build Web services that are lightweight, maintainable and scalable.

A RESTful API is an application program interface (API) that uses HTTP requests to GET, PUT, POST and DELETE data. Representational state transfer (REST), which is used by browsers, can be thought of as the language of the Internet. 

ASP.NET Core is a open-source and cross-platform framework for building modern cloud-based Internet-connected applications, such as web apps, IoT apps and mobile backends. It was architected to provide an optimized development framework for apps that are deployed to the cloud or run on-premises Required: Visual studio 2015 


Application Programming Interface is important for keeping the common thing centrally


Parallel Linq / Task-based Async Programming

What is Core ?
Each core displayed as a separate graph under the "CPU Usage History" section so count of graphs is the total core (processor) count for system.
--------------------------------------------------------------------------
Processor -> Core
Process - > Thread -> Handle
--------------------------------------------------------------------------

Parallel LINQ (PLINQ)

It's a way to run LINQ queries in parallel on multi-core/multi-processor systems, in order to speed them up.

IEnumerable<int> parallelResults =
from item in sourceData.AsParallel()
where item % 2 == 0
select item;
foreach (int item in parallelResults)
{
Console.WriteLine("Item {0}", item);
}

Result would not be come in proper sorting order but if we remove AsParallel(),It will give proper sequential order.

--------------------------------------------------------------------------

Task-based Async Programming


task resembles a thread or ThreadPool work item, but at a higher level of abstraction. The term task parallelism refers to one or more independent tasks running concurrently.

using System;
using System.Threading;
using System.Threading.Tasks;

public class Example
{
   public static void Main()
   {
      Thread.CurrentThread.Name = "Main";

        // Create a task and supply a user delegate by using a lambda expression. 
        Task taskA = new Task( () => Console.WriteLine("Hello from taskA."));
        // Start the task.
        taskA.Start();

        // Output a message from the calling thread.
        Console.WriteLine("Hello from thread '{0}'.", 
                          Thread.CurrentThread.Name);
        taskA.Wait();
   }
}
// The example displays output like the following:
//       Hello from thread 'Main'.
//       Hello from taskA.
--------------------------------------------------------------------------

December 16, 2016

Javascript vs Jquery


  • jQuery in itself is written in JavaScript.
  • JavaScript was first appeared on 1995 while jQuery was initially released in August 26, 2006.
  • JavaScript is an Object Oriented Programming (OOP) language while jQuery is a cross-platform JavaScript library designed to simplify the client-side scripting of HTML.
  • JavaScript is a scripting language that works with all web browsers while jQuery is only a framework that is a fast and concise JavaScript library that simplifies the HTML document.
  • In case of using JavaScript you are required to writer your own script that can be time consuming. In case of using jQuery you are not required to write much scripting that already exists in libraries.
  • JavaScript is combination of both ECMA script and DOM while jQuery has DOM.
  • JavaScript has many processes in creating web-based applications while creating a web-based application with the help of jQuery has become easier.
  • Animations are not possible using JavaScript while these can be easily created using jQuery
  • jQuery support only Firefox, Google Chrome, Safari, Opera, and Internet Explorer while JavaScript is supported by all major web browsers without plug-ins.
javascript Jquery
function changeBackground(color) {
   document.body.style.background = color;
}
onload="changeBackground('red');"
$('body').css('background', '#ccc'); 
document.getElementById("example") $('#example')
document.getElementsByClassName("example") $('.example')
document.getElementById("btn")
.addEventListener("click", function () {
    document.getElementById("txtbox").value = "Hello World";
});
$('#btn').click(function () {
    $('#txtbox').val('Hello World');
});

datetime code


Dim dateString, format As String
dateString = "MM" & "/" & dd & "/" & yyyy & " " & HH & ":00"
dateString = dateString.Replace("-", "/")

Dim provider As CultureInfo = CultureInfo.InvariantCulture
format = "MM/dd/yyyy HH:mm:ss"
Try
   fromdate = Date.ParseExact(dateString, format, provider)
Catch ex As FormatException
   ShowAlert(ex.Message)
End Try

Generate Captcha in asp.net



Page : GenerateCaptcha.aspx

        protected void Page_Load(object sender, EventArgs e)
        {
            ClsWorkFlow objwork = new ClsWorkFlow();
            string strCaptcha = objwork.Decrypt(Request.QueryString["cap"]);

            Response.Clear();
            int height = 30;
            int width = 100;

            Bitmap bmp = new Bitmap(width, height);
            RectangleF rectf = new RectangleF(10, 5, 0, 0);
            Graphics g = Graphics.FromImage(bmp);
            g.Clear(Color.White);
            g.SmoothingMode = SmoothingMode.AntiAlias;
            g.InterpolationMode = InterpolationMode.HighQualityBicubic;
            g.PixelOffsetMode = PixelOffsetMode.HighQuality;
            Font f = new Font("Thaoma", 12, FontStyle.Italic);
            g.DrawString(strCaptcha, f, Brushes.Red, rectf);
            g.DrawRectangle(new Pen(Color.Red), 1, 1, width - 2, height - 2);
            g.Flush();
            Response.ContentType = "image/jpeg";
            bmp.Save(Response.OutputStream, ImageFormat.Jpeg);
            g.Dispose();
            bmp.Dispose();
        }

Call the page 

        public void FillCapctha()
        {
            try
            {
                Random random = new Random();
                string combination = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
                StringBuilder captcha = new StringBuilder();
                for (int i = 0; i <= 6; i++)
                {
                    captcha.Append(combination[random.Next(combination.Length)]);
                }
                ViewState["captcha"] = captcha.ToString();
                helper obj = new helper();
                ClsWorkFlow objwork = new ClsWorkFlow();
                imgCaptcha.ImageUrl = "GenerateCaptcha.aspx?cap=" + ViewState["captcha"].ToString();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

November 25, 2016

Javascript validation and useful methods

Perfect Calendar in textbox with some validation


<asp:TextBox ID="txtFromDate" CssClass="Textbox" runat="server" ValidationGroup="Report"
Width="120px" onkeyup="if(this.value != ''){this.value = '';confirm('Please select from calendar.');}return false;"></asp:TextBox>

 <asp:RequiredFieldValidator ID="rfvtxtFromDate" runat="server" ErrorMessage="Enter From Date"
                        ControlToValidate="txtFromDate" ValidationGroup="Report">*</asp:RequiredFieldValidator>

<cc1:CalendarExtender ID="ceFromDate" runat="server" TargetControlID="txtFromDate"
Format="dd/MM/yyyy"></cc1:CalendarExtender>

On Key Up event


function validateAplabeticValue(that) {
            var re = /[^a-z.\s]/gi;

            if (re.test(that.value)) {
                that.value = that.value.replace(re, '');
                alert('Enter only alphabetic value');
            }
        }

  <asp:TextBox ID="txtExtstakhld" runat="server" 
onkeyup="validateAplabeticValue(this);"
MaxLength="30" Width="300px"></asp:TextBox>

Check javascript enable or not


 <noscript>
        <div>
            You must enable javascript to continue.
        </div>
    </noscript>

if you are using old browser then run the below script
 <!--[if lt ie 9]>
<script type="text/javascript">
alert("You are using old IE version, Please upgrade to the latest");
         window.location="http://windows.microsoft.com/en-IN/internet-explorer/download-ie";
</script>
<![endif]-->


Allow Only Alphabets


var specialKeys = new Array();
specialKeys.push(0); //Tab for Firefox
specialKeys.push(8); //Backspace
specialKeys.push(9); //Tab
specialKeys.push(32); //Space
function onlyAlphabets(e, t) {
    try {
        if (window.event) {
            var charCode = window.event.keyCode;
        }
        else if (e) {
            var charCode = e.which;
        }
        else { return true; }
        if ((charCode > 64 && charCode < 91) || (charCode > 96 && charCode < 123))
            return true;
        else {

            for (var num in specialKeys) {
                if (charCode == specialKeys[num])
                    return true;
            }
            return false;
        }
    }
    catch (err) {
        alert(err.Description);
    }
}


Allow Only Alphabets


function onlyAlphabetsNoSpace(e, t) {
    try {
        if (window.event) {
            var charCode = window.event.keyCode;
        }
        else if (e) {
            var charCode = e.which;
        }
        else { return true; }
        if ((charCode > 64 && charCode < 91) || (charCode > 96 && charCode < 123))
            return true;
        else {
            for (var num in specialKeys) {
                if (specialKeys[num] == 32)
                    return false;
                if (charCode == specialKeys[num])
                    return true;
            }
            return false;
        }
    }
    catch (err) {
        alert(err.Description);
    }
}


<asp:TextBox runat="server" ID="txtidfirstname" MaxLength="12" CssClass="txt-box-full" 
onkeypress="return onlyAlphabetsNoSpace(event,this);" ondrop="return false;" onpaste="return false;" />


 function validateAplabeticValue(that) {
            var re = /[^a-z.\s]/gi;

            if (re.test(that.value)) {
                that.value = that.value.replace(re, '');
                alert('Enter only alphabetic value');
            }
        }

Allow alphanumeric


function IsAlphaNumeric(e) {

    var keyCode = e.keyCode == 0 ? e.charCode : e.keyCode;
    var ret = ((keyCode >= 48 && keyCode <= 57) || (keyCode >= 65 && keyCode <= 90) || (keyCode >= 97 && keyCode <= 122) || (specialKeys.indexOf(e.keyCode) != -1 && e.charCode != e.keyCode));
    if (ret) {
        return true;
    } else {
        for (var num in specialKeys) {
            if (keyCode == specialKeys[num])
                return true;
        }
        return false;
    }
}


Allow Decimal Number


function isNumberDecimalKey(evt) {
    var charCode = (evt.which) ? evt.which : event.keyCode;
    if (charCode != 46 && charCode > 31 && (charCode < 48 || charCode > 57)) {
        return false;
    } else {
        // If the number field already has . then don't allow to enter . again.
        if (evt.target.value.search(/\./) > -1 && charCode == 46) {
            return false;
        }
        return true;
    }
}


Allow Number


function isNumber(evt) {
    evt = (evt) ? evt : window.event;
    var charCode = (evt.which) ? evt.which : evt.keyCode;
    //if (charCode > 31 && (charCode < 48 || charCode > 57)) {
       
    //    return false;
    //}
    //return true;
    if (charCode > 47 && charCode < 58) {
        return true;
    } else {
        for (var num in specialKeys) {
            if (charCode == specialKeys[num])
                return true;
        }
        return false;
    }
}

Change the Value of other control


    function ddlPan() {
        var ddl = document.getElementById("<%=ddlPAN.ClientID%>");
        var SelVal = ddl.options[ddl.selectedIndex].value;
        if (SelVal == "N" || SelVal == "") {
            document.getElementById("<%=txtPANNumber.ClientID%>").value = "";
            document.getElementById("<%=txtPANNumber.ClientID%>").disabled = true;
        }
        else
            document.getElementById("<%=txtPANNumber.ClientID%>").disabled = false;
    }


    <asp:DropDownList runat="server" ID="ddlPAN" CssClass="dropdown-box-full" onchange="ddlPan()">

November 8, 2016

Common model popup for all the pages

we can use common model popup for all pages

Master Page Code snippet

 <cc1:ModalPopupExtender ID="mppopup" runat="server" BehaviorID="modalpopup" BackgroundCssClass="backgroundmodal"
            TargetControlID="btnpopup" CancelControlID="btnCancel" OkControlID="btnOkay"
            PopupControlID="panelmodal">
        </cc1:ModalPopupExtender>
        <asp:Button runat="server" ID="btnpopup" OnClick="btnpopup_Click" Text="PopUp" CssClass="hide" /><!--dummy button-->
        <asp:Panel ID="panelmodal" Style="display: none" CssClass="modal-dialog" runat="server">
            <div class="modal-content">
                <div class="modal-header">
                    <h4 class="modal-title" runat="server" id="myModalheader">Alert</h4>
                </div>
                <div class="modal-body">
                    <div class="alert-content">
                        <p runat="server" id="palertmessage">Hello, this is an alert</p>
                    </div>
                </div>
                <div class="modal-footer">
                    <asp:Button ID="btnOkay" runat="server" Text="Ok" CssClass="btn-small" UseSubmitBehavior="true" OnClientClick="javascript:skipLN();" />
                    <asp:Button ID="btnCancel" runat="server" Text="Can" CssClass="btn-small" UseSubmitBehavior="true" OnClientClick="javascript:skipLN();" />
                </div>
            </div>
        </asp:Panel>


class - find the control from master page and did the dynamic activity

public void CallModalPopup(MasterPage master, string RedirectPageName, string AlertBody, string AlertHeader = "Notification", string OKtext = "OK", string CanText = "CANCEL", bool ShowOk = true, bool showCancel = true, bool skipLN = true)
        {

            AjaxControlToolkit.ModalPopupExtender mp = (AjaxControlToolkit.ModalPopupExtender)master.FindControl("mppopup");

            System.Web.UI.HtmlControls.HtmlGenericControl body = (System.Web.UI.HtmlControls.HtmlGenericControl)master.FindControl("palertmessage");

            System.Web.UI.HtmlControls.HtmlGenericControl header = (System.Web.UI.HtmlControls.HtmlGenericControl)master.FindControl("myModalheader");

            Button okay = (Button)master.FindControl("panelmodal").FindControl("btnOkay");
            Button cancel = (Button)master.FindControl("panelmodal").FindControl("btnCancel");

            okay.OnClientClick = "";
            if (RedirectPageName != "")
                if (RedirectPageName.Contains("window.open"))
                    okay.OnClientClick = RedirectPageName;
                else if (skipLN)
                    okay.OnClientClick = "javascript:skipLN();window.location.href='" + RedirectPageName + "'";
                else
                {
                    okay.OnClientClick = "window.location.href='" + RedirectPageName + "'";
                    HttpContext.Current.Session["UserID"] = "ERROR";
                }
            okay.UseSubmitBehavior = true;
            okay.Text = OKtext;
            okay.Focus();
            cancel.Text = CanText;
   
            if (!showCancel)
                cancel.Attributes.Add("style", "display:none !important;");
            body.InnerText = AlertBody;
            header.InnerText = AlertHeader;

            mp.Show();
   
        }

call from Page

CallModalPopup(this.Master, "", "You can register interest for upto 3 interest areas and job roles", showCancel: false);

November 6, 2016

WWF -Project structure

PROJECT STRUCTURE CHANGED AS FRAMEWORK CHANGED







Part 1: Windows workflow foundation (WWF)

WWF is workflow Framework for Microsoft product.

WF Framework is compose of library,Execution Engine, Rules engine, a number of activities, a number of supporting runtime services.

WF contains graphical debugger.

The engine is designed in such a way that the developer has a free choice between building the workflow as code constructs or in a declarative fashion using XAML. 

Workflow: A workflow models a process as a set of activities applied to work in progress.

A workflow is constructed from a number of activities, and these activities are executed at runtime.

A number of built-in activities can be used for general-purpose work, 
and you can also create your own custom activities and plug these into the workflow as necessary


Workflow Runtime Engine: 
Every running workflow instance is created and maintained by an in-process runtime engine that is commonly referred to as the workflow runtime engine. 

There can be several workflow runtime engines within an application domain. 

Each instance of the runtime engine can support multiple workflow instances running concurrently.

Because a workflow is hosted in-process, a workflow can easily communicate with its host application.


Why should we use ?

  • Can see workflow visually. (More understandable way)
  • Separation between business logic and its implementation
  • No Need to Complie the workflow as it is xml. This flexibility even goes further and the engine allows for the runtime alteration of the executing workflow.
  • Due to it is library,it is flexible to included in application or site.

Activities : Activities run like tree structure.
Activities have two types of behavior
Runtime: specifies the actions upon execution.
Designtime: controls the appearance of the activity and its interaction while being displayed within the designer. 

Services
The workflow runtime engine uses many services when a workflow instance runs. Windows Workflow Foundation provides default implementations of the runtime services that meet the needs of many types of applications, such as a persistence service, which stores the execution details of a workflow instance in a SQL database. These service components are pluggable, which allows applications to provide these services in ways that are unique to their execution environment. Other types of services used by the runtime engine include scheduling services, transaction services, and tracking services.

Custom services can be created to extend the Windows Workflow Foundation platform by deriving from the base service classes. An example of this would be a persistence service that uses an XML file instead of a database for storage.

Persistency :

Windows Workflow Foundation simplifies the process of creating stateful, long-running, persistent workflow applications. The workflow runtime engine manages workflow execution and enables workflows to remain active for long periods of time and survive application restarts. This durability is a key tenet of Windows Workflow Foundation. It means that workflows can be unloaded from memory while awaiting input and serialized into a persistent store, such as a SQL database or XML file. Whenever the input is received, the workflow runtime engine loads the workflow state information back into memory and continues execution of the workflow.

Windows Workflow Foundation provides the SqlWorkflowPersistenceService that integrates well with Microsoft SQL Server to persist workflow information easily and efficiently. You can also create your own persistence service to store workflow state information anywhere you want by deriving from the WorkflowPersistenceService base class. 

Tracking
Tracking is the ability to specify and capture information about workflow instances and store that information as the instances execute. Windows Workflow Foundation provides the SqlTrackingService, which is a tracking service that uses a SQL database to store the collected tracking information. You can also write your own tracking service to collect and store this information in any format that your application requires.

When a new workflow is created, the tracking service requests a tracking channel to be associated with that workflow. All of the tracking information from the workflow is then sent to this tracking channel.

The tracking service can track three types of events:
  • Workflow instance events
  • Activity events
  • User events
You can configure the type and amount of information that your service wants to receive for a particular workflow instance or types of workflow by providing a tracking profile.

The tracking framework also provides the ability to extract information about activities or the workflow during an event. If a specific property or field in your activity or workflow needs to be tracked, you can provide this information in the extracts section of the tracking profile, and that information will be extracted during the specified event. 

Serialization
Workflows, activities, and rules can be serialized and deserialized. This enables you to persist them, use them in workflow markup files, and view their properties, fields, and events in a workflow designer.

Windows Workflow Foundation provides default serialization capabilities for standard activities, or you can create your own for custom activities. For example, with a custom activity serializer, you can decide which members are serialized and how they are serialized. This determines if those members are visible or hidden in a workflow designer

October 31, 2016

Dynamic Data site in ASP.NET


If you want to do only CRUD operation on site then this is the best template
Dynamic Data supports scaffolding, which is a way to automatically generate Web pages for each table in the database. Scaffolding lets you create a functional Web site for viewing and editing data based on the schema of the data. You can easily customize scaffolding elements or create new ones to override the default behavior.


https://msdn.microsoft.com/en-us/library/ee845452.aspx

http://www.c-sharpcorner.com/UploadFile/Dorababu742/dynamic-data-entities-web-application/

http://www.dotnetcurry.com/ShowArticle.aspx?ID=232