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;
}
}
}
}
ASP.NET MVC 实现页落网资源分享网站+充值管理+后台管理(5)之业务层的更多相关文章
- ASP.NET MVC 实现页落网资源分享网站+充值管理+后台管理(13)之会员登录注册
源码下载地址:http://www.yealuo.com/Sccnn/Detail?KeyValue=c891ffae-7441-4afb-9a75-c5fe000e3d1c 会员中心,是我们与用户交 ...
- ASP.NET MVC 实现页落网资源分享网站+充值管理+后台管理(1)之数据库设计
本文主要讲解本项目网站所应用到的知识点,及数据库的相关设计: 一.知识点 (1)本项目主要采取ASP.NET MVC的编程模式,相信你已经了解到了MVC的具体含义是什么,这里不再赘述,有不了解的朋友, ...
- ASP.NET MVC 实现页落网资源分享网站+充值管理+后台管理(16)之轻博客
源码下载地址:http://www.yealuo.com/Sccnn/Detail?KeyValue=c891ffae-7441-4afb-9a75-c5fe000e3d1c 项目到上面一步其实已经算 ...
- ASP.NET MVC 实现页落网资源分享网站+充值管理+后台管理(15)之前台网站页面
源码下载地址:http://www.yealuo.com/Sccnn/Detail?KeyValue=c891ffae-7441-4afb-9a75-c5fe000e3d1c 本项目主要是一个素材的分 ...
- ASP.NET MVC 实现页落网资源分享网站+充值管理+后台管理(14)之会员中心管理
源码下载地址:http://www.yealuo.com/Sccnn/Detail?KeyValue=c891ffae-7441-4afb-9a75-c5fe000e3d1c 会员中心,主要包含了会员 ...
- ASP.NET MVC 实现页落网资源分享网站+充值管理+后台管理(9)之系统登录
前面我们已经做好了一个文章管理功能模块,接下来,我们回头来做登录窗口,登录不仅涉及到登录验证还涉及到登录日志还有缓存时长等. 对于缓存的相关设置,我们已经写好封装在Bobo.Utilities.dll ...
- ASP.NET MVC 实现页落网资源分享网站+充值管理+后台管理(7)之扩展基类和区域创建以及文本编辑配置
一.扩展基类和区域创建 (1)在应用之前,我们先在表现层创建一个公共的系统扩展文件来(SystemExtension)存放我们需要延伸和扩展的方法类. 在常规的项目系统操作中,我们都需要用到增删查改的 ...
- ASP.NET MVC 实现页落网资源分享网站+充值管理+后台管理(2)之创建项目
我们在创建项目的时候一定要遵循层次和命名的原则,同时也要有统一的规范,无论是多人项目还是单人项目,能够让人看着一目了然并赏析悦目,做一个有追求的程序员. 例如IA.WebApp是视图控制器层(表现层) ...
- ASP.NET MVC 实现页落网资源分享网站+充值管理+后台管理(8)之文章管理
到这一步,我们整个项目的核心搭建已经算是完成了,接下来就是我们业务功能的实际应用,也就是表现层的设计和实现,如果你是一个项目负责人,到这一步,接下来的工作就可以交给下面的兄弟去完成了,在这里我们用文章 ...
- ASP.NET MVC 实现页落网资源分享网站+充值管理+后台管理(4)之业务仓储工厂
在创建业务层之前,我们先来熟悉一下业务仓储工厂Bobo.Repository.dll程序集,后续的业务操作,我们都将通过这个程序集中的方法传递数据库操作,其介于数据库操作与业务层之间,详情可前往< ...
随机推荐
- HDU4251-The Famous ICPC Team Again(划分树)
Problem Description When Mr. B, Mr. G and Mr. M were preparing for the 2012 ACM-ICPC World Final Con ...
- bzoj1800 飞行棋
脑筋急转弯. 提示:矩形矩形矩形.O(n)O(n)O(n). 再提示:直角. 再提示:直径. 代码: //Serene #include<algorithm> #include<io ...
- JavaScript实现,控制一个文本框只能输入正整数,如输入不符合条件则文本框全部字体标红
腾讯2014年研发职位笔试题Web前端方向简单题第一题. 代码: <html> <head> <title>test JavaScript</title> ...
- java把Word文件转成html的字符串返回出去
1.需求是把前端上传的word文件解析出来,生成html的字符串返回给前端去展示,Word里面的图片可以忽略不显示,所以这段代码去掉了解析图片的代码 package com.lieni.core.ut ...
- 洛谷1758 BZOJ1566 管道取珠题解
题目链接 一道人类智慧的dp题 首先我们可以将∑ai^2转化为求取两次,两次一样的方案数 然后用f[i][j][k][l]表示第一个人在第一个串中取到i第二个串中取到j 第二个人在一个串中取到k第二个 ...
- python 约束. 异常处理. MD5. 日志处理
一.约束 1.抛异常 # # 项目经理写的 class Base: # # 对子类进行了约束. 必须重写该方法 # # 以后上班了. 拿到公司代码之后. 发现了NotImplementedError ...
- 使用epoll实现简单的服务器
1. 头文件 #ifndef __TCP_SERVER_H__ #define __TCP_SERVER_H__ #include <unistd.h> #include <stdi ...
- Streamy 使用RDBMS
- @codeforces - 117C@ Cycle
目录 @description@ @solution@ @accepted code@ @details@ @description@ 给定一个竞赛图(有向完全图),请找出里面的某个三元环,或者判断不 ...
- uni-app禁止滑动穿透
<view class="topWrapper" v-show="chooseShow" @click="chooseShow = false& ...