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

2020/08/10 Jessica
Actions:
1.DB 異動 版本號 b6b7a1b
2. 加入隨便從Server下發命令機制 (For測試用)
3.顯示Http connection訊息

Jessica.Tseng 4 жил өмнө
parent
commit
a13aef5c67

BIN
EVCB_OCPP.WSServer/DLL/EVCB_OCPP.Domain.dll


+ 1 - 0
EVCB_OCPP.WSServer/EVCB_OCPP.WSServer.csproj

@@ -128,6 +128,7 @@
   </ItemGroup>
   <ItemGroup>
     <Compile Include="Dto\ErrorDetails.cs" />
+    <Compile Include="Helper\TypeHelper.cs" />
     <Compile Include="Service\BusinessServiceFactory.cs" />
     <Compile Include="Service\HttpClientService.cs" />
     <Compile Include="Service\LoadingBalanceService.cs" />

+ 7 - 0
EVCB_OCPP.WSServer/Message/BasicMessageHandler.cs

@@ -367,5 +367,12 @@ namespace EVCB_OCPP.WSServer.Message
             }
             return msg;
         }
+
+        internal string GenerateDestroyRequest(string uniqueId, string action, string request)
+        {
+           
+
+            return string.Format(CALL_FORMAT, uniqueId, action, request);
+        }
     }
 }

+ 25 - 1
EVCB_OCPP.WSServer/ProtalServer.cs

@@ -38,6 +38,20 @@ using System.Diagnostics;
 
 namespace EVCB_OCPP.WSServer
 {
+    public class DestroyRequest : IRequest
+    {
+        public string Action { get; set; }
+
+        public bool TransactionRelated()
+        {
+            return false;
+        }
+
+        public bool Validate()
+        {
+            return true;
+        }
+    }
     internal class ProtalServer
     {
         static private ILogger logger = NLog.LogManager.GetCurrentClassLogger();
@@ -1044,7 +1058,7 @@ namespace EVCB_OCPP.WSServer
                                             }
                                         }
 
-                                        if (_RequestType != null)
+                                        if (_RequestType != null && item.CreatedBy!= "Destroyer")
                                         {
                                             request = JsonConvert.DeserializeObject(item.OutRequest, _RequestType) as IRequest;
                                             uuid = session.queue.store(request);
@@ -1052,6 +1066,16 @@ namespace EVCB_OCPP.WSServer
                                             Send(session, rawRequest, string.Format("{0} {1}", action, "Request"), "");
                                         }
 
+                                        if (_RequestType != null && item.CreatedBy == "Destroyer")
+                                        {
+                                            Console.WriteLine("********************************");
+                                            request = Activator.CreateInstance(_RequestType) as IRequest;
+                                            Console.WriteLine("++++++++++++++++++++++++++++++++++++++++");
+                                            uuid = session.queue.store(request);
+                                            string rawRequest = msgAnalyser.GenerateDestroyRequest(uuid, item.OutAction, item.OutRequest);
+                                            Send(session, rawRequest, string.Format("{0} {1}", action, "Request"), "");
+                                        }
+
                                         AddConfirmMessage(charger_SN, item.Id, item.SerialNo, item.OutAction, uuid);
 
                                         #region 更新資料表單一欄位

+ 1 - 1
SocketBase/AppServerBase.cs

@@ -1409,7 +1409,7 @@ namespace SuperSocket.SocketBase
             appSession.SocketSession.Closed += OnSocketSessionClosed;
 
             if (Config.LogBasicSessionActivity && Logger.IsInfoEnabled)
-                Logger.Info(session, "A new session connected!");
+                Logger.Info(session, "A new session connected! ");
 
             OnNewSessionConnected(appSession);
             return true;

+ 1 - 0
SuperWebSocket/WebSocketServer.cs

