Virtual Labs BizTalk

KHÓA ĐÀO TẠO: XÂY DỰNG HỆ THỐNG THỰC HÀNH LABS BIZTALK


Virtual Labs BizTalk

I.            Giới thiệu về khóa học

1.   Mục đích:

–          Hiện nay trên thị trường hầu hết các doanh nghiệp, Trường đại học, cao đẳng hoặc phổ thông, các Tổ chức khai thác sử dùng hệ thống quản lý CNTT hầu hết là không tập trung, không có kiến trúc nền tảng về hệ thống PaaS hoặc VDI hoặc không có giải pháp sâu tới người dùng thực tế.

–          Chi phí dịch vụ, đào tạo thường xuyên cao và phải tái đầu tư liên tục.

–          Để chủ động hơn trong việc kiểm soát, cũng như phát triển hệ thống quản lý hạ tầng công nghệ, tạo điều kiện tốt cho sự phát triển của tổ chức. Chúng tôi đưa ra các khoá đào tạo tư vấn giải pháp xây dựng hệ thống thực hành LABs cho nhiều mô hình tổ chức khác nhau.

–          Một trong những nội dung đào tạo của chúng tôi đó là: “Xây dựng hệ thống thực hành LAB BIZTALK”.

2.   Nội dung:

Đến với khóa học các bạn được học và thực hành cách cấu hình, cài đặt, xây dựng, vận hành một hệ thống LAB BIZTALK trên môi trường ảo hóa của VMware.

Khóa học hướng đến đào tạo cho các học viên những kiến thức tổng quát và xuyên xuốt các vấn đề:

  1. Cách thức, quy trình xây dựng giải pháp.
  2. Hệ thống mạng ảo (vNIC).
  3. Hệ thống máy chủ ảo (VMs).
  4. Thiết kế thành phần vApp.

II.         Đối tượng tham gia

–          Quản trị CNTT của Tổ chức, Công ty, Doanh nghiệp đang quản lý một môi trường nhiều máy chủ: có nhu cầu học thiết lập hệ thống bizTalk cho tổ chức của mình, có kỹ năng về tích hợp hệ thống nội bộ, bên ngoài và các đối tác thương mại để phát triển các ứng dụng xử lý kinh doanh có sử dụng BizTalk Server 2010, 2013.

–          Lãnh đạo CNTT: quan tâm tới các giải pháp xử lý thông tin liên hoàn, truy xuất nguồn gốc dữ liệu, xử lý quy trình chuỗi dữ liệu trong tổ chức kinh doanh như: siêu thị, smart chain, giám sát thông tin giữa nhiều khâu tổ chức, giữa các doanh nghiệp liên kết khác nhau…

–          Kỹ sư hệ thống: những người đang thiết kế và quản lý một cơ sở hạ tầng doanh nghiệp tư nhân, tổ chức, nhà nước.

III.       Yêu cầu với học viên

  1. Có kiến thức cơ bản về Hệ điều hành Windows / Linux, hệ thống mạng (Network).
  2. Kiến thức cơ bản về hệ thống ảo hóa vSphere của VMware, Virtual Box, Hyper-V.
  3. Ưu tiên các bạn có kiến thức về hệ thống Active Directory, SSO, ADFS, Domain Controller, CSDL SQL Server, Quản trị BizTalk.

 

IV.      Lợi ích của việc tham gia khóa học:

  1. Học viên có thể chủ động xây dựng hệ thống thực hành LAB BizTalk: Hệ thống Demo để người quản trị và người lập trình BizTalk biết được cách cấu hình hệ thống và hướng phát triển ứng dụng nhóm.
  2. Được đào tạo vững chắc kiến thức nền tảng hệ thống Lab, trên đó có thể tiến hành cài đặt, cấu hình, triển khai, giám sát và quản lý môi trường BizTalk. Thực hành trên nhiều máy chủ có cài đặt BizTalk, phát triển các ứng dụng tích hợp, đăng nhập 1 lần, tích hợp các sản phẩm thương mại.
  3. Có công cụ, môi trường thực nghiệm sẵn sang để giám sát chất lượng sản phẩm phần mềm, chăm sóc dịch vụ ứng dụng của khách hàng qua các giai đoạn phát triển phiên bản khác nhau.
