Xceedas

Xceedas
xceedas

Friday 30 January 2015

Microsoft Office for Android Available Now


Microsoft made available the office apps for Android. Preview version of office apps were made available two months back.
 
Microsoft free Office apps for iPhone and iPad was launched in November, 2014.
 
Word, Excel and PowerPoint for Android tablet is available in the Google Play store as free downloads. OneNote for Android is available already. Download the free apps and log in with your Microsoft Account to start working with files as you do in PC. The free Microsoft Word app provides a core experience for viewing, creating and editing docs on tablets with a screen size of 10.1 inches or smaller. Premium features are only available with Office 365 subscription.
 
 
 
 
 
 
 
New Outlook for iOS and new Outlook for Android preview is also available for download. Manage your email, schedule a meeting, and share your schedule as efficiently as you do on your computer.
 
  
  

Thursday 29 January 2015

Creating PDF with ASP.Net MVC and RazorPDF

In this post we are going to learn how we can easily create PDF from ASP.Net application with the help of Razor PDF NuGet package.


About Razor PDF:

This NuGet package is created by Al Nyveldt It internally uses ITextSharp an open source PDF convertor library. RazorPDF uses Razor View engine to create iTextXML which is in tern used to produce PDF file. You can get more information about that at below link.

https://www.nuget.org/packages/RazorPDF

Example(Creating PDF with ASP.Net MVC):

So what we are we waiting for ? Let’s create a simple example. To create example first thing we need to a create and ASP.Net MVC application.

ASPNETPDFDemoApplication

Once you click on OK. It will ask for type of project. We are going to create ASP.Net MVC internet application.

MVCTypeApplicationRazorPDF

Once you click on it will create an application. The next thing you need to install a NuGet package. You need to type following command on your NuGet Package manager console.

NuGetPackageforASPNETMVCPDF

Like following.

NugetPacketManagerConsoleForCreatingPDFinaspnetmvc

Now our application is ready to create PDF files. Now to create an example Let’s create a model class ‘Customer’ to create a listing of customers in the application.
namespace PDFDemor.Models
{
    public class Customer
    {
        public int CustomerID { get; set; }
        public string FirstName { get; set; }
        public string LastName { get; set; }
    }
}
Now Custom class is ready. So let’s create an CustomerController with listing of customer ActionResult like following.

CreatingControllerToCreatePDFinaspnetmvc

Now once you click Add It will create CustomerController. In index ActionResult I have created following code. Where I have created an list and pass it to view.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using PDFDemo.Models;
 
namespace PDFDemo.Controllers
{
    public class CustomerController : Controller
    {
        //
        // GET: /Customer/
 
        public ActionResult Index()
        {
            List<Customer> customers= new List<Customer>();
 
            for (int i = 1; i <= 10; i++)
            {
                Customer customer = new Customer
                {
                    CustomerID = i,
                    FirstName = string.Format("FirstName{0}", i.ToString()),
                    LastName = string.Format("LastName{0}", i.ToString())
                };
                customers.Add(customer);
            }
            return View(customers);
        }
 
    }
}
Now lt’s time to create view for listing of customers like following.

CreatingaViewforPDfListing

Once you click add it will create a view and now let’s run that application. It will look like following.

image

