|
@@ -26,17 +26,13 @@ namespace SCADA_DAQ
|
|
|
/// </summary>
|
|
|
bool isShutDown = false;
|
|
|
ILog Log { get; set; } = null;
|
|
|
-
|
|
|
private EventWaitHandle evh;
|
|
|
public App App { get; private set; }
|
|
|
private static SystemControl systemControl;
|
|
|
-
|
|
|
private static readonly object syncObj = new object();
|
|
|
-
|
|
|
private readonly List<AdvanceTimer> Timers = new List<AdvanceTimer>();
|
|
|
private readonly Task initTask;
|
|
|
private readonly Task initServer;
|
|
|
- private ServiceHost host = null;
|
|
|
public string UidVersion { get; }
|
|
|
|
|
|
private string SoftWareId { get; set; }
|
|
@@ -156,9 +152,6 @@ namespace SCADA_DAQ
|
|
|
var st = new Stopwatch();
|
|
|
st.Start();
|
|
|
EicpCoreManage.AppRuntime = App;
|
|
|
- host = ServiceHost.Instance;
|
|
|
- (App as IApp).ServiceHost = host;
|
|
|
- host.Start(App);
|
|
|
try
|
|
|
{
|
|
|
App.RuntimeInfo.StartTime = DateTime.Now;
|
|
@@ -175,11 +168,15 @@ namespace SCADA_DAQ
|
|
|
{ SCADA.CommonLib.LoggerHelper.LogLevel.None,log4net.Core.Level.Off},
|
|
|
};
|
|
|
LogManager.GetRepository().Threshold = logLevel[App.SystemConfig.LogLevel];
|
|
|
- Log.Info($"App {App.RuntimeInfo.ProductId} ({UidVersion}) is starting ……");
|
|
|
+ Log.Info($"App {App.RuntimeInfo.ProductId} ({UidVersion}) [{App.SystemConfig.ComputerTag}] is starting ……");
|
|
|
Task.WaitAll(initServer);
|
|
|
Console.WriteLine($"系统初始化完成 {DateTime.Now:yyyy-MM-dd HH:mm:ss,fff}");
|
|
|
Func<bool> action = null;
|
|
|
LoadLicense();
|
|
|
+ App.RuntimeInfo.ComputerId = App.RuntimeInfo.LicenseInfo.Computer.ComputerId;
|
|
|
+ var host = ServiceHost.Instance;
|
|
|
+ App.ServiceHost = host;
|
|
|
+ host.Start(App);
|
|
|
App.Dispatcher.Invoke(new Action(() =>
|
|
|
{
|
|
|
if (App.MainWindow is MainWindow window)
|
|
@@ -200,7 +197,7 @@ namespace SCADA_DAQ
|
|
|
{
|
|
|
App.RuntimeInfo.LicenseInfo = LicenseManage.GetLicenseInfo(App.RuntimeInfo.ProductId);
|
|
|
}
|
|
|
- App.RuntimeInfo.ComputerId = App.RuntimeInfo.LicenseInfo.Computer.ComputerId;
|
|
|
+
|
|
|
|
|
|
App.Dispatcher.Invoke(new Action(() =>
|
|
|
{
|
|
@@ -277,19 +274,20 @@ namespace SCADA_DAQ
|
|
|
|
|
|
private void ReportAppInfo(bool isOnline = true)
|
|
|
{
|
|
|
- if (App.RuntimeInfo.LicenseInfo != null && (App.RuntimeInfo.LicenseInfo.LicenseType == LicenseType.TempLicense || App.RuntimeInfo.LicenseInfo.LicenseType == LicenseType.Permanentlicense))
|
|
|
+ var license = App.RuntimeInfo.LicenseInfo;
|
|
|
+ if (license != null && (license.LicenseType == LicenseType.TempLicense || license.LicenseType == LicenseType.Permanentlicense))
|
|
|
{
|
|
|
var reportInfo = new
|
|
|
{
|
|
|
SessionID = App.RuntimeInfo.SessionId,
|
|
|
- AppName = App.RuntimeInfo.LicenseInfo?.AppName,
|
|
|
+ AppName = license?.AppName,
|
|
|
Version = UidVersion,
|
|
|
CustomerTag = App.SystemConfig.ComputerTag,
|
|
|
- ComputerId = App.RuntimeInfo.LicenseInfo?.Computer.ComputerId,
|
|
|
- LicenseId = App.RuntimeInfo.LicenseInfo?.LicenseId,
|
|
|
- LicenseType = App.RuntimeInfo.LicenseInfo?.LicenseType.ToString(),
|
|
|
- ActiveTime = App.RuntimeInfo.LicenseInfo?.ActiveTime,
|
|
|
- ExpireDate = App.RuntimeInfo.LicenseInfo?.ActiveTime.AddDays(App.RuntimeInfo.LicenseInfo.ExpireDays),
|
|
|
+ ComputerId = license?.Computer.ComputerId,
|
|
|
+ LicenseId = license?.LicenseId,
|
|
|
+ LicenseType = license?.LicenseType.ToString(),
|
|
|
+ ActiveTime = license?.ActiveTime,
|
|
|
+ ExpireDate = license?.ActiveTime.AddDays(license.ExpireDays),
|
|
|
TotalOutputPcs = Env.TotalOutputPcs.Value,
|
|
|
TotalOutputQty = Env.TotalOutputQty.Value,
|
|
|
IsOnline = isOnline
|
|
@@ -305,18 +303,17 @@ namespace SCADA_DAQ
|
|
|
private void FalatReport(Exception exception)
|
|
|
{
|
|
|
if (isShutDown) return;
|
|
|
- if (App.RuntimeInfo.LicenseInfo != null &&
|
|
|
- (App.RuntimeInfo.LicenseInfo.LicenseType == LicenseType.TempLicense ||
|
|
|
- App.RuntimeInfo.LicenseInfo.LicenseType == LicenseType.Permanentlicense))
|
|
|
+ var license = App.RuntimeInfo.LicenseInfo;
|
|
|
+ if (license != null && (license.LicenseType == LicenseType.TempLicense || license.LicenseType == LicenseType.Permanentlicense))
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
EicpCoreManage.FalatReport(new
|
|
|
{
|
|
|
SessionID = App.RuntimeInfo.SessionId,
|
|
|
- AppName = App.RuntimeInfo.LicenseInfo?.AppName,
|
|
|
+ AppName = license?.AppName,
|
|
|
Version = UidVersion,
|
|
|
- ComputerId = App.RuntimeInfo.LicenseInfo?.Computer?.ComputerId,
|
|
|
+ ComputerId = license?.Computer?.ComputerId,
|
|
|
SoftwareID = SoftWareId,
|
|
|
Customer = System.Windows.Forms.Application.CompanyName,
|
|
|
Message = exception.Message,
|
|
@@ -333,7 +330,7 @@ namespace SCADA_DAQ
|
|
|
}
|
|
|
public bool RestartHost()
|
|
|
{
|
|
|
- return host.Restart();
|
|
|
+ return App.ServiceHost.Restart();
|
|
|
}
|
|
|
|
|
|
private void Application_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
|
|
@@ -344,7 +341,6 @@ namespace SCADA_DAQ
|
|
|
{
|
|
|
FalatReport(e.Exception);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
|
|
@@ -373,7 +369,7 @@ namespace SCADA_DAQ
|
|
|
{"HCNETSDKLib.zip",null },
|
|
|
{"RunTime.zip",null },
|
|
|
{"SyntecLib_v4.zip",null},
|
|
|
- {"FocasLib.zip",AppDomain.CurrentDomain.BaseDirectory },
|
|
|
+ {"Fwlib.zip",AppDomain.CurrentDomain.BaseDirectory },
|
|
|
{"DeviceCfg.zip",null},
|
|
|
{"x86_x64.zip",null },
|
|
|
};
|
|
@@ -416,7 +412,7 @@ namespace SCADA_DAQ
|
|
|
public void ApplicationDispose(int exitCode)
|
|
|
{
|
|
|
isShutDown = true;
|
|
|
- if (host != null) host.Stop();
|
|
|
+ App.ServiceHost?.Stop();
|
|
|
foreach (var item in Timers)
|
|
|
{
|
|
|
item.Dispose();
|