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

Merge branch 'master' of https://dev.azure.com/ZerovaSD/OCPP%20Backend/_git/EVCB_OCPP.OCPPServer.16J into mastertrans

Robert 1 жил өмнө
parent
commit
143338f1af

+ 20 - 5
EVCB_OCPP.WSServer/Message/CoreProfileHandler.cs

@@ -215,8 +215,9 @@ namespace EVCB_OCPP.WSServer.Message
                                     .Select(x => x.ConfigureSetting).FirstOrDefault();
 
                                 if (configVaule != null)
-                                {
+                                {                                    
                                     int.TryParse(configVaule, out heartbeat_interval);
+                                    heartbeat_interval = heartbeat_interval == 0 ? GlobalConfig.GetHEARTBEAT_INTERVAL() : heartbeat_interval;
                                 }
                             }
                             if (session.IsPending == true)
@@ -612,11 +613,11 @@ namespace EVCB_OCPP.WSServer.Message
                                 {
                                     var transaction = db.TransactionRecord.Where(x => x.Id == stopRequest.transactionId
                                      && x.ChargeBoxId == session.ChargeBoxId).FirstOrDefault();
-                                  
+
                                     var businessService = BusinessServiceFactory.CreateBusinessService(session.CustomerId.ToString());
                                     idTagInfo = string.IsNullOrEmpty(stopRequest.idTag) ? null : (stopRequest.idTag == "Backend" ?
                                        new IdTagInfo() { expiryDate = DateTime.UtcNow.AddDays(1), status = AuthorizationStatus.Accepted } : (await businessService.Authorize(session.ChargeBoxId, stopRequest.idTag, transaction.ConnectorId)).IdTagInfo);
-                                                               
+
 
                                     #region PnC 邏輯
                                     if (!string.IsNullOrEmpty(stopRequest.idTag))
@@ -691,8 +692,20 @@ namespace EVCB_OCPP.WSServer.Message
                                         transaction.Receipt = string.Empty;
                                         transaction.Cost = session.IsBilling ? -1 : 0;
 
-                                        if (stopRequest.transactionData != null && stopRequest.transactionData.Count > 0)
+                                        if (stopRequest.transactionData == null || stopRequest.transactionData.Count == 0)
+                                        {                                         
+                                            stopRequest.transactionData = new List<MeterValue>()
+                                            {
+                                                new MeterValue() {  timestamp= stopRequest.timestamp, sampledValue=new List<SampledValue>()}
+                                            };
+
+                                        }
+
+                                        if (stopRequest.transactionData != null && stopRequest.transactionData.Count >= 0)
                                         {
+                                            //清除 StopTransaction TransactionData 
+                                            stopRequest.transactionData[0].sampledValue.Clear();
+
                                             stopRequest.transactionData[0].sampledValue.Add(new SampledValue()
                                             {
                                                 context = ReadingContext.Transaction_End,
@@ -703,6 +716,8 @@ namespace EVCB_OCPP.WSServer.Message
                                                 measurand = Measurand.TotalEnergy,
                                                 value = decimal.Subtract(transaction.MeterStop, transaction.MeterStart).ToString()
                                             });
+
+                                         
                                         }
 
                                         await db.SaveChangesAsync();
@@ -747,7 +762,7 @@ namespace EVCB_OCPP.WSServer.Message
                                 if (stopRequest.transactionData != null)
                                 {
                                     if (stopRequest.transactionData.Count > 0)
-                                    {
+                                    {                                       
                                         using (var _meterDb = new MeterValueDBContext())
                                         {
                                             foreach (var item in stopRequest.transactionData)

+ 16 - 18
EVCB_OCPP.WSServer/Message/FirmwareManagementProfileHandler.cs

@@ -89,7 +89,7 @@ namespace EVCB_OCPP.WSServer.Message
                             {
                                 using (var db = new MainDBContext())
                                 {
-                                    var item = db.MachineOperateRecord.Where(x => x.ChargeBoxId == session.ChargeBoxId && x.RequestType == 0)
+                                    var item = db.MachineOperateRecord.Where(x => x.ChargeBoxId == session.ChargeBoxId && x.Action== "UpdateFirmware" && x.RequestType == 0)
                                         .OrderByDescending(x => x.CreatedOn).FirstOrDefault();
                                     if (item != null)
                                     {
@@ -111,23 +111,22 @@ namespace EVCB_OCPP.WSServer.Message
                         {
                             DiagnosticsStatusNotificationRequest _request = request as DiagnosticsStatusNotificationRequest;
 
-                            using (var db = new MainDBContext())
+
+                            if (_request.status != Packet.Messages.SubTypes.DiagnosticsStatus.Idle)
                             {
-                                db.MachineOperateRecord.Add(new MachineOperateRecord()
+                                using (var db = new MainDBContext())
                                 {
-                                    CreatedOn = DateTime.UtcNow,
-                                    ChargeBoxId = session.ChargeBoxId,
-                                    SerialNo = Guid.NewGuid().ToString(),
-                                    RequestContent = JsonConvert.SerializeObject(_request, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore, Formatting = Formatting.None }),
-                                    EVSE_Status = 0,
-                                    EVSE_Value = _request.status.ToString(),
-                                    Status = 0,
-                                    RequestType = 0,
-                                    Action = _request.Action.ToString()
-
-                                });
-
-                                await db.SaveChangesAsync();
+                                    var item = db.MachineOperateRecord.Where(x => x.ChargeBoxId == session.ChargeBoxId && x.Action == "GetDiagnostics" && x.RequestType == 1)
+                                        .OrderByDescending(x => x.CreatedOn).FirstOrDefault();
+                                    if (item != null)
+                                    {
+                                        item.EVSE_Status = (int)_request.status;
+                                        item.FinishedOn = DateTime.UtcNow;
+                                    }
+
+                                    await db.SaveChangesAsync();
+                                }
+
                             }
 
 
@@ -180,8 +179,7 @@ namespace EVCB_OCPP.WSServer.Message
                             if (operation != null)
                             {
                                 operation.FinishedOn = DateTime.UtcNow;
-                                operation.Status = 1;//電樁有回覆
-                                operation.EVSE_Status = (int)1;//OK
+                                operation.Status = 1;//電樁有回覆                             
                                 operation.EVSE_Value = string.IsNullOrEmpty(evse_rep) ? operation.EVSE_Value : evse_rep;
                                 db.SaveChanges();
                             }

+ 4 - 4
EVCB_OCPP.WSServer/Properties/AssemblyInfo.cs

@@ -31,8 +31,8 @@ using System.Runtime.InteropServices;
 //
 // 您可以指定所有的值,或將組建編號或修訂編號設為預設值
 // 指定為預設值: 
-// [assembly: AssemblyVersion("1.2.0.0")]
-[assembly: AssemblyVersion("1.2.0.0")]
-[assembly: AssemblyFileVersion("1.2.0.0")]
+// [assembly: AssemblyVersion("1.3.1.0")]
+[assembly: AssemblyVersion("1.3.1.0")]
+[assembly: AssemblyFileVersion("1.3.1.0")]
 
-[assembly: AssemblyInformationalVersion("ccf2678")]
+[assembly: AssemblyInformationalVersion("d2f0755")]

+ 2 - 1
EVCB_OCPP.WSServer/ProtalServer.cs

@@ -749,6 +749,7 @@ namespace EVCB_OCPP.WSServer
                                 if (action == Actions.StopTransaction && replyResult.CallErrorMsg == "Reject Response Message")
                                 {
                                     //do nothing 
+                                    logger.Warn(replyResult.Exception.ToString());
                                 }
                                 else
                                 {
@@ -1026,7 +1027,7 @@ namespace EVCB_OCPP.WSServer
                             var result = await conn.QueryAsync<string>(strSql);
 
                             GlobalConfig.DenyModelNames = result.FirstOrDefault().Split(',').ToList();
-                            logger.Debug(string.Format("Current DenyList:[{0}]", string.Join(",", GlobalConfig.DenyModelNames)));
+                          //  logger.Debug(string.Format("Current DenyList:[{0}]", string.Join(",", GlobalConfig.DenyModelNames)));
                         }
 
 

BIN
SuperWebSocket/bin/Debug/SuperWebSocket.dll


BIN
SuperWebSocket/bin/Debug/SuperWebSocket.pdb


+ 27 - 0
azure-pipelines.yml

@@ -0,0 +1,27 @@
+# Starter pipeline
+# Start with a minimal pipeline that you can customize to build and deploy your code.
+# Add steps that build, run tests, deploy, and more:
+# https://aka.ms/yaml
+
+trigger:
+- master
+
+pool:
+  vmImage: ubuntu-latest
+
+steps:
+- task: AdvancedSecurity-Codeql-Init@1
+  inputs:
+    languages: 'csharp'
+
+- task: github/codeql-action/autobuild@v2
+- script: echo Hello, world!
+  displayName: 'Run a one-line script'
+
+- script: |
+    echo Add other tasks to build, test, and deploy your project.
+    echo See https://aka.ms/yaml
+  displayName: 'Run a multi-line script'
+
+- task: AdvancedSecurity-Dependency-Scanning@1
+- task: AdvancedSecurity-Codeql-Analyze@1