using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel.Activation;
using System.ServiceModel;
using System.Text;
using QMFrameWork.ServiceInterface;
using QMFrameWork.ServiceLibrary;
using QMAPP.Entity.Sys;
using QMAPP.BLL.Sys;
namespace QMFrameWork.WebServiceHost
{
///
/// 登录服务
///
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
public class LoginService : ILoginService
{
///
/// 用户登录验(用户名和密码登录)
///
/// 登录信息
/// 登录凭据
/// 登录信息
public LoginInfo IsLogin(LoginInfo login, CredentialInfo c)
{
try
{
login = new LoginBLL().IsLogin(login);
if (login == null)
{
return login;
}
c.UserName = login.UserName;
if (c.CredentialID != null)
{
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);
}
}
///
/// 获取登录信息
///
/// 登录凭据
/// 登录信息
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;
}
}
}
}