@@ -111,6 +111,23 @@ namespace Learun.Application.Web.Areas.Permission.Controllers | |||
perm_FunctionVisitIBLL.SaveEntity(keyValue,entity); | |||
return Success("保存成功!"); | |||
} | |||
/// <summary> | |||
/// 退出实体数据 | |||
/// <param name="keyValue">主键</param> | |||
/// <summary> | |||
/// <returns></returns> | |||
[HttpPost] | |||
[AjaxOnly] | |||
public ActionResult DoOutHandle(string keyValue) | |||
{ | |||
var result = perm_FunctionVisitIBLL.DoOutHandle(keyValue); | |||
if (!result) | |||
{ | |||
return Fail("操作失败!"); | |||
} | |||
return Success("操作成功!"); | |||
} | |||
#endregion | |||
} | |||
@@ -31,6 +31,9 @@ | |||
<a id="lr_edit" class="btn btn-default"><i class="fa fa-pencil-square-o"></i> 修改</a> | |||
<a id="lr_delete" class="btn btn-default"><i class="fa fa-trash-o"></i> 删除</a> | |||
</div> | |||
<div class=" btn-group btn-group-sm"> | |||
<a id="lr_outhandle" class="btn btn-default"><i class="fa fa-pencil-square-o"></i> 退出</a> | |||
</div> | |||
</div> | |||
</div> | |||
<div class="lr-layout-body" id="gridtable"></div> | |||
@@ -62,6 +62,30 @@ var bootstrap = function ($, learun) { | |||
}); | |||
} | |||
}); | |||
// 退出 | |||
$('#lr_outhandle').on('click', function () { | |||
var keyValue = $('#gridtable').jfGridValue('PVId'); | |||
if (learun.checkrow(keyValue)) { | |||
var PIsLoginSuccess = $('#gridtable').jfGridValue('PIsLoginSuccess'); | |||
if (PIsLoginSuccess != true && PIsLoginSuccess != "true") { | |||
learun.alert.warning("此应用无法退出!"); | |||
return false; | |||
} | |||
var IsOut = $('#gridtable').jfGridValue('IsOut'); | |||
if (IsOut == true || IsOut == "true") { | |||
learun.alert.warning("此应用已退出!"); | |||
return false; | |||
} | |||
learun.layerConfirm('是否确认退出该项!', function (res) { | |||
if (res) { | |||
learun.postForm(top.$.rootUrl + '/Permission/Perm_FunctionVisit/DoOutHandle', { keyValue: keyValue }, function () { | |||
refreshGirdData(); | |||
}); | |||
} | |||
}); | |||
} | |||
}); | |||
}, | |||
// 初始化列表 | |||
initGird: function () { | |||
@@ -77,11 +101,17 @@ var bootstrap = function ($, learun) { | |||
}, | |||
{ label: "用户名称", name: "PUName", width: 100, align: "left" }, | |||
{ label: "访问情况", name: "PContent", width: 400, align: "left" }, | |||
{ label: "是否已退出", name: "IsOut", width: 100, align: "left" }, | |||
{ | |||
label: "是否退出", name: "IsOut", width: 70, align: "center", formatter: function (cellvalue) { | |||
return cellvalue == true ? "<i class=\"fa fa-toggle-on\"></i>" : "<i class=\"fa fa-toggle-off\"></i>"; | |||
} | |||
}, | |||
{ label: "退出日期", name: "OutDate", width: 150, align: "left" }, | |||
], | |||
mainId: 'PVId', | |||
isPage: true, | |||
rows: 100 | |||
rows: 100, | |||
sidx: 'PDate desc', | |||
}); | |||
page.search(); | |||
}, | |||
@@ -118,6 +118,30 @@ namespace Learun.Application.TwoDevelopment.Permission | |||
} | |||
} | |||
/// <summary> | |||
/// 退出实体数据 | |||
/// <param name="keyValue">主键</param> | |||
/// <summary> | |||
/// <returns></returns> | |||
public bool DoOutHandle(string keyValue) | |||
{ | |||
try | |||
{ | |||
return perm_FunctionVisitService.DoOutHandle(keyValue); | |||
} | |||
catch (Exception ex) | |||
{ | |||
if (ex is ExceptionEx) | |||
{ | |||
throw; | |||
} | |||
else | |||
{ | |||
throw ExceptionEx.ThrowBusinessException(ex); | |||
} | |||
} | |||
} | |||
#endregion | |||
} | |||
@@ -48,7 +48,7 @@ namespace Learun.Application.TwoDevelopment.Permission | |||
/// 是否登录成功 | |||
/// </summary> | |||
[Column("PISLOGINSUCCESS")] | |||
public bool PIsLoginSuccess { get; set; } | |||
public bool? PIsLoginSuccess { get; set; } | |||
/// <summary> | |||
/// 用户编号 | |||
/// </summary> | |||
@@ -58,7 +58,12 @@ namespace Learun.Application.TwoDevelopment.Permission | |||
/// 是否退出第三方应用 | |||
/// </summary> | |||
[Column("ISOUT")] | |||
public bool IsOut { get; set; } | |||
public bool? IsOut { get; set; } | |||
/// <summary> | |||
/// 退出时间 | |||
/// </summary> | |||
[Column("OUTDATE")] | |||
public DateTime? OutDate { get; set; } | |||
#endregion | |||
#region 扩展操作 | |||
@@ -43,6 +43,12 @@ namespace Learun.Application.TwoDevelopment.Permission | |||
/// <summary> | |||
/// <returns></returns> | |||
void SaveEntity(string keyValue, Perm_FunctionVisitEntity entity); | |||
/// <summary> | |||
/// 退出实体数据 | |||
/// <param name="keyValue">主键</param> | |||
/// <summary> | |||
/// <returns></returns> | |||
bool DoOutHandle(string keyValue); | |||
#endregion | |||
} | |||
@@ -3,7 +3,11 @@ using Learun.DataBase.Repository; | |||
using Learun.Util; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Configuration; | |||
using System.Data; | |||
using System.IO; | |||
using System.Net; | |||
using System.Net.Http; | |||
using System.Text; | |||
namespace Learun.Application.TwoDevelopment.Permission | |||
@@ -43,7 +47,7 @@ namespace Learun.Application.TwoDevelopment.Permission | |||
dp.Add("PUName", "%" + queryParam["PUName"].ToString() + "%", DbType.String); | |||
strSql.Append(" AND a.PUName Like @PUName "); | |||
} | |||
return this.BaseRepository().FindList<Perm_FunctionVisitEntity>(strSql.ToString(),dp, pagination); | |||
return this.BaseRepository().FindList<Perm_FunctionVisitEntity>(strSql.ToString(), dp, pagination); | |||
} | |||
catch (Exception ex) | |||
{ | |||
@@ -95,7 +99,7 @@ namespace Learun.Application.TwoDevelopment.Permission | |||
{ | |||
try | |||
{ | |||
this.BaseRepository().Delete<Perm_FunctionVisitEntity>(t=>t.PVId == keyValue); | |||
this.BaseRepository().Delete<Perm_FunctionVisitEntity>(t => t.PVId == keyValue); | |||
} | |||
catch (Exception ex) | |||
{ | |||
@@ -143,6 +147,66 @@ namespace Learun.Application.TwoDevelopment.Permission | |||
} | |||
} | |||
/// <summary> | |||
/// 退出实体数据 | |||
/// <param name="keyValue">主键</param> | |||
/// <summary> | |||
/// <returns></returns> | |||
public bool DoOutHandle(string keyValue) | |||
{ | |||
try | |||
{ | |||
var entity = this.BaseRepository().FindEntity<Perm_FunctionVisitEntity>(keyValue); | |||
if (entity != null && entity.PIsLoginSuccess == true && entity.IsOut != true) | |||
{ | |||
var functionEntity = this.BaseRepository().FindEntity<Perm_FunctionEntity>(entity.Fid); | |||
if (functionEntity != null && !string.IsNullOrEmpty(functionEntity.FOutUrl)) | |||
{ | |||
string outUrl = functionEntity.FOutUrl; | |||
if (outUrl.Contains("?")) | |||
{ | |||
outUrl = string.Format("{0}&no={1}", functionEntity.FOutUrl, DESEncrypt.Encrypt(entity.PUNo ?? " ", DESEncrypt.Decrypt(functionEntity.FSecret, ConfigurationManager.AppSettings["SSOPublicSecret"]), false)); | |||
} | |||
else | |||
{ | |||
outUrl = string.Format("{0}?no={1}", functionEntity.FOutUrl, DESEncrypt.Encrypt(entity.PUNo ?? " ", DESEncrypt.Decrypt(functionEntity.FSecret, ConfigurationManager.AppSettings["SSOPublicSecret"]), false)); | |||
} | |||
try | |||
{ | |||
HttpWebRequest webrequest = (HttpWebRequest)WebRequest.Create(outUrl); | |||
HttpWebResponse response = (HttpWebResponse)webrequest.GetResponse(); | |||
using (StreamReader streamReader = new StreamReader(response.GetResponseStream())) | |||
{ | |||
string responseData = streamReader.ReadToEnd(); | |||
if (!string.IsNullOrEmpty(responseData)) | |||
{ | |||
this.BaseRepository().ExecuteBySql($"update Perm_FunctionVisit set IsOut=1,OutDate='{DateTime.Now}' where PVId='{entity.PVId}' "); | |||
return true; | |||
} | |||
} | |||
} | |||
catch (Exception) | |||
{ | |||
return false; | |||
} | |||
} | |||
} | |||
return false; | |||
} | |||
catch (Exception ex) | |||
{ | |||
if (ex is ExceptionEx) | |||
{ | |||
throw; | |||
} | |||
else | |||
{ | |||
throw ExceptionEx.ThrowServiceException(ex); | |||
} | |||
} | |||
} | |||
#endregion | |||
} | |||