camstar 服务健康检查和故障自动恢复
新建控制台程序,引用camstar 的InsiteXmlclient
代码如下
class Program
{
static void Main(string[] args)
{
try
{
var sessionId = Guid.NewGuid().ToString("N");
var client = new csiClient();
var connection = client.createConnection("127.0.0.1", 2881);
var session = connection.createSession("CamstarAdmin", "mes++2020", sessionId);
var document = session.createDocument("EmployeeMaint");
var service = document.createService("EmployeeMaint");
var inputData = service.inputData();
inputData.namedObjectField("ObjectToChange").setRef("InsiteAdmin");
inputData.perform("Load");
service.setExecute();
service.requestData().requestField("CompletionMsg");
var reaponsDoc = document.submit();
if (reaponsDoc.checkErrors())
{
Console.WriteLine("验证用户失败");
}
else
{
Console.WriteLine("验证用户成功");
}
}
catch (Exception)
{
StartService();
}
}
static void StartService()
{
Process.Start(new ProcessStartInfo("net")
{
Arguments = "stop \"InSite Server\"",
UseShellExecute = false
});
Process.Start(new ProcessStartInfo("net")
{
Arguments = "start \"InSite Server\"",
UseShellExecute = false
});
}
}
编译生成
复制到服务器上添加计划任务