First, Smart Client is in short, Smart Client Smart Client is such an extensible desktop application that integrates different applications: it can not contact deployment, you need to install, dynamically load, Xcopy Running without modifying the registry, you can dynamically upgrade, automatically update, can easily use the WEB run without worrying about the firewall problem and convenient offline application, convenient connection Webservices's Windows application II, Smart Client features 1. Dynamic loading That is, 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 call between the above first point does not use a direct reference method, the more loosely coupled coupling of the system is implemented to the application upgrade update. 3. Further modularity, due to the loose coupling characteristics of the application, the further modularity of the system has become possible, new features, and new features to join only new modules that meet interface definitions and add a connection. There is no need to modify the reproduction of existing procedures. 4. When the zero contact deployment is installed, simply download a main program file to the local, running directly, no need to change the registry or shared system components, 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 centralized management of the enterprise system. . 6. Automatic updates Simply publish new versions on the server, automatically discover the latest version of the program and application components by the client, and download and update automatically. 7. Applications that are available online and offline Smart Client applications Although the network load assembly, once loaded, the assembly is cached locally. 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 Users can set the client application according to the preferences, and the configuration information will be saved to the server. 9. The perfect integration of WebServices SMART Client Apps 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 there to be a lot of advertisements, the thin web solution does not necessarily become 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.
5. SMART Client's operation mode 1. Boot program Operation mode a) Local running this way of operation seems to be a local application, its advantage is to help you control the creation of the installation directory and related icons, and A concise uninstallation can be provided. Deritage is that you need to make a MSI installation file and setup on the client. b) Network operation is just a complete network operation mode, running and opening the web page online - Enter a URL in the browser address bar or click on the corresponding connection on the web page. 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. Loading method of components A) Loading a component directly from the network is to load from the network using the package loader using the .NET framework, one of this way 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) Downloading to the local loading of dynamically loaded components locally, then downloading the assembly to the local folder and then loads from local loading, this way does not depend on the browser cache, that is, the application The program component is still running normally when it is downloaded from the network after running once after running (if it is set to the component needs). 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. Component's rendering how the components here are of course referring to interface components, and if not involved in the user interface, of course, there is nothing to show. a) After the component is loaded, the boot boot is used as a very common component rendering method, 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) As a subsidiary of the carrier platform, in the presented manner of the component as a child, it is designed as an MDI form, and then sets the ParentForm property of the loaded assembly to the bearer platform. c) Components As the control of the bearer platform, the components are not instantiated in the form of a form, but is instantiated by the user control, and then dynamically add it to a tray of the bearer form ( It is usually a panel. Six, SMART Client Security Problem 1. Client's Code Access Security (CAS) said that 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 Download a code, and you run it under a high privilege account, the operating system opens a variety of 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 server side of the server here is actually the identity verification of WebServices. Although it is also possible from the theoretical Forms authentication, 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 uses the user's Windows account to authenticate as the domain account. b) .NET PassPort authentication uses the .NET Passport account associated with the user. Net Passport account. c) Custom authentication Use SOAP to deliver account information to Web service, which is a relatively safe way, and does not have to deliver certificates for each WebMethod (part of parameters), if still If you don't feel that you can encrypt the SOAP header, or simply use the SOAP to pass the security certificate. Here is only the way to authenticate using SOAP does not encrypt the username and password. When a service request is sent to the server, the request will be intercepiled by WebServiceAuthenticationModule. WebServiceAuthenticationModule starts to analyze the requested SOAP header, resolve the username and password sent by the client, and perform 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. . 7. SMART Client Development Principles 1. WebServices Development Principles A) Authentication: SOAP header is first generated into a custom HTTP module (here the WebServiceAuthenticationModule that I do) and registered in WebConfig; Add a WebServiceAuthenticationModule defined SOAPAUTHHEADER field type, and apply the SOAPAUTHHEADER attribute to our web service method, and then use the name of the name of this field to define the constructor of this property; for the client, each time You need to fill the SOAP header to WebServices, and after WebServices define the SOAP header, the client's proxy class will generate the corresponding class agent. First, create a service object instance represent our web service, then create a SOAP header object instance, and populates the SOAP header, then associate the SOAP header with the agent to use our web service. b) Coarse granularity, less interface development WebServices should be: coarse granularity, less interface, thus delivering the value of the delay costs of the network request.
c) Each .ASMX file is open and independent, and less data set is to minimize the size of the client component. When using the WebServices application, if one. The ASMX file is open to too many functions and too many assemblies, which will inevitably make the client component too bloated, and actually it may be just 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 achievement of data descriptions This principle is to achieve modularization, and a functional implementation does not require much to depend on the related module. 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 minimized because the Smart Client is loaded over the network, so a single assembly should be minimized to quickly load. b) Calling principles of the program set: Since the interface is a system, it is unparalleled 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: The interface is defined here. The key points of the development are set. The interface is defined, this article sees this, it is not difficult to conclusion, the necessary conditions for many superiority achievements of Smart Client are defined and implemented a series of definition ports. standard. 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. 8. Development Difficulties in Smart Client SMART Client is a more complex system that is different from previously common applications, so its debugging technology is more complicated than before, 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 Develops Need Resolved 1. Data Local Cache and Update Smart Client is a browser cache mechanism and online offline applications, then the data accessed by the in theory should also be Will go locally, as for the facts, have not seen the relevant information, need further experiments and arguments. 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. The normalization of interface definitions comes to the importance of defining a standardized interface, which is obviously a fairly important and a problem that must be resolved is: How do I define our general-specific interface? 3. The development of the upgrade procedure involves the problem of the load method of the components mentioned earlier. If you use the first way to download the component to the local, then you need to resolve the development of the upgrade program, though Speaking of MicrosoftUpdaterapplicationBlock, but at least we have to understand it and learn how to use it. Ten, Smart Client development needs to do the preparatory work, saying that the sharpener does not mistaken, to develop a sophisticated Smart Client application, walk less and improve the development efficiency during the future development, I suggest SMART The following preparations are made before the Client application develops: 1. Define a universal interface to make a universal and specific application component interface. 2. Develop universal components and then develop some general components: a) Interface class between interface set components, according to actual needs, can put several interfaces together to develop a assembly, divided into a number of interface sets Come. b) The boot program 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 functionality is simple. c) Local file reading and writing the general class of reading and writing client local files developed for Smart Client Applications, its core code is as follows: // obtains independent storage area IsolatedStorageFile isoStore = ISOLATORAGESCOPE by user, domain, and assembly .User
IsolatedStorageScope.domain | IsolatedStorageScope.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 of exceptional components for the characteristics development of SmartClient, where there are more processing of network abnormalities (such as networks, etc.). e) Permissions Control the Permissions Control Module developed for Smart Client, which should be divided into two parts, server side, and clients. 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). Author Blog:
http://blog.9cbs.net/lornshrimp/