Intelligent client application model 1. Define: an extensible desktop application that integrates different applications, and has the following features:
¨ No 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 time.
¨ 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.
¨ Offline Application: Allows to be separated from the server, using local client programs and application components.
¨ Dynamically load 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. 2. DOTNET platform example (1) Network operation
The .NET Framework installation provides a mechanism for hooking Internet Explorer 5.01 and higher to listen to 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.
In order to make your intelligent application to run, you need to change some of the security settings of some clients, essentially to notify the client runtime to believe your application. 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.
Precautions:
This way of operation usually needs to set a user's 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: .config application configuration files If there is some correlation between the versions of some application set files, in some cases (such as: Network sudden interruption) may be out
(2) Creating a program client application: 1) Login 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 The problem with client data and server data synchronization.)
2) After verification by the application server, obtain the application components that the user can load according to the user rights set by the system, and obtain the personalized configuration information of the user from the database, combining these configuration information into an XML. The configuration file stream is passed to the client application. This step is usually performed by a web service call.
3) The client program parses the configuration file stream, sets the main format according to the personalized configuration information, and 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.
4) (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 automatic download, and prompt the user update. 5) The user will display the user interface that the application component itself is 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 a 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 dynamic loading assembly in .NET:
Using system.reflection;
/ / Network operation mode, the loaded assembly path is the URL address on the server.
askMBLYFILENAME = "http://smartclient/appcomponent1.dll";
// Local running mode, loaded assembly path is local directory path
askEMBLYFILENAME = @ "c: /smartclient/appcomponent1.dll";
AskEMBLY ASM = askMBLY.LOADFROM (askMBLYFILENAME);
2) The main form of the client application is used as the container of the application component, and the user interface of the application component can be displayed by two ways:
The first way is to design the client application as a multi-document interface (MDI) application, each application component contains a respective start-up mainfield, and the client application performs each application component, will construct and display The component is started. The "Window" menu item containing the submenu is often switched between the main window or the application is used in the MDI 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 component 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 an event 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.
Note When using this method, if you constructed the type instance contains a parameter constructor, these parameter objects must be an object accessed across the application domain, that is, a sequentially-sequenceable object. You can set the survival policy of the remote object by inheriting the MarshalByrefObject object or using the [Serializable] feature tag class.
(3) Publishing Procedure 1) Set a virtual directory on the publish and update server (such as: smartclient) to place all files of the application component in the appropriate directory.
Setting attributes in the virtual directory must include: read and directory browsing permissions, and execute the license as pure script.
For local mode, you need to set multiple directories based on the version number of the client application, and all files of different versions are stored. (You can also store only updated files in the new version of the directory, but you need to modify the update component. When the user updates the version, you must download the files larger than all new version of the current version to prevent some cases. A version of the file is missing questions). In the local mode of operation, you will also need to maintain a newer list file in the root directory because it allows users to log in with an old version of the client application.
2) Release a web service. The Web service mainly completes the following tasks:
¨ Execute the authentication of client users
¨ Get the list of application components that the user allowed by the entire application system, contains the location of the application component, the file name, and the configuration information required for the application component itself. (In the local mode of operation, the list is related to the version)
¨ Get personalized configuration information from the user from the database, and the information obtained in the previous step is combined into an XML file stream.
¨¨ Return the configuration file stream to the client application.
3) Place the client application in the virtual root directory as the loader of the application component assembly, and add a link to the client application on the enterprise internal website. For network operation, a link to the Security Policy Deployment Package (MSI) file will also be provided.
User execution steps for the first time
Network operation mode:
¨ Download and install the security policy deployment package
¨ Download and execute client applications by clicking on the link of the client application
¨ Add this link to your favorites or create desktop shortcuts for easy operation.
Local Operation:
¨ Not directly click on the link to the client application, save this link to the directory of the user selection
¨ Execute client applications in Explorer
¨ Establish shortcuts for executable on the desktop for easy operation
(4) Update the program network operation mode is more simple, and only the updated file can directly cover the old file directly. Its disadvantage is that the reference files included with some assessments cannot be automatically downloaded new versions, and only updates can be implemented after emptying the client's IE cache.
The update steps for local running methods are as follows:
¨¨ Create a directory named in the server virtual root directory, incremental updates simply copy the updated file to the directory, otherwise you need to copy all files to the directory.
¨ Modify the file saved all versions of the list and indicates the latest version number of the current event, and is used to make a version comparison with the client.
(5) Extended application components In order to realize the scalability of enterprise application systems, through interface definitions, the application developer can make it easy to add their own application components to the client application by implementing these interfaces. The following describes the mainly included methods and properties in some interfaces.
1) Application Component Name Properties: Annotation Text for indicating the function of the application component.
2) Application Components In Client Application Elements: Refers to the toolbar, menu bar, drop-down menu item and list box, etc. on the client application, and you need to provide application components to provide Text, pictures, icons, menus, event processing methods, etc.
3) Initialization method: The method of executing when the client application loads the application component. When loading the application assembly, for the configuration information of each application component itself included by the configuration file, the client application is not parsed, but the configuration information is passed to the application component when initializing the application components. Increase flexibility.
4) Get Application Component Loader Method: After obtaining the application component loader, you can obtain the shared data required by the application by the public method included in it.
5) Get the method of the application component start control: The start control can be a form or user control. 6) Close the method of the application component (optional): This method is performed when the client application is turned off. The application component itself determines whether it can be turned off according to its own situation, and immediately release the system resources occupied by the component. For the MDI application, you can process in the shutdown event of the startup form without this method.
The application component loader within the client application can determine whether the component meets the excuse definition by enumerating the type of component set. At the same time, multiple application components can be packaged in an application set. This process is very time consuming.