ASP.NET MVC 实现页落网资源分享网站+充值管理+后台管理(5)之业务层
业务层主要负责定义业务逻辑(规则、工作流、数据完整性等),接收来自表示层的数据请求,逻辑判断后,向数据访问层提交请求,并传递数据访问结果,业务逻辑层实际上是一个中间件,起着承上启下的重要作用。
在我们的项目中,所有的数据库语句和和逻辑判断尽量写在业务层(IA.Business)里面,这样既能规范层级的作用,同时也规范团队协作的标准,我们在业务层中的类都以实体类名称加上Bll来命名(如:Base_SysLogBll.cs)。
首先,我们需要创建业务类IA.Business:
创建好之后,我们需要引入Bobo.DataAccess.dll和Bobo.Repository.dll、Bobo.Utilities.dll程序集,以及IA.Entity实体。
然后我们需要根据实体类,创建对应的Bll业务类,如:
using Bobo.Repository; using IA.Entity; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace IA.Business { // <summary> /// 文章信息表 /// <author> /// <name>YHB</name> /// <date>2018.10.18</date> /// </author> /// </summary> public class Com_ArticleBll : RepositoryFactory<Com_Article> { } }
这样我们依次把我们需要用的业务类建好,并通过业务仓储工厂继承IRepository接口(: RepositoryFactory<Com_Article>) 我们可以为不同的业务类创建不同的文件夹存放,比如系统的基础业务类,如Base_SysLogBll.cs、Base_DataDictionaryDetailBll.cs、Base_ProvinceCityBll.cs、Base_UserBll.cs等,我们把他放在SystemBusiness文件夹下,这样可以跟常规业务类划分开来。
下面,我们重点列出这几个业务类文件的方法内容,这些方法内容都是一般常规系统会用到的,其他一些特殊或者将会用到的,会在后续边用的过程中,在写入进去,包括其他常规的业务类。
(1)Base_SysLogBll
using Bobo.DataAccess; using Bobo.DataAccess.DataBase; using Bobo.Repository; using Bobo.Utilities; using Bobo.Utilities.Membership; using IA.Entity; using System; using System.Collections.Generic; using System.Data.Common; using System.Linq; using System.Reflection; using System.Text; using System.Threading; using System.Threading.Tasks; namespace IA.Business.SystemBusiness { /// <summary> /// 系统日志表 /// <author> /// <name>YHB</name> /// <date>2018.08.18</date> /// </author> /// </summary> public class Base_SysLogBll : RepositoryFactory<Base_SysLog> { #region 静态实例化 private static Base_SysLogBll item; public static Base_SysLogBll Instance { get { if (item == null) { item = new Base_SysLogBll(); } return item; } } #endregion public Base_SysLog SysLog = new Base_SysLog(); #region 写入操作日志 /// <summary> /// 写入作业日志 /// </summary> /// <param name="ObjectId">对象主键</param> /// <param name="OperationType">操作类型</param> /// <param name="State">状态</param> /// <param name="Remark">操作说明</param> /// <returns></returns> public void WriteLog(string ObjectId, OperationType OperationType, string State, string Remark = "") { SysLog.SysLogId = CommonHelper.GetGuid(); SysLog.ObjectId = ObjectId; SysLog.LogType = CommonHelper.GetString((int)OperationType); if (ManageProvider.Provider.IsOverdue()) { SysLog.IPAddress = ManageProvider.Provider.Current().IPAddress; SysLog.IPAddressName = ManageProvider.Provider.Current().IPAddressName; SysLog.CompanyId = ManageProvider.Provider.Current().CompanyId; SysLog.DepartmentId = ManageProvider.Provider.Current().DepartmentId; SysLog.CreateUserId = ManageProvider.Provider.Current().UserId; SysLog.CreateUserName = ManageProvider.Provider.Current().UserName; } SysLog.ModuleId = DESEncrypt.Decrypt(CookieHelper.GetCookie("ModuleId")); SysLog.Remark = Remark; SysLog.Status = State; ThreadPool.QueueUserWorkItem(new WaitCallback(WriteLogUsu), SysLog);//放入异步执行 } private void WriteLogUsu(object obSysLog) { Base_SysLog VSysLog = (Base_SysLog)obSysLog; DataFactory.Database().Insert(VSysLog); } /// <summary> /// 写入作业日志(新增操作) /// </summary> /// <param name="entity">实体对象</param> /// <param name="OperationType">操作类型</param> /// <param name="State">状态</param> /// <param name="Remark">操作说明</param> /// <returns></returns> public void WriteLog<T>(T entity, OperationType OperationType, string State, string Remark = "") { IDatabase database = DataFactory.Database(); DbTransaction isOpenTrans = database.BeginTrans(); try { SysLog.SysLogId = CommonHelper.GetGuid(); SysLog.ObjectId = DatabaseCommon.GetKeyFieldValue(entity).ToString(); SysLog.LogType = CommonHelper.GetString((int)OperationType); SysLog.IPAddress = ManageProvider.Provider.Current().IPAddress; SysLog.IPAddressName = ManageProvider.Provider.Current().IPAddressName; SysLog.CompanyId = ManageProvider.Provider.Current().CompanyId; SysLog.DepartmentId = ManageProvider.Provider.Current().DepartmentId; SysLog.CreateUserId = ManageProvider.Provider.Current().UserId; SysLog.CreateUserName = ManageProvider.Provider.Current().UserName; SysLog.ModuleId = DESEncrypt.Decrypt(CookieHelper.GetCookie("ModuleId")); if (Remark == "") { SysLog.Remark = DatabaseCommon.GetClassName<T>(); } SysLog.Remark = Remark; SysLog.Status = State; database.Insert(SysLog, isOpenTrans); //添加日志详细信息 Type objTye = typeof(T); foreach (PropertyInfo pi in objTye.GetProperties()) { object value = pi.GetValue(entity, null); if (value != null && value.ToString() != " " && value.ToString() != "") { Base_SysLogDetail syslogdetail = new Base_SysLogDetail(); syslogdetail.SysLogDetailId = CommonHelper.GetGuid(); //syslogdetail.SysLogId = SysLog.SysLogId; syslogdetail.PropertyField = pi.Name; syslogdetail.PropertyName = DatabaseCommon.GetFieldText(pi); syslogdetail.NewValue = "" + value + ""; database.Insert(syslogdetail, isOpenTrans); } } database.Commit(); } catch { database.Rollback(); } } /// <summary> /// 写入作业日志(更新操作) /// </summary> /// <param name="oldObj">旧实体对象</param> /// <param name="newObj">新实体对象</param> /// <param name="OperationType">操作类型</param> /// <param name="State">状态</param> /// <param name="Remark">操作说明</param> /// <returns></returns> public void WriteLog<T>(T oldObj, T newObj, OperationType OperationType, string State, string Remark = "") { IDatabase database = DataFactory.Database(); DbTransaction isOpenTrans = database.BeginTrans(); try { SysLog.SysLogId = CommonHelper.GetGuid(); SysLog.ObjectId = DatabaseCommon.GetKeyFieldValue(newObj).ToString(); SysLog.LogType = CommonHelper.GetString((int)OperationType); SysLog.IPAddress = ManageProvider.Provider.Current().IPAddress; SysLog.IPAddressName = ManageProvider.Provider.Current().IPAddressName; SysLog.CompanyId = ManageProvider.Provider.Current().CompanyId; SysLog.DepartmentId = ManageProvider.Provider.Current().DepartmentId; SysLog.CreateUserId = ManageProvider.Provider.Current().UserId; SysLog.CreateUserName = ManageProvider.Provider.Current().UserName; SysLog.ModuleId = DESEncrypt.Decrypt(CookieHelper.GetCookie("ModuleId")); if (Remark == "") { SysLog.Remark = DatabaseCommon.GetClassName<T>(); } SysLog.Remark = Remark; SysLog.Status = State; database.Insert(SysLog, isOpenTrans); //添加日志详细信息 Type objTye = typeof(T); foreach (PropertyInfo pi in objTye.GetProperties()) { object oldVal = pi.GetValue(oldObj, null); object newVal = pi.GetValue(newObj, null); if (!Equals(oldVal, newVal)) { if (oldVal != null && oldVal.ToString() != " " && oldVal.ToString() != "" && newVal != null && newVal.ToString() != " " && newVal.ToString() != "") { Base_SysLogDetail syslogdetail = new Base_SysLogDetail(); syslogdetail.SysLogDetailId = CommonHelper.GetGuid(); //syslogdetail.SysLogId = SysLog.SysLogId; syslogdetail.PropertyField = pi.Name; syslogdetail.PropertyName = DatabaseCommon.GetFieldText(pi); syslogdetail.NewValue = "" + newVal + ""; syslogdetail.OldValue = "" + oldVal + ""; database.Insert(syslogdetail, isOpenTrans); } } } database.Commit(); } catch { database.Rollback(); } } /// <summary> /// 写入作业日志(删除操作) /// </summary> /// <param name="oldObj">旧实体对象</param> /// <param name="KeyValue">对象主键</param> /// <param name="State">状态</param> /// <param name="Remark">操作说明</param> public void WriteLog<T>(string[] KeyValue, string State, string Remark = "") where T : new() { IDatabase database = DataFactory.Database(); DbTransaction isOpenTrans = database.BeginTrans(); try { foreach (var item in KeyValue) { T Oldentity = database.FindEntity<T>(item.ToString()); SysLog.SysLogId = CommonHelper.GetGuid(); SysLog.ObjectId = item; SysLog.LogType = CommonHelper.GetString((int)OperationType.Delete); SysLog.IPAddress = ManageProvider.Provider.Current().IPAddress; SysLog.IPAddressName = ManageProvider.Provider.Current().IPAddressName; SysLog.CompanyId = ManageProvider.Provider.Current().CompanyId; SysLog.DepartmentId = ManageProvider.Provider.Current().DepartmentId; SysLog.CreateUserId = ManageProvider.Provider.Current().UserId; SysLog.CreateUserName = ManageProvider.Provider.Current().UserName; SysLog.ModuleId = DESEncrypt.Decrypt(CookieHelper.GetCookie("ModuleId")); if (Remark == "") { SysLog.Remark = DatabaseCommon.GetClassName<T>(); } SysLog.Remark = Remark; SysLog.Status = State; database.Insert(SysLog, isOpenTrans); //添加日志详细信息 Type objTye = typeof(T); foreach (PropertyInfo pi in objTye.GetProperties()) { object value = pi.GetValue(Oldentity, null); if (value != null && value.ToString() != " " && value.ToString() != "") { Base_SysLogDetail syslogdetail = new Base_SysLogDetail(); syslogdetail.SysLogDetailId = CommonHelper.GetGuid(); //syslogdetail.SysLogId = SysLog.SysLogId; syslogdetail.PropertyField = pi.Name; syslogdetail.PropertyName = DatabaseCommon.GetFieldText(pi); syslogdetail.NewValue = "" + value + ""; database.Insert(syslogdetail, isOpenTrans); } } } database.Commit(); } catch { database.Rollback(); } } #endregion /// <summary> /// 清空操作日志 /// </summary> /// <param name="CreateDate"></param> /// <returns></returns> public int RemoveLog(string KeepTime) { StringBuilder strSql = new StringBuilder(); DateTime CreateDate = DateTime.Now; if (KeepTime == "7")//保留近一周 { CreateDate = DateTime.Now.AddDays(-7); } else if (KeepTime == "1")//保留近一个月 { CreateDate = DateTime.Now.AddMonths(-1); } else if (KeepTime == "3")//保留近三个月 { CreateDate = DateTime.Now.AddMonths(-3); } if (KeepTime == "0")//不保留,全部删除 { strSql.Append("DELETE FROM Base_SysLog"); return DataFactory.Database().ExecuteBySql(strSql); } else { strSql.Append("DELETE FROM Base_SysLog WHERE 1=1 "); strSql.Append("AND CreateDate <= @CreateDate"); List<DbParameter> parameter = new List<DbParameter>(); parameter.Add(DbFactory.CreateDbParameter("@CreateDate", CreateDate)); return DataFactory.Database().ExecuteBySql(strSql, parameter.ToArray()); } } /// <summary> /// 获取系统日志列表 /// </summary> /// <param name="ModuleId">模块ID</param> /// <param name="ParameterJson">搜索条件</param> /// <param name="jqgridparam">分页条件</param> /// <returns></returns> public List<Base_SysLog> GetPageList(string ModuleId, string ParameterJson, ref JqGridParam jqgridparam) { StringBuilder strSql = new StringBuilder(); List<DbParameter> parameter = new List<DbParameter>(); strSql.Append(@"SELECT * FROM ( SELECT l.SysLogId , l.ObjectId , l.LogType , l.IPAddress , l.IPAddressName , l.CreateDate , l.CreateUserId , l.CreateUserName , l.ModuleId AS Module, m.FullName AS ModuleId , l.Remark , l.State FROM Base_SysLog l LEFT JOIN Base_Module m ON m.ModuleId = l.ModuleId ) A WHERE 1 = 1"); //strSql.Append(WhereSql); if (!string.IsNullOrEmpty(ModuleId)) { strSql.Append(" AND Module = @ModuleId"); parameter.Add(DbFactory.CreateDbParameter("@ModuleId", ModuleId)); } return Repository().FindListPageBySql(strSql.ToString(), parameter.ToArray(), ref jqgridparam); } /// <summary> /// 获取系统日志明细列表 /// </summary> /// <param name="SysLogId">系统日志主键</param> /// <returns></returns> public List<Base_SysLogDetail> GetSysLogDetailList(string SysLogId) { string WhereSql = " AND SysLogId = @SysLogId Order By CreateDate ASC"; List<DbParameter> parameter = new List<DbParameter>(); parameter.Add(DbFactory.CreateDbParameter("@SysLogId", SysLogId)); return DataFactory.Database().FindList<Base_SysLogDetail>(WhereSql, parameter.ToArray()); } } /// <summary> /// 操作类型 /// </summary> public enum OperationType { /// <summary> /// 登陆 /// </summary> Login = 0, /// <summary> /// 新增 /// </summary> Add = 1, /// <summary> /// 修改 /// </summary> Update = 2, /// <summary> /// 删除 /// </summary> Delete = 3, /// <summary> /// 其他 /// </summary> Other = 4, /// <summary> /// 访问 /// </summary> Visit = 5, /// <summary> /// 离开 /// </summary> Leave = 6, /// <summary> /// 查询 /// </summary> Query = 7, /// <summary> /// 安全退出 /// </summary> Exit = 8, } }
(2)Base_DataDictionaryDetailBll
using Bobo.DataAccess; using Bobo.Repository; using Bobo.Utilities; using IA.Entity; using System; using System.Collections.Generic; using System.Data; using System.Data.Common; using System.Linq; using System.Text; using System.Threading.Tasks; namespace IA.Business.SystemBusiness { // <summary> /// 数据字典表 /// <author> /// <name>YHB</name> /// <date>2018.10.18</date> /// </author> /// </summary> public class Base_DataDictionaryDetailBll : RepositoryFactory<Base_DataDictionaryDetail> { /// <summary> /// 根据字典类型和编码获取字典详细 /// </summary> /// <param name="DataDictionaryType"></param> /// <param name="Code"></param> /// <returns></returns> public List<Base_DataDictionaryDetail> GetDataducListByTypeCode(string DataDictionaryType, string Code) { StringBuilder Sql = new StringBuilder(); List<DbParameter> param = new List<DbParameter>(); Sql.Append(@"SELECT * FROM Base_DataDictionaryDetail WHERE DeleteMark<>1"); if (!StringHelper.IsNullOrEmpty(DataDictionaryType)) { Sql.Append(@" AND DataDictionaryType=@DataDictionaryType"); param.Add(DbFactory.CreateDbParameter("@DataDictionaryType", DataDictionaryType)); } if (!StringHelper.IsNullOrEmpty(Code)) { Sql.Append(@" AND Code=@Code"); param.Add(DbFactory.CreateDbParameter("@Code", Code)); } return Factory.FindListBySql(Sql.ToString(), param.ToArray()); } /// <summary> /// 获取类型关键字 /// </summary> /// <param name="DataDictionaryTitle"></param> /// <param name="DataDictionaryType"></param> /// <returns></returns> public List<Base_DataDictionaryDetail> GetDataDictionaryList(string DataDictionaryTitle, string DataDictionaryType) { StringBuilder Sql = new StringBuilder(); List<DbParameter> param = new List<DbParameter>(); Sql.Append(@"SELECT * FROM Base_DataDictionaryDetail WHERE DeleteMark<>1"); if (!StringHelper.IsNullOrEmpty(DataDictionaryType)) { Sql.Append(@" AND DataDictionaryType=@DataDictionaryType"); param.Add(DbFactory.CreateDbParameter("@DataDictionaryType", DataDictionaryType)); } if (!StringHelper.IsNullOrEmpty(DataDictionaryTitle)) { Sql.Append(@" AND DataDictionaryTitle like @DataDictionaryTitle"); param.Add(DbFactory.CreateDbParameter("@DataDictionaryTitle", '%' + DataDictionaryTitle + '%')); } return Factory.FindListBySql(Sql.ToString(), param.ToArray()); } /// <summary> /// 获取关于协会分页数据 /// </summary> /// <param name="ArticleTitle"></param> /// <param name="jgp"></param> /// <returns></returns> public DataTable GetAboutTablePage(ref JqGridParam jgp) { StringBuilder Sql = new StringBuilder(); List<DbParameter> param = new List<DbParameter>(); Sql.Append(@"SELECT * FROM( SELECT X1.DataDictionaryTitle,X1.Code,X1.SortCode,X2.* from (SELECT * FROM dbo.Base_DataDictionaryDetail WHERE DeleteMark<>1 AND DataDictionaryType='About') X1 LEFT JOIN (SELECT * FROM Com_Article WHERE DeleteMark<>1 AND State=1) X2 ON X1.Code=x2.ArticleType) TT WHERE 1=1 "); return Factory.FindTablePageBySql(Sql.ToString(), param.ToArray(), ref jgp); } /// <summary> /// /// </summary> /// <param name="jgp"></param> /// <returns></returns> public DataTable GetAboutTableAllPage(ref JqGridParam jgp) { StringBuilder Sql = new StringBuilder(); List<DbParameter> param = new List<DbParameter>(); Sql.Append(@"SELECT * FROM( SELECT X1.DataDictionaryTitle,X1.Code,X1.SortCode,X2.* from (SELECT * FROM dbo.Base_DataDictionaryDetail WHERE DeleteMark<>1 AND DataDictionaryType='About') X1 LEFT JOIN (SELECT * FROM Com_Article WHERE DeleteMark<>1) X2 ON X1.Code=x2.ArticleType) TT WHERE 1=1 "); return Factory.FindTablePageBySql(Sql.ToString(), param.ToArray(), ref jgp); } /// <summary> /// 添加关键字 /// </summary> /// <param name="ContentKey"></param> /// <returns></returns> public int SubContentKey(string ContentKey) { List<DbParameter> param = new List<DbParameter>(); string[] ContentKeyArr = ContentKey.Split(','); int num = 0; try { if (ContentKeyArr.Length > 0) { foreach (var item in ContentKeyArr) { StringBuilder Sql = new StringBuilder(); Sql.Append(@"DELETE Base_DataDictionaryDetail WHERE DeleteMark<>1 AND DataDictionaryType='ContentKey' AND DataDictionaryTitle='" + item + "'"); Factory.ExecuteBySql(Sql); Base_DataDictionaryDetail entiy = new Base_DataDictionaryDetail(); entiy.DataDictionaryTitle = item; entiy.DataDictionaryType = "ContentKey"; entiy.Create(); Factory.Insert(entiy); } num = 1; } else { num = 0; } } catch { num= 0; } return num; } /// <summary> /// 获取有数据的关键字 /// </summary> /// <param name="Type">关键字类型</param> /// <returns></returns> public List<Base_DataDictionaryDetail> GetContentKeyList(string Type) { StringBuilder Sql = new StringBuilder(); List<DbParameter> param = new List<DbParameter>(); if (!StringHelper.IsNullOrEmpty(Type)) { Sql.Append(@"SELECT * FROM( SELECT (SELECT COUNT(FileID) FROM dbo.Com_Attachment WHERE DeleteMark<>1 AND ContentKey like '%'+x.DataDictionaryTitle+'%' AND FileType=@FileType) FileCount, x.DataDictionaryTitle, x.DataDictionaryType, '"+Type+@"' Code, x.DeleteMark FROM dbo.Base_DataDictionaryDetail x) T WHERE DataDictionaryType='ContentKey' AND DeleteMark<>1 AND FileCount>0"); param.Add(DbFactory.CreateDbParameter("@FileType", Type)); } return Factory.FindListBySql(Sql.ToString(), param.ToArray()); } } }
(3)Base_ProvinceCityBll
using Bobo.DataAccess; using Bobo.Repository; using Bobo.Utilities; using IA.Entity; using System; using System.Collections.Generic; using System.Data.Common; using System.Linq; using System.Text; using System.Threading.Tasks; namespace IA.Business.SystemBusiness { // <summary> /// 省市区域表 /// <author> /// <name>YHB</name> /// <date>2018.10.18</date> /// </author> /// </summary> public class Base_ProvinceCityBll : RepositoryFactory<Base_ProvinceCity> { /// <summary> /// 获取区域列表 /// </summary> /// <param name="ParentId">附件ID</param> /// <param name="Category">区域类型(province,city)</param> /// <param name="Code">区划代码</param> /// <param name="FullName">区域名称</param> /// <returns></returns> public List<Base_ProvinceCity> GetProvinceCityList(string ParentId, string Category, string Code, string FullName) { StringBuilder whereSql = new StringBuilder(); List<DbParameter> param = new List<DbParameter>(); whereSql.Append(@" AND DeleteMark<>1"); if (!StringHelper.IsNullOrEmpty(ParentId)) { whereSql.Append(@" AND ParentId=@ParentId"); param.Add(DbFactory.CreateDbParameter("@ParentId", ParentId)); } if (!StringHelper.IsNullOrEmpty(Category)) { whereSql.Append(@" AND Category=@Category"); param.Add(DbFactory.CreateDbParameter("@Category", Category)); } if (!StringHelper.IsNullOrEmpty(Code)) { whereSql.Append(@" AND Code=@Code"); param.Add(DbFactory.CreateDbParameter("@Code", Code)); } if (!StringHelper.IsNullOrEmpty(FullName)) { whereSql.Append(@" AND FullName like '%" + FullName + "%'"); } whereSql.Append(@" ORDER BY SortCode DESC"); return Factory.FindList(whereSql.ToString(), param.ToArray()); } } }
(4)Base_UserBll
using Bobo.DataAccess.DebugLog; using Bobo.Repository; using Bobo.Utilities; using Bobo.Utilities.Membership; using IA.Entity; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; namespace IA.Business.SystemBusiness { /// <summary> /// 系统用户表 /// </summary> public class Base_UserBll : RepositoryFactory<Base_User> { /// <summary> /// 用户登录 /// </summary> /// <param name="Account"></param> /// <param name="Password"></param> /// <param name="IPAddressName"></param> /// <param name="IPAddress"></param> /// <returns></returns> public int UserLogin(string Account, string Password, string IPAddressName, string IPAddress) { if (!this.IsLinkServer()) { throw new Exception("服务器连接不上," + DbResultMsg.ReturnMsg); } else { Base_User entity = Factory.FindEntity("Account", Account); if (!StringHelper.IsNullOrEmpty(entity) && !StringHelper.IsNullOrEmpty(entity.UserId)) { if (entity.Password == Md5Helper.CreateMd5(DESEncrypt.Encrypt(Password, BaseFactory.BaseHelper().GetPwodKey()).ToLower(), 32).ToLower()) { IManageUser imanageuser = new IManageUser(); imanageuser.UserId = entity.UserId; imanageuser.Account = entity.Account; imanageuser.UserName = entity.RealName; imanageuser.Gender = Convert.ToString(entity.Sex); imanageuser.Code = "System"; imanageuser.LogTime = DateTime.Now; imanageuser.CompanyId = "系统"; imanageuser.DepartmentId = "系统"; imanageuser.IPAddress = IPAddress; imanageuser.IPAddressName = IPAddressName; imanageuser.IsSystem = true; imanageuser.Password = Md5Helper.CreateMd5(DESEncrypt.Encrypt(Password, BaseFactory.BaseHelper().GetPwodKey()).ToLower(), 32).ToLower(); ManageProvider.Provider.AddCurrent(imanageuser, false); return 1;//登录成功 } else { return 3;//密码错误 } } else { return 2;//账户不存在 } } } /// <summary> /// 判断是否连接服务器 /// </summary> /// <returns></returns> public bool IsLinkServer() { StringBuilder strSql = new StringBuilder(); strSql.Append("SELECT GETDATE()"); DataTable dt = Repository().FindTableBySql(strSql.ToString()); if (dt != null && dt.Rows.Count > 0) { return true; } else { return false; } } } }