Probe into the Smart Client Technical Technology

zhaozj2021-02-16  62

First, what is smart client?

Briefly, the Smart Client Smart Client is such an expandable desktop application that integrates different applications: it can have no contact deployment, that is, it is necessary to install, dynamically loaded, XCOPY can run without modifying the registry You can dynamically upgrade, automatically update, which can be easily connected to the firewall problem without worrying about the firewall problem and easy access to webservices for Windows applications.

Second, the characteristics of Smart Client

1. Dynamically loaded, you need to install

The mutual call between the various components of the application does not use direct reference, but is dynamically loaded, that is, the way to install, effectively reduces the consumption of system resources. Application software developers can develop according to the public interface of the enterprise application system, and then publish the application component on the enterprise server, and the client application will automatically discover and load the application component.

2. More loose coupling

Since the mutual calls between the above-mentioned constitutors do not use direct reference, the system implemented more loosely coupled, providing an application upgrade update to the application upgrade.

3. Further modularization

Due to the loose coupling characteristics of the application, the further modularity of the system makes it possible, new features, new features, only need to develop new modules that meet interface definitions and add a connection. There is no need to modify the reproduction of existing procedures.

4. Zero Contact Deployment

As long as you do one main program file to the local, you can run it directly, you don't have to change the registry or shared system components, and other application components will be automatically downloaded at the first runtime.

5. Network load application components

Smart Client's application can easily load applications from the web server, and because the programs and load are implemented from the 80-port, there is no need to consider the firewall problem, which provides convenient for the centralized management of the enterprise system.

6. Automatic update

Simply publish the new version of the program on the server, automatically discover the latest version of the program and application components by the client, and download and update automatically.

7. Applications available online with offline

The SMART Client application despite the use of network loading assemblies, but once loaded, the assembly is cached to the local. When the user starts at least once an application, its assembly is downloaded and cached to the local memory, so the user can run your smart client offline (by converting the browser to offline working status), suppose the application is not You can run it permanently access Web Services or a shared database.

The biggest benefit of building a smart client is to use offline. Although the connection between the business is getting closer, we still can't provide a continuous connection to the enterprise application. Offline mode of operation can automatically receive data and application updates when you re-online, this feature is that people want to get, but before .NET, this is difficult to achieve. Like the fat client, the smart client distributes a lot of processing to the client, which is for the server to eliminate the load that needs to be borne in a web-based application. Finally, the intelligent client takes a user hopes that the application is working - allowing fast data access and management without the need for unnecessary screen updates.

8. Personalized user interface

The user can set the client application according to the preferences, and the configuration information will be saved to the server.

9. Perfect integration with WebServices

The Smart Client app can be easily integrated with WebServices, so you can easily enjoy the perfect user experience of the C / S application without worrying about a series of issues such as firewalls.

Third, the advantage of Smart Client

Despite a lot of advertisements, thin web solutions don't have to be the future of all enterprise applications. Don't discard WinForms to build an idea of ​​enterprise applications, because enterprise applications require centralized distribution. The following table describes the contrast between Smart Client and thin web solutions: function

Intelligent client

Web application

You can work offline

can

not easy

Concentrated deployment

can

can

Advanced GUI characteristics

Have

Have

High performance GUI

can

Cannot

Uninstall processing to the client

can

limited

Update via HTTP

can

can

Safety

Yes

Yes

Do not touch the client installation

Not; need to build a load application to change the security configuration of .NET (unless you use Microsoft Transaction Server or Citrix, but if so, the application can only be used online)

Yes

Most time only transfer data

Yes

Not; the transmission of the content, .NET control is displayed in IE

Client needs .NET Framework

Yes

Not

Platform and client are independent

Not

Yes

Suitable for e-commerce or internet applications

Not; most suitable for enterprise internal applications

Yes

Take advantage of our client-wide resources

can

Cannot

Table 1 comparison

You can simplify your decision process by comparing the functions of your smart client and web applications.

Fourth, Smart Client's Work Model

Figure 1. Smart client working model

The application loader uses HTTP to access and download assembly from a virtual directory on the web server. After downloading, the assembly is cached, only when needed.

