IPCameraHelper.cs
2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using OnlineStore.Common;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration.Install;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Threading.Tasks;
namespace OnlineStore.DeviceLibrary
{
public class IPCameraHelper
{
//"E:\\Codes\\CSharp-Workspace\\MyProject\\WindowsService\\IPCamService\\bin\\Debug\\IPCamService.exe"
static string baseDir = ConfigHelper.Config.Get("IPCamService_HttpServer", "http://localhost:8088");
public static void StartIPCamService()
{
string appFilePath = ConfigHelper.Config.Get("IPCamService_FilePath", @"D:\IPCamera");
if (Directory.Exists(appFilePath))
{
var exe = "IPCamera.exe";
try
{
Process process = new Process();
process.StartInfo = new ProcessStartInfo();
process.StartInfo.FileName = exe;
process.StartInfo.WorkingDirectory = appFilePath;
process.Start();
LogUtil.info($"启动软件:{appFilePath}\\{exe}");
}
catch (Exception ex)
{
LogUtil.error($"启动软件失败:{appFilePath}\\{exe}",ex);
}
}
}
public static void StartRecord(string camName, string fileName = "")
{
Task.Factory.StartNew(delegate
{
string url = $"{baseDir}/cam/startRecord?camName={camName}&filename={fileName}";
string res = HttpHelper.Get(url);
LogUtil.info($"开始记录视频:{fileName},{res}");
});
}
public static void StopRecord(string camName)
{
Task.Factory.StartNew(delegate
{
string url = $"{baseDir}/cam/stopRecord?camName={camName}";
string res = HttpHelper.Get(url);
LogUtil.info($"停止记录视频:{res}");
});
}
}
}