Advertisements

Sửa lỗi khi không truy cập được CSDL của MS SQL Server Express 2008


Thật bực bội khi 1 website đang chạy bằng IIS7.5 .ASPX và có dùng SQL Express bổng không chạy được nữa, lỗi

Don’t have permission to access SQL Server Express 2008?

Tìm nguyên nhân: Lúc đầu nhìn có vẻ không hiểu tại sao lại lỗi, nguyên nhân không biết nó phát xuất từ đâu.

Bình tĩnh dò vết các báo lỗi thì mới mường tượng ra là do 2 nguyên nhân cơ bản sau:

Xác định lỗi:

1. Do vá lỗi update của SQL 2008 theo Windows Server Update từ bản vá SQL lên SP1, SP2, Sp3…

2. Vá lỗi cấu hình từ các hướng dẫn của BaseLine Security 2.2 và các hướng dẫn của Secunia và Windows Server Perfomance Security.

Chính những nguyên nhân trên đã dẫn lỗi của SQL Express càng ngày càng xa và khó có thể giúp chúng ta (người quản trị Web Hosting) dễ dàng phát hiện ra, dẫn tới người lập trình Web và người quản trị Hosting có thể ping nhau không biết ddi tới đâu.

Phương án sửa:

Lỗi nằm ở quyền của Account đã login và cài bản SQL Express đã bị rút thông công, mất quyền truy cập các SQL PipeLine và quyền truy cập databases với quyền “SysAdmin”.

Các bước sửa lỗi:

  1. Tắt  SQL Server Express từ  màn control Administrator tool\ Services

  2. Mở  cmd window (Run as Admin) và chạy ở chế độ single-user mode as local admin và gõ lệnh sau:

    “c:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\Binn\sqlservr.exe" -m -s SQLEXPRESS

  3. Mở tiếp 1 cửa sổ cmd mới (Run as Admin)

  4. gõ lệnh sqlcmd

    sqlcmd -S .\SQLEXPRESS

  5. Bây giờ hãy nhập user theo kiểu ‘domain\user’ vào nhóm sysadmin role:

    1. sp_addsrvrolemember ‘domain\user’, ‘sysadmin’

    2. GO

  6. Ctrl+C  bấm tổ hợp phím này để đóng  cửa sổ đầu tiên bạn đã mở single-user mode bằng lệnh  cmd để ngừng chế độ SQL Server cmd.

  7. Khởi động lại dịch vụ của SQL Server Express.

  8. Đăng nhập trở lại SQL Express bằng  Management Studio và truy cập bằng account bạn vừa thêm ở bước 5 thuộc nhóm “sysadmin.”

Sưu tầm: Các phương thức bổ sung giao diện cho các ứng dụng làm từ LightSwitch 2011


This walkthrough demonstrates how to create a theme extension for Visual Studio LightSwitch. A theme extension defines a color and font palette for the LightSwitch shell.

To create a theme extension, you must do the following:

  1. Create a theme extension project.

  2. Specify the display name and description.

  3. Define the theme.

  4. Test the theme extension.

Prerequisites


  • Visual Studio Professional 2012

  • Visual Studio 2012 SDK

  • LightSwitch Extensibility Toolkit for Microsoft Visual Studio 2012

Create a Theme Extension Project


The first step is to create a project and add a LightSwitch Theme template.

