新增三模块批量删除API+采集地址启用停用+安装测试脚本
parent
bfb9c5a014
commit
b76f1acc55
@ -0,0 +1,43 @@
|
||||
# CNC 采集服务 - 卸载脚本
|
||||
# 需要管理员权限运行
|
||||
# 用法: .\uninstall.ps1
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
$serviceName = "CncCollector"
|
||||
|
||||
Write-Host "================================================" -ForegroundColor Cyan
|
||||
Write-Host " CNC 机床数据采集服务 - 卸载脚本" -ForegroundColor Cyan
|
||||
Write-Host "================================================" -ForegroundColor Cyan
|
||||
|
||||
# 检查管理员权限
|
||||
$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
|
||||
if (-not $isAdmin) {
|
||||
Write-Host "[错误] 请以管理员权限运行此脚本!" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
$svc = Get-Service -Name $serviceName -ErrorAction SilentlyContinue
|
||||
if (-not $svc) {
|
||||
Write-Host "[提示] 服务未安装,无需卸载。" -ForegroundColor Yellow
|
||||
exit 0
|
||||
}
|
||||
|
||||
# 停止服务
|
||||
if ($svc.Status -eq 'Running') {
|
||||
Write-Host "[1/2] 停止服务..." -ForegroundColor Green
|
||||
Stop-Service -Name $serviceName -Force
|
||||
Start-Sleep -Seconds 3
|
||||
}
|
||||
|
||||
# 删除服务
|
||||
Write-Host "[2/2] 删除服务..." -ForegroundColor Green
|
||||
sc.exe delete $serviceName | Out-Null
|
||||
Start-Sleep -Seconds 2
|
||||
|
||||
$check = Get-Service -Name $serviceName -ErrorAction SilentlyContinue
|
||||
if (-not $check) {
|
||||
Write-Host "`n[成功] 服务已卸载。" -ForegroundColor Green
|
||||
Write-Host " 提示: 安装目录 C:\CncCollector 未删除,如需请手动清理。" -ForegroundColor Yellow
|
||||
} else {
|
||||
Write-Host "[错误] 服务删除失败,请手动检查。" -ForegroundColor Red
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace CncModels.Dto
|
||||
{
|
||||
/// <summary>
|
||||
/// 批量删除请求
|
||||
/// </summary>
|
||||
public class BatchDeleteRequest
|
||||
{
|
||||
/// <summary>要删除的ID列表</summary>
|
||||
public List<int> Ids { get; set; }
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue