private async void btn_cancel_abort_Click(object sender, EventArgs e)
        {
            try
            {
                if (selection_index == -1)
                {
                    return;
                }
                btn_cancel_abort.Enabled = false;
                var mcs_cmd = cmdMCSshowList[selection_index];
                CancelActionType cnacel_type = default(CancelActionType);
                if (mcs_cmd.TRANSFERSTATE < sc.E_TRAN_STATUS.Transferring)
                {
                    cnacel_type = CancelActionType.CmdCancel;
                }
                else if (mcs_cmd.TRANSFERSTATE < sc.E_TRAN_STATUS.Canceling)
                {
                    cnacel_type = CancelActionType.CmdAbort;
                }
                else
                {
                    MessageBox.Show($"Command ID:{mcs_cmd.CMD_ID.Trim()} can't excute cancel / abort,\r\ncurrent state:{mcs_cmd.TRANSFERSTATE}", "Cancel / Abort command fail.", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                await Task.Run(() => mainform.BCApp.SCApplication.TransferService.AbortOrCancel(mcs_cmd.CMD_ID, cnacel_type));

                updateTransferCommand();
            }
            catch { }
            finally
            {
                btn_cancel_abort.Enabled = true;
            }
        }
        private void RegisterTransferManagementEvent()
        {
            Post["TransferManagement/MCSQueueSwitch"] = (p) =>
            {
                var    scApp  = SCApplication.getInstance();
                string result = string.Empty;

                try
                {
                    string AutoAssign   = Request.Query.AutoAssign.Value ?? Request.Form.AutoAssign.Value ?? string.Empty;
                    bool   isAutoAssign = Convert.ToBoolean(AutoAssign);
                    scApp.getEQObjCacheManager().getLine().MCSCommandAutoAssign = isAutoAssign;
                    result = "OK";
                }
                catch (Exception ex)
                {
                    result = "MCS Queue Switch update failed with exception happened";
                }

                var response = (Response)result;
                response.ContentType = restfulContentType;
                return(response);
            };

            Post["TransferManagement/CancelAbort"] = (p) =>
            {
                var    scApp     = SCApplication.getInstance();
                bool   isSuccess = true;
                string result    = string.Empty;

                CancelActionType cnacel_type = default(CancelActionType);
                string           mcs_cmd_id  = Request.Query.mcs_cmd.Value ?? Request.Form.mcs_cmd.Value ?? string.Empty;
                try
                {
                    ATRANSFER mcs_cmd = scApp.CMDBLL.GetTransferByID(mcs_cmd_id);
                    if (mcs_cmd == null)
                    {
                        result = $"Can not find transfer command:[{mcs_cmd_id}].";
                    }
                    else
                    {
                        if (mcs_cmd.TRANSFERSTATE < sc.E_TRAN_STATUS.Transferring)
                        {
                            cnacel_type = CancelActionType.CmdCancel;
                            bool btemp = scApp.TransferService.AbortOrCancel(mcs_cmd_id, cnacel_type);
                            if (btemp)
                            {
                                result = "OK";
                            }
                            else
                            {
                                result = $"Transfer command:[{mcs_cmd_id}] cancel failed.";
                            }
                        }
                        else if (mcs_cmd.TRANSFERSTATE < sc.E_TRAN_STATUS.Canceling)
                        {
                            cnacel_type = CancelActionType.CmdAbort;
                            bool btemp = scApp.TransferService.AbortOrCancel(mcs_cmd_id, cnacel_type);
                            if (btemp)
                            {
                                result = "OK";
                            }
                            else
                            {
                                result = $"Transfer command:[{mcs_cmd_id}] adort failed.";
                            }
                        }
                        else
                        {
                            result = $"Command ID:{mcs_cmd.ID.Trim()} can't excute cancel / abort,\r\ncurrent state:{mcs_cmd.TRANSFERSTATE}";
                        }
                    }
                }
                catch (Exception ex)
                {
                    isSuccess = false;
                    result    = "Execption happend!";
                    logger.Error(ex, "Execption:");
                }
                var response = (Response)result;
                response.ContentType = restfulContentType;
                return(response);
            };


            Post["TransferManagement/ForceFinish"] = (p) =>
            {
                var       scApp            = SCApplication.getInstance();
                bool      isSuccess        = true;
                string    result           = string.Empty;
                string    mcs_cmd_id       = Request.Query.mcs_cmd.Value ?? Request.Form.mcs_cmd.Value ?? string.Empty;
                ACMD      cmd              = scApp.CMDBLL.GetCommandByTransferCmdID(mcs_cmd_id);
                AVEHICLE  excute_cmd_of_vh = scApp.VehicleBLL.cache.getVehicle(cmd.VH_ID);
                ATRANSFER mcs_cmd          = scApp.CMDBLL.GetTransferByID(mcs_cmd_id);
                try
                {
                    //todo kevin 需要再Reviwer下
                    //if (cmd != null)
                    //{
                    //    scApp.VehicleBLL.doTransferCommandFinish(excute_cmd_of_vh.VEHICLE_ID, cmd.ID, CompleteStatus.ForceFinishByOp, 0);
                    //    scApp.VIDBLL.initialVIDCommandInfo(excute_cmd_of_vh.VEHICLE_ID);
                    //}
                    //scApp.CMDBLL.updateCMD_MCS_TranStatus2Complete(mcs_cmd_id, E_TRAN_STATUS.Aborted);
                    //scApp.ReportBLL.newReportTransferCommandFinish(mcs_cmd, excute_cmd_of_vh, sc.Data.SECS.AGVC.SECSConst.CMD_Result_Unsuccessful, null);
                    result = "OK";
                }
                catch
                {
                    result = "ForceFinish failed.";
                }

                var response = (Response)result;
                response.ContentType = restfulContentType;
                return(response);
            };

            Post["TransferManagement/AssignVehicle"] = (p) =>
            {
                var    scApp  = SCApplication.getInstance();
                string result = string.Empty;

                string mcs_cmd_id = Request.Query.mcs_cmd.Value ?? Request.Form.mcs_cmd.Value ?? string.Empty;
                string vh_id      = Request.Query.vh_id.Value ?? Request.Form.vh_id.Value ?? string.Empty;
                try
                {
                    ATRANSFER mcs_cmd = scApp.CMDBLL.GetTransferByID(mcs_cmd_id);
                    scApp.CMDBLL.assignCommnadToVehicle(mcs_cmd_id, vh_id, out result);
                }
                catch (Exception ex)
                {
                    result = "Assign command to  vehicle failed with exception happened.";
                }

                var response = (Response)result;
                response.ContentType = restfulContentType;
                return(response);
            };
            Post["TransferManagement/ShiftCommand"] = (p) =>
            {
                var    scApp  = SCApplication.getInstance();
                string result = string.Empty;

                string mcs_cmd_id = Request.Query.mcs_cmd.Value ?? Request.Form.mcs_cmd.Value ?? string.Empty;
                string vh_id      = Request.Query.vh_id.Value ?? Request.Form.vh_id.Value ?? string.Empty;

                try
                {
                    ATRANSFER mcs_cmd       = scApp.CMDBLL.GetTransferByID(mcs_cmd_id);
                    var       excute_result = scApp.TransferService.CommandShift(mcs_cmd_id, vh_id);
                    result = excute_result.result;
                }
                catch (Exception ex)
                {
                    result = "Shift command failed with exception happened.";
                }

                var response = (Response)result;
                response.ContentType = restfulContentType;
                return(response);
            };

            Post["TransferManagement/ChangeStatus"] = (p) =>
            {
                var    scApp      = SCApplication.getInstance();
                string result     = string.Empty;
                bool   isSuccess  = true;
                string mcs_cmd_id = Request.Query.mcs_cmd.Value ?? Request.Form.mcs_cmd.Value ?? string.Empty;
                string sstatus    = Request.Query.status.Value ?? Request.Form.status.Value ?? string.Empty;
                try
                {
                    ATRANSFER     mcs_cmd = scApp.CMDBLL.GetTransferByID(mcs_cmd_id);
                    E_TRAN_STATUS status  = (E_TRAN_STATUS)Enum.Parse(typeof(E_TRAN_STATUS), sstatus, false);

                    if (mcs_cmd != null)
                    {
                        isSuccess = scApp.CMDBLL.updateTransferCmd_TranStatus(mcs_cmd_id, status);
                        if (isSuccess)
                        {
                            result = "OK";
                        }
                        else
                        {
                            result = "Update status failed.";
                        }
                    }
                    else
                    {
                        result = $"Can not find MCS Command[{mcs_cmd_id}].";
                    }
                }
                catch (Exception ex)
                {
                    result = "Update status failed with exception happened.";
                }

                //Todo by Mark

                var response = (Response)result;
                response.ContentType = restfulContentType;
                return(response);
            };

            Post["TransferManagement/Priority"] = (p) =>
            {
                var    scApp      = SCApplication.getInstance();
                string result     = string.Empty;
                bool   isSuccess  = true;
                string mcs_cmd_id = Request.Query.mcs_cmd.Value ?? Request.Form.mcs_cmd.Value ?? string.Empty;
                string priority   = Request.Query.priority.Value ?? Request.Form.priority.Value ?? string.Empty;
                try
                {
                    ATRANSFER mcs_cmd   = scApp.CMDBLL.GetTransferByID(mcs_cmd_id);
                    int       iPriority = Convert.ToInt32(priority);
                    if (mcs_cmd != null)
                    {
                        isSuccess = scApp.CMDBLL.updateCMD_MCS_PrioritySUM(mcs_cmd, iPriority);
                        if (isSuccess)
                        {
                            result = "OK";
                        }
                        else
                        {
                            result = "Update priority failed.";
                        }
                    }
                    else
                    {
                        result = $"Can not find MCS Command[{mcs_cmd_id}].";
                    }
                }
                catch (Exception ex)
                {
                    result = "Update priority failed with exception happened.";
                }

                var response = (Response)result;
                response.ContentType = restfulContentType;
                return(response);
            };
        }
        private void RegisterVehilceEvent()
        {
            Get["AVEHICLES/{ID}"] = (p) =>
            {
                string   vh_id    = p.ID;
                AVEHICLE vh       = SCApplication.getInstance().VehicleBLL.cache.getVehicle(vh_id);
                var      response = (Response)vh.ToString();
                response.ContentType = restfulContentType;

                return(response);
            };
            Get["AVEHICLES"] = (p) =>
            {
                string          vh_id    = p.ID;
                List <AVEHICLE> vhs      = SCApplication.getInstance().getEQObjCacheManager().getAllVehicle();
                var             response = (Response)JsonConvert.SerializeObject(vhs);
                response.ContentType = restfulContentType;

                return(response);
            };
            //Get["AVEHICLES/(?<all>)"] = (p) =>
            Get["AVEHICLES/_search"] = (p) =>
            {
                List <AVEHICLE> vhs = null;

                foreach (string name in Request.Query)
                {
                    switch (name)
                    {
                    case "SectionID":
                        string sec_id = Request.Query[name] ?? string.Empty;
                        vhs = SCApplication.getInstance().VehicleBLL.cache.loadVehicleBySEC_ID(sec_id);
                        break;
                    }
                }
                var response = (Response)JsonConvert.SerializeObject(vhs);
                response.ContentType = restfulContentType;

                return(response);
            };

            Get["metrics"] = (p) =>
            {
                int total_idle_vh_clean        = SCApplication.getInstance().VehicleBLL.cache.getNoExcuteMcsCmdVhCount(E_VH_TYPE.Clean);
                int total_idle_vh_Dirty        = SCApplication.getInstance().VehicleBLL.cache.getNoExcuteMcsCmdVhCount(E_VH_TYPE.Dirty);
                int total_cmd_is_queue_count   = SCApplication.getInstance().CMDBLL.getCMD_MCSIsQueueCount();
                int total_cmd_is_running_count = SCApplication.getInstance().CMDBLL.getCMD_MCSIsRunningCount();

                string ohxc_excute_info = string.Empty;

                StringBuilder sb = new StringBuilder();
                setOhxCContent(sb, nameof(total_idle_vh_clean), total_idle_vh_clean, "current idle clean car");
                setOhxCContent(sb, nameof(total_idle_vh_Dirty), total_idle_vh_Dirty, "current idle dirty car");
                setOhxCContent(sb, nameof(total_cmd_is_queue_count), total_cmd_is_queue_count, "cmd number being queued");
                setOhxCContent(sb, nameof(total_cmd_is_running_count), total_cmd_is_running_count, "cmd number being executed");

                var response = (Response)sb.ToString();
                response.ContentType = restfulContentType;
                return(response);
            };

            Post["AVEHICLES/ViewerUpdate"] = (p) =>
            {
                SCApplication   scApp = SCApplication.getInstance();
                List <AVEHICLE> vhs   = scApp.getEQObjCacheManager().getAllVehicle();

                //foreach (AVEHICLE vh in vhs)
                //{
                //    scApp.VehicleService.PublishVhInfo(vh, null);
                //    SpinWait.SpinUntil(() => false, 10);
                //}

                var response = (Response)"OK";
                response.ContentType = restfulContentType;
                return(response);
            };

            //Post["api/io/T2STK100T01/waitin/CST01"] = (p) =>
            //{

            //    var response = (Response)"OK";
            //    response.ContentType = restfulContentType;
            //    return response;
            //};

            Post["AVEHICLES/SendCommand"] = (p) =>
            {
                var        scApp        = SCApplication.getInstance();
                bool       isSuccess    = true;
                string     vh_id        = Request.Query.vh_id.Value ?? Request.Form.vh_id.Value ?? string.Empty;
                string     carrier_id   = Request.Query.carrier_id.Value ?? Request.Form.carrier_id.Value ?? string.Empty;
                string     from_port_id = Request.Query.from_port_id.Value ?? Request.Form.from_port_id.Value ?? string.Empty;
                string     to_port_id   = Request.Query.to_port_id.Value ?? Request.Form.to_port_id.Value ?? string.Empty;
                E_CMD_TYPE e_cmd_type   = default(E_CMD_TYPE);
                string     cmd_type     = Request.Query.cmd_type.Value ?? Request.Form.cmd_type.Value ?? string.Empty;

                string result = string.Empty;
                try
                {
                    ACMD     cmd_obj  = null;
                    AVEHICLE assignVH = null;

                    assignVH  = scApp.VehicleBLL.cache.getVehicle(vh_id);
                    isSuccess = assignVH != null;
                    if (isSuccess)
                    {
                        isSuccess = Enum.TryParse(cmd_type, out e_cmd_type);
                        if (isSuccess)
                        {
                            switch (e_cmd_type)
                            {
                            case E_CMD_TYPE.Move:
                            case E_CMD_TYPE.Load:
                            case E_CMD_TYPE.Unload:
                            case E_CMD_TYPE.LoadUnload:
                                string from_adr = from_port_id;
                                string to_adr   = to_port_id;
                                //scApp.MapBLL.getAddressID(from_port_id, out from_adr);
                                //scApp.MapBLL.getAddressID(to_port_id, out to_adr);
                                scApp.CMDBLL.doCreatCommand(vh_id, out cmd_obj,
                                                            cmd_type: e_cmd_type,
                                                            source: from_adr,
                                                            destination: to_adr,
                                                            carrier_id: carrier_id,
                                                            gen_cmd_type: SCAppConstants.GenOHxCCommandType.Manual);
                                sc.BLL.CMDBLL.CommandCheckResult check_result_info =
                                    sc.BLL.CMDBLL.getCallContext <sc.BLL.CMDBLL.CommandCheckResult>
                                        (sc.BLL.CMDBLL.CALL_CONTEXT_KEY_WORD_OHTC_CMD_CHECK_RESULT);
                                isSuccess = check_result_info.IsSuccess;
                                result    = check_result_info.ToString();
                                if (isSuccess)
                                {
                                    //isSuccess = scApp.VehicleService.doSendCommandToVh(assignVH, cmd_obj);
                                    isSuccess = scApp.VehicleService.Send.Command(assignVH, cmd_obj);
                                    if (isSuccess)
                                    {
                                        result = "OK";
                                    }
                                    else
                                    {
                                        result = "Send command to vehicle failed!";
                                    }
                                }
                                else
                                {
                                    result = "Command create failed!";
                                    //bcf.App.BCFApplication.onWarningMsg(this, new bcf.Common.LogEventArgs("Command create fail.", check_result_info.Num));
                                }
                                break;

                            case E_CMD_TYPE.Teaching:
                                isSuccess = scApp.VehicleService.Send.Teaching(vh_id, from_port_id, to_port_id);
                                break;
                            }
                        }
                        else
                        {
                            result = $"Try parse Command Type:[{cmd_type}] failed!";
                        }
                    }
                    else
                    {
                        result = $"Vehicle :[{vh_id}] not found!";
                    }
                }
                catch (Exception ex)
                {
                    isSuccess = false;
                    result    = "Execption happend!";
                    logger.Error(ex, "Execption:");
                }

                var response = (Response)result;
                response.ContentType = restfulContentType;
                return(response);
            };

            Post["AVEHICLES/SendReset"] = (p) =>
            {
                var    scApp     = SCApplication.getInstance();
                bool   isSuccess = true;
                string vh_id     = Request.Query.vh_id.Value ?? Request.Form.vh_id.Value ?? string.Empty;

                string result = string.Empty;
                try
                {
                    AVEHICLE assignVH = null;
                    assignVH = scApp.VehicleBLL.cache.getVehicle(vh_id);

                    isSuccess = assignVH != null;

                    if (isSuccess)
                    {
                        isSuccess = scApp.VehicleService.Send.StatusRequest(vh_id, true);
                        if (isSuccess)
                        {
                            result = "OK";
                        }
                        else
                        {
                            result = "Send vehicle status request failed.";
                        }
                    }
                    else
                    {
                        result = $"Vehicle :[{vh_id}] not found!";
                    }
                }
                catch (Exception ex)
                {
                    isSuccess = false;
                    result    = "Execption happend!";
                    logger.Error(ex, "Execption:");
                }

                var response = (Response)result;
                response.ContentType = restfulContentType;
                return(response);
            };

            Post["AVEHICLES/SendCancelAbort"] = (p) =>
            {
                var    scApp     = SCApplication.getInstance();
                bool   isSuccess = true;
                string vh_id     = Request.Query.vh_id.Value ?? Request.Form.vh_id.Value ?? string.Empty;
                string cmd_id    = "";//todo kevin 需要指定cmd id
                string result    = string.Empty;
                try
                {
                    ACMD cmd = scApp.CMDBLL.GetCMD_OHTCByID(cmd_id);
                    if (cmd == null)
                    {
                        result    = $"Can't find command:[{cmd_id}] in database.";
                        isSuccess = false;
                    }
                    AVEHICLE assignVH = null;
                    if (isSuccess)
                    {
                        assignVH  = scApp.VehicleBLL.cache.getVehicle(vh_id);
                        isSuccess = assignVH != null;
                    }
                    if (isSuccess)
                    {
                        string mcs_cmd_id = cmd_id;
                        if (!string.IsNullOrWhiteSpace(mcs_cmd_id))
                        {
                            ATRANSFER mcs_cmd = scApp.CMDBLL.GetTransferByID(mcs_cmd_id);
                            if (mcs_cmd == null)
                            {
                                result = $"Can't find MCS command:[{mcs_cmd_id}] in database.";
                            }
                            else
                            {
                                CancelActionType actType = default(CancelActionType);
                                if (mcs_cmd.TRANSFERSTATE < sc.E_TRAN_STATUS.Transferring)
                                {
                                    actType   = CancelActionType.CmdCancel;
                                    isSuccess = scApp.TransferService.AbortOrCancel(mcs_cmd_id, actType);
                                    if (isSuccess)
                                    {
                                        result = "OK";
                                    }
                                    else
                                    {
                                        result = "Send command cancel/abort failed.";
                                    }
                                }
                                else if (mcs_cmd.TRANSFERSTATE < sc.E_TRAN_STATUS.Canceling)
                                {
                                    actType   = CancelActionType.CmdAbort;
                                    isSuccess = scApp.TransferService.AbortOrCancel(mcs_cmd_id, actType);
                                    if (isSuccess)
                                    {
                                        result = "OK";
                                    }
                                    else
                                    {
                                        result = "Send command cancel/abort failed.";
                                    }
                                }
                                else
                                {
                                    result = $"MCS command:[{mcs_cmd_id}] can't excute cancel / abort,\r\ncurrent state:{mcs_cmd.TRANSFERSTATE}";
                                }
                            }
                        }
                        else
                        {
                            string ohtc_cmd_id = cmd_id;
                            if (string.IsNullOrWhiteSpace(ohtc_cmd_id))
                            {
                                result = $"Vehicle:[{vh_id}] do not have command.";
                            }
                            else
                            {
                                ACMD ohtc_cmd = scApp.CMDBLL.GetCMD_OHTCByID(ohtc_cmd_id);
                                if (ohtc_cmd == null)
                                {
                                    result = $"Can't find vehicle command:[{ohtc_cmd_id}] in database.";
                                }
                                else
                                {
                                    CancelActionType actType = ohtc_cmd.CMD_STATUS >= E_CMD_STATUS.Execution ? CancelActionType.CmdAbort : CancelActionType.CmdCancel;
                                    isSuccess = scApp.VehicleService.Send.Cancel(assignVH.VEHICLE_ID, ohtc_cmd_id, actType);
                                    if (isSuccess)
                                    {
                                        result = "OK";
                                    }
                                    else
                                    {
                                        result = "Send vehicle status request failed.";
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        result = $"Vehicle :[{vh_id}] not found!";
                    }
                }
                catch (Exception ex)
                {
                    isSuccess = false;
                    result    = "Execption happend!";
                    logger.Error(ex, "Execption:");
                }

                var response = (Response)result;
                response.ContentType = restfulContentType;
                return(response);
            };

            Post["AVEHICLES/PauseEvent"] = (p) =>
            {
                bool          isSuccess  = false;
                SCApplication scApp      = SCApplication.getInstance();
                string        vh_id      = Request.Query.vh_id.Value ?? Request.Form.vh_id.Value ?? string.Empty;
                string        event_type = Request.Query.event_type.Value ?? Request.Form.event_type.Value ?? string.Empty;
                PauseEvent    pauseEvent = default(PauseEvent);
                isSuccess = Enum.TryParse(event_type, out pauseEvent);
                if (isSuccess)
                {
                    isSuccess = scApp.VehicleService.Send.Pause(vh_id, pauseEvent, PauseType.Normal);
                }

                var response = (Response)(isSuccess ? "OK" : "NG");
                response.ContentType = restfulContentType;
                return(response);
            };


            Post["AVEHICLES/PauseStatusChange"] = (p) =>
            {
                bool          isSuccess  = false;
                string        result     = string.Empty;
                SCApplication scApp      = SCApplication.getInstance();
                string        vh_id      = Request.Query.vh_id.Value ?? Request.Form.vh_id.Value ?? string.Empty;
                string        pauseType  = Request.Query.pauseType.Value ?? Request.Form.pauseType.Value ?? string.Empty;
                string        event_type = Request.Query.event_type.Value ?? Request.Form.event_type.Value ?? string.Empty;
                PauseType     pause_type = default(PauseType);
                PauseEvent    pauseEvent = default(PauseEvent);
                isSuccess = Enum.TryParse(pauseType, out pause_type);

                if (isSuccess)
                {
                    isSuccess = Enum.TryParse(event_type, out pauseEvent);

                    if (isSuccess)
                    {
                        isSuccess = scApp.VehicleService.Send.Pause(vh_id, pauseEvent, pause_type);
                        if (isSuccess)
                        {
                            result = "OK";
                        }
                        else
                        {
                            result = $"Send pause request to vehicle:{vh_id} failed.";
                        }
                    }
                    else
                    {
                        result = $"Can't recognize Pause Event:{event_type}.";
                    }
                }
                else
                {
                    result = $"Can't recognize Pause Type:{pauseType}.";
                }

                var response = (Response)result;
                response.ContentType = restfulContentType;
                return(response);
            };

            Post["AVEHICLES/ModeStatusChange"] = (p) =>
            {
                string        result      = string.Empty;
                bool          isSuccess   = false;
                SCApplication scApp       = SCApplication.getInstance();
                string        vh_id       = Request.Query.vh_id.Value ?? Request.Form.vh_id.Value ?? string.Empty;
                string        modeStatus  = Request.Query.modeStatus.Value ?? Request.Form.modeStatus.Value ?? string.Empty;
                VHModeStatus  mode_status = default(VHModeStatus);
                isSuccess = Enum.TryParse(modeStatus, out mode_status);
                try
                {
                    if (isSuccess)
                    {
                        scApp.VehicleBLL.cache.updataVehicleMode(vh_id, mode_status);
                        result = "OK";
                    }
                    else
                    {
                        result = $"Can't recognize mode status:{modeStatus}.";
                    }
                }
                catch (Exception ex)
                {
                    result = $"Update vehicle:{vh_id} mode status failed.";
                    logger.Error(ex, "Exception");
                }
                var response = (Response)result;
                response.ContentType = restfulContentType;
                return(response);
            };

            Post["AVEHICLES/ResetAlarm"] = (p) =>
            {
                var    scApp     = SCApplication.getInstance();
                string result    = string.Empty;
                bool   isSuccess = true;
                string vh_id     = Request.Query.vh_id.Value ?? Request.Form.vh_id.Value ?? string.Empty;
                try
                {
                    isSuccess = scApp.VehicleService.Send.AlarmReset(vh_id);
                    if (isSuccess)
                    {
                        result = "OK";
                    }
                    else
                    {
                        result = "Reset alarm failed.";
                    }
                }
                catch (Exception ex)
                {
                    result = "Reset alarm failedwith exception happened.";
                }

                var response = (Response)result;
                response.ContentType = restfulContentType;
                return(response);
            };

            Post["Engineer/ForceCmdFinish"] = (p) =>
            {
                var    scApp     = SCApplication.getInstance();
                string vh_id     = Request.Query.vh_id.Value ?? Request.Form.vh_id.Value ?? string.Empty;
                bool   isSuccess = scApp.CMDBLL.forceUpdataCmdStatus2FnishByVhID(vh_id);
                if (isSuccess)
                {
                    var vh = scApp.VehicleBLL.cache.getVehicle(vh_id);
                    //vh.NotifyVhExcuteCMDStatusChange();
                    vh.onExcuteCommandStatusChange();
                }
                var response = (Response)(isSuccess ? "OK" : "NG");
                response.ContentType = restfulContentType;
                return(response);
            };
        }