C#.net Large Enterprise Information System integration rapid development Platform version 4.2-External service invocation, internal service invocation optimization, service oriented

Source: Internet
Author: User
Tags dotnet

Now the information system is more and more complex, more and more large, not only need the internal is a whole, but also need to provide a lot of external service calls.

1: What other people call the most convenient? Called in a different development language.
2: What does the return status of the service look like? Helps to troubleshoot problems.
3: The security of the service, the transition of the upgrade, performance efficiency should be guaranteed.
4: The service also needs to have full call logging and so on.

Here is a service call validity judgment function code for your reference.

1 //-----------------------------------------------------------------2 //All rights Reserved, Copyright (C), Hairihan TECH, Ltd.3 //-----------------------------------------------------------------4 5 usingSystem;6 usingSystem.Collections.Generic;7 usingSystem.Data;8 usingServicestack.redis;9 Ten namespacedotnet.business One { A     usingDotnet.model; -     usingdotnet.utilities; -  the     /// <summary> -     ///Baseservicesettingmanager -     ///Service Management -     ///  +     ///Change of record -     ///  +     ///2015.12.25 Version: 1.0 Jirigala primary key finishing.  A     ///  at     /// <author> -     ///        <name>Jirigala</name> -     ///        <date>2015.12.25</date> -     /// </author>  -     /// </summary> -      Public Partial classBaseservicesettingmanager:basemanager in     { -         /// <summary> to         ///Check if a service call is allowed to be called?  +         ///1: Do you want to log?  -         ///2: Do I need to bury the dots? Check performance? Frequency of access, etc.? Number of calls?  the         ///3: Non-legal call? Is it a log record?  *         ///4: Exception to be processed?  $         /// </summary>Panax Notoginseng         /// <param name= "AppKey" >Apply unique identities</param> -         /// <param name= "Appsecret" >app's signing key</param> the         /// <param name= "Calllimit" >whether to restrict</param> +         /// <param name= "Systemcode" >Access Subsystem</param> A         /// <param name= "Permissioncode" >judge the permission number</param> the         /// <returns>Verify the situation</returns> +          Public StaticBaseresult Checkservice (stringAppKey,stringAppsecret,BOOLCalllimit =false,stringSystemcode ="Base",stringPermissioncode =NULL) -         { $Baseresult result =NewDotNet.Utilities.BaseResult (); $Result. Status =false; -  -             //appkey:23286115 the             //appsecret:c8d1f06f599d7370467993c72a34c701 -             //permissioncode: "User.add"Wuyi  the             stringIpAddress = Utilities.getipaddress (true); -  Wu             //1: Is it reasonable to determine the parameters? Target service, always can not be empty, otherwise how to distinguish who in call this service?  -             if(string. IsNullOrEmpty (AppKey)) About             { $Result. StatusCode ="Accessdeny"; -Result. StatusMessage ="Appkey is empty, access is denied"; -                 returnresult; -             } A  +             //2: Determine whether in the interface role, only in the interface role, you can make remote calls, it is also convenient to the interface at any time to kick out.  the             stringRolecode ="Interface"; -             if(!Baseusermanager.isinrolebycache (Systemcode, AppKey, Rolecode)) $             { theResult. StatusCode ="Accessdeny"; theResult. StatusMessage ="non-interface user, Access denied"; the                 returnresult; the             } -  in             //3: Determine the frequency of the call? Need high-speed judgment here, not always go to the database? The efficiency of the call is high, can not be dragged to the remote interface to the dead, their services are not normal.  the             if(Calllimit && pooledredishelper.calllimit (AppKey,Ten,10000)) the             { AboutResult. StatusCode ="Accessdeny"; theResult. StatusMessage ="access is too frequent, access denied"; the                 returnresult; the             } +  -             //4: Determine if the signature is valid? Is it out of date? Can support multiple signatures, easy to upgrade, easy to compatible, easy to have an excessive buffer period. In order to improve security, it is necessary to have a signature.  the             if(!Baseservicesettingmanager.checkservicebycache (AppKey, Appsecret))Bayi             { theResult. StatusCode ="Accessdeny"; theResult. StatusMessage ="illegal signature, access denied"; -                 returnresult; -             } the  the             //5: Is it legal to judge the other's IP? 1 service programs, can have multiple IPs. Services can be treated as a user, a target user may also be configured with multiple services, usually remote connection.  theBaseuserlogonmanager Userlogonmanager =NewBaseuserlogonmanager (); theBaseuserlogonentity userlogonentity =Userlogonmanager.getobject (AppKey); -             if(Baseusermanager.checkipaddressbycache (userlogonentity, IpAddress,true)) the             { theResult. StatusCode ="Accessdeny"; theResult. StatusMessage ="illegal IP, Access denied";94                 returnresult; the             } the  the             //6: Determine if you have permission? Avoid being called by the transition, drag the database, can be used in a cached way to judge, it is not easy to be dragged down by clients, partners. 98             if(!string. IsNullOrEmpty (permissioncode) &&!Basepermissionmanager.isauthorizedbycache (Systemcode, AppKey, Permissioncode)) About             { -Result. StatusCode ="Accessdeny";101Result. StatusMessage ="No Permissions"+ Permissioncode +", access is denied";102                 returnresult;103             }104  the             //7: Is the judgment valid? Determine if the time is right? 106Baseusermanager Usermanager =NewBaseusermanager ();107Baseuserentity userentity =Usermanager.getobject (AppKey);108Userlogonresult Userlogonresult =Usermanager.checkuser (userentity, userlogonentity);109             if(!string. IsNullOrEmpty (Userlogonresult.statuscode)) the             {111Baseloginlogmanager.addlog (Systemcode, userentity, IpAddress,string. Empty,string. Empty, userlogonresult.statusmessage); theResult. StatusCode =Userlogonresult.statuscode;113Result. StatusMessage =Userlogonresult.statusmessage; the                 returnresult; the             } the 117             //8: The current need to judge, all added. 118Result. Status =true;119             returnresult; -         }121     }122}

With a proven, stable system code, everything will be smoother, faster, and more smooth. There will be fewer setbacks.

C#.net Large Enterprise Information System integration rapid development Platform version 4.2-External service invocation, internal service invocation optimization, service oriented

Related Article

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.