V. SMART Client's way of operation

1. The way the boot process is operating

a) Local operation

This way of operation seems to be a local application, which is the benefit of help you control the creation of the installation directory and related icons, and provide a simple uninstallation. Deritage is that you need to make a MSI installation file and setup on the client.

b) Network operation

Just a complete network operation method, running and opening the webpage on the Internet - Enter a URL in the browser address bar or click the appropriate connection on the web. The advantage of this way of operation is to realize the real zero contact deployment, you don't need to install anything on the client, of course, the harm is also obvious: its URL path often be intercepted by software such as flashget. Download instead of running directly.

2. Method of loading components

a) Load directly from the network

One component is loaded by using the .NET framework assembly loader directly loaded from the network, one of this approach is simple, and can implement an automatic assembly update, see the following code:

Using system.reflection;

/ / Network operation mode, the loaded assembly path is the URL address on the server.

askMBLYFILENAME = "http://smartclient/appcomponent1.dll";

AskEMBLY ASM = askMBLY.LOADFROM (askMBLYFILENAME);

A few sentences that realize the network loading of the assembly, and the key sentence is Assembly.LoadFrom (askMBLYFILENAME).

Of course, this way is simple but there is also a bad place, that is, this way is very dependent on the browser's cache mechanism. Once the cache is emptied, the program is unable to work, which is a very troublesome problem.

b) download to the local then load from local

Another way to dynamically load the assembly is to download the assembly to the local folder and then load it from local, which does not rely on the browser cache, that is, the application component is just after running (if it is If you are set to download from the network when you need it, the application is still running normally even if the cache is offline and cleaned. The disadvantage is that the assembly cannot be downloaded from the network to the local. You need to use the Windows Background Intelligent Transfer Service. You cannot fully update the assembly, you need to manually write an assembly loader, this stuff can use MicrosoftUpDateRapplicationBlock, and All source code. 3. Method of rendering of components

The components you talk here will of course refer to the interface component. If it does not involve the user interface, it is of course not to talk about what is the way.

a) Hide boot procedure after component loading

As a very common component rendering, the assembly is instantiated as a form, and then use the form.show () method to be rendered, and the boot form is hidden in form.hide ().

b) Components as a sub-form of the carrier platform

In the presentation of the component as a subform, it is designed as an MDI form, and then sets the ParentForm property of the loaded assembly to the bearer platform to display.

c) Components as controls for carrying platforms

In this manner, the component is not instantiated in the form of a form, but is instantiated by the user control, and then dynamically adds it into a tray of the bearer form (usually panel).

Six, SMART Client security issues

1. Client code access security (CAS)

Speaking of the Web mode is directly running, you can't talk about the code access security (Code access security) problem, if a hacker can convince or induce you to download a code, and you run it under a high privilege account, that operation The system is open to various hazard portals. This situation is the reason why the famous Declaration "is running under minimum permissions", everyone should pay attention to this.

However, .NET Framework provides more advanced features than this identity-based security. The CAS mechanism enforced by the CLR allows for code (actually a unit of Assembliy, .NET Framework) to specify different credit levels, such as digital certificates or source site or URLs. In this way, .NET Framework only allows for known or trusted source code.

To make your intelligent application to run, you need to change some client security settings - essentially notify the client runtime to believe in the assembly of your application. One way is to add a site with your assembly to the IE to trust in the list of Site, and then use the Microsoft .NET Framework Configuration tool installed in your management tool directory to modify the .NET Framework security settings. Open the Framework Configuration tool, right-click Runtime Security Policy, then select Adjust Security. Adjust the trust level to Full Trust for all sites specified in Trusted Sites. As a choice, you can also use the Framework Configurative tool to modify the security policy so that it trusts your application's individual assembly. Right-click Runtime Security Policy to select Trust Assembly.

2. Server-side authentication

The authentication here is actually the authentication of WebServices, although it is feasible from the theoretical Forms authentication, but WebServices is a A2A.

(Application to Application), then try not to use this as a better authentication method that is more suitable for human-computer interaction.

a) Windows authentication

Use the user's Windows account to authenticate if the domain account is verified.

