using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel.Activation;
using System.ServiceModel;
using System.Text;
using System.Configuration;
using QMFrameWork.ServiceInterface;
using QMFrameWork.ServiceLibrary;
using QMAPP.Entity.Sys;
using QMAPP.BLL.Sys;
namespace QM.Exchange.Core
{
///
/// 登录服务
///
public class LoginService : ILoginService
{
#region 用户登录验(用户名和密码登录)
///
/// 用户登录验(用户名和密码登录)
///
/// 登录信息
/// 登录凭据
/// 登录信息
public LoginInfo IsLogin(LoginInfo login, CredentialInfo c)
{
try
{
login = new LoginBLL().IsLogin(login);
if (login == null)
{
return login;
}
////是否限制超级用户权限
//if (ConfigurationManager.AppSettings["LimitSuperPower"] != null)
//{
// if (ConfigurationManager.AppSettings["LimitSuperPower"].ToString().ToLower() != "false")
// {
// //限制超级用户权限
// login.LimitSuperPower = true;
// }
//}
c.UserName = login.UserName;
SessionManager.Add(c.CredentialID, new ServiceSession { SessionID = c.CredentialID, UserCredential = c, UserLogin = login }, new TimeSpan(0, 60, 0));
return login;
}
catch (Exception ex)
{
QMFrameWork.Log.LogManager.LogHelper.Error(
new QMFrameWork.Log.LogInfo { ClientIP = "localhost", UserName = "admin", Info = "执行服务异常", ErrorInfo = ex });
throw new FaultException(ex.Message);
}
}
#endregion
#region 获取登录信息
///
/// 获取登录信息
///
/// 登录凭据
/// 登录信息
public LoginInfo GetLoginInfo(CredentialInfo c)
{
try
{
ServiceSession session = SessionManager.GetSession(c.CredentialID);
if (session != null)
{
return session.UserLogin;
}
else
{
return null;
}
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
}
}