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程序集,后续的业务操作,我们都将通过这个程序集中的方法传递数据库操作,其介于数据库操作与业务层之间,详情可前往< ...
随机推荐
- 对快速排序的分析 Quick Sort
快速排序 快排的基本思想是:通过一趟排序将待排记录分割成独立的两部分,其中一部分记录的关键字均比另一部分记录的关键字小,则可分别对这两部分记录继续进行排序,以达到整个序列有序.通常可选第一个记录为基准 ...
- PHP生成唯一的促销/优惠/折扣码,由字母和数字组成。
首先我们先搞清楚什么是促销/优惠/折扣码?它有什么用作: 每一个电子商务网站,现在有一种或多种类型的优惠/折扣/优惠券系统,给大家分享一下如何在PHP生成唯一的促销/折扣码.主要是实现一个优惠码系统, ...
- hdu3879 最大权闭合图
若a,b 2点能够相连,那么可以得到ci的价值,也就是说a,b是得到c的前提条件,对于每一个点,又有耗费. 对于本题,先求出最多能够得到的利益有多少,最小割=未被 选的用户的收益之和 + 被选择的站点 ...
- (六)IO流之过滤流
过滤字节流FilterInputStream和FilterOutputStream BufferedInputStream和BufferedOutputStream 需要使用已存在的节点流来构造 ...
- [ITOO]动态建库 标签: 库数据库mysql 2016-07-17 21:23 241人阅读 评论(2) 收
最近一直在做权限系统的动态建库,动态建库,说白了就是在你点击"注册"按钮的时候,根据你输入的信息,来创建一个企业所需要的数据库的过程,因为现阶段并没有提供购买等功能,所以暂时咱们是 ...
- hdu 1025 lis 注意细节!!!【dp】
感觉这道题浪费了我半个小时的生命......哇靠!原来输出里面当len=1时是road否则是roads!!! 其实做过hdu 1950就会发现这俩其实一样,就是求最长上升子序列.我用结构体记录要连线的 ...
- 12-2 js基础
一 数据类型 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UT ...
- 2018-8-10-win10-uwp-如何在DataTemplate绑定方法
title author date CreateTime categories win10 uwp 如何在DataTemplate绑定方法 lindexi 2018-08-10 19:16:50 +0 ...
- Python基础:常用函数
1:enumerate enumerate(sequence, start=0) 该函数返回一个enumerate对象(一个迭代器).其中的sequence参数可以是序列.迭代器或者支持迭代的其他对象 ...
- 【小程序案例】支付宝小程序-MQTT模器,IoT设备通过WSS接入阿里云IoT物联网平台
支付宝小程序-MQTT模拟器通过WSS接入阿里云IoT物联网平台 小程序效果: 1. 准备工作 1.1 注册阿里云账号 开通阿里云账号,并通过支付宝实名认证 https://www.aliyun.co ...