Smart Client (SmartClient)

xiaoxiao2021-03-05  46

Smart client (SmartClient)

This paper mainly discusses the client application model based on the enterprise environment. Since I have worked in the development of the traditional client / server two-layer structure application and the development of multi-layer structural applications based on the .NET platform, this article will focus on .NET A smart client application model on the platform, and a more complete client software framework is constructed step by step according to the needs of the general enterprise application system.

Introduction The concept of smart clients is proposed as a characteristic of the Microsoft.Net platform. In fact, its many features already existed in traditional applications, just .NET platform provides support from system and language levels, making development intelligent customers End application is more convenient. This article will discuss the functions and features of the intelligent client from the perspective of the enterprise application system and how to implement it on the .NET platform.

Overview 1. The current client application model compares the current client application model is roughly divided into two: C / S (Client / Server Model) and B / S (Browser / Server Model). Software developers based on corporate environments, how to go to the browser-based thin client (Thin Client) application model, and how to go between the corresponding rich client (RICH Client), faced Difficult generation replacement. The advantages and disadvantages of browser-based applications:

Easy to install: You can be used in many tablets and have nothing to do with the operation platform of the client algorometer. Most computers have been installed by default (some application systems need IE, or need to install Java virtual machines, which is temporary and neglected). Easy to deploy and maintenance: just need to deploy and maintain on the server side. You must work online: work efficiency and network delay is related. The resources of the client computer cannot be fully utilized: can only render the user interface through a limited HTML language, and there is no use of the client computer's calculation processing power. You can only print the information using the browser's printing function, not applicable to the company's report printing. The network transmission is large: Since the client cannot save status data, the user interface content must be transmitted between the client and the server and the required data. The security is low. For the server, you can filter data through firewall software because all transfer content is based on HTTP ports. However, it is difficult to encrypt and sign the data to ensure integrity during transmission. (HTTPS does not seem to solve the problem) Applications suitable for e-commerce or do not require strict control of the client.

Frequently and disadvantages of rich client applications:

You can work offline: Prerequisites the ability to have cache data locally, which involves synchronization with server data. Take advantage of the resources of the client computer: You can provide users with a wealth of interface elements, you can access the native disks with the native application interface (API), and the speed is faster. The network transmission is small: just transfer data between the client and the server. The security is high. It can be convenient to perform encryption and decryption operations on the client and servers, and can also eliminate traditional applications such as firewalls and HTTP obstacles through Web Service. The installation, deployment and maintenance work is more cumbersome: there is a certain limit and requirements for the client computer on the operational platform and additional software. Suitable for enterprise internal applications.

Currently, there is another browser-based thin client application. They are provided to users through technology and tools such as Microsoft Terminal Server, Citrix System's Independent Computing Architecture and MetaFrame products. These types of solutions allow users to use the experience of fat clients and managed by centralized software installation and maintenance, which is very cost-effective to the company. The problem with this mode is that when the application is not connected to the application server, the user cannot be used. The client does not perform real processing, processing completely relying on the application server, which causes server performance issues and consumes the CPU cycle of desktop computers. In short, relative to rich clients, browser-based models is a great model for information technology (IT) system administrators, but there are many shortcomings for developers and users. Microsoft .NET Framework will meet the needs of these triples. Its intelligent client application model combines the powerful functionality and flexibility of rich client models, as well as easy deployment and stability based on browser-based models. 2, other functions that the client application should also have for the enterprise application system, the client application as the interactive interface of the entire system and the user, but also considers the following functions: security: The security here is mainly the application level Security, mainly through user permissions, role assignments. For client applications, a login form or login page is usually required to complete user identity. Applications with higher security requirements may also need to provide reliable security services for applications through public key infrastructure (PKI), and clients attach an encrypted signature module. Scalability: Client applications should have the ability to include a variety of different types of application modules, while also improving the entire system in the continuous increase in use during use. Therefore, the client application can be designed as a container, and each application module is dynamically loaded by the container as components. Configurability: Due to user permissions and user preferences, the client-loaded application components and presentations are different from person. It is necessary to pass the application system to the client, and the user's personalized configuration information is required to interpret and present the corresponding user interface.

In summary, we define the next general definition of the smart client application model: an extensible desktop application that integrates different applications, and has the following features:

