Lecture 11th: improving the user experience of Web applications-using smart clients to develop distributed Windows Forms applications

Source: Internet
Author: User

2005.3.8 ou yanliang

Course Introduction

How to use Smart Client technology to build Microsoft Windows Forms Application and make it scalable like Web Applications

 

Basic Content

Familiar with. NET Development

What is the concept of multi-physical hierarchy?

 

Course Arrangement

What is a smart client?

Design Philosophy

Occasionally Connected applications

How to Develop

Code access security

 

Smart Client

"Smart Client" is not a specific technology: it integrates many concepts, design methods and technologies

The Smart Client combines the advantages of a fat client with a powerful user interface and the advantages of a Web application with strong scalability

Multiple loosely coupled physical layers

Generally, as the presentation layer, the Windows UI communicates with the Web Service (intermediate layer) as the business logic layer.

 

Features of Smart Clients

Occasionally Connected applications can be developed.

Real Distributed Processing

Make full use of client hardware resources

The benefits of central deployment can be fully utilized to facilitate software upgrades.

Microsoft Application Blocks can effectively help you build applications with occasional connections and automatic upgrades

 

Demonstration 1

A simple Smart Client application

 

Any Windows form can be converted into an application of a smart client.

Deploy the exe file of the WindowsForm application in the virtual directory of IIS

Then we access this exe file through Http, And the browser will automatically download it from IIS to the local GAC, and then run this exe file.

 

Design Considerations

Whether to enable the middle layer to support simple client devices (PDA, telephone, etc)

Whether to create an application supporting occasional connections

Deployment Problems

Security and code access security

 

More complex applications

Warning

Security

Configuration

Code access security

Occasional connection considerations

Deployment Problems

 

Demonstration 2

A slightly more complex Smart Client application

 

If our application tries to access our Disk

If you deploy this application on the IIS server and run it on the browser, the code will attempt to access the local disk, an exception occurs when a program from the Internet does not have the permission to access the local disk. To solve this problem, we can use the configuration tool to configure access security.

We can create a new security policy.

We choose to limit a Url security policy.

To configure Security Policy permissions, we select full trust.

After the security policy is configured, run the previous application and create a file locally.

 

Microsoft Offline Application Block

Download data and continue working when the network connection is disconnected

Able to detect network connections

Notify all registered components of changes in connection status

Download and buffer data, and allow the application to continue working when the network connection is unavailable

Stores changed data locally when the application is offline

Synchronize the changed data with the server when the network connection is available

 

: Http://msdn.microsoft.com/library/en-us/dnpag/html/offline.asp

 

Demonstration 3

Offline data

The ConnectionState is the status of the current network connection. If it is the first time you log on, you will wait for the next network connection to change the attribute.

We added a delegate in the constructor, which listens through OfflineBlockBuilder. When OfflineBlockBuilder finds that the network connection status changes, it notifies us of the delegate passed in, then we can do things based on the changes in the network status.

Use of Offline code

In fact, Offline is a simple encapsulation of the Offline provided by Microsoft. The following is the running result.

In the Online mode, we can directly read information from the database; otherwise, we can obtain data from the Cache. When caching data, the Cache actually uses the Hash table.

Cache is a self-compiled class

The data in the Cache is serialized into binary data and stored in files. When the application is re-opened, binary information is read from the file, and the reverse string is converted into a Cache object.

We can choose whether the data layer is Online or the Controller layer in the presentation layer or MVC.

We also wrote a RefreshCache function, which actually creates a new thread to constantly cache the latest data Online.

AsynchRefreshCache actively downloads data from WebService Online, and then saves the cached data to the disk.

The application will keep calling AsynchRefreshCache, because we have established a thread to do this.

 

Deployment Options

"No-touch" deployment

Deployed on the IIS server, enter a Url in the browser to temporarily download and run the application, that is, the first example. This method has no overhead, but there is a limitation that the downloaded application may not be able to access local resources. The client needs to configure some security policies through the. NET Framework.

Xcopy

If you want to perform complex configurations on the application, it has certain restrictions.

"Bootstrpper" can download all required application sets over the Internet

Installer

Package it into a Setup file, and the client installs it using the installation package

 

Deployment considerations

Download the. NET Windows Forms application from a browser

Applications downloaded from the Internet may cause security risks.. NET may affect some functions of applications.

Upgrading applications using applications and Updater Application Block is not subject to any restrictions.

 

Updater Application Block

To help you:

Upgrade. NET applications using the "Pull" Mechanism

The server compares its version with the client version. If the server version is higher, the client automatically downloads the latest program.

Use encryption technology to verify the validity of the updated application assembly. The updated application assembly is used only after verification.

User intervention is not required during application upgrade.

Automatically upgrade the application to the latest version.

 

: Http://www.microsoft.com/downloads/details.aspx? FamliyId = C6C17F3A-D957-4B17-9B97-296FB4927C30 & displaylang = en

Tutorial: http://dotnetjunkies.com/WebLog/bsblog/archive/2004/06/10/16118/aspx

 

Demo

We can write our own code to monitor the work of Updater and control the work of Updater.

If it is Online, we will instantiate an AutoUpdate.

When the thread exits, we stop monitoring the current network connection status.

To enable the unsafe modifier, you must modify the Allow Unsafe Code Blocks attribute in the project attribute.

Use of Updater. We first copy all the code to the file to be deployed.

The following describes how to automatically upgrade an application.

If your application needs to be upgraded, you need to close the application and restart it. If the application needs to be closed, its thread disappears and cannot be opened by itself. The AppStart function is used to create an application shell, and AppStart is used to start the application. If the application is updated, AppStart is notified, and AppStart is disabled, then restart the application.

Manifest is a tool used to compile software engineering versions.

Specify project directory

Make sure that the Version number of the server project is updated, and the Version number here is the same as the latest Version number.

We can use this tool to generate the private key and public key, import the private key into this program, and sign the application.

After the configuration, save the configuration. In this case, a Manifest file is added to our application, and we will package and deploy it together.

The deployed file contains a configuration file appstart.exe. config.

Corresponding configurations must also be available in our project.

The client puts the updated application assembly in the baseDir directory. The server downloads the Manifest from the xmlFile directory and copies it to the xmlFileDest directory. After the copy operation is completed, the application version of Manifest and the running application version are compared to determine whether to upgrade the application.

Run the program. If there is a new version, the system will prompt whether to download the new version.

After the upgrade, the appstart.exe. config configuration file will also be updated

 

Summary

A smart client is not a specific technology, but it consists of many concepts, design methods, and technologies.

Windows Forms and Web Service provide. NET Support for Smart Clients

Smart clients need to consider many issues: Target customers, code access security, deployment problems, and occasional connections.

Microsoft Application Block provides a solution for the deployment of Smart Clients

2010.10.18

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.