Pages

The TransportManager failed to listen on the supplied URI using the NetTcpPortSharing service

If you are starting fresh to WCF and trying to run service, you might an issue like this:

The TransportManager failed to listen on the supplied URI using the NetTcpPortSharing service: failed to start the service because it is disabled. An administrator can enable it by running 'sc.exe config NetTcpPortSharing start= demand'..System.ComponentModel.Win32Exception (0x80004005): The service cannot be started, either because it is disabled or because it has no enabled devices associated with it


The exception message is self-explanatory:

NetTcpPortSharing service is disabled on the machine you are trying to run service on. You can enable service by:

Solution:


  • Open cmd and Type 
  • sc.exe config NetTcpPortSharing start= demand
  • Press Enter

Or

  • Open Run Type services.msc and click OK
  • In Services window find Net.Tcp Port Sharing Service
  • Go to Properties and change the Startup type to Manual. 

good luck!!!


jQuery Wait, Loading animation

When any type of jQuery process fire show waiting screen . You copy this code in Master page or your web page only. And show output.

Example :


<div class="WaitScreen">
</div>
<style type="text/css">
        .WaitScreen {
            display: none;
            position: fixed;
            z-index: 100000;
            top: 0;
            left: 0;
            height: 100%;
            width: 100%;
            background: rgba( 255, 255, 255, .4 ) url('https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQFEgxZRlEBM1TGgRTuKM_JPGnpR5iLi5YBVkIIP5zZz2SGCC0LQlEqnZXQWf1SiUEH9MI_d7MO29ztECollKuylzSdlpeRnG34GZJXGxo45Gho0JfRiGu8UwWlQrnjmH0Efp1R-XM4V8L/s1600/loading.gif') 50% 50% no-repeat;
        }
       

        body.loading {
            overflow: hidden;
        }

        body.loading .WaitScreen {
                display: block;
        }
    </style>
    <script type="text/javascript">

        $body = $("body");

        $(document).on({
            ajaxStart: function () { $body.addClass("loading"); },
            ajaxStop: function () { $body.removeClass("loading"); }
        });


    </script>

Move Over 10 lakh Rows in a MiliSecond in Sql Server

How to copy the contents of an entire table into another table? Traditionally speaking, we as developers will use SELECT INTO or a INSERT INTO statement to load a destination table. This is a still a great way of accomplishing the task at hand, but it is not nearly fast as what I am about to show you. The method I am about to show you is not for all scenarios, but it can be very handy.

Example :

USE [dbName]
GO

IF EXISTS(SELECT 1 FROM sys.tables WHERE NAME = 'TestData')
BEGIN
    DROP TABLE [dbo].[TestData];
END
GO
CREATE TABLE [dbo].[TestData](
 RowNum INT PRIMARY KEY,
 SomeId INT,
 SomeCode CHAR(2)
);
GO

INSERT INTO [dbo].[TestData]
SELECT TOP 10000000 
    ROW_NUMBER() OVER (ORDER BY t1.NAME) AS RowNumber,
    ABS(CHECKSUM(NEWID()))%2500+1 AS SomeId, 
    CHAR(ABS(CHECKSUM(NEWID()))%26+65)
    + CHAR(ABS(CHECKSUM(NEWID()))%26+65) AS SomeCode
FROM 
    Master.dbo.SysColumns t1,
    Master.dbo.SysColumns t2
GO

IF EXISTS(SELECT 1 FROM sys.tables WHERE NAME = 'NewTestData')
BEGIN
    DROP TABLE [dbo].[NewTestData];
END
GO

--Create New Table To Move Data To
CREATE TABLE [dbo].[NewTestData](
 RowNum INT PRIMARY KEY,
 SomeId INT,
 SomeCode CHAR(2)
);
GO
--Now the fun part……. behold the power of SQL Server!!!!!!!!!!!!!!!!
--Move data to the new table
SET STATISTICS TIME ON;
SET STATISTICS IO ON;

ALTER TABLE [dbo].[TestData] SWITCH to [dbo].[NewTestData];

SET STATISTICS TIME OFF;
SET STATISTICS IO OFF;
GO

/*
 SQL Server Execution Times:
   CPU time = 0 ms,  elapsed time = 0 ms.

 SQL Server Execution Times:
   CPU time = 0 ms,  elapsed time = 1 ms.
*/
--Next, I will verify the results.
SELECT COUNT(*) FROM [dbo].[TestData]; --0
SELECT COUNT(*) FROM [dbo].[NewTestData]; --10,000,000

/*
-----------
0
(1 row(s) affected)
-----------
10000000
(1 row(s) affected)
*/

Billiving - Online Billing Management System



This Application Developed in 2013

Technology Used

MVC, Knockout.js, Angular.js, Node.js, JQuery, Restful WEB APIs, Entity Framework, Repository Pattern, SQL Server 2012

In Sort this application is Online Billing Management System

Description : BILLIVING is a professional online invoicing service, designed for small businesses and freelancers to print invoices and documents online without any paper work. It saves time and money for various business owners to automate the process to print and generate documents online. It’s a paperless free scheme which users can incorporate into their business processes and also purchase the services to have more advanced features.