None contact deployment: When installing, just download a main program file to the local, running directly, no need to change the registry or shared system component, other application components will be automatically downloaded at the first runtime. 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 automatically download and update. Application Offline: Allows the server to work with local client programs and application components. Dynamically loaded application components: Application software developers can develop according to the public interface of the enterprise application system, then publish the application component on the enterprise server, and the client application will automatically discover and load the application component. Personalized user interface: Users can set the client application according to the preferences, and the configuration information will be saved to the server.

Here we will describe the above features as an example to be described in detail with the .NET platform WinForms application.

.NET platform WinForms application example 1. System requirements 1, client software requirements

Any operating system that supports .NET Framework has installed SP1 .NET Framework Internet Explorer 5.0.1 or later

2, server software requires automatic release, update server: Microsoft .NET Framework, MDAC2.7, IIS

Second, the operation mode client application has two ways of operation. Different running methods will directly affect the subsequent assembly publish and updates. The following will explain the detailed explanation: 1. Network run .NET Framework installation provides a mount Internet Explorer 5.01 And higher versions to listen to the mechanism of the requested .NET assembly. During the request, the executable is downloaded to the disk called an assembly download cache (Windows2000 is: c: / documents and settings / administrator / local settings / application data / assembly in a subdirectories), The assembly itself and other related assemblies it references are also downloaded to the local IE cache (Windows2000 is: C: / Documents and Settings / Administrator / local settings / temporary Internet files). Then, the process named IEEXEC starts the application in an environment with limited security settings. For example: You can enter a .NET executable (http: //smartclient/myApplication.exe) published on the web server in the address bar of IE, IE does not prompt you as much as other files, and It is directly executed. In this way, the application runs with very limited security settings (INTERNET Rights Set), the permissions in this permissions include: Security, File dialog, print, independent storage file, user interface. Independent storage files allow your application to save some data (Windows2000 is: c: / documents and settings / administrator.tomato / local settings / application data / ISOLATEDSTINGS / Application Data / ISOLATEDSTINGS / Application Data / ISOLATEDSTINGER), the default storage space is 10MB), you You can save the data through the class in the system.io.isolatedStorage namespace without thriving. Example: // by user, domain, assemblies get isolated storage IsolatedStorageFile isoStore = IsolatedStorageFile.GetStore (IsolatedStorageScope.User | IsolatedStorageScope.Domain | IsolatedStorageScope.Assembly, null, null); // create a directory isoStore.CreateDirectory ( "TestDir" ); // file IsolatedStorageFileStream isoStream1 = new IsolatedStorageFileStream create ( "TestDir // test.txt", FileMode.Create, isoStore); // write to file StreamWriter writer = null; writer = new StreamWriter (isoStream1); writer.WriteLine ( "Hello isolated"); Writer.close (); isostream1.close (); In order to make your smart application to run, you need to change some client security settings, essentially to notify the client runtime to believe your app . One way is to add a site with your assembly to the IE to trust the Site list, 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, select Run Launch Security Policy, then select Adjust the security zone. For all sites specified in the trusted site, adjust the trust level to full trust. As a choice, you can also use the Framework Configurative tool to modify the security policy so that it trusts the individual assembly of your application. Right-click Run Launch Security Policy to select the level of trust in the assembly. Another optional method is to use the code group to help you improve the security settings of the application's assembly with the Framework Configuration tool. You need to make this change in desktop users using your application. To help complete this task, the Framework Configuration Tool can create a Microsoft Installer (MSI) deployment package that contains security policies. The MSI has installed the application loader to distribute the security policies and loader assembly you need for your application. Right-click Run Launch Security Policy to select Create a deployment package. In the network run, the automatic update is done with the Cache mechanism of IE. That is, when you need to download and run an application, IE sends an HTTP request to the web server. The request will get the latest update date of the program on the server, if the date is greater than the date of the local cache or the local cache If you exist, you download it from the server, otherwise the program directly uses the local cache. Therefore, for the version mechanism of the .NET itself, it cannot be used as a version update. Only when an assembly file is referenced to another assembly, it will determine the version number according to its own version of the machine. Note: This way of operation usually needs to set the security policy before running. When loading the application component, a complete URL address is required. If the application set needs to call the Web Service, the server address where the Web Service can only download the assembly, which can construct a redirection to resolve this issue. Some files may not be able to complete the version update by an automatic update mechanism, such as the configuration file for .config applications. If there is some correlation between the versions of some application set files, in some cases, in some cases (such as the network suddenly interrupted) may appear correctly to properly load and lead to an error in client applications. If the user clears the cache of IE, the client application will not be able to work offline.

2. Local run as the name suggests, this running method client application and other application components are not running in IE cache and .NET download cache, requiring users to download client assemblies and save them into a local directory and run. This client application and other application components have all local security privileges. Although not involving security issues, how does the application component and the automatic update of the program are implemented? This requires a separate component to complete these tasks. With this link address, you can download a very well-supported extensive automatic update component (http://www.gotdotnet.com/team/windowsformDater.zip), which provides source code, some examples, and documentation in this package file. This update component uses HTTP-DAV technology to complete the transfer between files and clients, so there is a certain limit on the web server, IIS5.0 and new version of Apache support this feature. For details, see the contents of the documentation. Precautions:

Since you need to implement your update and download, you will increase a certain amount of work. (That is to use third-party update components, it also needs to be improved to meet your own requirements) basically solve the shortcomings of network operation, but you need to re-download all files every time you update (if you use incremental updates, somewhere In the case, a version of the file is missing will appear), which will increase the network traffic. Updates and downloads should be performed in the background thread without affecting the user's normal operation. Third, create a program client application to perform steps:

log in system. You usually require a login form by entering the username and password or any other way. (This step requires the client application to execute online online, so you can consider providing a button that is offline on the form, and then directly uses the configuration file copy of the server when the last online login is used. This will trigger some security issues and Client data and server data synchronization issues.) After the application server verification, obtain the user's application component and its corresponding configuration information according to the user rights set by the system, and obtain the personalized configuration information of the user from the database. , Combine these configuration information into an XML configuration file stream to pass to the client application. This step is usually performed by a web service call. The client program parsed the configuration file stream, sets the main format according to the personalized configuration information, load the corresponding assembly file according to the application component configuration information. Save the configuration file to use it when you work from the line. (Local Operation Mode) Start the background update thread, the line is scheduled to search the update server has the latest version of the program, if there is, download and prompt the user update. The user interface to which the application component itself will be displayed in the client main form by clicking the button or menu of the appropriate application component.

The client application basically includes a login form, a main form, and an application component loader. There is an application component set class in the loader, and some methods are provided for communication between the main program and application components and between different application components, and some application components provide data as a public component to other applications, so it should pass Unified methods to get data. Precautions and recommendations: 1. For network operation mode, the program set is downloaded from the server to the local cache, while the download process of the local operation mode is executed by the update component, and the client main form is executed. Method for dynamically loaded an assembly in .NET: use system.reflection; // Network running mode, loaded assembly path to the URL address on the server AssemblyFileName = "http: //smartclient/appcomponent1.dll"; // Local Operation, loaded assembly paths are local directory path assemblyFileName = @ "c: /smartclient/appcomponent1.dll"; askLL "; assembly asm = askMBLY.LOADFROM (askMBLYFILENAME); 2, client application mainfield as an application component The container can display the user interface of the application component by two methods: The first way is to design the client application as a multi-document interface (MDI) application, each application component contains respective start-up main forms. When the client application executes each application component, the startup form type of the component will be constructed and displayed. The "Window" menu item containing the submenu is often switched between the main window or application. Another way is to reserve an application interface area in the primary window interface of the client application, and each application component is added to the control array of the application interface area as a user control. Application interface area is typically a panel (PANE) control, switches between the various applications by changing the Z order of the user control (Control. Bringtofront ()). 3. When the client application loads the appropriate application components based on the configuration information, you need to create the corresponding button and menu item on the toolbar or menu of the client main form, and add events to facilitate user operation. The client application and application components should be kept independent, reducing the association to reflect the client application structure clear and simple. This can be achieved through the callback (event delegate) in .NET. 4, .NET Due to the cause of the cache, the following problem occurs when the assembly is loaded: // Load assembly asm = askMBLY.LOADFROM (@ "c: /smartclient/appcomponent1.dll"; activator.createInstanceFrom (ASM) .Gettype ("AppComponent1.mainform"); // Loading a file name in different directories in different directories, different assemblies assembli, assembly, assembly, assembly, assembly, assembly, Assembly asmbly.loadFrom (@ "c: /test/appcomponent1.dll) Activator.createInstanceFrom (ASM.GETTYPE ("AppComponent1.mainform"); After the second load, there is no correctly constructed the form type in different directories, but used the first time in the cache. The type of constructor is loaded. In order to solve the above problems, these two types instance must be constructed in different application domains (Domain).

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

New Post(0)