开源.NET 开发框架及框架API说明书(BWFW)(含并行计算及中英文分词功能)
包括:
1、Microsoft.Bussines.CommonProxy.dll
框架核心API库 包括:常用加密解密,缓存集群,IP地址库,Html Parse,金额转换,GoogleMap Api,Google PR,ImageMagick(图片处理),SharpZipLib压缩解压缩,中文分词核心库
2、WebSystem.Framework.dll
框架核心API库 包括:与Discuz相关的集成登陆,Evaluator计算表达式,Excel相关处理,Pdf处理,Msmq消息队列处理,ThreadPool(线程池,用于并发处理)
3、FrameWork.Extension.Toolkit.dll
针对DotNet基类扩展方法核心库
4、WebSystem.Framework.DAO.dll
数据访问层核心库:包括 DbHelperSQL,MySqlDbHelper,AccessDbHelper,实体层,数据库连接池 等
5、WebSystem.WebControls.dll
常用服务器控件核心库 主要提供后台开发使用
6、Business.Processing.dll
业务处理核心类库(定义前后台业务处理基类,支付,手机短信,序列号,用户等级,查询中心,报表处理中心等)
下面我举几个简单的例子,大家要是觉得有兴趣可以具体应用体验体验
1、小写金额转大写人民币金额
string XXrmb = "100";
string DXrmb = XXrmb.DecodeMoneyCn();
执行结果 DXrmb = "壹佰元"
不要诧异,用了框架任何 string 类都自动具有这样的功能了,这叫 .NET Extension Method
2、大写金额转小写人民币金额
string DXrmb = "壹佰元";
string XXrmb = XXrmb.EncodeMoneyCn();
执行结果 XXrmb = "100"
3、中英文混合分词
string Sentence = "中国人民战胜小日本,大获全胜全体成员非常高兴!";
string Sentence = Sentence.Segmentation().ToValue();
执行结果 Sentence = "中国","人民","战胜","小","日本","大","获","全胜","全体","成员","非常","高兴"
不要惊诧,一个中文分词就这么简单
执行前,中文分词库下载地址 http://www.bwsyq.com/Segmentation.rar 将解压后的 Segmentation目录 放在网站项目的 App_Data目录下即可
4、实体存储到二进制文件,实体从二进制文件读取到实体集
///实体定义
public class USER001: BaseBo
{
private string _F0001;
private string _F0002;
private string _F0003;
private int _F0004;
private decimal _F0005;
private DateTime _F0006;
public string F0001
{
get { return _F0001; }
set { _F0001 = value; }
}
public string F0002
{
get { return _F0002; }
set { _F0002 = value; }
}
public string F0003
{
get { return _F0003; }
set { _F0003 = value; }
}
public int F0004
{
get { return _F0004; }
set { _F0004 = value; }
}
public decimal F0005
{
get { return _F0005; }
set { _F0005 = value; }
}
public DateTime F0006
{
get { return _F0006; }
set { _F0006 = value; }
}
}
///保存多条数据到二进制文件中
protected void Button1_Click(object sender, EventArgs e)
{
USER001 USER001 = new USER001();
USER001.F0001 = "1";
USER001.F0002 = "b";
USER001.F0003 = "c";
USER001.F0004 = 4;
USER001.F0005 = (decimal)5;
USER001.F0006 = DateTime.Now;
USER001.SaveToFile(@"e://USER001.dat");
USER001.F0001 = "a";
USER001.F0002 = "b";
USER001.F0003 = "c";
USER001.F0004 = 4;
USER001.F0005 = (decimal)5;
USER001.F0006 = DateTime.Now;
USER001.SaveToFile(@"e://USER001.dat");
USER001.F0001 = "a1";
USER001.F0002 = "b";
USER001.F0003 = "c";
USER001.F0004 = 4;
USER001.F0005 = (decimal)5;
USER001.F0006 = DateTime.Now;
USER001.SaveToFile(@"e://USER001.dat");
USER001.F0001 = "21";
USER001.F0002 = "3";
USER001.F0003 = "4";
USER001.F0004 = 5;
USER001.F0005 = (decimal)6;
USER001.F0006 = DateTime.Now;
USER001.SaveToFile(@"e://USER001.dat");
}
///从二进制文件中直接返回实体集合
protected void Button2_Click(object sender, EventArgs e)
{
USER001 USER001 = new USER001();
ArrayList al = USER001.ReadFromFile(@"e://USER001.dat");
}
///根据某个字段和值删除对应的记录
protected void Button3_Click(object sender, EventArgs e)
{
USER001 USER001 = new USER001();
USER001.DeleteFromFile(@"e://USER001.dat", "F0001", "a1");
}
///从二进制文件中直接返回实体集合并按给定的字段进行排序
protected void Button4_Click(object sender, EventArgs e)
{
USER001 USER001 = new USER001();
ArrayList al = USER001.ReadFromFile(@"e://USER001.dat", "F0001", OrderByType.ASC);
}
5、并行计算(Thread Pool 线程池的具体应用)
///进行并行计算
protected void Page_Load(object sender, EventArgs e)
{
DoWork();
}
///多任务同时启动,全部执行完毕并返回执行结果
public void DoWork()
{
SThreadPool sThreadPool = new SThreadPool();
IWorkItemResult wir1 =
sThreadPool.QueueWorkItem(new
WorkItemCallback(this.DoSomeWork1), null);
IWorkItemResult wir2 =
sThreadPool.QueueWorkItem(new
WorkItemCallback(this.DoSomeWork2), null);
IWorkItemResult[] wirs =
new IWorkItemResult[] { wir1, wir2 };
int index = SThreadPool.WaitAny(wirs);
int result = 0;
if (index != WaitHandle.WaitTimeout)
{
for(int i=0;i<wirs.Length;i++)
result += (int)wirs[i].Result;
}
sThreadPool.Shutdown();
TextBox1.Text = result.ToString();
}
///任务项1
private object DoSomeWork1(object state)
{
return 1;
}
///任务项2
private object DoSomeWork2(object state)
{
return 2;
}
///任务项n
......
6、根据IP地址直接获取 IP地址所在的地区和国家省市
IpKu ipku = new IpKu("69.64.156.81");
TextBox1.Text = "地区:" + ipku.Area + " 国家省市:" + ipku.Country;
根据IP地址获取所在地区和省市就这么简单
IP地址库下载地址 http://www.bwsyq.com/ipku.rar 将解压后的 ipku.dat 放在网站项目的 App_Data目录下即可
中文分词库下载地址 http://www.bwsyq.com/Segmentation.rar 将解压后的 Segmentation目录 放在网站项目的 App_Data目录下即可
类似的功能还有很多很多,我就不一一举例了,大家有时间可以参考 BWFW 开发框架API说明书 (跟MSDN结构一模一样)
框架 Source Code 及全部第三方类库(the third lib)
API下载地址:http://www.bwsyq.com/BWFW.chm http://www.bwsyq.com/BWFW.rar
框架及第三方类库下载地址:http://www.bwsyq.com/BwsyqFrameork.rar
全部代码上百万行,API文档跟MSDN结构一模一样
欢迎各位同行,高人前辈多多指教, QQ 99923309!
顺祝 国庆愉快,心想事成!
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/erp2/archive/2010/10/01/5918066.aspx