Skip to content

Commit 826659d

Browse files
committed
除超级管理员外,其他账户不允许同时在线
1 parent 0fa9cd9 commit 826659d

File tree

2 files changed

+38
-4
lines changed

2 files changed

+38
-4
lines changed

软件系统客户端模版/FormMainWindow.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ private void ThreadPoolDownloadSizeLarge()
742742
if (result.Content[0] == 'Y')
743743
{
744744
byte[] data = Convert.FromBase64String(result.Content.Substring(1));
745-
string path32 = path + @"\" + PortraitSupport.SmallPortrait;
745+
string path32 = path + @"\" + PortraitSupport.LargePortrait;
746746
System.IO.File.WriteAllBytes(path32, data);
747747
System.Diagnostics.Process.Start(path32);
748748
}

软件系统服务端模版/FormServerWindow.cs

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -495,8 +495,18 @@ private void DataProcessingWithStartA(AsyncStateOne state, int customer, string
495495
//提取账户,密码
496496
string name = SoftBasic.GetValueFromJsonObject(json, UserAccount.UserNameText, "");
497497
string password = SoftBasic.GetValueFromJsonObject(json, UserAccount.PasswordText, "");
498-
net_simplify_server.SendMessage(state, customer, UserServer.ServerAccounts.CheckAccountJson(
499-
name, password, state.GetRemoteEndPoint().Address.ToString()));
498+
499+
UserAccount account = UserServer.ServerAccounts.CheckAccount(name, password, state.GetRemoteEndPoint().Address.ToString());
500+
//检测是否重复登录
501+
if(account.LoginEnable)
502+
{
503+
if(IsClinetOnline(account.UserName))
504+
{
505+
account.LoginEnable = false;
506+
account.ForbidMessage = "该账户已经登录";
507+
}
508+
}
509+
net_simplify_server.SendMessage(state, customer, JObject.FromObject(account).ToString());
500510
}
501511
else if (customer == CommonHeadCode.SimplifyHeadCode.更新公告)
502512
{
@@ -849,7 +859,7 @@ private void Net_socket_server_AllClientsStatusChange(string data)
849859
{
850860
//此处决定要不要将在线客户端的数据发送所有客户端
851861
net_socket_server.SendAllClients(CommonHeadCode.MultiNetHeadCode.总在线信息, data);
852-
862+
Net_Socket_All_Clients = data;
853863
if (IsWindowShow && IsHandleCreated)
854864
{
855865
BeginInvoke(new Action(() =>
@@ -860,6 +870,30 @@ private void Net_socket_server_AllClientsStatusChange(string data)
860870
}
861871
}
862872

873+
/// <summary>
874+
/// 所有在线客户端的信息
875+
/// </summary>
876+
private string Net_Socket_All_Clients = string.Empty;
877+
/// <summary>
878+
/// 用来判断客户端是否已经在线,除了超级管理员,其他的账户不允许重复在线,重复登录的账户予以特殊标记
879+
/// </summary>
880+
/// <returns>该客户端是否在线</returns>
881+
private bool IsClinetOnline(string userName)
882+
{
883+
if (userName == "admin") return false;
884+
if(Net_Socket_All_Clients.Contains($"Name:{userName}#"))
885+
{
886+
return true;
887+
}
888+
else if(Net_Socket_All_Clients.EndsWith($"Name:{userName}"))
889+
{
890+
return true;
891+
}
892+
else
893+
{
894+
return false;
895+
}
896+
}
863897

864898
#endregion
865899

0 commit comments

Comments
 (0)