Key features

  • Documents
  • Branding
  • E-mail & Alerts
  • Reminders
  • Payments
  • Recurring
  • Bulk Invoicing
  • Currencies & Languages
  • Inventory
  • Catalog
  • Multiple Companies
  • Backup & Security
  • API

WEB API RESTful API

Web APIs has become an very important topic in the last year. We at M-Way Solutions are working every day with different backend systems and therefore we know about the importance of a clean API design.

Typically we use a RESTful design for our web APIs. The concept of REST is to separate the API structure into logical resources. There are used the HTTP methods GET, DELETE, POST and PUT to operate with the resources.

Good practices to design a clean RESTful API:

Use nouns but no verbs

For an easy understanding use this structure for every resource:

Resource GET read POST create PUT update DELETE
/cars Returns a list of cars Create a new ticket Bulk update of cars Delete all cars
/cars/711 Returns a specific car Method not allowed (405) Updates a specific ticket Deletes a specific ticket

Do not use verbs:

/getAllCars
/createNewCar
/deleteAllRedCars

GET method and query parameters should not alter the state

Use PUT, POST and DELETE methods instead of the GET method to alter the state.

Do not use GET for state changes:

GET /users/711?activate or
GET /users/711/activate

Use plural nouns

Do not mix up singular and plural nouns. Keep it simple and use only plural nouns for all resources.

/cars instead of /car
/users instead of /user
/products instead of /product
/settings instead of /setting

Use sub-resources for relations

If a resource is related to another resource use subresources.

GET /cars/711/drivers/ Returns a list of drivers for car 711
GET /cars/711/drivers/4 Returns driver #4 for car 711
 

Use HTTP headers for serialization formats

Both, client and server, need to know which format is used for the communication. The format has to be specified in the HTTP-Header.

Content-Type defines the request format.
Accept defines a list of acceptable response formats.

Use HATEOAS

Hypermedia as the Engine of Application State is a principle that hypertext links should be used to create a better navigation through the API.

{
  "id": 711,
  "manufacturer": "bmw",
  "model": "X5",
  "seats": 5,
  "drivers": [
   {
    "id": "23",
    "name": "Stefan Jauker",
    "links": [
     {
     "rel": "self",
     "href": "/api/v1/drivers/23"
    }
   ]
  }
 ]
}

Provide filtering, sorting, field selection and paging for collections

Filtering:

Use a unique query parameter for all fields or a query language for filtering.

GET /cars?color=red Returns a list of red cars
GET /cars?seats<=2 Returns a list of cars with a maximum of 2 seats

Sorting:

Allow ascending and descending sorting over multiple fields.

GET /cars?sort=-manufactorer,+model

This returns a list of cars sorted by descending manufacturers and ascending models.

Field selection

Mobile clients display just a few attributes in a list. They don’t need all attributes of a resource. Give the API consumer the ability to choose returned fields. This will also reduce the network traffic and speed up the usage of the API.

GET /cars?fields=manufacturer,model,id,color

Paging

Use limit and offset. It is flexible for the user and common in leading databases. The default should be limit=20 and offset=0

GET /cars?offset=10&limit=5

To send the total entries back to the user use the custom HTTP header: X-Total-Count.

Links to the next or previous page should be provided in the HTTP header link as well. It is important to follow this link header values instead of constructing your own URLs.

Link: https://yourdomain.com/sample/api/v1/cars?offset=15&limit=5; rel="next",
https://yourdomain.com/sample/api/v1/cars?offset=50&limit=3; rel="last",
https://yourdomain.com/sample/api/v1/cars?offset=0&limit=5; rel="first",
https://yourdomain.com/sample/api/v1/cars?offset=5&limit=5; rel="prev",

Version your API

Make the API Version mandatory and do not release an unversioned API. Use a simple ordinal number and avoid dot notation such as 2.5.

We are using the url for the API versioning starting with the letter "v"

/blog/api/v1

Handle Errors with HTTP status codes

It is hard to work with an API that ignores error handling. Pure returning of a HTTP 500 with a stacktrace is not very helpful.

Use HTTP status codes

The HTTP standard provides over 70 status codes to describe the return values. We don’t need them all, but there should be used at least a mount of 10.

200 - OK - Eyerything is working
201 - OK - New resource has been created
204 - OK - The resource was successfully deleted
304 - Not Modified - The client can use cached data
400 - Bad Request - The request was invalid or cannot be served. The exact error should be explained in the error payload. E.g. "The JSON is not valid"
401 - Unauthorized - The request requires an user authentication
403 - Forbidden - The server understood the request, but is refusing it or the access is not allowed.
404 - Not found - There is no resource behind the URI.
422 - Unprocessable Entity - Should be used if the server cannot process the enitity, e.g. if an image cannot be formatted or mandatory fields are missing in the payload.
500 - Internal Server Error - API developers should avoid this error. If an error occurs in the global catch blog, the stracktrace should be logged and not returned as response.

Use error payloads