To create an extension project
  1. On the menu bar in Visual Studio, choose File, New Project.

  2. In the New Project dialog box, select the LightSwitch node, and then select LightSwitch Extension Library (Visual Basic) or LightSwitch Extension Library (C#).

  3. In the Name field, type TestThemeExtension as the name for your extension library. This name will appear on the Extensions tab of the LightSwitch Application Designer.

  4. Choose the OK button to create a solution that contains the seven projects that are required for the extension.

To choose an extension type
  1. In Solution Explorer, select the TestThemeExtension.Lspkg project.

  2. On the menu bar, choose Project, Add New Item.

  3. In the Add New Item dialog box, select LightSwitch Theme.

  4. In the Name field, enter TestTheme as the name for your extension.

  5. Choose the OK button. Files will be added to several projects in your solution.

Specify the Display Name and Description


The default name for your theme is “TestTheme” and the default description is “TestTheme description.” Both of these will appear in the Application Designer at design time. Therefore, you will change them to something more meaningful.

To specify the display name and description
  1. In Solution Explorer, choose the TestThemeExtension.Common project.

  2. Expand the Metadata and Themes nodes, and open the TestTheme.lsml file.

  3. In the Theme element, replace the DisplayName value with Test Theme, and replace the Description value with This is my first try at creating a theme. As follows.

    Xml

    Copy

    <Theme Name="TestTheme">
        <Theme.Attributes>
          <DisplayName Value="Test Theme"/> 
          <Description Value="This is my first try at creating a theme."/>
        </Theme.Attributes>
      </Theme>
    

    These are the values that developers will see when they select your theme on the General Properties tab of the application designer.

At this point you have created a theme, and you can test it in a LightSwitch application.

Define the Theme


The LightSwitch Theme project template added a TestTheme.xaml file to the TestThemeExtension.Client project. This file contains the resource directory for the LightSwitch shell; the default values and styles define the appearance of the LightSwitch Blue Theme (Default) theme that is the default for LightSwitch applications. You define your own theme by modifying some or all of the values in this file. For more information on the available styles, see Control Elements for LightSwitch Themes.

To define the theme
  1. In Solution Explorer, choose the TestThemeExtension.Client project.

  2. Expand the Presentation and Themes nodes, and open the TestTheme.xaml file.

  3. On the menu bar, choose Edit, Find and Replace, Quick Replace.

  4. In the Find and Replace dialog box, enter Segoe UI, Arial in the Find what field, and enter Segoe Script in the Replace with field.

  5. Choose Current Document in the Look in list, and then choose Replace All.

    Eleven occurrences will be replaced, defining Segoe Script for all of the font values.

  6. In the TestTheme.xaml file, locate the TextBoxBackgroundBrush element, and replace <SolidColorBrush x:Key=”TextBoxBackgroundBrush” Color=”White”/> with <SolidColorBrush x:Key=”TextBoxBackgroundBrush” Color=”Yellow”/>.

  7. Locate the ToolbarBackgroundBrush element and replace <SolidColorBrush x:Key=”ToolbarBackgroundBrush” Color=”#FFE9EDF1″/ with <SolidColorBrush x:Key=”ToolbarBackgroundBrush” Color=”Red”/.

    Note that the color values can be entered as either a System.Drawing.Color value or a hexadecimal color value.

    TipTip

    You can also open the .xaml file in Microsoft Expression Blend 4 and change the colors in a visual designer.

At this point you have created a rudimentary theme, and you can test it in a LightSwitch application.

Test the Theme Extension


You can test the theme extension in an experimental instance of Visual Studio. If you have not already tested another LightSwitch extensibility project, you have to enable the experimental instance first.

To enable an experimental instance
  1. In Solution Explorer, select the TestThemeExtension.Vsix project.

  2. On the menu bar, choose Project, TestThemeExtension.Vsix Properties.

  3. On the Debug tab, under Start Action, choose Start external program.

  4. Enter the path of the Visual Studio executable, devenv.exe.

    By default on a 32-bit system, the path is C:\Program Files\Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe; on a 64-bit system, it is C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe.

  5. In the Command line arguments field, type /rootsuffix Exp as the command-line argument.

    NoteNote

    All subsequent LightSwitch extensibility projects will also use this setting, by default.

To test the theme
  1. On the menu bar, choose Debug, Start Debugging. An experimental instance of Visual Studio opens.

  2. In the experimental instance, on the menu bar, choose File, Open Project.

  3. In the Open Project dialog box, select any existing LightSwitch application project and open it.

  4. On the menu bar, choose Project, ProjectName Properties.

  5. In the project designer, on the Extensions tab, check the TestThemeExtension check box.

  6. Select the General Properties tab, and in the Theme list, choose Test Theme.

  7. On the menu bar, choose Debug, Start Debugging. Observe the changes in appearance in the running application.

Next Steps


This completes the theme extension walkthrough; you should now have a fully functioning theme extension that you can reuse in any LightSwitch project. Of course, you might want to modify the styles to make the theme a bit more pleasing to the eye; the walkthrough is only intended to show you the necessary techniques.

If you are going to distribute your extension, there are a couple more steps that you must take. To make sure that the information displayed for your extension in the project designer and in Extension Manager are correct, update the properties for the VSIX package. For more information, see How to: Set VSIX Package Properties. In addition, there are several things to consider if you are going to distribute your extension publicly. For more information, see How to: Distribute a LightSwitch Extension.

 

LightSwitch Metro Theme Extension Sample

Introduction

This sample demonstrates how to recreate the LightSwitch Metro Theme extension, a contemporary theme for Visual Studio LightSwitch applications.

Building the Sample

The prerequisites for this sample are:

In addition to these prerequisites, you should be proficient in either Visual Basic or C# and should be familiar with theming in Silverlight. We also recommend that you be familiar with creating Visual Studio extensions using the Visual Studio SDK.

Description

This sample expands upon the Help topic Walkthrough: Creating a Theme Extension, which demonstrates a simple theme that defines fonts and colors. The Metro theme also makes use of styles, defining new appearance and behavior for the built-in LightSwitch control templates. To provide a consistent experience, you will need to define Resource Dictionaries in the form of a .xaml file for each control template, as shown in the following illustration:

Additional styles are defined in the MetroStyles.xaml file, which also contains a MergedDictionaries node that references the other .xaml files. When LightSwitch loads the extension, it reads in all of the style information and applies it to the built-in templates, providing a different look and feel for your application.

There isn’t much code in this sample; most of the work is done in xaml. You can use this sample as a starting point for your own theme, changing the fonts, colors, and styles to create your own look. Enjoy!

More Information

For more information on creating extensions for Visual Studio LightSwitch, seeVisual Studio LightSwitch 2011 Extensibility Toolkit.

 

LightSwitch Extensibility Toolkit for Visual Studio 2012

Visual Studio LightSwitch is a tool for developing business applications for the desktop, web, and cloud. You can extend the functionality of LightSwitch by creating extensions using Microsoft Visual Studio Professional 2012, the Visual Studio 2012 SDK, and the LightSwitch Extensibility Toolkit for Microsoft Visual Studio 2012.

The following are required in order to create LightSwitch extensions:

  • Visual Studio Professional 2012

  • Visual Studio 2012 SDK

  • LightSwitch Extensibility Toolkit for Microsoft Visual Studio 2012

In addition to these prerequisites, you should be proficient in either Visual Basic or C# and should be familiar with both Windows Presentation Foundation (WPF) and Silverlight. We also recommend that you be familiar with creating Visual Studio extensions using the Visual Studio SDK.

Extension Types


There are six types of extensions for LightSwitch:

  • Business types

    Let you wrap a base data type in a semantic type, providing additional validation and display capabilities in LightSwitch while continuing to store the data in its underlying type. They can include a Silverlight control for displaying data.

  • Custom controls

    Silverlight user controls with additional attributes to make them usable in and better integrated with LightSwitch.

  • Data sources

    Domain service adapter class that enables LightSwitch to work with other data sources.

  • Screen templates

    Can be used to create screens that have common layout patterns different from the standard screen layouts provided by LightSwitch.

  • Shells

    Let you create an application shell with a different layout and different capabilities than the standard LightSwitch application shell.

  • Themes

    Let you create a different appearance and behavior for LightSwitch applications and controls.

The LightSwitch Extensibility Toolkit for Microsoft Visual Studio 2012 includes templates that contain the necessary files for each extension type.

Creating LightSwitch Extension Projects


The LightSwitch Extensibility Toolkit for Microsoft Visual Studio 2012 installs two new project templates, LightSwitch Extension Library (Visual Basic) and LightSwitch Extension Library (Visual C#), that can be used to create extensions. When you select one of these project types, a solution with seven projects is generated:

  • The projects with names that end in .Client, .Client.Design, .Common, .Design, and .Server contain the various parts of the extension items that will be added to the library.

    Content ​project

    Purpose​

    Referenced by​

    Client

    Contains client implementations that should be deployed with a LightSwitch application but are not found in the Common project. For example, controls, shells, and themes.

    Client sub-project

    Client.Design

    Contains implementations necessary during the debugging of a LightSwitch application. For example, control images or custom property editors for the runtime screen designer.

    Client sub-project

    Common

    Contains ​implementations that are common to both the client and the server. For example, metadata loaders and validators.

    Client sub-project, server sub-project, Visual Studio IDE

    Design

    Contains implementations for design time integrated development environment (IDE) operations. For example, a screen template.

    Visual Studio IDE

    Server

    Contains server implementations that should be deployed with a LightSwitch application but are not found in the Common project. For example, data sources.​

    Server sub-project

  • The .Lspkg project packages the previous five projects so that LightSwitch can unpack and reference them when the package is installed.

  • The .Vsix project packages the generated .Lspkg file into a .Vsix package so that it can be added to LightSwitch through the Extension Manager.

The contents of each project will differ depending on which extension type template is selected. To learn more about how to create extensibility projects, see How to: Create a LightSwitch Extension Project

Developing LightSwitch Extensions


The process of developing a LightSwitch extension is like that of developing a Visual Studio extension using the Visual Studio SDK. As with any extension, you create an extensibility project, write code for the extension, debug the extension, set properties for the .Vsix package, and distribute the extension.

The actual code that you have to write will vary depending on the extension type. To start working with a particular extension type, see one of the following topics:

As with any Visual Studio extension, you debug a LightSwitch extension by using an experimental instance of Visual Studio. To learn more about how to debug, see How to: Debug or Test a LightSwitch Extension.

Once your extension is complete, you will want to set properties in the .Vsix package to identify the extension. For more information, see How to: Set VSIX Package Properties. The final step is to publish your extension on Visual Studio Gallery. For more information, see How to: Distribute a LightSwitch Extension.

Sưu tầm: Creating A LightSwitch Theme Extension using Expression Blend


image

Visual Studio LightSwitch allows you to create Theme extensions. A theme controls the overall look of a LightSwitch application.

image

Microsoft has an article, Walkthrough: Creating a Theme Extension, that covers the basics of creating themes for LightSwitch, however, this article will go a bit deeper and demonstrate creating more complex themes.

First note that the following are required in order to create LightSwitch extensions:

image

First, we create an extension project in Visual Studio.

image

We add a New Item to the .Lspkg project.

image

We add a Theme to the project.

image

A number of files are created in the various projects in the solution, including files in the Theme folder in the .Client project.

image

We click on the .Vsix project…

image

We then Start Debugging. This will open another instance of Visual Studio.

image

We create or open a LightSwitch project and go into Properties.

image

We click on the Extensions tab and enable the theme extension.

image

On the General Properties tab we select the Theme.

image

We then run the application.

image

The application shows with the default theme.

We now close the application, and the Visual Studio instance, and return to the extensions project.

Creating a Basic Theme

image

We right-click on the .xaml file and open it in Expression Blend.

image

When we click on the Resources tab, we can easily alter the brush styles.

image

When we run the application we see that our changes are reflected.

A More Advanced Theme

image

If we look at the LightSwitch Metro Theme we see an example of a more advanced theme.

image

It contains a class that implements the IThemeExtension interface, and an associated resource file.

See Jan Van der Haegen‘s article: Adding control styles to your LightSwitch theme extension for a full explanation of the the IThemeExtension interface.

image

We add a new class that implements the IThemeExtension interface using the following code:

using System;
using System.ComponentModel.Composition;
using Microsoft.LightSwitch.Theming;
using System.Collections.Generic;
using Microsoft.LightSwitch.Model;

namespace SimpleGreenTheme.Presentation.Themes
{
    [Export(typeof(IThemeExtension))]
    [Theme(GreenTheme.ThemeId, GreenTheme.ThemeVersion)]
    internal class MetroStyles :
        IThemeExtension
    {
        IEnumerable<Uri> IThemeExtension.GetControlStyleResources(
            string themeId, string themeVersion, IEnumerable<IModuleDefinition> modules)
        {
            yield return new
                Uri(@"/SimpleGreenTheme.Client;component/Presentation/Themes/GreenStyles.xaml", 
                UriKind.Relative);
        }
    }
}

image

Next, we add a Resource Dictionary to the project.

image

We can download Silverlight Themes from this link to “grab some ideas” Smile.

image

When we open the resource file in Expression Blend

image

We can visually edit the theme.

image

When we run the application we are able to see our advanced theming of controls.

Download Code

The LightSwitch project is available at http://lightswitchhelpwebsite.com/Downloads.aspx

Cách sửa lỗi khi lập trình bằng Visual Studio Lightswitch 2011


Trong quá trình lập trình và debug Build Project chúng ta rất thường hay gặp các lỗi sau:

1. If a user has installed SharePoint 2010 on a Windows 7 machine the default SQLExpress Instance is “SharePoint” which doesn’t connect to the default instance of SQLExpress needed by LightSwitch
—————————————-
An error occurred while establishing a connection to SQL Server instance ‘.\.\SharePoint’.
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections.

2. Cannot connect to PC-NAME\SQLEXPRESS. A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 – Error Locating Server/Instance Specified) (Microsoft SQL Server, Error: -1) For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=-1&LinkId=20476

3. I cannot run any LightSwitch program

I downloaded and installed LigthSwitch hopping to start beta testing immediately. Unfortunatelly, it cannot access the SQLExpress database instance, and I could not figure-out what is wrong.

Các bước sửa lỗi như sau:

Bước 1.

Changing the option in Options ==> Database Tools==>Data Connections will apply to the new projects that you create.

Try looking for the .lsproj file for you project on the file system. If you open this file in notepad, you’ll see a SQLEPXRESSINSTANCENAME element which will be set to SQLEXPRESS. Correcting this setting may fix your problem.

Bước 2.

Deleting all files in the dir ‘%LOCALAPPDATA%\Microsoft\Microsoft SQL Server Data\SQLEXPRESS’ solved the problem.

Bước 3.

Please check the ServerName which you provided. It should match with the below shown Name in the UserName textbox, and that name should followed with \SQLEXPRESS:

Connect dialog

Bước 4.

I know this question is old, but in case it helps anyone make sure the SQL Server Browser is running in the Services MSC. I installed SQL Server Express 2008 R2 and the SQL Server Browser Service was set to Disabled.

  1. Start->Run->Services.msc
  2. Find “SQL Server Browser”->Right Click->Properties
  3. Set Startup Type to Automatic->Click Apply
  4. Retry your connection.

Khởi động cùng dòng sản phẩm lập trình LOB “Dòng sản phẩm ứng dụng cho Doanh nghiệp” của Visual Studio LightSwitch 2010


You might know that LightSwitch is now in Beta 2 stage. Microsoft released it few days ago. I have a series of Tutorials on LightSwitch Beta 1 where we discussed on creating database tables using the LightSwitch table designer.

In this tutorial, we will discuss how to attach an existing database table available in your SQL server database. This was also available in Beta 1 release. This time, we will discuss with the latest version. Read the full post and at the end, leave your feedback.

If you are new to LightSwitch, you may like to read my previous chapters too. You can find them here: “Beginners Guide to Visual Studio LightSwitch“. I appreciate your feedback.

Setting up Environment

To start with, we need Visual Studio LightSwitch. Currently it is in Beta 2 stage, which you can download from Microsoft download site. Click the below image to download the installer:

Make sure that, you already have Visual Studio 2010 SP1 installed in your machine. If you don’t have SP1, you can also download it from here:

Once your development machine is ready with LightSwitch Beta 2, open Visual Studio 2010 and create a new LightSwitch project as shown below:

image

Once you hit “OK”, it will take some time to generate the project.

Quick Look into Existing Table

Let us create a new table called “EmployeeTable” in our SQL Server database. You can use your existing table too. If you don’t have SQL Server installed in your PC, you can use the SQLExpress also for working with that.

Here is our table definition which we will use to attach to our LightSwitch application:

image

In our table, we have “EmpID” as the Primary key, some strings and one date field. You can see the definition in the above screenshot.

Connecting External DataSource

Now once you have your table ready, it is the time to connect to it from your application. To do this, in the Visual Studio IDE home page, you will find one option called “Attach to external Data Source” (as shown below):

image

Click the link to open the connection Wizard. Alternatively, you can right click on the “Data Sources” folder inside your solution Explorer (as shown below) and from the context menu, click “Add Data Source…”. This will also do the same trick from you.

image

Ok, let us click the link from the Home Page (if you are unable to find it, you can open it from View -> Home Page). Have a look at it here:

image

Let’s click on the link in the Home Page to continue attaching on the external data source.

image

This will open up the “Attach Data Source Wizard” dialog in the screen.

image

From the above screen, chose “Database” and click “Next”. This will open another dialog called “Connection Properties” for you. In this dialog, you will be able to configure your database connection settings.

image

Select the “Server name”, “Authentication information” and “Database name” from the dialog. Click “Test Connection” to check whether the connection established. On success, click “OK” to continue.

image

Now, it will start retrieving your database tables for you and show them in the screen.

image

Select the appropriate table that you want to connect from the above dialog and give your proper name to the DataSource name. For this tutorial, we will use our existing table named “EmployeeTable“. Click “Finish” to attach the table with your solution.

Once you click “Finish”, it will import the table information and show it up on the screen (as shown below):

image

Here you will see that it kept the proper Data Type that we have in our original table. That’s all about attaching an existing table in LightSwitch application.

image

Now open the Solution Explorer. You will see that it actually created the Data Source named “employeeData“, and in that data source we have the table called “EmployeeTable“. Hey, all this without writing a single piece of code, as you can see.

Bắt đầu với LOB (Line of Biz) và Visual Studio LightSwitch 2010


Beginners Guide to Visual Studio LightSwitch

By Kunal Chowdhury

 

Introduction

Visual Studio LightSwitch is a new tool for building data-driven Silverlight Application using Visual Studio IDE. It automatically generates the User Interface for a DataSource without writing any code. You can write a small amount of code also to meet your requirement. Recently, I got some time to explore Visual Studio LightSwitch. I created a small DB application with proper data inserting UI within a small amount of time (without any XAML or C# code). Here in this article, I will guide you to understand it with the help of a small application. There will be a series of articles on this topic regularly. Read the complete article to learn about creating a Silverlight data driven application with the help of Visual Studio LightSwitch.

Setting up LightSwitch Environment

Microsoft Visual Studio LightSwitch Beta 1 is a flexible, business application development tool that allows developers of all skill levels to quickly build and deploy professional-quality desktop and Web business applications. To start with LightSwitch application development, you need to install the Visual Studio LightSwitch in your development machine. To do so, follow the below steps:

  • Install Visual Studio 2010
  • Install Visual Studio LightSwitch

The LightSwitch installation will install all other components to your PC one by one including SQL Express, Silverlight 4, LightSwitch Beta server, etc. You can download the LightSwitch Beta 1 from here: Microsoft Download Center (Visual Studio LightSwitch Beta 1).

Creating a LightSwitch Project

Once you installed Visual Studio LightSwitch, run the Product to create a new project. Go to File –> New –> Project or press Ctrl + Shift + N to open the “New Project”. From the left panel, select “LightSwitch”. In the right pane, it will filter the LightSwitch project templates. This will include of type VB & C#. Select your respective type. Here I will use the C# version.

image

In the above dialog Window, enter the name of the project, select proper location for the project to create and hit “Ok”. This will create the blank LightSwitch project for you by the Visual Studio 2010 IDE. It will take some time for the project creation. So, be patient.

Create a Database Table

After the project has been created by the IDE, it will open up the following screen:

image

You can see that, it has two options in the UI. You can create a new table for your application. Also, you can attach an external database. If you open the Solution Explorer, you will see that, the project is totally empty. It has only two folders named “Data Sources” and “Screens”. “Data Sources” stores your application data, i.e. Database Tables. On the other side, the “Screens” folder stores the UI screens created by you. I will describe them later in this tutorial. Let’s create a new Table for our application. Click on the “Create new table” to continue. This will bring up the following screen on your desktop:

image

In the above page, you can design your Table structure as you do in the SQL server while creating a new table. Each table will have a “Id” assigned to the table of type “Int32” & it is a Primary Key to the table. Add some additional columns to the table.

image

In the above snapshot, you can see that, there are several column types (data types) available in LightSwitch application. For our sample application, we will create 4 additional columns called “FirstName (String)”, “LastName (String)”, “Age (Int16)” and “Marks (Decimal)”. Change the title of the table from “Table1Item” to “StudentTable”. This name will be used while saving the table. Save the table now. If you want to change the name of the table later, just rename the table header and save it. This will automatically update the table name.

image

Be sure to set all the fields as “Required” field. This will be helpful validating the data. I will show it to you later.

Create a Data Entry Screen

Once you are done with structuring your database table columns, you will need to create a UI screen for your application to insert records. Click on the “Screen…” button from the top panel as shown in the below snapshot:

image

This will open the “Add New Screen” dialog window to the screen. Select “New Data Screen” from the Screen Template, provide a Screen Name in the right panel & choose the database table as Screen Data from the dropdown.

image

Click “Ok” to continue. This will create a new UI screen for your application to insert new data record by end user. Now, in the solution explorer you can see that, the “Data Sources” folder has one database named “ApplicationData” and it has a table called “StudentTables”. In the “Screens” folder, you can find the recently created data entry screen named “CreateNewStudentTable”. You can change the design of the UI from the below screen:

image

You can add or delete new fields or controls. You can also rearrange the controls in the UI. For our first sample application, we will go with the default layout controls.

See the Application in Action

Woo!!! Our application is ready. We will be able to insert new records in our database table from our application. No need to write a single line of code. What? You are not agreeing with me! Let’s run the application by pressing F5. This will build your solution. It will take some time to compile the solution. Once it builds successfully, it will open the following UI in your desktop:

image

It is a Silverlight OOB Application. If you want to confirm, right click on the application & you will see the Silverlight context menu pops up in the screen. OMG!!! We didn’t do anything to design the above UI! The Visual Studio LightSwitch automatically created the screen for you with a “Save” and “Refresh” button. You can see a collapsible “Menu” panel at the left of the screen. In the right side, you will see tabular panel containing some labels and TextBox which will be required to insert data in your application database. In the top right corner of the screen, you will see a “Customize Screen” button. Once you click this, it will pop up another Child Window for you to customize the application screen at runtime. This will not be visible, once you deploy the application. We will cover them later in different article.

Validation of Fields

As I told you earlier, our application is ready. So, what to do for writing some simple validation for our application? Wait, you don’t have to worry about that. LightSwitch internally does that for you. Let’s have a demo on it. In the form panel, insert some data. We will purposefully write invalid data in the “Age” field. Instead of entering age, we will enter some text in the age field. If you press tab or click elsewhere (on lost focus), it will do the validation & show the error on the screen.

image

You can see the validation error popup in the screen as shown here:

image

Now enter proper values for all of the fields and click “Save”. This will save the records properly.

More on Save

Once you entered proper values in the input boxes, click “Save” to store the record.

image

This will save the record and add another field called “Id” in the UI. The value for the Id will be 1 (one) as this was our first record & will increase by 1 as we add more records.

image

To add more records, close the current tab and click “CreateNewStudentTable” menu item from the left panel.

image

Now enter some records and click Save button. You will see it in action that, the Id is automatically increasing by 1 as and when you are saving a new record.

image

If you have any unsaved records and want to close the tab or want to add a new record, it will open a message dialog to the screen warning about unsaved changes. It will ask you to save the changes before proceeding.

image

Click “Save” to save the unsaved record to database. Click “Discard” if you don’t want to save the record. Click “Cancel” to stay on the same page.

Customize the Screen

If you want to change the UI at runtime, click on the “Customize Screen” button available at the top right corner of the application window. Remember, this button will not visible once you deploy the application. Once you click the button, it will popup the Customization screen. Here you can change the layout of the screen, insert come new field or delete something which already exists. For now, we will not go with changing the layout or controls. I will cover them in another article.

image

Here, we will change the display name of the new student menu item. Select the top level node of the screen items and in the properties panel, change the “Display Name” from the default one to “New Student”. Now save the settings and restart the application for the changes to take effect. Once you run your application now, you will see the display name of the menu item has been changed to the entered value, i.e. “New Student”. This is more meaningful than the default text.

image

If you want to do the same thing inside the Visual Studio IDE, go to the properties pane as shown in the below figure. Find the “Display Name” property and change the display name to your own meaningful name. Run the application to see it in action.

image

You can change many other properties from the properties panel too.