ASP.NET原创框架八-应用模块常用重要类库介绍

ASP.NET原创框架八-应用模块常用重要类库介绍

汉字转拼音类

public class ChineseToPinyin

汉字转拼音

一、static public string convertAllPinyin(string Chstr)

Chstr:要转的汉字字符串

返回转换后的拼音


压缩zip类

public class iZip

一、内存数据压缩

static public byte[] Compress(byte[] data, int offset, int length, int level)

data:要压缩的数据

offset:数据偏移位置

length:数据长度

level:压缩等级(1-9)

返回压缩的数据


二、内存数据解压

static public byte[] Decompress(byte[] data)

data:要解压的数据

返回解压后的数据


三、压缩串

static public byte[] CompressString(string str, Encoding enc/*=null*/, int level/*= 9*/)

str:压缩的串

enc:串编码格式

level:压缩等级

返回压缩后的数据


四、解压获得串

static public string DecompressString(byte[] data, Encoding enc)

data:压缩的数据

enc:串编码格式

返回解压后的串


五、快速压缩

static public void FastCreateZip(string zipPath, string folderPath, string fileFilter, string password)

zipPath:压缩文件

folderPath:要压缩的目录

fileFilter:要压缩的文件后缀

password:密码


六、快速解压

static public void FastExtractZip(string zipPath, string folderPath, string fileFilter, string password)

zipPath:压缩文件

folderPath:解压后释放的目录

fileFilter:要解压的文件后缀

password:密码


七、压缩文件夹

public static void CompressDirectory(string dirPath, string GzipFileName, int CompressionLevel, bool deleteDir)

dirPath:要打包的文件夹

GzipFileName:目标文件名

CompressionLeve:压缩品质级别(0~9)

deleteDir:是否删除原文件夹


八、解压缩文件

public static void Decompress(string GzipFile, string targetPath)

GzipFile:压缩包文件名

targetPath:解压缩目标路径


WebService调用类

WebServiceHelper

一、 动态调用WebService

public static object InvokeWebService(string url, string classname, string methodname, params object[] args)

url:WebService地址

classname:类名

methodname:方法名(模块名)

args:参数列表


Http客户端通用访问类

public partial class XNWindowHttpClient

一、清除post的header

public void ClearPostHeader()


二、添加一个header

public void AddHeader(string name,string value)

name:header名称

value:header值


三、清除状态

public void ClearSession()


四、设置自动跳转

public void SetAutoRedirect()


五、设置不自动跳转

public void SetNoAutoRedirect()


六、设置为手机端方式访问

public void SetIphone()


七、设置PC端访问方式

public void SetPC()


八、设置文本GB编码格式

public void SetGBCharset()


九、设置文本UTF8编码格式

public void SetUT8Charset()


十、添加一个cookie

public void AddCookie(string Name, string Value)

Name:要添加的cookie名称

Value:添加的cookie值


十一、添加一批cookie

public void AddCookies(List<Cookie> m_TCookieList)

m_TCookieList:cookie列表


十二、获得cookie串

public string GetCookie()


十三、获得header

public List<Hashtable> GetHeader()


十四、获得一个文件

public bool GetFile(string url, string Referer, string PathFile, string IP = null, int port = 0, string username = null, string pwd = null)

url:文件地址

Referer:访问前一个地址

PathFile:下载保存文件名

IP:代理IP地址(可不用代理)

username:代理用户名

pwd:代理用户密码


十五、获得一个文件

public bool GetFile(string url, string PathFile, string IP = null, int port = 0, string username = null, string pwd = null)

url:文件地址

PathFile:下载保存文件名

IP:代理IP地址(可不用代理)

port:代理端口

username:代理用户名

pwd:代理用户密码


十六、一个Get请求

public string GetUrl(String url, string Referer, string IP = null, int port = 0, string username = null, string pwd = null)

url:访问地址

Referer:访问前一个地址

IP:代理IP地址(可不用代理)

port:代理端口

username:代理用户名

pwd:代理用户密码

返回Get请求的串


十七、一个Get请求

public string GetUrl(String url, string IP = null, int port = 0, string username = null, string pwd = null)

url:访问地址

IP:代理IP地址(可不用代理)

port:代理端口

username:代理用户名

pwd:代理用户密码

返回Get请求的串


十八、一个Form提交

public bool PostForm(String url, String sData, out string strResult, out string goUrl, string IP = null, int port = 0, string username = null, string pwd = null)

url:访问地址

sData:Post的数据

strResult:Post返回的数据

goUrl:请求后跳转的页面

IP:代理IP地址(可不用代理)

port:代理端口

username:代理用户名

pwd:代理用户密码


十九、Post数据

public string PostData(String url, String sData, string IP = null, int port = 0, string username = null, string pwd = null)

url:访问地址

sData:Post的数据