All exceptions should be mapped in an error payload. Here is an example how a JSON payload should look like.

{
  "errors": [
   {
    "userMessage": "Sorry, the requested resource does not exist",
    "internalMessage": "No car found in the database",
    "code": 34,
    "more info": "http://dev.mwaysolutions.com/blog/api/v1/errors/12345"
   }
  ]
}

Allow overriding HTTP method

Some proxies support only POST and GET methods. To support a RESTful API with these limitations, the API needs a way to override the HTTP method.

Use the custom HTTP Header X-HTTP-Method-Override to overrider the POST Method.

Dynamic GridView Control in C# ASP.Net

In webapplications, one the most widely task is showing a table of information to clients. In Asp.net, we make utilization of the Datagrid, Datalist and Repeater controls. Every day, the need of showing the information will be diverse. Now, we will explain to you about "How to Create Dynamic GridView Control in C#/ASP.Net". Please read the steps carefully.

Implementing Dynamic GridView Control

Utilizing the gridview to show the articles will show the article a little in diverse layout when compared with Datalist. Appoint the below figure, Dynamic Gridview.

Constructing Dynamic GridView

Showing the articles in gridview will be different from showing in datalist. For that, i have made two Template classes :
  • DynamicGridViewTextTemplate
  • DynamicGridViewURLTemplate
Dynamicgridviewtexttemplate class is utilized to include a layout column with label while Dynamicgridviewurltemplate class is utilized to include URL of the article.

TemplateClass for GridView

public class DynamicGridViewTextTemplate : ITemplate
{
    string _ColName;
    DataControlRowType _rowType;
    int _Count;
    public DynamicGridViewTextTemplate(string ColName, DataControlRowType RowType)
    {
        _ColName = ColName;
        _rowType = RowType;
    }
    public DynamicGridViewTextTemplate(DataControlRowType RowType, int ArticleCount)
    {
        _rowType = RowType;
        _Count = ArticleCount;
    }
    public void InstantiateIn(System.Web.UI.Control container)
    {
        switch (_rowType)
        {
            case DataControlRowType.Header:
                Literal lc = new Literal();
                lc.Text = "" + _ColName + "";
                container.Controls.Add(lc);
                break;
            case DataControlRowType.DataRow:              
                 Label lbl = new Label();
                 lbl.DataBinding += new EventHandler(this.lbl_DataBind);
                 container.Controls.Add(lbl);              
                break;
            case DataControlRowType.Footer:
                Literal flc = new Literal();
                flc.Text = "Total No of Articles:" + _Count + "";
                container.Controls.Add(flc);
                break;
            default:
                break;
        }
    }
 
  
    private void lbl_DataBind(Object sender, EventArgs e)
    {
        Label lbl  = (Label)sender;
        GridViewRow row = (GridViewRow)lbl.NamingContainer;
        lbl.Text =DataBinder.Eval(row.DataItem, _ColName).ToString();
    }
 
}
public class DynamicGridViewURLTemplate : ITemplate
{
    string _ColNameText;
    string _ColNameURL;
    DataControlRowType _rowType;
 
    public DynamicGridViewURLTemplate(string ColNameText, string ColNameURL, DataControlRowType RowType)
    {
        _ColNameText = ColNameText;
        _rowType = RowType;
        _ColNameURL = ColNameURL;
    }
    public void InstantiateIn(System.Web.UI.Control container)
    {
        switch (_rowType)
        {
            case DataControlRowType.Header:
                Literal lc = new Literal();
                lc.Text = "" + _ColNameURL + "";
                container.Controls.Add(lc);
                break;
            case DataControlRowType.DataRow:
                HyperLink hpl = new HyperLink();
                hpl.Target = "_blank";
                hpl.DataBinding += new EventHandler(this.hpl_DataBind);
                container.Controls.Add(hpl);
                break;
            default:
                break;
        }
    }
 