@@ -598,6 +598,7 @@ namespace SuperWebSocket
 
             while (!string.IsNullOrEmpty(line = reader.ReadLine()))
             {
+                Console.WriteLine(session.SessionID + " " + line);
                 if (string.IsNullOrEmpty(firstLine))
                 {
                     firstLine = line;

BIN
TestTool.RemoteTriggerAPP/DLL/EVCB_OCPP.Domain.dll


+ 4 - 3
TestTool.RemoteTriggerAPP/MainWindow.xaml

@@ -5,7 +5,7 @@
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
         xmlns:local="clr-namespace:TestTool.RemoteTriggerAPP"      
         mc:Ignorable="d"
-        Title="下發測試用工具(公司內網) V1.1.22 (20200709)" Height="481" Width="639">
+        Title="下發測試用工具(公司內網) V1.1.23 (20200723)" Height="481" Width="652">
     <Viewbox>
         <Grid Margin="0,2,2,0">
             <Grid.ColumnDefinitions>
@@ -26,8 +26,8 @@
                 <ComboBoxItem>RemoteStartTransaction</ComboBoxItem>
                 <ComboBoxItem>RemoteStartTransaction_ChargingProfile</ComboBoxItem>
                 <ComboBoxItem>RemoteStopTransaction</ComboBoxItem>
-                <ComboBoxItem>SoftReset</ComboBoxItem>
-                <ComboBoxItem>HardReset</ComboBoxItem>
+                <ComboBoxItem>Reset_SoftReset</ComboBoxItem>
+                <ComboBoxItem>Reset_HardReset</ComboBoxItem>
                 <ComboBoxItem>UnlockConnector</ComboBoxItem>
                 <ComboBoxItem>GetLocalListVersion</ComboBoxItem>
                 <ComboBoxItem>SendLocalAuthorizationList_Full</ComboBoxItem>
@@ -79,6 +79,7 @@
             <TextBox x:Name="uxExpiryTimeTb"  Margin="325,117,10,283" Text="2020/02/06 12:00" Grid.Column="1"></TextBox>
             <Label Content="LocalListSize:" HorizontalAlignment="Left" Height="27" Margin="294,74,0,0" VerticalAlignment="Top" Width="87" Grid.Column="1"/>
             <TextBox x:Name="uxLocalListSizeTb" Text="0" HorizontalAlignment="Left" Height="27" Margin="381,74,0,0" VerticalAlignment="Top" Width="44" RenderTransformOrigin="3.714,1" Grid.Column="1"/>
+            <CheckBox x:Name="uxDestroyCb" Content="破壞模式" HorizontalAlignment="Left" Height="27" Margin="325,165,0,0" VerticalAlignment="Top" Width="100" Grid.Column="1" FontSize="18" Foreground="#FFF11010" Checked="uxDestroyCb_Checked" Unchecked="uxDestroyCb_Unchecked"/>
         </Grid>
     </Viewbox>
 </Window>

+ 308 - 199
TestTool.RemoteTriggerAPP/MainWindow.xaml.cs

@@ -33,6 +33,7 @@ using EVCB_OCPP.Packet.Messages.Reservation;
 using EVCB_OCPP.Packet.Messages.SmartCharging;
 using System.Threading;
 using System.Net.Http;
+using Newtonsoft.Json.Converters;
 
 namespace TestTool.RemoteTriggerAPP
 {
@@ -41,12 +42,14 @@ namespace TestTool.RemoteTriggerAPP
     /// </summary>
     public partial class MainWindow : Window
     {
+
         string action = "";
         List<UploadFile> publishes = new List<UploadFile>();
         FTPClient UploadClient = new FTPClient(@"ftp://test.evsocket.phihong.com.cn", "testocpp", "testocpp");
-        string chargingProfilePath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "chargingProfile.json");
-        string dataTransferPath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "dataTransfer.json");
+        string chargingProfilePath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SetChargingProfile.json");
+        string dataTransferPath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "DataTransfer.json");
         int selectedPublish = -1;
+        bool isDestroyMode = false;
         public MainWindow()
         {
 
@@ -63,193 +66,211 @@ namespace TestTool.RemoteTriggerAPP
 
         private void UxSubmitBtn_Click(object sender, RoutedEventArgs e)
         {
+            if (isDestroyMode)
+            {
+                try
+                {
+                    string actualAction = action.Split('_')[0];
+                    var uuid = Guid.NewGuid().ToString();                 
+                    WritetoDB(uuid,null, actualAction, GetDestroyVersionData(actualAction));
+                    uxMsgTb.Text = string.Format("Send Actions: {0} UUID:{1}", actualAction, uuid);
+                }
+                catch (Exception ex)
+                {
+                    MessageBox.Show(ex.ToString());
+                }
 
-            switch (action)
+            }
+            else
             {
-                #region Core Profile
-                case "ChangeAvailability_Inoperative":
-                    {
-                        SetChangeAvailability_Inoperative();
-                    }
-                    break;
-                case "ChangeAvailability_Operative":
-                    {
-                        SetChangeAvailability_Operative();
-                    }
-                    break;
-                case "DataTransfer":
-                    {
-                      var request =  VerifyDataTransfer(dataTransferPath);
-                        SetDataTransfer(request);
-                    }
-                    break;
-                case "GetConfiguration":
-                    {
-                        if (uxConfigKeyTb.Text == "")
+                switch (action)
+                {
+                    #region Core Profile
+                    case "ChangeAvailability_Inoperative":
+                        {
+                            SetChangeAvailability_Inoperative();
+                        }
+                        break;
+                    case "ChangeAvailability_Operative":
                         {
-                            SetGetConfiguration_ALL();
+                            SetChangeAvailability_Operative();
                         }
-                        else
+                        break;
+                    case "DataTransfer":
                         {
-                            SetGetConfiguration();
+                            var request = VerifyDataTransfer(dataTransferPath);
+                            SetDataTransfer(request);
                         }
+                        break;
+                    case "GetConfiguration":
+                        {
+                            if (uxConfigKeyTb.Text == "")
+                            {
+                                SetGetConfiguration_ALL();
+                            }
+                            else
+                            {
+                                SetGetConfiguration();
+                            }
 
-                    }
-                    break;
-                case "ChangeConfiguration":
-                    {
-                        SetChangeConfiguration();
+                        }
+                        break;
+                    case "ChangeConfiguration":
+                        {
+                            SetChangeConfiguration();
 
-                    }
-                    break;
-                case "ClearCache":
-                    {
-                        SetClearCache();
-                    }
-                    break;
-                case "RemoteStartTransaction":
-                    {
-                        SetRemoteStartTransaction();
-                    }
-                    break;
-                case "RemoteStartTransaction_ChargingProfile":
-                    {
-                        var chargingProfile = VerifyChargingProfile(chargingProfilePath);
-                        if (chargingProfile != null)
+                        }
+                        break;
+                    case "ClearCache":
                         {
-                            SetRemoteStartTransaction(chargingProfile);
+                            SetClearCache();
                         }
-                        else
+                        break;
+                    case "RemoteStartTransaction":
                         {
-                            uxMsgTb.Text = "Please check chargingProfile.json exist in " + AppDomain.CurrentDomain.BaseDirectory;
+                            SetRemoteStartTransaction();
                         }
+                        break;
+                    case "RemoteStartTransaction_ChargingProfile":
+                        {
+                            var chargingProfile = VerifyChargingProfile(chargingProfilePath);
+                            if (chargingProfile != null)
+                            {
+                                SetRemoteStartTransaction(chargingProfile);
+                            }
+                            else
+                            {
+                                uxMsgTb.Text = "Please check chargingProfile.json exist in " + AppDomain.CurrentDomain.BaseDirectory;
+                            }
 
-                    }
-                    break;
-                case "RemoteStopTransaction":
-                    {
-                        SetRemoteStopTransaction();
-                    }
-                    break;
-                case "HardReset":
-                    {
-                        SetHardReset();
-                    }
-                    break;
-                case "SoftReset":
-                    {
-                        SetSoftReset();
-                    }
-                    break;
-                case "UnlockConnector":
-                    {
-                        SetUnlockConnector();
-                    }
-
-                    break;
-                #endregion
-                #region Local Authorization
-                case "GetLocalListVersion":
-                    {
-                        GetLocalListVersion();
-                    }
-                    break;
-                case "SendLocalAuthorizationList_Full":
-                    {
-                        SendLocalAuthorizationList(true);
-                    }
-                    break;
-                case "SendLocalAuthorizationList_Diff":
-                    {
-                        SendLocalAuthorizationList(false);
-                    }
-                    break;
-                #endregion
-                case "GetDiagnostics_FTP":
-                    {
-                        GetDiagnostics(true);
-                    }
-                    break;
-                case "GetDiagnostics_HTTP":
-                    {
-                        GetDiagnostics(false);
-                    }
-                    break;
-                case "ReserveNow":
-                    {
-                        ReserveNow();
-                    }
-                    break;
-                case "CancelReservation":
-                    {
-                        CancelReservation();
-                    }
-                    break;
-                case "ClearChargingProfile":
-                    {
-                        ClearChargingProfile();
-                    }
-                    break;
-                case "GetCompositeSchedule":
-                    {
-                        GetCompositeSchedule();
-                    }
-                    break;
-                case "SetChargingProfile":
-                    {
-                        var chargingProfile = VerifyChargingProfile(chargingProfilePath);
-                        if (chargingProfile != null)
+                        }
+                        break;
+                    case "RemoteStopTransaction":
+                        {
+                            SetRemoteStopTransaction();
+                        }
+                        break;
+                    case "Reset_HardReset":
                         {
-                            SetChargingProfile(chargingProfile);
+                            SetHardReset();
                         }
-                        else
+                        break;
+                    case "Reset_SoftReset":
                         {
-                            uxMsgTb.Text = "Please check chargingProfile.json exist in " + AppDomain.CurrentDomain.BaseDirectory;
+                            SetSoftReset();
+                        }
+                        break;
+                    case "UnlockConnector":
+                        {
+                            SetUnlockConnector();
                         }
 
-                        //SetChargingProfile(new SetChargingProfileRequest()
-                        //{
-                        //    connectorId = 0,
-                        //    csChargingProfiles = new csChargingProfiles()
-                        //    {
-                        //        chargingProfileId = 1,
-                        //        chargingProfileKind = ChargingProfileKindType.Recurring,
-                        //        chargingProfilePurpose = ChargingProfilePurposeType.ChargePointMaxProfile,
-                        //        chargingSchedule = new ChargingSchedule()
-                        //        {
-                        //            chargingRateUnit = ChargingRateUnitType.W,
-                        //            chargingSchedulePeriod = new List<ChargingSchedulePeriod>()
-                        //                            {
-                        //                                new ChargingSchedulePeriod(){  startPeriod=0, limit=int.Parse(uxConfigValueTb.Text)}
-                        //                            },
-                                  
-
-                        //        },
-                        //        recurrencyKind = RecurrencyKindType.Daily,
-                        //        stackLevel = 1,
-
-                        //    }
-                        //});
+                        break;
+                    #endregion
+                    #region Local Authorization
+                    case "GetLocalListVersion":
+                        {
+                            GetLocalListVersion();
+                        }
+                        break;
+                    case "SendLocalAuthorizationList_Full":
+                        {
+                            SendLocalAuthorizationList(true);
+                        }
+                        break;
+                    case "SendLocalAuthorizationList_Diff":
+                        {
+                            SendLocalAuthorizationList(false);
+                        }
+                        break;
+                    #endregion
+                    case "GetDiagnostics_FTP":
+                        {
+                            GetDiagnostics(true);
+                        }
+                        break;
+                    case "GetDiagnostics_HTTP":
+                        {
+                            GetDiagnostics(false);
+                        }
+                        break;
+                    case "ReserveNow":
+                        {
+                            ReserveNow();
+                        }
+                        break;
+                    case "CancelReservation":
+                        {
+                            CancelReservation();
+                        }
+                        break;
+                    case "ClearChargingProfile":
+                        {
+                            ClearChargingProfile();
+                        }
+                        break;
+                    case "GetCompositeSchedule":
+                        {
+                            GetCompositeSchedule();
+                        }
+                        break;
+                    case "SetChargingProfile":
+                        {
+                            var chargingProfile = VerifyChargingProfile(chargingProfilePath);
+                            if (chargingProfile != null)
+                            {
+                                SetChargingProfile(chargingProfile);
+                            }
+                            else
+                            {
+                                uxMsgTb.Text = "Please check chargingProfile.json exist in " + AppDomain.CurrentDomain.BaseDirectory;
+                            }
+
+                            //SetChargingProfile(new SetChargingProfileRequest()
+                            //{
+                            //    connectorId = 0,
+                            //    csChargingProfiles = new csChargingProfiles()
+                            //    {
+                            //        chargingProfileId = 1,
+                            //        chargingProfileKind = ChargingProfileKindType.Recurring,
+                            //        chargingProfilePurpose = ChargingProfilePurposeType.ChargePointMaxProfile,
+                            //        chargingSchedule = new ChargingSchedule()
+                            //        {
+                            //            chargingRateUnit = ChargingRateUnitType.W,
+                            //            chargingSchedulePeriod = new List<ChargingSchedulePeriod>()
+                            //                            {
+                            //                                new ChargingSchedulePeriod(){  startPeriod=0, limit=int.Parse(uxConfigValueTb.Text)}
+                            //                            },
+
+
+                            //        },
+                            //        recurrencyKind = RecurrencyKindType.Daily,
+                            //        stackLevel = 1,
+
+                            //    }
+                            //});
 
-                    }
-                    break;
-
-                #region Trigger Profile
-                case "TriggerMessage_BootNotification":
-                case "TriggerMessage_DiagnosticsStatusNotification":
-                case "TriggerMessage_FirmwareStatusNotification":
-                case "TriggerMessage_Heartbeat":
-                case "TriggerMessage_MeterValues":
-                case "TriggerMessage_StatusNotification":
-                    {
-                        SetRemoteTrigger(action);
-                    }
-                    break;
-                #endregion
-                default:
-                    break;
+                        }
+                        break;
+
+                    #region Trigger Profile
+                    case "TriggerMessage_BootNotification":
+                    case "TriggerMessage_DiagnosticsStatusNotification":
+                    case "TriggerMessage_FirmwareStatusNotification":
+                    case "TriggerMessage_Heartbeat":
+                    case "TriggerMessage_MeterValues":
+                    case "TriggerMessage_StatusNotification":
+                        {
+                            SetRemoteTrigger(action);
+                        }
+                        break;
+                    #endregion
+                    default:
+                        break;
 
+                }
             }
+
         }
 
         private void SetDataTransfer(DataTransferRequest request)
@@ -438,7 +459,7 @@ namespace TestTool.RemoteTriggerAPP
                 var request = new GetDiagnosticsRequest()
                 {
 
-                    location = new Uri(ftp ? "ftp://evseocpp:evseocpp@test.evsocket.phihong.com.cn/" : "http://test.evsocket.phihong.com.cn:9003/api/v1/file/"),
+                    location = new Uri(ftp ? "ftp://evseocpp:evseocpp@ocpp.phihong.com.tw/" : "http://ocpp.phihong.com.tw:9003/api/v1/file/"),
                     retries = 1,
                     retryInterval = 30,
                     startTime = DateTime.Now.AddHours(-1).ToUniversalTime(),
@@ -516,18 +537,62 @@ namespace TestTool.RemoteTriggerAPP
                 //    }
                 //});
 
-                //request.localAuthorizationList.Add(new AuthorizationData()
-                //{
-                //    idTag = "772690F5",
-                //    idTagInfo = new IdTagInfo()
-                //    {
-                //        parentIdTag = "0000000000000000001",
-                //        expiryDate = DateTime.UtcNow.AddMonths(1),
-                //        status = AuthorizationStatus.Accepted
-                //    }
-                //});
+                request.localAuthorizationList.Add(new AuthorizationData()
+                {
+                    idTag = "AA",
+                    idTagInfo = new IdTagInfo()
+                    {
+                        parentIdTag = "SuperVisor",
+                        expiryDate = DateTime.UtcNow.AddMinutes(5),
+                        status = AuthorizationStatus.Accepted
+                    }
+                });
+
+                request.localAuthorizationList.Add(new AuthorizationData()
+                {
+                    idTag = "BB",
+                    idTagInfo = new IdTagInfo()
+                    {
+                        parentIdTag = "SuperVisor",
+                        expiryDate = DateTime.UtcNow.AddMinutes(5),
+                        status = AuthorizationStatus.Accepted
+                    }
+                });
 
-                for (int i = 0; i < size; i++)
+                request.localAuthorizationList.Add(new AuthorizationData()
+                {
+                    idTag = "CC",
+                    idTagInfo = new IdTagInfo()
+                    {
+                        parentIdTag = "SuperVisor",
+                        expiryDate = DateTime.UtcNow.AddMinutes(5),
+                        status = AuthorizationStatus.Accepted
+                    }
+                });
+
+                request.localAuthorizationList.Add(new AuthorizationData()
+                {
+                    idTag = "DD",
+                    idTagInfo = new IdTagInfo()
+                    {
+                        parentIdTag = "SuperVisor",
+                        expiryDate = DateTime.UtcNow.AddMonths(-1),
+                        status = AuthorizationStatus.Invalid
+                    }
+                });
+
+                request.localAuthorizationList.Add(new AuthorizationData()
+                {
+                    idTag = "EE",
+                    idTagInfo = new IdTagInfo()
+                    {
+                        parentIdTag = "SuperVisor",
+                        expiryDate = DateTime.UtcNow.AddMonths(-1),
+                        status = AuthorizationStatus.Invalid
+                    }
+                });
+
+                for (int i = 0; i < size - request.localAuthorizationList.Count(); i++)
                 {
                     request.localAuthorizationList.Add(new AuthorizationData()
                     {
@@ -814,7 +879,7 @@ namespace TestTool.RemoteTriggerAPP
 
 
 
-        private void WritetoDB(string uuid, IRequest request)
+        private void WritetoDB(string uuid, IRequest request, string action = "", string destroyData = "")
         {
             using (var db = new MainDBContext())
             {
@@ -823,21 +888,21 @@ namespace TestTool.RemoteTriggerAPP
                     CreatedOn = DateTime.Now.ToUniversalTime(),
                     ChargeBoxId = uxChargeBoxIdTb.Text,
                     SerialNo = uuid,
-                    RequestContent = JsonConvert.SerializeObject(request, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore, Formatting = Formatting.None }),
+                    RequestContent = !string.IsNullOrEmpty(destroyData) ? destroyData : JsonConvert.SerializeObject(request, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore, Formatting = Formatting.None }),
                     EVSE_Status = 0,
                     Status = 0,
                     RequestType = 1,
-                    Action = request.Action.ToString()
+                    Action = !string.IsNullOrEmpty(destroyData) ? action : request.Action.ToString()
 
                 });
 
                 db.ServerMessage.Add(new ServerMessage()
                 {
                     ChargeBoxId = uxChargeBoxIdTb.Text,
-                    CreatedBy = "TestTool",
+                    CreatedBy = !string.IsNullOrEmpty(destroyData) ? "Destroyer" : "TestTool",
                     CreatedOn = DateTime.Now.ToUniversalTime(),
-                    OutAction = request.Action.ToString(),
-                    OutRequest = JsonConvert.SerializeObject(request, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore, Formatting = Formatting.None }),
+                    OutAction = !string.IsNullOrEmpty(destroyData) ? action : request.Action.ToString(),
+                    OutRequest = !string.IsNullOrEmpty(destroyData) ? destroyData : JsonConvert.SerializeObject(request, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore, Formatting = Formatting.None }),
                     SerialNo = uuid,
                     InMessage = string.Empty
 
@@ -893,18 +958,18 @@ namespace TestTool.RemoteTriggerAPP
             ufObj.FileName = md5 + ufObj.FileExtensionName;
             ufObj.FilePath = "~/UploadFiles/Fw/" + ufObj.FileName;
             ufObj.FileSize = size;
-            ufObj.FileMD5 = md5;      
+            ufObj.FileMD5 = md5;
             ufObj.OriginName = System.IO.Path.GetFileName(uxUploadFileTb.Text);
-            ufObj.FileUrl = new Uri(Properties.Settings.Default.FilePreUrl + ufObj.FilePath.Replace("~/", "")).ToString();          
+            ufObj.FileUrl = new Uri(Properties.Settings.Default.FilePreUrl + ufObj.FilePath.Replace("~/", "")).ToString();
             ufObj.VendorId = "TestTool";
-            ufObj.ModelName= "TestTool";
+            ufObj.ModelName = "TestTool";
             ufObj.ModuleId = 0;
 
             using (var db = new MainDBContext())
             {
                 db.UploadFile.Add(ufObj);
                 db.SaveChanges();
-              
+
             }
 
             string filePath = uxUploadFileTb.Text;
@@ -929,7 +994,7 @@ namespace TestTool.RemoteTriggerAPP
         private async Task UploadTask(string filePath, string fileName)
         {
 
-            bool uploadResult = UploadClient.FtpUploadBroken(filePath, @"ftp://test.evsocket.phihong.com.cn/" + fileName);
+            bool uploadResult = UploadClient.FtpUploadBroken(filePath, @"ftp://ocpp.phihong.com.tw/" + fileName);
 
             await Dispatcher.BeginInvoke(new Action(() =>
             {
@@ -990,9 +1055,9 @@ namespace TestTool.RemoteTriggerAPP
             ufObj.FileName = md5 + ufObj.FileExtensionName;
             ufObj.FilePath = "~/UploadFiles/Fw/" + ufObj.FileName;
             ufObj.FileSize = size;
-            ufObj.FileMD5 = md5;        
+            ufObj.FileMD5 = md5;
             ufObj.OriginName = System.IO.Path.GetFileName(uxUploadFileTb.Text);
-            ufObj.FileUrl = new Uri(Properties.Settings.Default.FTPFilePreUrl + ufObj.FileName).ToString();        
+            ufObj.FileUrl = new Uri(Properties.Settings.Default.FTPFilePreUrl + ufObj.FileName).ToString();
             ufObj.VendorId = "TestTool";
             ufObj.ModelName = "TestTool";
             ufObj.ModuleId = 0;
@@ -1001,7 +1066,7 @@ namespace TestTool.RemoteTriggerAPP
             {
                 db.UploadFile.Add(ufObj);
                 db.SaveChanges();
-              
+
             }
 
 
@@ -1030,12 +1095,12 @@ namespace TestTool.RemoteTriggerAPP
                 {
                     string prefix = i.FileUrl.StartsWith("ftp") ? "FTP" : "HTTP";
                     sb.Clear();
-                    sb.Append(string.Format("[{0}]", prefix));                  
+                    sb.Append(string.Format("[{0}]", prefix));
                     sb.Append("_上傳日期:");
                     sb.Append(i.CreatedOn.ToString());
                     sb.Append("_檔名:");
                     sb.Append(i.OriginName);
-                   
+
                     uxPublishCb.Items.Add(sb.ToString());
                     uxPublishCb.SelectedIndex = 0;
                 }
@@ -1089,7 +1154,7 @@ namespace TestTool.RemoteTriggerAPP
             {
 
                 var machine = db.Machine.Where(x => x.ChargeBoxId == uxChargeBoxIdTb.Text).FirstOrDefault();
-                machine.FW_AssignedVersion = null;              
+                machine.FW_AssignedVersion = null;
                 db.SaveChanges();
             }
 
@@ -1101,9 +1166,53 @@ namespace TestTool.RemoteTriggerAPP
         {
             Properties.Settings.Default.ChargeBoxId = uxChargeBoxIdTb.Text;
             Properties.Settings.Default.Save();
-          
+
+        }
+
+
+        private string GetDestroyVersionData(string action)
+        {
+            string result = "";
+            try
+            {
+                string path = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, action + ".json");
+                var request = JsonConvert.DeserializeObject(File.ReadAllText(path));
+                result = JsonConvert.SerializeObject(request);
+            }
+            catch (Exception ex)
+            {
+                uxMsgTb.Text += "解析檔案發生問題 " + ex.ToString();
+            }
+
+            return result;
         }
 
-       
+        private void uxDestroyCb_Checked(object sender, RoutedEventArgs e)
+        {
+            isDestroyMode = true;
+            uxConnectorIdTb.IsEnabled = false;
+            uxReservationTb.IsEnabled = false;
+            uxIdTagTb.IsEnabled = false;
+            uxParentIdTagTb.IsEnabled = false;
+            uxTransactionIdTb.IsEnabled = false;
+            uxLocalListSizeTb.IsEnabled = false;
+            uxConfigKeyTb.IsEnabled = false;
+            uxConfigValueTb.IsEnabled = false;
+            uxExpiryTimeTb.IsEnabled = false;
+        }
+
+        private void uxDestroyCb_Unchecked(object sender, RoutedEventArgs e)
+        {
+            isDestroyMode = false;
+            uxConnectorIdTb.IsEnabled = true;
+            uxReservationTb.IsEnabled = true;
+            uxIdTagTb.IsEnabled = true;
+            uxParentIdTagTb.IsEnabled = true;
+            uxTransactionIdTb.IsEnabled = true;
+            uxLocalListSizeTb.IsEnabled = true;
+            uxConfigKeyTb.IsEnabled = true;
+            uxConfigValueTb.IsEnabled = true;
+            uxExpiryTimeTb.IsEnabled = true;
+        }
     }
 }