So everything looks good now. Now It’s time to create PDF document for same list. Let’s create a new action result method called PDF in same controller.
public ActionResult PDF()
{
    List<Customer> customers = new List<Customer>();
 
    for (int i = 1; i <= 10; i++)
    {
        Customer customer = new Customer
        {
            CustomerID = i,
            FirstName = string.Format("FirstName{0}", i.ToString()),
            LastName = string.Format("LastName{0}", i.ToString())
        };
        customers.Add(customer);
    }
 
    return new RazorPDF.PdfResult(customers, "PDF");
}
Here in the above code I have created a list and send it to a PDF Result which will result in PDF Document.Now let’s create a Razor view for that action result like following.
@model List<PDFDemo.Models.Customer>
@{
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
</head>
<body>
    <h2>Html List in PDF</h2>
    <table width="100%">
        <tr>
            <td>First Name</td>
           
            <td>Last Name</td>
        </tr>
        @foreach (var item in Model)
        {
            <tr>
                <td>@item.FirstName</td>
               
                <td>@item.LastName</td>
            </tr>
        }
    </table>
</body>
</html>
Here you can see I have printed a simple table with first name  and last name. I have made layout=null as I don’t want any HTML. Now let’s run this application. And my list is converted in PDF as expected.

image

That’s it. It’s very easy to create PDF with ASP.Net with Razor PDF.

Apple Watch Availability in April


 
In a recent announcement, Apple CEO, Tim Cook mentioned that the development and delivery of Apple Watch is on schedule and it will start shipping in April month to US retailers. He also said that his expectations with the new wearable "are very high."
 
"I'm using it every day and love it and can't live without it," Cook said.
In sept last year, Apple-unveiled Apple Watch that will start selling in April this year. The Apple watch pricing is starting at $349 and is compatible with iPhone 5, iPhone 5c, iPhone 6, and iPhone 6 Plus.

Wednesday 28 January 2015

Onion Architecture in MVC Applications

Introduction
Pre-Requisites
This article is meant for my fellow developers with knowledge of ASP.NET MVC and are wondering what architecture to choose. I am trying to write this article to be as simple and easy to understand and implement.

Let's Start
The Onion Architecture was introduced by Jeffery Palermo in 2008 with the intent to make applications loosely coupled and with proper separation among the folders and the various areas of concern in the application. This makes the development easier, the testing of the application easier and the maintenance becomes easier. During the initial stage of development, the Software Requirement Specifications (SRS) is made and proper planning is done regarding what should be the approach, what technologies are to be used and then is done. The most difficult part is choosing the proper architecture so that the maintenance becomes easier. Here, the points that are kept in mind are:
  1. All code depends on layers closer to the center.

  2. Domain Models will be at the Center or the Core.

  3. The inner layer defines the interfaces whereas the outer layer implements these interfaces members.

  4. There is a layered behavior around the domain.

  5. The infrastructure for containing the data and the service implementation should be pushed to the edge. Along with the infrastructure, the UI concerns are also pushed to the edge.
Background
There are many architectures used in web applications, but the question is how to choose the architecture that would help attain loose coupling that is most essential. Loose Coupling depends on a separation of concerns. That means that each layer will be independent of each other. What is tightly coupled and loosely coupled?

choosing
Yes, exactly as you are thinking my dear readers. But still let me discuss the difference quickly. A tightly coupling is where the one object/entity needs to have knowledge of other objects or we can say they depend largely on the interfaces where the service methods are declared. This can be avoided in small applications, but in large applications, these terms are required to be kept in mind, else it may lead to chaos.

chaos
A loose coupling, yes is the opposite, where there is very less dependency amongst the objects and the interfaces for which there is a chance of a clean separation of concerns and proper flexibility in the applications since it makes the framework more stable and enables proper maintainability. And it makes the developers happy.

happy

The following shows the Onion Architecture at glance:

Onion Architecture at glance

In the preceding image, as we can see, the Core is the Domain model. This layer contains the POCO entities.

Domain objects are:

 1.Encapsulates application business logic and rules.
 2.Maintains any state that is required.
 3.Does not depend on external infrastructure concerns.
In this article and demo I have added the Repository interfaces in the Core.

The Layers above in Brown has the Service Interfaces. The layer in Green is the implementation layer, or the Infrastructure Layer, where the Repositories and the Services methods are implemented. The Error Logging (especially NLog) is used. Also the Dependency Injection is implemented here to inject the dependencies into the controllers.

The layer in Blue (the outer layer) has the testing and the User Interfaces.

Thus, this was a simple description of the architecture, but the following diagram explains it better:

Architecture

Here we can see there is no transitive dependency among the Test, UI and the Data Access that seems better for the Unit testing in MVC applications. This is the Layered Onion Architecture that proves to make an application loosely coupled.

The application service implementation as we can see is in a separate layer and the dependency finally is on the Core Domain. The Green arrows in the diagram represents the dependencies. Now let's look at a sample code. The demo is provided in the article for download.

Using the code
In this demo we will see how simple the folder structure of the solution is. Let's see the structure:

demo start

This is how simple the solution of the project would look like if we use the Onion Architecture. Now let's look at an expanded project:

expanded project

Let's discuss each of the folders one by one.

The Core
The Core

This is how the core looks like. The core folder contains a class library project, that has interfaces both for Repositories and Services and the Model with the a .tt (T4 template) file that is autogenerated containing the POCO entities since I have used the Database First approach here. An important thing to note here is the .edmx file that is generated by the use of the Database First approach that contains the .tt file. To move that to the Core folder from the .edmx, cut the .tt file and paste that into the folder you want to, here Core -> Models. Only doing this does not end the topic, we need to specify the physical path of that file as shown in the diagram below:

physical path

As you can see in the image, there is a folder called Interface. As the name suggests, this contains the Repositories and Service Interfaces.

Infrastructure
Infrastructure

This folder contains more than one project and contains the integral part of an application. The first project in this solution is a class library project with the first folder Data containing the .edmx file. An .edmx file, as defined in the MSDN, is a conceptual model and a storage model and the relationships among them. This also contains the Context classes and the .tt file, but regarding the .tt file we have already discussed the core since we have moved this file to the core project. The first project also contains the Repository and Service implementations as specified in the interface.

The main and the best part is the second project in the infrastructure, in other words the Dependency Injection, is an integral part when we want the Separation of concerns/Loose coupling in an application. In the preceding figure, we have two classes, one for each of the Repository Module and the Service Module. In the demo project, I have used Ninject. On adding Ninject for MVC from the Nuget Package, it adds NinjectWebCommon.cs to the App_Start folder that looks as in the following snippet:
  1. using System.Collections.Generic;  
  2. using DemoStart.Core.Interfaces;  
  3. using DemoStart.Infrastructure.DependencyInjection;  
  4. using DemoStart.Infrastructure.Logging;  
  5. using DemoStart.Infrastructure.Services;  
  6. using Ninject.Modules;  
  7. [assembly: WebActivatorEx.PreApplicationStartMethod(typeof(DemoStart.App_Start.NinjectWebCommon), "Start")]  
  8. [assembly: WebActivatorEx.ApplicationShutdownMethodAttribute(typeof(DemoStart.App_Start.NinjectWebCommon), "Stop")]  
  9.   
  10. namespace DemoStart.App_Start  
  11. {  
  12.     using System;  
  13.     using System.Web;  
  14.   
  15.     using Microsoft.Web.Infrastructure.DynamicModuleHelper;  
  16.   
  17.     using Ninject;  
  18.     using Ninject.Web.Common;  
  19.   
  20.     public static class NinjectWebCommon   
  21.     {  
  22.         private static readonly Bootstrapper bootstrapper = new Bootstrapper();  
  23.   
  24.         ///   
  25.         <summary> /// Starts the application /// </summary>  
  26.           
  27.         public static void Start()   
  28.         {   
  29.             DynamicModuleUtility.RegisterModule(typeof(OnePerRequestHttpModule));   
  30.             DynamicModuleUtility.RegisterModule(typeof(NinjectHttpModule));   
  31.             bootstrapper.Initialize(CreateKernel);   
  32.         }   
  33.           
  34.         <summary> /// Stops the application. /// </summary>  
  35.           
  36.         public static void Stop()   
  37.         {   
  38.             bootstrapper.ShutDown();      
  39.         } ///  
  40.           
  41.         <summary> /// Creates the kernel that will manage your application. /// </summary>  
  42.           
  43.         /// <returns>The created kernel.</returns>   
  44.           
  45.         private static IKernel CreateKernel()   
  46.         {   
  47.             var kernel = new StandardKernel();   
  48.             try   
  49.             {   
  50.                 kernel.Bind<func<ikernel>>().ToMethod(ctx => () => new Bootstrapper().Kernel);   
  51.                 kernel.Bind<ihttpmodule>().To<httpapplicationinitializationhttpmodule>();   
  52.                 RegisterServices(kernel);   
  53.                 return kernel;   
  54.             }   
  55.             catch   
  56.             {   
  57.                 kernel.Dispose();   
  58.                 throw;   
  59.             }   
  60.         }   
  61.           
  62.         <summary> /// Load your modules or register your services here! /// </summary>  
  63.           
  64.         ///The kernel.   
  65.           
  66.         private static void RegisterServices(IKernel kernel)   
  67.         {   
  68.             var modules = new List<ininjectmodule>   
  69.             {   
  70.                 new RepositoryModule(), new ServiceModule()   
  71.             };   
  72.               
  73.             kernel.Load(modules);   
  74.             kernel.Bind<iloggingservice>().To<loggingservice>();   
  75.         }   
  76.     }   
Once we have added the Ninject for the MVC to our project, the next big thing to do is to bind the interfaces of the repositories and services to the Implementations such as in the following snippets.

For RepositoryModule.cs
  1. public class RepositoryModule :NinjectModule  
  2. {  
  3.     public override void Load()  
  4.     {  
  5.         // BINDINGS..  
  6.         Bind<idemointerfacerepository>().To<demointerfaceimplementationrepository>();  
  7.     }  
 For ServiceModule.cs
  1. public class ServiceModule : NinjectModule  
  2. {  
  3.    public override void Load()  
  4.    {  
  5.        // BINDINGS..  
  6.        Bind<idemointerfaceservice>().To<demointerfaceimplementationservice>();  
  7.         
  8.    }  
Now, you will be wondering why we the Repository and Service. The Service methods are the Bridge/Flyover between the Controller/Business Logic and the Repository implementation, for making it more loosely coupled since there will be another layer between the Business logic and the Data access layer.

The next project is the Logging project that is the error logging that helps in logging the errors/exceptions to the database. Here in this demo project, I have used NLog.

Dependencies
In this architecture, the Web project has its dependencies on the other two projects, in other words the Core and the Infrastructure.

The Infrastructure project depends on the Core and the Core is independent of every other. As in the diagram for the Onion Architecture we have proven that the Core remains in the Core/Center and there is no transitive dependency amongst the UI and the Test with the data Access Layer. Check the images below:

Dependencies

You can check the dependencies among the projects and the Core that is independent.

Points of Interest
Finally, straight from the words of Jeffery Palermo, the father of this concept:

1.The application is built around an independent object model.
2.The layers inside define the interfaces (the core) and the outer layers implement them.
3.The coupling direction is towards the center, as in an Onion, as the name suggests.

Thus, the Onion Architecture helps decouple the Infrastructure and the Business (Controller) and the User Interface (Views) without getting into the OOP concept or has no new concepts with regards to the domain-driven approach.

This is thus a very simple and general, but very effective architecture. I hope readers will love this.

References

Jeffery Palmero.
Peel Onion Archi.

What is Digital Marketing

Introduction Digital marketing is a term, which used for promotion of products or brands by using electronic media such as PC, Laptop, tablets, Smart phone, etc.

Digital marketing used to different platforms such as website, e-mails, social network and apps.

 Feature scope of Digital marketing You know, 97 % American consumers use online media when reaching product and services.
 Benefits
 1. Consumers have access to information any time, any place that they want.
 2. Consumers can find your store, location and your contact information about product and    services.  
3.Consumers learn about new offers and promotions.
WHAT IS ONLINE MARKETING
Online marketing is a sub group of digital marketing. Online marketing means marketing of products using online channels such as social websites (FB, Twitter), emails, etc.
The different thinks are use of online marketing. Look at the same following thinks: Line up Line-up means, what you achieve with your marketing campaign? So first you can set line-up for online marketing.
For Example: Establish our brand in social media, build up our website visibility.
 Objectives
You will develop specific objectives for each goal. Some point’s mind, when you create objective: 1.What is objective exactly?
 2.The objective has to be measurable?
 3.The object has to achievable and reasonable?
For Example: get more than 1000 Twitter followers, get more than 1000 Facebook fans. Work out of a specific objective Objective to make you, and then you have to work on it. Such as you want to achieve 1000 Facebook users, then, mind some points: 1
.Provide reasons for people to become Facebook fans.
2.Engage with the community. List your tactics Always keep mind and create a list of very specific tastes, which you will utilize to achieve your marketing goals.
For example:
Share special deals,
Tweet and re-tweet regularly,
 Find and follow relevant people.
Find and follow relevant people.

New Power BI Available Now

Microsoft announced important changes to the Power BI service which include a free Power BI offering, price reductions and exciting new features and tools such as the Power BI Designer and iOS mobile apps. Power BI, it is a cloud-based business analytics service (software-as-a -service) for non-technical business users. With just a browser – any browser – or a Power BI mobile app, customers can keep a pulse on their business via live operational dashboards. They can deeply explore their business data, through interactive visual reports, and enrich it with additional data sources. The new Power BI Preview have additional features like:
 1. Sign up - US business email account holders can try the new Power BI Preview for FREE. International users will get free offer in future. Power BI Pro will be available in low monthly price and additional data capacity for the enterprises.
 2. Pull out reports from sources such as GitHub, Marketo, Microsoft Dynamics CRM, Salesforce, SendGrid and Zendesk.
3.New Tool “Power BI Designer” allows business analysts to connect to, model and visually analyze their data.
4.Power BI for iPad Preview is also available for download from Apple App Store.

Tuesday 27 January 2015

How to Login in Website With Facebook User Id and Password

This is a general question but important now a days for every developer. There is a defined step-by-step process for logging into a website through Facebook user id and password.
  1. Log into your Facebook account and go to "Manage app".
  2. Create new apps (if you have already an app).

    Create New App
  3. Next.

    Facebook App
  4. If you want to make Sand box public then check the Disabled sandbox mood.

    Disabled Sandbox Mode
  5. I will use a "<div>" for showing the login with Facebook button:
     
    <div class="fb-Login">
    <input type="button" id="btnFacebook" name="btnFacebook" value="" class="fb-Button" />
    </div>
     
  6. Then a "<script>" after the "<body>" tag:
     
    <body >
    <div id="fb-root"></div>
    <script type="text/javascript" language="javascript" src="js/fb-Login.js"></script>
     
  7. Then facebooklogoin.js:
     
         //Edited by dkp
            // Load the SDK Asynchronously
            (function (d) {
                var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
                if (d.getElementById(id)) { return; }
                js = d.createElement('script'); js.id = id; js.async = true;
                js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
                ref.parentNode.insertBefore(js, ref);
            } (document));
            // Additional JS functions here
            window.fbAsyncInit = function () {
                FB.init({
                    appId: '408537542603090',
                    channelUrl: '//http://yoururl.com/channel.html',
                    status: true,
                    cookie: true,
                    xfbml: true
                });
                FB.getLoginStatus(function (response) {
                    if (response.status == 'connected') {
                        // window.location = "http://dubaibricks.com/siteuser/home.aspx";
                        //connected
                        //alert("You are already login with facebook userid and password.");
                    } else if (response.status == 'not_authorized') {
                        alert("Please use normal signin with userid and password!Otherwise Provide us to fetch necessary informations from facebook like Email,date of birth.These are all private not public!")
                        FB.logout(function (response) {
                            //logout
                            alert("You are Signout successfully!Thank you.");
                        });
                        // not_authorized
                    } else {
                        // not_logged_in
                        //window.location = "http://96.0.68.12/";
                    }
                });
            };
            function login() {
                FB.login(function (response) {
                    if (response.authResponse) {
                        Getloginuserdetails();
                    } else {
                    }
                }, { scope: 'email,user_birthday,user_location' });
            }
            function Getloginuserdetails() {
                FB.api('/me', function (response) {
                    //alert('Welcome ' + response.first_name + ',' + response.last_name + ',' + response.gender + ',' + response.email + ',' + response.birthday);
                    var date = new Date();
                    var curyear = date.getFullYear();
                    //var curmonth = date.getMonth()+1;
                    //var curdate = date.getDate();
                    //var datediff = parent()
                    var yeardiff = parseInt(curyear) - parseInt(response.birthday.substr(6, 4))
                    if (yeardiff < 18) {
                        alert("Your age must be 18 years or above")
                        FB.logout(function (response) {
                            // user is now logged out
                        });
                    }
                    else {
                        var data = response.first_name + "|" + response.last_name + "|" + response.email + "| |";
                        data += response.gender + "| |" + yeardiff + "|";
                        $.ajax({
                            type: "POST",
                            async: false,
                            url: "Handler/registration.ashx",
                            data: data,
                            beforeSend: function (xhr) { xhr.setRequestHeader("X-AjaxPro-Method", "REGISTRATION-FB"); },
                            success: function (response) {
                                window.location = response;
                            },
                            error: function (xhr) {
                                //alert(xhr.status)
                                //alert(xhr.statusText);
                                //alert(xhr.responseText);
                                alert("!Sorry im am not fething your essential information.Please Try again later.");
                            }
                        });
                    }
                });
            }

  8. The channel.html:
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
    </head>
    <body>
        <script type="text/javascript" language="javascript" src="//connect.facebook.net/en_US/all.js"></script>
    </body>
    </html>

  9. Screen like this:

    Login Page
  10. Click "Sign in with Facebook":

    Signin in Facebook
  11. Login with Facebook credentials in your website. 

Monday 26 January 2015

Microsoft Announced Surface Hub

 Imagine an 84-inch smart whiteboard with 4k display, a built-in WiFi at your office meeting that you could use to write, and erase using a pen or a finger? You could open Web, documents, and objects, highlight them, pan and rotate them, and even zoom-in and zoon-out them. And at the end of the meeting, save and share them. That is what Microsoft’s newest Surface Hub is all about.  On Jan 23, Microsoft introduced the new preview release of Windows 10 announcing the Surface Hub as one of the features available in Windows 10.  Microsoft Surface Hub comes in two sizes - a 55-inch HD and 84-inch 4K.  Surface hub is a large screen touch smart device runs on Windows 10 powered by Intel i5/i7 processor, 120Hz (refresh rate 8.33 milliseconds), 84-inch screen, and 4k Ultra HD display. Loaded with Skype for Business, Office, and OneNote whiteboard and a full 1080p cameras on each sides, and a built-in mic makes the Surface Hub a perfect candidate for office meetings and presentations.