    private void hpl_DataBind(Object sender, EventArgs e)
    {
        HyperLink hpl = (HyperLink)sender;
        GridViewRow row = (GridViewRow)hpl.NamingContainer;
        hpl.NavigateUrl = DataBinder.Eval(row.DataItem, _ColNameURL).ToString();
        hpl.Text = "
" + DataBinder.Eval(row.DataItem, _ColNameText).ToString() + "
"; } }

Using the Template Class in GridView

Utilizing dynamic template in gridview is not the same as datalist i.e. we will make the dynamic gridview in column wise with header layout, item template and footer layout from the first column till the last.

Steps:

  • Create a Gridview Object.
  • Create an instance of TemplateField object.
  • Instantiate the Dynamic template class with proper ListItemType and assign it to corresponding template property of TemplateField object and finally add this object to the column collection of GridView. Refer the below code for better understanding.

Templates of GridView

TemplateField tf = new TemplateField();
                tf.HeaderTemplate = new DynamicGridViewTextTemplate("ArticleID", DataControlRowType.Header);
                tf.ItemTemplate = new DynamicGridViewTextTemplate("ArticleID", DataControlRowType.DataRow);
                tf.FooterTemplate = new DynamicGridViewTextTemplate(DataControlRowType.Footer, ds.Tables[i].Rows.Count); 
In the event that you analyze the usage of Datalist, in Gridview we won't make dynamic template for the grid within we make it for the grid's column (Templatefield). Appoint the below code (Using Template class) for clear understanding.

Using Template class

for (int i = 0; i < ds.Tables.Count; i++)
        {
            if (ds.Tables[i].Rows.Count > 0)
            {
                GridView gvDynamicArticle = new GridView();
                gvDynamicArticle.Width = Unit.Pixel(700);
                gvDynamicArticle.BorderWidth = Unit.Pixel(0);
                gvDynamicArticle.Caption = "
+ ds.Tables[i].Rows[0]["Category"].ToString() + " Articles
"; gvDynamicArticle.AutoGenerateColumns = false; gvDynamicArticle.ShowFooter = true; TemplateField tf = null; tf = new TemplateField(); tf.HeaderTemplate = new DynamicGridViewTextTemplate("ArticleID", DataControlRowType.Header); tf.ItemTemplate = new DynamicGridViewTextTemplate("ArticleID", DataControlRowType.DataRow); tf.FooterTemplate = new DynamicGridViewTextTemplate(DataControlRowType.Footer, ds.Tables[i].Rows.Count); gvDynamicArticle.Columns.Add(tf); tf = new TemplateField(); tf.HeaderTemplate = new DynamicGridViewTextTemplate("Title", DataControlRowType.Header); tf.ItemTemplate = new DynamicGridViewTextTemplate("Title", DataControlRowType.DataRow); gvDynamicArticle.Columns.Add(tf); tf = new TemplateField(); tf.HeaderTemplate = new DynamicGridViewTextTemplate("Description", DataControlRowType.Header); tf.ItemTemplate = new DynamicGridViewTextTemplate("Description", DataControlRowType.DataRow); gvDynamicArticle.Columns.Add(tf); tf = new TemplateField(); tf.HeaderTemplate = new DynamicGridViewURLTemplate("Title", "URL", DataControlRowType.Header); tf.ItemTemplate = new DynamicGridViewURLTemplate("Title", "URL", DataControlRowType.DataRow); gvDynamicArticle.Columns.Add(tf); tf = new TemplateField(); tf.HeaderTemplate = new DynamicGridViewTextTemplate("Author", DataControlRowType.Header); tf.ItemTemplate = new DynamicGridViewTextTemplate("CreatedBy", DataControlRowType.DataRow); gvDynamicArticle.Columns.Add(tf); gvDynamicArticle.RowDataBound += new GridViewRowEventHandler(this.DynamicGrid_RowDataBound); gvDynamicArticle.DataSource = ds.Tables[i]; gvDynamicArticle.DataBind(); phDynamicGridHolder.Controls.Add(gvDynamicArticle); } }
In the above code (Using Template class), we can unmistakably comprehend that we are making the dynamic template for the gridview's column instead of Datalist where we made the template for the grid itself. To throw more light on this it implies that we are making the first column's header, item and footer and adding it to the gridview's column list through Templatefield article till the last column as I said before.

ASP.NET 5 and MVC 6 in State of Security, OAuth 2.0, OpenID Connect and IdentityServer

So let's have a look at the bits & pieces and how IdentityServer can help in implementing authentication for MVC web Apps and APIs.

IdentityServer

IdentityServer is an extensible OAuth 2.0 authorization server and OpenID Connect provider framework. It is different from the old authorization server middleware as it operates on a higher level of abstraction. IdentityServer takes care of all the protocol and data management details while you only need to model your application architecture using clients, users and resources.
IdentityServer is currently available as OWIN middleware only (as opposed to native ASP.NET 5 middleware)- that means it can be used in Katana-based hosts and ASP.NET 5 hosts targeting the "full .NET framework" aka DNX451. It does currently not run on the Core CLR - but we are working on it.
You wire up IdentityServer in ASP.NET 5 using the typical application builder extension method pattern:
public void Configure(IApplicationBuilder app)
{
    var idsrvOptions = new IdentityServerOptions
    {
        Factory = new IdentityServerServiceFactory()
                        .UseInMemoryUsers(Users.Get())
                        .UseInMemoryClients(Clients.Get())
                        .UseInMemoryScopes(Scopes.Get()),
    };

    app.UseIdentityServer(idsrvOptions);
}

For this sample we use in-memory data sources, but you can connect to any data source you like.
The Users class simply defines two test users (Alice and Bob of course) - I won't bore you with the details. Scopes on the other hand define the resources in your application, e.g. identity resources like email addresses or roles, or resource scopes that represent your APIs:
public static IEnumerable Get()
{
    return new[]
    {
        // standard OpenID Connect scopes
        StandardScopes.OpenId,
        StandardScopes.ProfileAlwaysInclude,
        StandardScopes.EmailAlwaysInclude,

        // API - access token will 
        // contain roles of user
        new Scope
        {
            Name = "api1",
            DisplayName = "API 1",
            Type = ScopeType.Resource,

            Claims = new List
            {
                new ScopeClaim("role")
            }
        }
    };
}
Clients on the other hand represent the applications that will request authentication tokens (also called identity tokens) and access tokens.
public static List Get()
{
    return new List
    {
        new Client
        {
            ClientName = "Test Client",
            ClientId = "test",
            ClientSecrets = new List
            {
                new Secret("secret".Sha256())
            },

            // server to server communication
            Flow = Flows.ClientCredentials,

            // only allowed to access api1
            AllowedScopes = new List
            {
                "api1"
            }
        },

        new Client
        {
            ClientName = "MVC6 Demo Client",
            ClientId = "mvc6",

            // human involved
            Flow = Flows.Implicit,

            RedirectUris = new List
            {
                "http://localhost:2221/",
            },

            // access to identity data and api1
            AllowedScopes = new List
            {
                "openid",
                "email",
                "profile",
                "api1"
            }
        }
    };
}
With these definitions in place we can now add an MVC application that uses IdentityServer for authentication, as well as an API that supports token-based access control.

MVC Web Application

ASP.NET 5 includes middleware for OpenID Connect authentication. With this middleware you can use any OpenID Connect compliant provider (see here) to outsource the authentication logic.
Simply add the cookie middleware (for local signin) and the OpenID Connect middleware pointing to our IdentityServer to the pipeline. You need to supply the base URL to IdentityServer (so the middleware can fetch the discovery document), the client ID, scopes, and redirect URI (compare to our client definition we did earlier). The following snippet requests the user's ID, email and profile claims in addition to an access token that can be used for the "api1" resource.
app.UseCookieAuthentication(options =>
{
    options.AuthenticationScheme = "Cookies";
    options.AutomaticAuthentication = true;
});

app.UseOpenIdConnectAuthentication(options =>
{
    options.Authority = "https://localhost:44300";
    options.ClientId = "mvc6";
    options.ResponseType = "id_token token";
    options.Scope = "openid email profile api1";
    options.RedirectUri = "http://localhost:2221/";

    options.SignInScheme = "Cookies";
    options.AutomaticAuthentication = true;
}

MVC Web API

Building web APIs with MVC that are secured by IdentityServer is equally simple - the ASP.NET 5 OAuth 2.0 middleware supports JWTs out of the box and even understands discovery documents now.
app.UseOAuthBearerAuthentication(options =>
{
    options.Authority = "https://localhost:44300";
    options.Audience = "https://localhost:44300/resources";
    options.AutomaticAuthentication = true;
});
Again Authority points to the base-address of IdentityServer so the middleware can download the metadata and learn about the signing keys.
Since the built-in middleware does not understand the concept of scopes, I had to fix that with this:
app.UseMiddleware(
   new List { "api1" });

Expect this be improved in future versions.

API Client

Tokens can be also requested programmatically - e.g. for server-to-server communication scenarios. Our IdentityModel library has a TokenClient helper class which makes that very easy:

async Task GetTokenAsync()
{
    var client = new TokenClient(
        "https://localhost:44300/connect/token",
        "test",
        "secret");

    return await client.RequestClientCredentialsAsync("api1");
}
…and using the token:
var client = new HttpClient();
client.SetBearerToken(response.AccessToken);

var result = await client.GetAsync("http://localhost:2025/claims”);

The full source code can be found here.

Summary

IdentityServer can be a replacement for the Katana authorization server middleware - but as I said it is a different mindset, since IdentityServer is not protocol oriented - but rather focusing on your application architecture. I should mention that there is actually a middleware for ASP.NET 5 that mimics the Katana approach - you can find it here.
In the end it is all about personal preference, and most importantly how comfortable you are with the low level details of the protocols.
There are actually much more samples on how to use IdentityServer in the samples repo. Give it a try.

Ordering a set of results +/- more option, iterating over an array

In the following example, I will once again provide the user with a set of options to order our results set. In this case, our order criteria options are sourced in an array. Depending on your use case, you may find the array fashion more practical than the object style. You should learn both.

Example :

<div>
   <h3>Order By:</h3>
   <select data-ng-model='selectedSortOrder3'
      data-ng-options="option.value as option.name for option in 
      [{'value':'+name','name':'Name: A-Z'},{'value':'-name','name':'Name: Z-A'}, 
      {'value':'+lastName','name':'Last Name: A-Z'}, 
      {'value':'-lastName','name':'Last Name: Z-A'}, 
      {'value':'+age','name':'Age: Young to Experienced'}, 
      {'value':'-age','name':'Age: Experienced to Young'}]" 
      data-ng-init="selectedSortOrder3='+age'">
   </select>  
</div>
<div>
   <h3>List of results:</h3>
   <div ng-repeat="person in results | orderBy:selectedSortOrder3">
      {{person.name}} {{person.lastName}} - {{person.age}}
   </div>
</div>  

Note: In order to iterate over this array, Angular provides us with a dsl expression we can use in the ng-options. In this case it will be 'option.value as option.name for option in in optionsSet'. There are other available expressions:
  • label for value in array
  • select as label for value in array
  • label group by group for value in array
  • select as label group by group for value in array

Mindbody online api integration Asp.net



Singup in MINDBODY and Get your API credentials

Before you can start integrating your MINDBODY data you will need credentials to access the MINDBODY API. If you are just developing for a single business, follow the steps below. If you want to access the data for more than one business you will need to contact MINDBODY directly for this information.
  • Complete the sign up form at the MINDBODY Partner Program website and write down your sourcename and key.Click Here
  • This next step can be tricky. You have to make a call to the SiteService on the MINDBODY SOAP server to get an activation code. I made a form you can fill out instead. (UPDATE: MINDBODY has included this tool on the partner program website) You need the sourcename and key that you wrote down in the first step as well as your site id. If you don’t know what your site id is, log in to your MINDBODY account and check the URL. Your site id comes after “?studioid=” at the end of the URL.
  • Give the activation link and code to the person with the ‘owner’ account for the MINDBODY site you want to access the data of.
    Some API methods require user credentials as well. Set up a user for your application by following these steps.

Step:

  • Log in to MINDBODY
  • Go to Toolbox -> Setup -> Staff -> Staff Management
  • Click Add New Staff Member


  • Enter something for the first and last name. I used first name “web” last name “developer”.
  • Create a staff login with a new username and password and write these down.


  • Save your new staff member.

Schedule

  • Clients can quickly see the latest schedule and sign up or pay for a class without ever leaving your website.
  • Calendar or list view options
  • Shows single or multi-locations
  • Automatically switches to mobile view when viewed from iPhone or Android phone
  • Shows classes and enrollments
  • Pick which day the schedule starts
  • Choose timeframe displayed
  • Class type and instructor filtering
  • Filter by day and/or time of day
  • Option to create a ‘Today’s Schedule’ widget
  • Changes made in MINDBODY auto-update in real-time

Enrollments

  • Clients can register and pay for the enrollments on the spot.
  • Set the timeframe, allows for up to a year.
  • Ability to hide enrollments already underway.
  • Select a summary or detailed views.
  • Narrow view also available for sidebars
  • Filter by day and/or time of day
  • Type and instructor filtering
  • Shows single or multi-locations
  • Automatically switches to mobile view when viewed from iPhone or Android phone
  • Changes made in MINDBODY auto-update in real-time

Appointments

  • Clients can search for and book appointments
  • Supports new client sign-ups and purchases
  • Choose how many days are displayed
  • Instructor and session type filtering
  • Supports 'request' and 'book' appointment modes in MINDBODY
  • Shows single or multi-locations
  • Automatically switches to mobile view when viewed from iPhone or Android phone
  • Changes made in MINDBODY auto-update in real-time

Registration

  • Clients can do paperless registration and get set up in your MINDBODY account.
  • Supports liability release agreements that are created/stored in MINDBODY
  • Creates profile in MINDBODY with information inputted by new registrant
  • Creates PDF of info supplied in profile in MINDBODY
  • Get notified of new registrants

Prospect

  • Leads fill this out when contacting you
  • Get notified of new prospects for better response time
  • Perfect for newsletter sign ups
  • Customize client indexes

Staff List

  • Lists bios, photos and schedules of staff on a webpage
  • Staff bios, photos and schedule from MINDBODY get pulled down into the website
  • Changes to MINDBODY automatically update on the website
  • Sort and order staff when displayed by widget on the website

Class List

  • Lists class descriptions, photos and schedules of classes on a webpage
  • Class descriptions, photos and schedule from MINDBODY get pulled down into the website
  • Changes to MINDBODY automatically update on the website

Simple basics of SOAP over view

SOAP is a platform independent protocol for exchanging information between websites. It’s fairly simple and easy to use once you understand how SOAP works. In your situation you want to access your data stored on MINDBODY’s servers. MINDBODY has provided a SOAP server that you can send XML formatted messages to and receive responses from over the http protocol.

Your SOAP messages are written in XML which is a markup language similar to HTML. Luckily using ASP.net we can abstract away the need to interact with the XML directly so it should make it a lot easier to work with.


API reference documentation

You need to know where to send your SOAP requests. In SOAP jargon these destinations are known as endpoints. You can find the endpoints here
Click here to open API documentation

Problem with API

Synchronize a web-application built for saving meditation and yoga related classes information of customers with MindBody API. The customers will signup into MindBody and their data should be captured from there and updated into the web-application database. The customers should be able to book appointments from the web-application which should be updated into the MindBody database.

Solution Provided

The credentials for Mind-body developer API were obtained. The source name, password, siteId, were all supplied to the SOAP request call . Then a query was fired on the MindBody database as a part of the request to fetch all the customers profile information present in MindBody. The data was retrieved in CSV format. Then a validation was implemented to check if the emails of the customers were present in the web-application database. If no then these records were created in the web-application database. The MindBody client id was inserted too. If the record of the customer was found then the record was updated with the MindBody client id received from the API.

A cron job was setup to sync the database daily with Mindbody looking for new customers. The client id from Mind Body was used for mapping between the application and the API.

The customers had access to an appointment form where they could select the location, and the appointment date for booking. Then a request was made to the MindBody server passing the location, date, staff id, client id to add the new appointment in the MindBody database. The status of the API was tracked to track the success / failure of the request.

The application helped the client streamline his business in terms of managing all the user related activities and sessions for yoga and meditation.

Integration with QuickBooks Online V3 API



We have developed tool that provides easy-to-use components for QuickBooks development, facilitating tasks such as adding, updating or retrieving customer information, vendor information, employee information, transactions etc.

QuickBooks is a small-business accounting software made by Intuit. It has online and desktop editions (Pro, Premier, etc.). It is widely used and Intuit provided an SDK so that third-party applications can access or write QuickBooks data. Applications communicate with QuickBooks using XML for requests and responses. Fortunately for us .NET developers, Intuit also provided the QBFC Library so we can use C# or VB to build requests or accept responses, although XML (or qbXML as Intuit calls it) is still used internally.

Cross Platform

Native editions available targeting major platforms & IDE's including: .NET, Java, ActiveX, ASP, Delphi, C++, etc.

Features

We have developed tool for QuickBooks developers that provides for quick and easy development of fully-integrated QuickBooks solutions. It eliminates much of the complexity of developing such solutions by providing easy to use components that facilitate tasks such as adding, updating or retrieving customer information, vendor information, employee information, transactions etc.

  • Internet-Enabled QuickBooks. Access QuickBooks remotely using the included /n software QBConnector & QBConnector Component.
  • Secure connection to the QB Connector using SSL and Digital Certificates.
  • Easy-to-use components greatly reduce the code required to work with common QuickBooks constructs.
  • Handles all QBXML parsing, COM communications, error handling, etc. allowing you to focus on your specific business requirements.
  • Integrates with Online shopping carts providing seamless integration between sales and accounting.
  • Easily export QuickBooks information to a database of choice or directly to XML.



Thank You

Unit of Work with Repository Pattern in MVC5 with Fluent NHibernate and Ninject

Unit of Work Pattern

The Unit of Work pattern is used to group one or more operations (usually database operations) into a single transaction or “unit of work”, so that all operations either pass or fail as one.

Repository Pattern

The Repository pattern is used to manage CRUD operations through an abstract interface that exposes domain entities and hides the implementation details of database access code.

Implementation

Domain Layer

The domain/business logic layer contains the interfaces for a unit of work and a generic repository.

IUnitOfWork Interface

A lightweight Unit of Work interface that defines methods for beginning and committing a transaction.
public interface IUnitOfWork
{
    void BeginTransaction();
    void Commit();
}

IRepository < t > Interface

A generic repository interface that exposes a standard set of methods for performing CRUD operations on entities within the system.
public interface IRepository< t >where T : IEntity
{
    IQueryable<t>
        GetAll();
        T GetById(int id);
        void Create(T entity);
        void Update(T entity);
        void Delete(int id);
}

Data Layer

The data layer contains the implementations of the above unit of work and repository interfaces using Fluent NHibernate as the ORM.

UnitOfWork Class

The UnitOfWork class contains methods for beginning and committing a transaction, it also exposes a Session property that returns the current NHibernate Session associated with the unit of work. Each UnitOfWork instance contains a single session.
The static constructor is used to implement the Singleton pattern for the NHibernate session factory, in C# static constructors are executed only once per application domain and are thread-safe which makes them ideal for implementing singletons.
public class UnitOfWork : IUnitOfWork
{
    private static readonly ISessionFactory _sessionFactory;
    private ITransaction _transaction;
 
    public ISession Session { get; private set; }
 
    static UnitOfWork()
    {
        // Initialise singleton instance of ISessionFactory, static constructors are only executed once during the
        // application lifetime - the first time the UnitOfWork class is used
        _sessionFactory = Fluently.Configure()
            .Database(MsSqlConfiguration.MsSql2008.ConnectionString(x => x.FromConnectionStringWithKey("UnitOfWorkExample")))
            .Mappings(x => x.AutoMappings.Add(
                AutoMap.AssemblyOf<product>(new AutomappingConfiguration()).UseOverridesFromAssemblyOf<productoverrides>()))
            .ExposeConfiguration(config => new SchemaUpdate(config).Execute(false, true))
            .BuildSessionFactory();
    }
 
    public UnitOfWork()
    {
        Session = _sessionFactory.OpenSession();
    }
 
    public void BeginTransaction()
    {
        _transaction = Session.BeginTransaction();
    }
 
    public void Commit()
    {
        try
        {
            _transaction.Commit();
        }
        catch
        {
            _transaction.Rollback();
            throw;
        }
        finally
        {
            Session.Close();
        }
    }
}

Repository< t > Class

A generic repository class that implements methods for performing CRUD operations on domain entities. You may notice that there aren't any transactions in this class, that's because transactions need to be implemented at a higher level because a transaction may contain several operations across different repositories.
public class Repository<t> : IRepository<t> where T : IEntity
{
    private UnitOfWork _unitOfWork;
    public Repository(IUnitOfWork unitOfWork){
        _unitOfWork = (UnitOfWork)unitOfWork;
    }
 
    protected ISession Session { get { return _unitOfWork.Session; } }
 
    public IQueryable<t> GetAll()
    {
        return Session.Query<t>();
    }
 
    public T GetById(int id)
    {
        return Session.Get<t>(id);
    }
 
    public void Create(T entity)
    {
        Session.Save(entity);
    }
 
    public void Update(T entity)
    {
        Session.Update(entity);
    }
 
    public void Delete(int id)
    {
        Session.Delete(Session.Load<t>(id));
    }
}

Web Layer

The web layer is the responsible for the configuration of dependency injection and transaction management.

NinjectWebCommon Class

This class is automatically added when you install the Ninject.MVC5 package from NuGet and contains the configuration for dependency injection. I've left out the code that I didn't touch.
The unit of work binding sets the scope to "InRequestScope()" which ensures that the same IUnitOfWork instance will be used everywhere within a single request. Having a single Unit or Work per request is necessary for the pattern to function correctly.
public static class NinjectWebCommon
{
     ...
 
    /// <summary>
    /// Load your modules or register your services here!
    /// </summary>
    /// <param name="kernel">The kernel.</param>
    private static void RegisterServices(IKernel kernel)
    {
        // unit of work per request
        kernel.Bind<iunitofwork>().To<unitofwork>().InRequestScope();
 
        // default binding for everything except unit of work
        kernel.Bind(x => x.FromAssembliesMatching("*").SelectAllClasses().Excluding<unitofwork>().BindDefaultInterface());
    }
}

MVC 5 BaseController Class

The base controller is used for beginning and committing transactions, this implementation uses a transaction per action so everything within an action is treated as a single Unit of Work. There is also a check to ensure that transactions are not created for child actions since any child action will already be running within the transaction of it's parent action.
I'm using public property injection for the IUnitOfWork property rather than constructor injection so controllers that inherit from BaseController won't need to call the base constructor passing the dependency.
public class BaseController : Controller
{
    [Inject]
    public IUnitOfWork UnitOfWork { get; set; }
 
    protected override void OnActionExecuting(ActionExecutingContext filterContext)
    {
        if (!filterContext.IsChildAction)
            UnitOfWork.BeginTransaction();
    }
 
    protected override void OnResultExecuted(ResultExecutedContext filterContext)
    {
        if (!filterContext.IsChildAction)
            UnitOfWork.Commit();
    }
}

CRM/ERP Business solutions



This Application Developed in 2011-June

Technology Used

Asp.net, Ajax, Jquery, MS SQL

The CRM Application which we have developed is comprehensive application covering the most of modules and complication of CRM activities. Our CRM not only manages Lead, customers and few reports but it also manages the complications such as arranty/guaranty, Payroll and commission calculation for sales and Tech people etc.

Key features

  • Lead/Customer entry & management
  • Customer search & contact Management
  • Customer flexpay info
  • Customer Order entry / Payment entry/ credit given on credit history
  • Ticket creation and assigning
  • Ticket Filter/search
  • PO Generation
  • Scheduling for the appointment
  • Equipment assigning
  • Invoice generation
  • Manual Invoice entry
  • Cycle maintaining for the ticket stages
  • Cycle maintaining for the appointment stages
  • Inventory management (stock checking, min/max stock, notification)
  • Import/export data with excel, PDF,CSV
  • Inventory filter search
  • Mail & message facilities
  • Shipment tracking
  • Commission Definition and Calculation
  • Payroll generation
  • Dashboard for Admin, user and customer
  • It’s a comprehensive CRM application which covers the Inventory management and Payroll/commission calculation for sales and tech force as well.
This Application is Built on 3 tire architecture using Asp.net and MS SQL with extensive use of Ajax and Jquery.

Thank You.

Tours and travels portal



This Application Developed in 2011-June

Technology Used

Asp.net, Ajax, Jquery, MS SQL 2008, API,Payment Integration

Project Description

Patel Tours And Travels (Patel Inn & Travels Pvt. Ltd.) is one of the leading traveling company in Gujarat, Maharashtra, Kutch with a well-built in offices to the linking cities like Ahmedabad, Rajkot, Baroda (Vadodara), Bhuj, Jamnagar, Gandhidham, Mumbai & Pune. Patel Tours And Travels offering services of many Volvo seating And Sleepers buses. Patel Tours And Travels has been in the traveling business more than 25 years. We have designed their website and also prepared their booking software and handling in proving services for the same.

View - Pateltoursandtravels.com


Key features

  • Online Booking
  • Bus schedule
  • Pay Online For Phone Booking
  • Cancellation
  • Bus Charter
  • User Management


Thank You

test

https://onedrive.live.com/redir?resid=91144EAB68D26154!3103&authkey=!AATHWVE3msYqYGo&ithint=folder%2czip


https://drive.google.com/folderview?id=0B8a2Mf8GF1wOaTN3U3VTZ0ZBcjg&usp=sharing