Эх сурвалжийг харах

1.加入MaintainMode設定

Jessica Tseng 2 жил өмнө
parent
commit
6516adffdb

+ 3 - 2
EVCB_OCPP.WSServer/App.config

@@ -13,9 +13,10 @@
      <add name="WebDBContext" connectionString="data source=172.1.2.187\SQLEXPRESS2017;initial catalog=StandardOCPP_Web;;persist security info=True;user id=sa;password=Ph0930118811;MultipleActiveResultSets=True;App=EntityFramework; Max Pool Size=500" providerName="System.Data.SqlClient" />
    </connectionStrings>
   <appSettings>   
-     <add key="LocalAuthAPI" value="" />
+    <add key="LocalAuthAPI" value="" />
     <add key="WSPort" value="2012" />
-    <add key="WSSPort" value="2016" />  
+    <add key="WSSPort" value="2016" />
+    <add key="MaintainMode" value="0" />
   </appSettings>
   <startup>
     <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.1" />

+ 11 - 4
EVCB_OCPP.WSServer/SuperSocket.Protocol/OCPPWSServer.cs

@@ -6,6 +6,7 @@ using SuperWebSocket;
 using SuperWebSocket.SubProtocol;
 using System;
 using System.Collections.Generic;
+using System.Configuration;
 using System.Linq;
 using System.Net;
 using System.Net.Security;
@@ -77,6 +78,12 @@ namespace OCPPServer.Protocol
 
             string[] words = session.Path.Split('/');
             session.ChargeBoxId = words.Last();
+
+            if (ConfigurationManager.AppSettings["MaintainMode"] == "1")
+            {
+                session.ChargeBoxId = session.ChargeBoxId + "_2";
+            }
+
             logger.Info(string.Format("ValidateHandshake: {0}", session.Path));
             bool isExistedSN = false;
             bool authorizated = false;
@@ -123,13 +130,13 @@ namespace OCPPServer.Protocol
 
                 if (session.Items.ContainsKey("Authorization") || session.Items.ContainsKey("authorization"))
                 {
-                   
+
                     using (var db = new MainDBContext())
                     {
 
                         authorizationKey = db.MachineConfiguration.Where(x => x.ChargeBoxId == session.ChargeBoxId && x.ConfigureName == StandardConfiguration.AuthorizationKey)
                                           .Select(x => x.ConfigureSetting).FirstOrDefault();
-                      
+
 
                         if (session.ISOCPP20)
                         {
@@ -152,8 +159,8 @@ namespace OCPPServer.Protocol
                     }
 
 
-                    
-                 
+
+
 
                 }
                 else