IP:代理IP地址(可不用代理)

port:代理端口

username:代理用户名

pwd:代理用户密码

返回Post数据


二十、调用WCF

public string PostWCF(String url, String json, string IP = null, int port = 0, string username = null, string pwd = null)

url:访问地址

json:Post的json数据

IP:代理IP地址(可不用代理)

port:代理端口

username:代理用户名

pwd:代理用户密码

返回Post数据



二十一、PostJson

public string PostJson(String url, String sData, out bool bOK, string Referer = null, string IP = null, int port = 0, string username = null, string pwd = null)

url:访问地址

sData:Post的json数据

bOK:返回执行是否成功

Referer:前一个访问地址

IP:代理IP地址(可不用代理)

port:代理端口

username:代理用户名

pwd:代理用户密码

返回Post数据



二十二、PostJson二

public bool PostReturnJson(String url, String sData, out string strResult, string IP = null, int port = 0, string username = null, string pwd = null)

url:访问地址

sData:Post的json数据

strResult:返回Post数据

IP:代理IP地址(可不用代理)

port:代理端口

username:代理用户名

pwd:代理用户密码


二十三、带证书的Post请求

public string HttpsPostUrl(string url, string sFormString, string sKeyFile, string sKeyPWD, string IP = null, int port = 0, string username = null, string pwd = null)

url:访问地址

sFormString:Post的数据

sKeyFile:证书文件

sKeyPWD:证书密码

IP:代理IP地址(可不用代理)

port:代理端口

username:代理用户名

pwd:代理用户密码


二十四、下载文件

public bool DownFile(string sUrl, string FilePath, string IP = null, int port = 0, string username = null, string pwd = null)

url:访问地址

FilePath:下载保存的文件

IP:代理IP地址(可不用代理)

port:代理端口

username:代理用户名

pwd:代理用户密码


二十五、设置不使用全局代理

public void SetNoUseGlobalProxy()


二十六、设置使用全局代理

public void SetUseGlobalProxy()


二十七、设置不使用系统代理

static public void SetNoUseSysDefaultProxy()


二十八、设置使用系统代理

static public void SetUseSysDefaultProxy()


各语言互通的加密类

public class PublicDES

一、加密串

public static string Encode(string source, string _DESKey)

source:要加密的串

_DESKey:秘钥

返回加密后的串


二、解密串

public static string Decode(string source, string sKey)

source:要解密的串

sKey:秘钥

返回解密后的串


和Java互通的加密类

public class RESJavaHelper


一、用私钥给数据进行RSA加密

public static string PrivateKeyEncrypt(string xmlPrivateKey, string strEncryptString)

xmlPrivateKey:私钥(XML格式字符串)

strEncryptString:要加密的数据

返回加密的数据



二、用公钥给数据进行RSA解密

public static string PublicKeyDecrypt(string xmlPublicKey, string strDecryptString)

xmlPublicKey:公钥(XML格式字符串)

strDecryptString:要解密数据

返回解密的数据



三、 使用公钥加密,分段加密

public static string EncrytByPublic(string publicKeyPath, string strEncryptString)

publicKeyPath:公钥

strEncryptString:要加密的数据

返回加密后的串


四、通过私钥解密,分段解密

public static string DecryptByPrivate(string privateKeyPath, string strDecryptString)

privateKeyPath:私钥

strDecryptString:要解密的数据

返回解密的数据


Json操作类

public static partial class JsonHelper

一、将一个对象转为指定类型

static public T OBJToType<T>(Object m_JsonObj)//将json的OBJ对象转为指定类型

T:要转换的类型

m_JsonObj:要转换的对象

返回转换后的对象


二、对象转为json串

static public string OBJToJsonStr(Object O)

O:要转换的对象

返回对象的json串


三、json串转为指定对象

static public T JsonStrToOBJ<T>(string jsonStr)

T:要转换的类型

jsonStr:要转换的json串

返回转换后的对象


四、DataRow转换为对象数组

static public Object DataRow2Object(DataRow[] m_Rows)

m_Rows:要转换的DataRow数组

返回对象数组 ArrayList


五、DataRow转hashtable

static public Hashtable DataRow2Hashtable(DataRow m_Row)


六、DataRow转指定类型

static public T DataRow2Object<T>(DataRow m_Row)


七、Object转Hashtable

public static void OBJToHashTable(object O, Hashtable h);

O:要转换的Object

h:转换后的Hashtable


八、Json串转hashtable

static public void JsonToHashtable(string jsonData, Hashtable h)

jsonData:要转换的json串

h:转换后的Hashtable


九、XML转json串

static public string XMLToJSON(string sXML)

sXML:XML串

返回json串


十、XML转Hashtable

static public bool XMLToHashtable(string sXML,Hashtable m_HH)

sXML:XML串

m_HH:转换后的Hashtable

举报
评论 0