MVC 是一种编程方式,它把代码分为3个不同的部分:模型、视图、和控制器。
模型——表示应用程序的数据或状态的代码。它封装了数据的所有操作,包括业务逻辑,如验证规则。它还包含与底层数据库交互操作所需要的代码。
视图——视图是用户界面,他给用户提供模型,允许用户在模型上执行操作。在视图和模型之间不一定是一对一关系,给定的模型可以通过多个视图可视化。对模型的任意改变都通过所关联视图中的变化反映出来。
控制器。
控制器——负责在模型和视图之间斡旋。用户在视图上执行操作时,控制器会响应该操作,还可以通过与模型直接交互,把该操作传递给模型。
Mvc的优点:清晰地区分了应用程序不同单元的功能。可以独立的开发这些单元,所以mvc应用非常适用于许多开发人员同时开发一个项目。
另一个优点是单元测试变得非常简单,可以为每个部分在需要的时候进行独立的单元测试。
Spring nhibernate
数据库层和业务逻辑层:
建立ExtendedHibernateDaoSupport 类 继承自 HibernateDaoSupport 实现基本数据操作。
public class ExtendedHibernateDaoSupport<T> : HibernateDaoSupport
{
///<summary>
///查询实体时需要加入状态判断
///</summary>
protectedString State;
///<summary>
///状态属性名, 须Spring配置
///</summary>
publicString StateStr
{
set
{
State = value;
}
}
///<summary>
///泛型类名
///</summary>
protectedreadonly StringClassName = typeof(T).Name;
///<summary>
///按页面搜索
///</summary>
///<returns>获取列表</returns>
publicIList<T> FindByPage(String whereString, intoffset, int pageSize)
{
returnHibernateTemplate.ExecuteFind(new PageSearchHibernateCallBack<T>((State == null ? " 1=1": (" jyObj." + State + "<>-1")) + whereString, offset,pageSize));
}
///<summary>
///批量删除
///</summary>
///<paramname="whereString">删除条件</param>
///<returns>影响行数</returns>
publicint DeleteByBatch(StringwhereString)
{
returnHibernateTemplate.Execute(!string.IsNullOrEmpty(State)? new ExcuteByHqlHibernateCallBack("Update " + ClassName + " as jyObj set " + State + "=-1 where 1=1 " + whereString)
: new ExcuteByHqlHibernateCallBack("delete from " + ClassName + " as jyObj where 1=1 " + whereString));
}
publicint DropByBatch(StringwhereString)
{
returnHibernateTemplate.Execute(new ExcuteByHqlHibernateCallBack("delete from " + ClassName + " where 1=1" + whereString));
}
publicvoid UpdateOrSaveOrDelByBatch(string queryString)
{
HibernateTemplate.Execute(new ExcuteBySqlHibernateCallBack(queryString));
}
publicvirtual IList<object> FindObjectsByQuery(String queryObjectString, StringwhereString)
{
returnHibernateTemplate.ExecuteFind(new FindObjectsHibernateCallBack<T>(queryObjectString,(State == null ? "1=1" : (" jyObj." +State + "<>-1")) +whereString));
}
publicIList<object>FindObjectsByQuery(string queryString)
{
returnHibernateTemplate.ExecuteFind(new FindObjectsHibernateCallBack(queryString));
}
publicIList<object>FindSqlObjectsByQuery(string sqlString)
{
returnHibernateTemplate.ExecuteFind(new FindSqlObjectsHibernateCallBack(sqlString));
}
}
classFindObjectsHibernateCallBack<T> : IFindHibernateCallback<object>
{
readonlyString _hql;
publicFindObjectsHibernateCallBack(StringqueryObjectString, String whereString)
{
_hql = "select " + queryObjectString + " from " + typeof(T).Name+ " as jyObj where" + whereString;
}
publicIList<object>DoInHibernate(NHibernate.ISession session)
{
returnsession.CreateQuery(_hql).List<object>();
}
}
classFindSqlObjectsHibernateCallBack: IFindHibernateCallback<object>
{
readonlyString _hql;
publicFindSqlObjectsHibernateCallBack(StringsqlString)
{
_hql = sqlString;
}
publicIList<object>DoInHibernate(NHibernate.ISession session)
{
returnsession.CreateSQLQuery(_hql).List<object>();
}
}
///<summary>
///连接查询 直接sql查询
///</summary>
classFindObjectsHibernateCallBack : IFindHibernateCallback<object>
{
readonlyString _hql;
publicFindObjectsHibernateCallBack(StringqueryString)
{
_hql = queryString;
}
publicIList<object>DoInHibernate(NHibernate.ISession session)
{
returnsession.CreateQuery(_hql).List<object>();
}
}
classExcuteByHqlHibernateCallBack : IHibernateCallback<int>
{
readonlyString _hql;
publicExcuteByHqlHibernateCallBack(String hql)
{
_hql = hql;
}
publicint DoInHibernate(NHibernate.ISession session)
{
returnsession.CreateQuery(_hql).ExecuteUpdate();
}
}
classExcuteBySqlHibernateCallBack : IHibernateCallback<int>
{
readonlyString _hql;
publicExcuteBySqlHibernateCallBack(String hql)
{
_hql = hql;
}
publicint DoInHibernate(NHibernate.ISession session)
{
try
{
return session.CreateSQLQuery(_hql).ExecuteUpdate();
}
catch(Exception ce)
{
throw ce;
}
}
}
classPageSearchHibernateCallBack<T> : IFindHibernateCallback<T>
{
readonlyString _whereString;
readonlyint _offset;
readonlyint _pageSize;
publicPageSearchHibernateCallBack(StringwhereString, int offset, int pageSize)
{
_whereString =whereString;
_offset = offset;
_pageSize = pageSize;
}
publicIList<T> DoInHibernate(NHibernate.ISession session)
{
returnsession.CreateQuery("from " + typeof(T).Name + "as jyObj where" +_whereString).SetFirstResult(_offset).SetMaxResults(_pageSize).List<T>();
}
}
}
工厂模式 IRep 定义数据操作接口
public interface IRep<T>
{
///<summary>
///按页面搜索
///</summary>
///<returns>获取列表</returns>
IList<T>FindByPage(String whereString, int offset, intpageSize);
///<summary>
///批量删除
///</summary>
///<param name="whereString">删除条件</param>
///<returns>影响行数</returns>
intDeleteByBatch(String whereString);
///<summary>
///批量清空,即使有state也清空
///</summary>
///<paramname="whereString">删除条件</param>
///<returns>影响行数</returns>
intDropByBatch(String whereString);
///<summary>
///批量操作 直接原生态执行sql语句
///</summary>
///<returns></returns>
voidUpdateOrSaveOrDelByBatch(string queryString);
///<summary>
/// 根据querystring查询某些属性列
///</summary>
///<paramname="queryObjectString">查询的属性列,例如:jyObj.UnitNO,jyOb.UnitName</param>
///<paramname="whereString">查询的条件字符串</param>
///<returns>object集合</returns>
IList<object> FindObjectsByQuery(String queryObjectString,StringwhereString);
///<summary>
///获取按条件查询数量
///</summary>
///<paramname="whereString">搜索条件</param>
intGetCount(String whereString);
///<summary>
///获取所有
///</summary>
///<returns>所有列表</returns>
IList<T>LoadAll();
///<summary>
///由whereString 获取list,条件可加jyObj
///</summary>
///<paramname="whereString">查询条件 </param>
///<returns>获取列表</returns>
IList<T>FindByQueryString(String whereString);
///<summary>
///由whereString 获取所有list,不关心实体状态值
///</summary>
///<paramname="whereString">查询条件</param>
///<returns>获取列表</returns>
IList<T>FindAllByQueryString(String whereString);
///<summary>
///删除实体,如果有状态值,则修改状态值
///</summary>
///<paramname="entity">实体</param>
voidDelete(T entity);
///<summary>
///彻底排除实体以及其相关孤儿实体
///</summary>
///<paramname="entity">实体</param>
voidDrop(T entity);
///<summary>
///无论有没有状态值,都彻底删除
///</summary>
///<paramname="entity">实体</param>
voidDeleteAnyWay(T entity);
///<summary>
///保存实体,如果实体state为空,则设置为1
///</summary>
///<paramname="entity">实体</param>
///<returns>保存后的实体</returns>
ObjectSave(T entity);
///<summary>
///修改实体
///</summary>
///<paramname="entity">实体</param>
voidUpdate(T entity);
///<summary>
///更新状态, 如果没有状态值则调用无效
///</summary>
///<paramname="entity"></param>
///<param name="state"></param>
voidUpdate(T entity, int state);
///<summary>
///更新或插入list实体
///</summary>
///<paramname="entities">实体list</param>
voidMerge(IEnumerable<object> entities);
///<summary>
///由主键获取实体
///</summary>
///<paramname="id">主键</param>
///<returns>实体</returns>
T Get(Object id);
///<summary>
///判断是否存在
///</summary>
///<paramname="whereString">搜索条件</param>
///<returns>真或假</returns>
boolIsExist(String whereString);
///<summary>
///由whereString 获取所有不重复keyWord的list,不关心实体状态值
///</summary>
///<paramname="keyWord">数据库字段(jyObj.KeyWord形式)</param>
///<paramname="whereString">查询条件</param>
IEnumerable<object> FindDistinctByQuery(String keyWord, StringwhereString);
///<summary>
///清空缓存
///</summary>
voidFlush();
///<summary>
///按条件获取前sum个Object
///</summary>
///<paramname="endSum">结束位置</param>
///<paramname="whereString">条件</param>
///<paramname="orderProp">顺序列</param>
///<paramname="isDesc">是否是降序</param>
///<param name="startSum">开始位置 </param>
///<returns>对象</returns>
IList<T>GetTopSumObjectByOrder(int startSum, int endSum, StringwhereString, String orderProp, bool isDesc);
///<summary>
/// hql 连接查询,可得到多个表连接的结果集
///</summary>
///<paramname="queryString">hql条件</param>
///<returns></returns>
IList<object> FindObjectsByQuery(string queryString);
///<summary>
/// sql语句查询
///</summary>
///<param name="sqlString"></param>
///<returns></returns>
IList<object> FindSqlObjectsByQuery(string sqlString);
}
}
实现类继承ExtendedHibernateDaoSupport 完成方法。
///<summary>
///标准Rep
///</summary>
///<typeparamname="T"></typeparam>
publicclass StandardRepository<T>: ExtendedHibernateDaoSupport<T>, IRep<T>
{
///<summary>
///获取所有
///</summary>
///<returns>所有列表</returns>
publicvirtual IList<T>LoadAll()
{
returnHibernateTemplate.Find<T>("from "+ ClassName + " as jyObj where " +(State == null ? "1=1": "jyObj." + State + "<>-1"));
}
///<summary>
///由whereString 获取list,条件可加jyObj
///</summary>
///<param name="whereString"></param>
///<returns>获取列表</returns>
publicvirtual IList<T>FindByQueryString(String whereString)
{
returnHibernateTemplate.Find<T>("from "+ ClassName + " as jyObj where " +(State == null ? "1=1": ("jyObj." + State + "<>-1")) + whereString);
}
///<summary>
///由whereString 获取所有list,不关心实体状态值
///</summary>
///<paramname="whereString">查询条件</param>
///<returns>获取列表</returns>
publicvirtual IList<T>FindAllByQueryString(String whereString)
{
returnHibernateTemplate.Find<T>("from "+ ClassName + " as jyObj where 1 = 1 "+ whereString);
}
///<summary>
///由whereString 获取所有不重复keyWord的list,不关心实体状态值
///</summary>
///<paramname="keyWord">数据库字段(jyObj.KeyWord形式)</param>
///<paramname="whereString">查询条件</param>
///<returns>返回获取列表</returns>
publicvirtual IEnumerable<object> FindDistinctByQuery(String keyWord, StringwhereString)
{
returnHibernateTemplate.Find<Object>("select distinct " + keyWord + " from " + ClassName + " as jyObj where " + (State == null ? " 1=1 ": ("jyObj." + State + "<>-1 "))
+ whereString);
}
///<summary>
///删除实体,如果有状态值,则修改状态值
///</summary>
///<paramname="entity">实体</param>
publicvoid Delete(T entity)
{
if(!string.IsNullOrEmpty(State))
{
typeof(T).GetProperty(State).SetValue(entity, Decimal.Parse("-1"),null);
Update(entity);
//DeleteByBatch(" and"+className+".Id='" + typeof(T).GetProperty("Id").GetValue(entity,null).ToString() + "'");
}
else
{
HibernateTemplate.Delete(entity);
}
}
///<summary>
///无论有没有状态值,都彻底删除
///</summary>
///<paramname="entity">实体</param>
publicvoid DeleteAnyWay(T entity)
{
HibernateTemplate.Delete(entity);
}
///<summary>
///保存实体
///</summary>
///<param name="entity">实体</param>
///<returns>保存后的实体</returns>
publicObject Save(T entity)
{
if(!string.IsNullOrEmpty(State))
{
try
{
System.Reflection.PropertyInfo prop =typeof(T).GetProperty(State);
if (prop.GetValue(entity, null)== null)
{
prop.SetValue(entity, new Decimal(1), null);
}
}
catch
{ }
}
returnHibernateTemplate.Save(entity);
}
///<summary>
///修改实体
///</summary>
///<paramname="entity">实体</param>
publicvoid Update(T entity)
{
HibernateTemplate.Update(entity);
}
publicvoid Merge(IEnumerable<object> entities)
{
foreach(var ob inentities)
{
HibernateTemplate.SaveOrUpdate(ob);
HibernateTemplate.Flush();
HibernateTemplate.Evict(ob);
}
}
///<summary>
///彻底排除实体以及其相关孤儿实体
///</summary>
///<paramname="entity">实体</param>
publicvoid Drop(T entity)
{
HibernateTemplate.Delete(entity);
}
///<summary>
///由主键修改实体
///</summary>
///<paramname="id">主键</param>
///<returns>实体</returns>
publicT Get(Object id)
{
//Tobj = HibernateTemplate.Load<T>(id);
//if(obj == null) return HibernateTemplate.Get<T>(id);
//returnHibernateTemplate.Get<T>(id);
returnHibernateTemplate.Get<T>(id); ;
}
///<summary>
///根据编号查找实体
///</summary>
///<paramname="no">编号</param>
///<returns></returns>
publicIList<string>Find(string no)
{
return HibernateTemplate.Find<string>(no);
}
///<summary>
///获取按条件查询数量
///</summary>
///<paramname="whereString"></param>
///<returns></returns>
publicvirtual intGetCount(String whereString)
{
whereString =whereString.Replace("ORDER BY", "order by");
varflag = whereString.IndexOf("order by",StringComparison.Ordinal);
if(flag != -1)
{
var strLen = whereString.Length - flag;
whereString =whereString.Replace(whereString.Substring(flag, strLen)," ");
}
returnint.Parse(HibernateTemplate.Find<Object>("selectcount(*) from " + ClassName + " asjyObj where " + (State == null ? "1=1" : ("jyObj."+ State + "<>-1 ")) +whereString).First<Object>().ToString());
}
///<summary>
///判断是否存在
///</summary>
///<paramname="whereString">搜索条件</param>
///<returns>真或假</returns>
publicbool IsExist(StringwhereString)
{
returnGetCount(whereString) > 0;
}
///<summary>
///按条件获取前sum个Object
///</summary>
///<paramname="endSum"></param>
///<paramname="whereString">条件</param>
///<paramname="orderProp">顺序列</param>
///<paramname="isDesc">是否是降序</param>
///<paramname="startSum"></param>
///<returns>对象</returns>
publicIList<T> GetTopSumObjectByOrder(int startSum, intendSum, String whereString, String orderProp, boolisDesc)
{
varquery = Session.CreateQuery("from "+ ClassName + " as jyObj where " +(State == null ? "1=1": ("jyObj." + State + "<>-1")) + whereString + " order by " + orderProp + (isDesc ? " desc" : "asc"));
varres = query.SetFirstResult(startSum).SetMaxResults(endSum).List<T>();
returnres;
}
///<summary>
///更新状态, 如果没有状态值则调用无效
///</summary>
///<paramname="entity"></param>
///<paramname="state"></param>
publicvoid Update(T entity, intstate)
{
if(State == null) return;
typeof(T).GetProperty(State).SetValue(entity,Decimal.Parse(state.ToString(CultureInfo.InvariantCulture)), null);
Update(entity);
}
///<summary>
///清空缓存
///</summary>
publicvoid Flush()
{
HibernateTemplate.Flush();
}
}
}
在数据库层配置业务逻辑层repository.xml,与实体类名相对应。
<?xmlversion="1.0"encoding="utf-8" ?>
<objectsxmlns="http://www.springframework.net"
xmlns:db="http://www.springframework.net/database">
<objectid="AppRep"type="Model.Repository.StandardRepository<Model.Entities.JyjtApp>, Model">
<propertyname="HibernateTemplate"ref="HibernateTemplate" />
</object>
</objects>
实体类JyjtApp.cs
public class JyjtApp
{
#region Member Variables
protectedGuid _id;
protectedstring _appName;
protectedstring _appRemark;
protectedstring _reserved1;
protectedstring _reserved2;
protectedstring _reserved3;
protectedIList _jyResources;
protectedIList _jyRoles;
protectedIList _jyUserApps;
}
配置实体类对应数据库的映射文件,要与数据库中表设计一样。JyjtApp.hbm.xml
<?xmlversion="1.0"encoding="utf-8" ?>
<hibernate-mappingxmlns="urn:nhibernate-mapping-2.2">
<classname="Model.Entities.JyjtApp,Model" table="jyjtApp">
<idname="Id"type="Guid"unsaved-value="null">
<columnname="appID"length="16"sql-type="guid"not-null="true"unique="true"index="PK_JYAPP"/>
<generatorclass="guid" />
</id>
<propertyname="AppName"type="String">
<columnname="appName"length="255"sql-type="varchar"not-null="false"/>
</property>
<propertyname="AppRemark"type="String">
<columnname="appRemark"length="16"sql-type="text"not-null="false"/>
</property>
<propertyname="Reserved1"type="String">
<columnname="reserved1"length="255"sql-type="varchar"not-null="false"/>
</property>
<propertyname="Reserved2"type="String">
<columnname="reserved2"length="255"sql-type="varchar"not-null="false"/>
</property>
<propertyname="Reserved3"type="String">
<columnname="reserved3"length="255"sql-type="varchar"not-null="false"/>
</property>
<bagname="jyResources"inverse="true"lazy="true"cascade="all-delete-orphan">
<keycolumn="appID"/>
<one-to-manyclass="Model.Entities.JyjtResource,Model"/>
</bag>
<bagname="jyRoles"inverse="true"lazy="true"cascade="all-delete-orphan">
<keycolumn="appID"/>
<one-to-manyclass="Model.Entities.JyjtRole,Model"/>
</bag>
<bagname="jyUserApps"inverse="true"lazy="true"cascade="all-delete-orphan">
<keycolumn="appID"/>
<one-to-manyclass="Model.Entities.JyjtUserApp,Model"/>
</bag>
</class>
</hibernate-mapping>
Hibernate.cfg.xml 配置文件
<?xmlversion="1.0"encoding="utf-8" ?>
<objectsxmlns="http://www.springframework.net"
xmlns:db="http://www.springframework.net/database">
<!--用以我们在其它的应用程序中,配置数据访问-->
<objecttype="Spring.Objects.Factory.Config.PropertyPlaceholderConfigurer,Spring.Core">
<propertyname="ConfigSections"value="databaseSettings"/>
</object>
<!--数据库和Nhibernate的相关配置 -->
<!--<db:providerid="DbProvider" provider="SqlServer-1.1"
connectionString="Server=DGZ\SQLEXPRESS; InitialCatalog=JyjtSysDBInUse_old;User ID=sa;Password=sa;Max Pool Size=75;Min PoolSize=5;Connect Timeout=30"/>-->
<!--<db:providerid="DbProvider" provider="SqlServer-1.1"
connectionString="Server=DGZ\SQLEXPRESS; InitialCatalog=JyjtSysDBInUse_BJ;User ID=sa;Password=sa;Max Pool Size=75;Min PoolSize=5;Connect Timeout=30"/>-->
<db:providerid="DbProvider"provider="SqlServer-1.1"connectionString="Server=“”;Initial Catalog=DataBase;;User ID=sa;Password=sa;Max PoolSize=75;Min Pool Size=5;Connect Timeout=30"/>
<!--SessionFactory对象,其中包括一些比较重要的属性-->
<objectid="NHibernateSessionFactory"type="Spring.Data.NHibernate.LocalSessionFactoryObject,Spring.Data.NHibernate21">
<propertyname="DbProvider"ref="DbProvider"/>
<propertyname="MappingAssemblies">
<list>
<value>Model</value>
</list>
</property>
<propertyname="HibernateProperties">
<dictionary>
<entrykey="hibernate.connection.provider"value="NHibernate.Connection.DriverConnectionProvider"/>
<entrykey="dialect"value="NHibernate.Dialect.MsSql2005Dialect"/>
<entrykey="hibernate.connection.driver_class"value="NHibernate.Driver.SqlClientDriver"/>
<entrykey="hibernate.connection.isolation"value="4"/>
<!--设置隔离级别 1:读操作未提交 2:读操作已提交(默认) 3:可重复读(默认) 4:可串行化-->
<entrykey="use_outer_join"value="true"/>
<entrykey="show_sql"value="true"/>
<!--自动建表(反向映射)-->
<!--<entrykey="hbm2ddl.auto" value="update"/>-->
<entrykey="adonet.batch_size"value="10"/>
<entrykey="command_timeout"value="60"/>
<!--显式启用二级缓存-->
<entrykey="cache.use_second_level_cache"value="true"/>
<!--启动查询缓存-->
<entrykey="cache.use_query_cache"value="true"/>
<entrykey="query.substitutions"value="true 1, false 0, yes'Y', no 'N"/>
<entrykey="proxyfactory.factory_class"value="NHibernate.ByteCode.Castle.ProxyFactoryFactory,NHibernate.ByteCode.Castle"/>
<!--<entrykey="proxyfactory.factory_class"value="NHibernate.ByteCode.LinFu.ProxyFactoryFactory,NHibernate.ByteCode.LinFu"/>-->
</dictionary>
</property>
<propertyname="ExposeTransactionAwareSessionFactory"value="true" />
</object>
<objectid="HibernateTemplate"type="Spring.Data.NHibernate.Generic.HibernateTemplate">
<propertyname="SessionFactory"ref="NHibernateSessionFactory" />
<propertyname="TemplateFlushMode"value="Auto" />
<propertyname="CacheQueries"value="true" />
</object>
</objects>
配置 webconfig
<configuration>
<configSections>
<sectionGroupname="system.web.extensions"type="System.Web.Configuration.SystemWebExtensionsSectionGroup,System.Web.Extensions, Version=3.5.0.0, Culture=neutral,PublicKeyToken=31BF3856AD364E35">
<sectionGroupname="scripting"type="System.Web.Configuration.ScriptingSectionGroup,System.Web.Extensions, Version=3.5.0.0, Culture=neutral,PublicKeyToken=31BF3856AD364E35">
<sectionname="scriptResourceHandler"type="System.Web.Configuration.ScriptingScriptResourceHandlerSection,System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"requirePermission="false"allowDefinition="MachineToApplication"/>
<sectionGroupname="webServices"type="System.Web.Configuration.ScriptingWebServicesSectionGroup,System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<sectionname="jsonSerialization"type="System.Web.Configuration.ScriptingJsonSerializationSection,System.Web.Extensions, Version=3.5.0.0, Culture=neutral,PublicKeyToken=31BF3856AD364E35"requirePermission="false"allowDefinition="Everywhere"/>
<sectionname="profileService"type="System.Web.Configuration.ScriptingProfileServiceSection,System.Web.Extensions, Version=3.5.0.0, Culture=neutral,PublicKeyToken=31BF3856AD364E35"requirePermission="false"allowDefinition="MachineToApplication"/>
<sectionname="authenticationService"type="System.Web.Configuration.ScriptingAuthenticationServiceSection,System.Web.Extensions, Version=3.5.0.0, Culture=neutral,PublicKeyToken=31BF3856AD364E35"requirePermission="false"allowDefinition="MachineToApplication"/>
<sectionname="roleService"type="System.Web.Configuration.ScriptingRoleServiceSection,System.Web.Extensions, Version=3.5.0.0, Culture=neutral,PublicKeyToken=31BF3856AD364E35"requirePermission="false"allowDefinition="MachineToApplication"/>
</sectionGroup>
</sectionGroup>
</sectionGroup>
<sectionGroupname="spring">
<sectionname="context"type="Spring.Context.Support.WebContextHandler,Spring.Web"/>
<sectionname="objects"type="Spring.Context.Support.DefaultSectionHandler,Spring.Core"/>
<sectionname="parsers"type="Spring.Context.Support.NamespaceParsersSectionHandler,Spring.Core"/>
</sectionGroup>
<sectionname="log4net"type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/>
<sectionname="customerconfig"type="Platform.Config.CustomerConfig,Platform"/>
</configSections>
<log4net>
<root>
<levelvalue="ERROR" />
<appender-refref="LogFileAppender" />
<appender-refref="RollingLogFileAppender" />
</root>
<loggername="NHibernate.SQL"additivity="false">
<levelvalue="DEBUG" />
<appender-refref="DebugSQL" />
<!--<appender-refref="RollingLogFileAppender" />-->
</logger>
<appendername="DebugSQL"type="log4net.Appender.TraceAppender">
<layouttype="log4net.Layout.PatternLayout">
<conversionPatternvalue="%date[%thread] %-5level %logger [%property{NDC}] -%message%newline" />
</layout>
</appender>
<appendername="AdoNetAppender_SqlServer"type="log4net.Appender.AdoNetAppender">
<bufferSizevalue="1"/>
<connectionTypevalue="System.Data.SqlClient.SqlConnection,System.Data, Version=1.0.3300.0, Culture=neutral,PublicKeyToken=b77a5c561934e089"/>
<connectionStringvalue="datasource=(local);initial catalog=pubs;integrated security=false;persist securityinfo=True;User ID=sa;Password=sa"/>
<commandTextvalue="INSERT INTO[Log4Net]([Text]) Values( @Description)"/>
<parameter>
<parameterNamevalue="@Description"/>
<dbTypevalue="String"/>
<sizevalue="1000"/>
<layouttype="log4net.Layout.PatternLayout">
<conversionPatternvalue="%X{description}"/>
</layout>
</parameter>
</appender>
<appendername="RollingLogFileAppender"type="log4net.Appender.RollingFileAppender">
<paramname="File" value="./errlog/log_"/>
<paramname="Encoding"value="UTF-8"></param>
<paramname="AppendToFile"value="true"/>
<paramname="DatePattern"value='yyyyMMdd--HH".html"'/>
<paramname="MaxSizeRollBackups"value="30"/>
<paramname="MaximumFileSize"value="10MB"/>
<paramname="RollingStyle"value="Date"/>
<paramname="StaticLogFileName"value="false"/>
<layouttype="log4net.Layout.PatternLayout">
<paramname="ConversionPattern"value="<HR COLOR=red>%n异常时间:%d [%t] <BR>%n异常级别:%-5p <BR>%n异 常 类:%c [%x] <BR>%n异常信息:%m在
 <BR><BR><BR>%n <HR Size=1>"/>