b) .NET Passport authentication

Use the .NET Passport account associated with the user to authenticate.

c) Custom authentication

Using SOAP to send account information to the web service is a relatively secure way to pass the full-time portal information, and do not have to deliver a certificate for each WebMethod (as a part of the parameter). If you still feel that you can, you can SOAP header is encrypted, or simply uses the SOAP to pass the security certificate. Here only describes how to authenticate using SOAP does not encrypt the username and password. When a service request is sent to the server, the request will be intercepted by WebServiceAuthenticationModule, and WebServiceAuthenticationModule begins to analyze the request. Soap header, analyze the username and password sent by the client, and authenticate authentication. If the authentication passes the user, WebServiceAuthenticationModule will issue authentication tickets to the user; if the authentication fails, WebServiceAuthenticationModule throws a message as "Access Deny!", Which can then interceise the exception and process it. .

Seven, SMART Client Development Principles

1. The principle of development of server-side

a) Authentication: SOAP header

First, you will be a custom HTTP module (here you do the webserviceauthenticationmodule) and register in WebConfig; add a WebServiceApertationModule type defined in Web Service Class, and apply the SOAPAUTHHEADER attribute to our web service method, Then use the name of the name of the field to define the constructor of this property; for the client, each time the request is sent to WebServices, you need to populate the SOAP header. After WebServices defines the SOAP header, the client's proxy class will also Generate the corresponding class agent, first create a service object instance represents our web service, then create a SOAP header object instance, and populate the SOAP header, then put the SOAP header associated with the agent so that we can use us Web service.

b) coarse granularity, less interface

Developing WebServices should be: coarse granularity, fewer interfaces, thus delivering the value of the delay costs of the network request.

c) Each .ASMX file is open to less and independent features, fewer data sets

The purpose of this is to try to minimize the size of the client component. When using the WebServices application, generate a proxy class, if a .asmx file is open to too many features and too many assemblies, it will make the client component It is too bloated, but in fact it can be used only one of the small part of the code. In general, a complete function may only have one or two database tables, others just aid. In this case, the primary table uses the data set, and the auxiliary table can only use an array. d) Self-satisfaction of data description

To achieve this, it is to achieve modularization, and a functional implementation does not require much to depend on the related modules. Still the above as an example, one .ASMX file, in addition to the public home data set and provides a full operation, it is generally, the only description of the auxiliary table should also provide a simplistic description of the auxiliary table (such as an array description) implementation. Such a client component only needs to reference one. TheASMX service can implement all the features.

2. Principles of the development of the client

a) Single assembly should be as small as possible

Since the Smart Client is loaded over the network, a single assembly should be as small as possible for quick loading.

b) Calling principles of the program center: through the interface

Since it is a system, it is unpaired between each component. The principle of calling the program center is to try not to reference directly, but should be communicated by an interface.

Of course, the interface that is said is a broad concept, and it should be said that there are still two implementations: abstraction classes and interfaces.

The benefits of using an abstract class are that there is no need to rewrite all implementations in the derived class, but the abstract class can be fully implemented, but more common is that partial implementation or does not implement, thereby encapsulating the general function of inheritance, but the problem is one Detective classes can only be inherited from a class. If you are expected to create multiple versions of the component, you create an abstract class. Abstract classes provide a simple and easy way to control component versions. By updating the base class, all inheritations are automatically updated with the changes. If you want to design a large function unit, use an abstract class. Use an abstract class if you want to provide a universal implementation between all implementations of the component.

One biggest advantage of using the interface is that your class can implement multiple interfaces so that you can define multiple small and different interfaces in system development. When developing components, one or several interfaces can be implemented as needed. Like a wooden, it is a fully abstract member collection, but "interface" is a completely abstract set, which can be seen as an operation definition contract. The implementation of the interface is completely left to developers. More importantly, once the interface is defined and accepted, it must remain unchanged to protect the application written in this interface. After the interface is released, it cannot be changed. If the created function will be used between a wide range of all-term objects, use the interface. Abstract classes should be used primarily for close objects, and the interface is best suited for unrelated classes to provide general functions. Use the interface if you want to design a small and concise function block. Abstract class allows the part to implement classes, and the interface does not contain any member's implementation.

