|
|
@@ -7,6 +7,7 @@ using System.Text.RegularExpressions;
|
|
7
|
7
|
using System.Net;
|
|
8
|
8
|
using System.IO;
|
|
9
|
9
|
using System.Collections.Generic;
|
|
|
10
|
+using System.Net.NetworkInformation;
|
|
10
|
11
|
|
|
11
|
12
|
namespace CallCenterApi.Common
|
|
12
|
13
|
{
|
|
|
@@ -273,6 +274,11 @@ namespace CallCenterApi.Common
|
|
273
|
274
|
}
|
|
274
|
275
|
}
|
|
275
|
276
|
|
|
|
277
|
+ /// <summary>
|
|
|
278
|
+ /// 网络文件是否存在
|
|
|
279
|
+ /// </summary>
|
|
|
280
|
+ /// <param name="url"></param>
|
|
|
281
|
+ /// <returns></returns>
|
|
276
|
282
|
public static bool FileIsExist(string url)
|
|
277
|
283
|
{
|
|
278
|
284
|
try
|
|
|
@@ -338,5 +344,29 @@ namespace CallCenterApi.Common
|
|
338
|
344
|
|
|
339
|
345
|
return Params.ToJson();
|
|
340
|
346
|
}
|
|
|
347
|
+
|
|
|
348
|
+ /// <summary>
|
|
|
349
|
+ /// 判断IP是否被占用
|
|
|
350
|
+ /// </summary>
|
|
|
351
|
+ /// <param name="port"></param>
|
|
|
352
|
+ /// <returns></returns>
|
|
|
353
|
+ public static bool PortInUse(int port)
|
|
|
354
|
+ {
|
|
|
355
|
+ bool inUse = false;
|
|
|
356
|
+
|
|
|
357
|
+ IPGlobalProperties ipProperties = IPGlobalProperties.GetIPGlobalProperties();
|
|
|
358
|
+ IPEndPoint[] ipEndPoints = ipProperties.GetActiveTcpListeners();
|
|
|
359
|
+
|
|
|
360
|
+ foreach (IPEndPoint endPoint in ipEndPoints)
|
|
|
361
|
+ {
|
|
|
362
|
+ if (endPoint.Port == port)
|
|
|
363
|
+ {
|
|
|
364
|
+ inUse = true;
|
|
|
365
|
+ break;
|
|
|
366
|
+ }
|
|
|
367
|
+ }
|
|
|
368
|
+
|
|
|
369
|
+ return inUse;
|
|
|
370
|
+ }
|
|
341
|
371
|
}
|
|
342
|
372
|
}
|