</layout>
</appender>
</log4net>
<spring>
<parsers>
<parsertype="Spring.Data.Config.DatabaseNamespaceParser,Spring.Data"/>
<parsertype="Spring.Transaction.Config.TxNamespaceParser,Spring.Data"/>
</parsers>
<context>
<resourceuri="config://spring/objects"/>
<resourceuri="assembly://Platform/Platform.Controllers/controller.xml"/>
<resourceuri="assembly://Platform/Platform.BLL/bll.xml"/>
<resourceuri="assembly://Platform/Platform.WebUtil/webutil.xml"/>
<resourceuri="~/hibernate.cfg.xml"/>
<resourceuri="assembly://Model/Model.Repository/repository.xml"/>
<resourceuri="assembly://Platform/Platform.MicroClass/thread.xml"/>
<resourceuri="assembly://Platform/Platform.ValidationUtil/validationutil.xml"/>
</context>
<objectsxmlns="http://www.springframework.net"/>
</spring>
<appSettings>
<addkey="Spring.Data.NHibernate.Support.OpenSessionInViewModule.SessionFactoryObjectName"value="NHibernateSessionFactory"/>
<addkey="ConnString"value="Server=.;Initial Catalog=database;User ID=sa;Password=sa;Max PoolSize=75;Min Pool Size=5;Connect Timeout=30"/>
</appSettings>
<system.web>
<sessionStatemode="StateServer"cookieless="false"timeout="720"></sessionState>
<!--
Setcompilation debug="true" to insert debugging
symbolsinto the compiled page. Because this
affectsperformance, set this value to true only
duringdevelopment.
-->
<compilationdebug="true">
<assemblies>
<addassembly="System.Core,Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<addassembly="System.Web.Extensions,Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<addassembly="System.Web.Abstractions,Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<addassembly="System.Web.Routing,Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<addassembly="System.Web.Mvc,Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<addassembly="System.Data.DataSetExtensions,Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<addassembly="System.Xml.Linq,Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<addassembly="System.Data.Linq,Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</assemblies>
</compilation>
<!--
The<authentication> section enables configuration
of thesecurity authentication mode used by
ASP.NET toidentify an incoming user.
-->
<authenticationmode="Forms">
<formsloginUrl="~/Logon/Logon"timeout="2880"/>
</authentication>
<membership>
<providers>
<clear/>
<addname="AspNetSqlMembershipProvider"type="System.Web.Security.SqlMembershipProvider,System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"connectionStringName="ApplicationServices"enablePasswordRetrieval="false"enablePasswordReset="true"requiresQuestionAndAnswer="false"requiresUniqueEmail="false"passwordFormat="Hashed"maxInvalidPasswordAttempts="5"minRequiredPasswordLength="6"minRequiredNonalphanumericCharacters="0"passwordAttemptWindow="10"passwordStrengthRegularExpression=""applicationName="/"/>
</providers>
</membership>
<profile>
<providers>
<clear/>
<addname="AspNetSqlProfileProvider"type="System.Web.Profile.SqlProfileProvider,System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"connectionStringName="ApplicationServices"applicationName="/"/>
</providers>
</profile>
<roleManagerenabled="false">
<providers>
<clear/>
<addconnectionStringName="ApplicationServices"applicationName="/"name="AspNetSqlRoleProvider"type="System.Web.Security.SqlRoleProvider,System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
<addapplicationName="/"name="AspNetWindowsTokenRoleProvider"type="System.Web.Security.WindowsTokenRoleProvider,System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</providers>
</roleManager>
<!--
The<customErrors> section enables configuration
of what todo if/when an unhandled error occurs
during theexecution of a request. Specifically,
it enablesdevelopers to configure html error pages
to bedisplayed in place of a error stack trace.
<customErrors mode="RemoteOnly"defaultRedirect="GenericErrorPage.htm">
<errorstatusCode="403" redirect="NoAccess.htm" />
<errorstatusCode="404" redirect="FileNotFound.htm" />
</customErrors>
-->
<pages>
<controls>
<addtagPrefix="asp"namespace="System.Web.UI"assembly="System.Web.Extensions,Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<addtagPrefix="asp"namespace="System.Web.UI.WebControls"assembly="System.Web.Extensions,Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</controls>
<namespaces>
<addnamespace="System.Web.Mvc"/>
<addnamespace="System.Web.Mvc.Ajax"/>
<addnamespace="System.Web.Mvc.Html"/>
<addnamespace="System.Web.Routing"/>
<addnamespace="System.Linq"/>
<addnamespace="System.Collections.Generic"/>
<!--<add namespace="MvcContrib.UI.Tags"/>
<addnamespace="MvcContrib.UI"/>
<addnamespace="MvcContrib.UI.Html"/>
<addnamespace="MvcContrib.UI.Html.Grid"/>
<addnamespace="MvcContrib"/>-->
</namespaces>
</pages>
<httpHandlers>
<removeverb="*"path="*.asmx"/>
<addverb="*"path="*.asmx"validate="false"type="System.Web.Script.Services.ScriptHandlerFactory,System.Web.Extensions, Version=3.5.0.0, Culture=neutral,PublicKeyToken=31BF3856AD364E35"/>
<addverb="*"path="*_AppService.axd"validate="false"type="System.Web.Script.Services.ScriptHandlerFactory,System.Web.Extensions, Version=3.5.0.0, Culture=neutral,PublicKeyToken=31BF3856AD364E35"/>
<addverb="GET,HEAD"path="ScriptResource.axd"type="System.Web.Handlers.ScriptResourceHandler,System.Web.Extensions, Version=3.5.0.0, Culture=neutral,PublicKeyToken=31BF3856AD364E35"validate="false"/>
<addverb="*"path="*.mvc"validate="false"type="System.Web.Mvc.MvcHttpHandler,System.Web.Mvc, Version=2.0.0.0, Culture=neutral,PublicKeyToken=31BF3856AD364E35"/>
</httpHandlers>
<httpModules>
<addname="ScriptModule"type="System.Web.Handlers.ScriptModule,System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<addname="UrlRoutingModule"type="System.Web.Routing.UrlRoutingModule,System.Web.Routing, Version=3.5.0.0, Culture=neutral,PublicKeyToken=31BF3856AD364E35"/>
<addname="OpenSessionInView"type="Spring.Data.NHibernate.Support.OpenSessionInViewModule,Spring.Data.NHibernate21"/>
<addname="Spring"type="Spring.Context.Support.WebSupportModule,Spring.Web"/>
</httpModules>
<httpRuntimeexecutionTimeout ="300"maxRequestLength ="102400"useFullyQualifiedRedirectUrl="true" />
</system.web>
<system.codedom>
<compilers>
<compilerlanguage="c#;cs;csharp"extension=".cs"warningLevel="4"type="Microsoft.CSharp.CSharpCodeProvider,System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<providerOptionname="CompilerVersion"value="v3.5"/>
<providerOptionname="WarnAsError"value="false"/>
</compiler>
<compilerlanguage="vb;vbs;visualbasic;vbscript"extension=".vb"warningLevel="4"type="Microsoft.VisualBasic.VBCodeProvider,System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<providerOptionname="CompilerVersion"value="v3.5"/>
<providerOptionname="OptionInfer"value="true"/>
<providerOptionname="WarnAsError"value="false"/>
</compiler>
</compilers>
</system.codedom>
<!--
Thesystem.webServer section is required for running ASP.NET AJAX under Internet
InformationServices 7.0. It is not necessary forprevious version of IIS.
-->
<system.webServer>
<validationvalidateIntegratedModeConfiguration="false"/>
<modulesrunAllManagedModulesForAllRequests="true">
<removename="ScriptModule"/>
<removename="UrlRoutingModule"/>
<addname="ScriptModule"preCondition="managedHandler"type="System.Web.Handlers.ScriptModule,System.Web.Extensions, Version=3.5.0.0, Culture=neutral,PublicKeyToken=31BF3856AD364E35"/>
<addname="UrlRoutingModule"type="System.Web.Routing.UrlRoutingModule,System.Web.Routing, Version=3.5.0.0, Culture=neutral,PublicKeyToken=31BF3856AD364E35"/>
</modules>
<handlers>
<removename="WebServiceHandlerFactory-Integrated"/>
<removename="ScriptHandlerFactory"/>
<removename="ScriptHandlerFactoryAppServices"/>
<removename="ScriptResource"/>
<removename="MvcHttpHandler"/>
<removename="UrlRoutingHandler"/>
<addname="ScriptHandlerFactory"verb="*"path="*.asmx"preCondition="integratedMode"type="System.Web.Script.Services.ScriptHandlerFactory,System.Web.Extensions, Version=3.5.0.0, Culture=neutral,PublicKeyToken=31BF3856AD364E35"/>
<addname="ScriptHandlerFactoryAppServices"verb="*"path="*_AppService.axd"preCondition="integratedMode"type="System.Web.Script.Services.ScriptHandlerFactory,System.Web.Extensions, Version=3.5.0.0, Culture=neutral,PublicKeyToken=31BF3856AD364E35"/>
<addname="ScriptResource"preCondition="integratedMode"verb="GET,HEAD"path="ScriptResource.axd"type="System.Web.Handlers.ScriptResourceHandler,System.Web.Extensions, Version=3.5.0.0, Culture=neutral,PublicKeyToken=31BF3856AD364E35"/>
<addname="MvcHttpHandler"preCondition="integratedMode"verb="*"path="*.mvc"type="System.Web.Mvc.MvcHttpHandler,System.Web.Mvc, Version=2.0.0.0, Culture=neutral,PublicKeyToken=31BF3856AD364E35"/>
<addname="UrlRoutingHandler"preCondition="integratedMode"verb="*"path="UrlRouting.axd"type="System.Web.HttpForbiddenHandler,System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</handlers>
</system.webServer>
<system.serviceModel>
</system.serviceModel>
</configuration>