成达考勤大屏幕

This commit is contained in:
2023-12-04 18:12:02 +08:00
parent d696348af5
commit c8077dc07c
20 changed files with 11776 additions and 1 deletions
@@ -0,0 +1,57 @@
using Aspose.Words.Lists;
using Fleck;
using Newtonsoft.Json;
using StackExchange.Redis;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace WebAPI.Common
{
public class PersonKqSocketSersvices
{
public static WebSocketServer webSocketServer;
public static Dictionary<String, IWebSocketConnection> allSockets;
public static void init(int port)
{
allSockets = new Dictionary<string, IWebSocketConnection>();
webSocketServer = new WebSocketServer("ws://0.0.0.0:" + port);
webSocketServer.Start(socket =>
{
socket.OnOpen = () =>
{
};
socket.OnClose = () =>
{
string socketKey = null;
foreach(var key in allSockets.Keys)
{
if(allSockets[key] == socket)
{
socketKey = key;
}
}
if (socketKey != null)
{
allSockets.Remove(socketKey);
}
};
socket.OnMessage = message =>
{
Dictionary<string, object> msg = JsonConvert.DeserializeObject<Dictionary<string,object>>(message);
string projectid = msg["projectid"].ToString();
if (allSockets.ContainsKey(projectid))
{
allSockets[projectid] = socket;
}
else
{
allSockets.Add(projectid , socket);
}
socket.Send("newinout");
};
});
}
}
}
@@ -7,6 +7,7 @@ using SgManager.AI;
using System.Configuration;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json;
using WebAPI.Common;
namespace WebAPI.Controllers
{
@@ -561,6 +562,20 @@ namespace WebAPI.Controllers
};
PersonInOutService.AddPersonInOut(newInOut);
if (PersonKqSocketSersvices.allSockets != null && PersonKqSocketSersvices.allSockets.ContainsKey(projectId))
{
var socket = PersonKqSocketSersvices.allSockets[projectId];
if (socket.IsAvailable)
{
socket.Send("newinout");
}
else
{
PersonKqSocketSersvices.allSockets.Remove(projectId);
}
}
}
catch (Exception ex)
{
+6 -1
View File
@@ -7,6 +7,7 @@ using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;
using System.Configuration;
using WebAPI.Common;
namespace WebAPI
{
@@ -28,9 +29,13 @@ namespace WebAPI
BLL.Funs.ConnString = ConfigurationManager.AppSettings["ConnectionString"];
BLL.Funs.PageSize = Convert.ToInt32(ConfigurationManager.AppSettings["PageSize"]);
BLL.ErrLogInfo.DefaultErrLogFullPath = Server.MapPath("~/ErrLog.txt");
PersonKqSocketSersvices.init(1000);
// 使api返回为json
GlobalConfiguration.Configuration.Formatters.XmlFormatter.SupportedMediaTypes.Clear();
}
}
}
+5
View File
@@ -59,6 +59,9 @@
<Reference Include="FineUIPro, Version=6.3.0.0, Culture=neutral, PublicKeyToken=9cbe753c029f291a">
<HintPath>..\FineUIPro\FineUIPro.dll</HintPath>
</Reference>
<Reference Include="Fleck, Version=1.2.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Fleck.1.2.0\lib\net45\Fleck.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.5.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
</Reference>
@@ -215,6 +218,7 @@
<Compile Include="Areas\HelpPage\SampleGeneration\TextSample.cs" />
<Compile Include="Areas\HelpPage\XmlDocumentationProvider.cs" />
<Compile Include="Common\ICache.cs" />
<Compile Include="Common\PersonKqSocketServices.cs" />
<Compile Include="Common\Redis.cs" />
<Compile Include="Controllers\BaseInfoController.cs" />
<Compile Include="Controllers\CommonController.cs" />
@@ -363,6 +367,7 @@
<Folder Include="Models\" />
<Folder Include="Properties\PublishProfiles\" />
<Folder Include="Views\Login\" />
<Folder Include="Views\Screen\" />
</ItemGroup>
<ItemGroup>
<Content Include="fonts\glyphicons-halflings-regular.woff2" />
+1
View File
@@ -2,6 +2,7 @@
<packages>
<package id="Antlr" version="3.5.0.2" targetFramework="net461" />
<package id="bootstrap" version="3.3.7" targetFramework="net461" />
<package id="Fleck" version="1.2.0" targetFramework="net461" />
<package id="jQuery" version="3.3.1" targetFramework="net461" />
<package id="Microsoft.AspNet.Cors" version="5.2.7" targetFramework="net461" />
<package id="Microsoft.AspNet.Mvc" version="5.2.4" targetFramework="net461" />