c) Key points: Definition of interface

Here is a key point of development, the definition of the interface, this article sees this, it is not difficult to conclusion, the necessary conditions for many superior superiority implementations of Smart Client are defined and implemented a series of definition of good interface criteria. Therefore, the first thing to do when system development is to carefully analyze and study all aspects of the system, and make a complete set of interfaces.

Creating an interface is to create a definition, and the interface definition will never be changed. "Interface invariance" is an important principle for component design, which is to protect existing systems written for using interfaces. Excellent interfaces are often small and independent, reducing the possible possible problems. In general, a closely related function should be aggregated into a group in an interface. There is too much to make the interface inconvenient to run, and too segmentation features will result in additional system overhead and reduce the simplicity of use. The ability to improve the system by adding an interface allows you to get the benefits of object-oriented programming. Eight, the development of Smart Client

Debugging technology

Smart Client is a complicated system that is different from previously common applications, so its debugging technology is more complicated than previous, and it is still a difficult point. Because the development code is mostly not an executable application, more is the DLL library file, which cannot be debugged directly, and a debugger must be written for indirect debugging. At the same time, because of loosely coupled and network loading, the local tight coupling commissioning and the actual operation are somewhat different. This is no effective solution.

Nine, smart client development needs to solve problems

1. Local cache and update of data

Smart Client is a browser cache mechanism and online offline applications, which should also be cached locally from theoretically speaking, as for the facts, and have not seen relevant information. Further experiments and arguments are needed. If there is no automatic cache, then you need to consider writing code to implement common data locally, after all, some data that is not often updated each time you read it. It is not too necessary to get it. (This also reflects Smart Client " The advantage is coming), then what way is adopted to the local, when needed to update the server is worth considering the problem.

2. Normalization of interface definitions

As mentioned earlier, the importance of defining the standardization interface is obviously important and the problem that must be resolved is: How do I define our universal and specifications?

3. Upgrade procedure development

This problem involves the problem of the load method of the components mentioned earlier. If you use the way the component is downloaded to the local and then loaded from the locally, then you need to resolve the development of the upgrade program, although there is MicrosoftUpdaterapplicationBlock, but at least We have to understand it and learn how to use it.

Ten, smart client development needs to do early preparatory work

As the saying goes, the sharpener is not misreading, and has to develop a sophisticated Smart Client application, walk less and improve the development efficiency during the development of development. I suggest that you will do the following preparation before the development of Smart Client applications. jobs:

Define universal interface

Develop a set of universal and standardized application components.

2. Develop universal components

Then develop some general components as follows:

a) interface set

Inter-component communication interface class, according to actual needs, you can put a number of interfaces together, and the slogan has developed several interfaces.

b) Guide procedure

The boot program is almost the only EXE executable in the Smart Client, which is responsible for the guidance and maintenance of the entire system, but in fact, the function is simple.

c) Local file reading and writing

A common class for reading and writing client local files for the characteristics of Smart Client applications, its core code is as follows:

/ / Get a separate storage area by user, domain, and assembly

IsolatedStorageFile isoStore = isolatedStorageFile.GetStore (isolatedStorageScope.user

IsolatedStorageScope.domain | IscolatedStorageScope.assembly, null, null; // Create a directory

Isostore.createdIRectory ("Testdir");

//Create a file

IsolatedStorageFileStream isostream1 = new isolatedStorageFileStream

("TestDir // Test.txt", FileMode.create, Isostore;

// Write file

Streamwriter Writer = NULL;

Writer = new streamwriter (isostream1);

Writer.writeline ("Hello isolated");

Writer.close ();

isostream1.close ();

d) abnormal processing

Abnormal assemblies developed for SmartClient features, where there are more than some processing of network abnormalities (such as networks, etc.).

e) authority control

The permission control module developed for the SMART Client, which should be divided into two parts, the server side, and the client. The server is mainly developing a WebServices authentication module that handles communication with the server-side authentication module and its own permissions control function (such as offline).

转载请注明原文地址:https://www.9cbs.com/read-24293.html

New Post(0)