/// <summary> ///Method:commandhelper///Author:liuyangyi///data:2016-05-10/// </summary> Public classCommand {///provides a method for standard MD5 encryption/// </summary> /// <param name= "Cort" ></param> /// <returns></returns> /// <summary> ///standard MD5 cipher encryption algorithm/// </summary> /// <param name= "tocrystring" ></param> /// <returns></returns> Public Static stringEXT_GETSTANDMD5 (stringtocrystring) {MD5CryptoServiceProvider hashmd5; HASHMD5=NewMD5CryptoServiceProvider (); returnBitconverter.tostring (Hashmd5.computehash (Encoding.Default.GetBytes (Tocrystring.trim ())). Replace ("-",""). ToUpper (); } /// <summary> ///Unix time Stamp/// </summary> /// <param name= "DateTime" ></param> /// <returns></returns> Public Static stringDatetimetounixtimestamp () {datetime datetime=DateTime.Now; varStart =NewDateTime (1970,1,1,0,0,0, Datetime.kind); returnConvert.toint64 (DateTime-start). totalseconds). ToString (); } /// <summary> ///Time Format/// </summary> /// <returns></returns> Public Static stringDatetimestamp () {datetime datetime=DateTime.Now; returnDateTime.ToString ("YYYY-MM-DD HH:mm:ss"); } /// <summary> ///remove null and signature parameters from the array and sort them in alphabetical order from A to Z/// </summary> /// <param name= "Dicarraypre" >parameter groups prior to filtering</param> /// <returns>Filtered parameter Groups</returns> Public Staticdictionary<string,Object> Filterpara (sorteddictionary<string,Object>dicarraypre) {Dictionary<string,Object> Dicarray =Newdictionary<string,Object>(); foreach(keyvaluepair<string,Object> Tempinchdicarraypre) { if(temp. Key.tolower ()! =" Sign"&& temp. Value! =NULL&& temp. Value! ="") {Dicarray.add (temp. Key, temp. Value); } } returnDicarray; } /// <summary> /// ///parameters for sorting and purging to null/// </summary> /// <param name= "O" ></param> /// <returns></returns> Public StaticDictionary<string, object>tomap (Object o) {sorteddictionary<string, object> map =Newsorteddictionary<string,Object>(); Type T=O.gettype (); propertyinfo[] Pi= T.getproperties (BindingFlags.Public |bindingflags.instance); foreach(PropertyInfo Pinchpi) {MethodInfo mi=P.getgetmethod (); if(Mi! =NULL&&mi. IsPublic) {map. Add (P.name, MI. Invoke (O,New( object[] {})); } } returnFilterpara (map); } /// <summary> ///concatenation of all elements of an array with "&" characters in the pattern "parameter = parameter value" into a string/// </summary> /// <param name= "Dicarray" ></param> /// <returns></returns> Public Static stringCreatelinkstring (dictionary<string,Object>Dicarray) {StringBuilder Prestr=NewStringBuilder (); foreach(keyvaluepair<string,Object> TempinchDicarray) { if(temp. Key.tolower ()! =" Sign"&& temp. Key.tolower ()! ="PID"&& temp. Value! =NULL&& temp. Value! ="") {prestr. Append (temp. Key+"="+ Temp. Value.tostring (). Replace (" ","") +"&"); } } //Remove the last & character intNlen =Prestr. Length; Prestr. Remove (Nlen-1,1); returnPrestr. ToString (); } }
Several parameter conversion methods used by C # itself