|
@@ -2,6 +2,7 @@
|
|
|
using SCADA.CommonLib;
|
|
|
using SCADA.CommonLib.Data.DIL;
|
|
|
using SCADA.CommonLib.Helper;
|
|
|
+using SCADA.Instrument.AIP;
|
|
|
using SysManage.User;
|
|
|
using System;
|
|
|
using System.Collections.ObjectModel;
|
|
@@ -19,34 +20,8 @@ namespace SCADA_DAQ
|
|
|
|
|
|
public static Schedual Schedual { get; internal set; } = Schedual.Instance;
|
|
|
|
|
|
- //public static readonly ConcurrentDictionary<string, BaseComm> CommResource = new ConcurrentDictionary<string, BaseComm>();
|
|
|
-
|
|
|
- public static DateTime StartTime { get; set; }
|
|
|
-
|
|
|
- public static int StartTick { get; internal set; }
|
|
|
-
|
|
|
- public static AutoSaveParameterItem<string> ProductName;
|
|
|
-
|
|
|
- public static AutoSaveParameterItem<string> CompanyName;
|
|
|
-
|
|
|
- public static AutoSaveParameterItem<string> MainDllName;
|
|
|
-
|
|
|
- public static AutoSaveParameterItem<string> DefaultUserName;
|
|
|
-
|
|
|
- public static AutoSaveParameterItem<string> WebServerAddress = AutoSaveParameterItem.Create("App.WebServer", "www.skdscada.com");
|
|
|
-
|
|
|
public static AutoSaveParameterItem<bool> DataBaseNeedRest { get; set; } = AutoSaveParameterItem.Create("App.DatabaseNeedRest", false);
|
|
|
|
|
|
- public static AutoSaveParameterItem<string> ComputerTag;
|
|
|
-
|
|
|
- public static AutoSaveParameterItem<int> RESTfulPort;
|
|
|
-
|
|
|
- public static AutoSaveParameterItem<int> RPCPort;
|
|
|
-
|
|
|
- public static AutoSaveParameterItem<bool> SingleModel;
|
|
|
-
|
|
|
- public static AutoSaveParameterItem<SCADA.CommonLib.LoggerHelper.LogLevel> LogLevel;
|
|
|
-
|
|
|
public static DataBaseConfig CurrentDbConfig { get; set; }
|
|
|
|
|
|
public static AutoSaveParameterItem<DatabaseSelector> CurrentDataBase { get; set; }
|
|
@@ -66,46 +41,8 @@ namespace SCADA_DAQ
|
|
|
/// </summary>
|
|
|
public static AutoSaveParameterItem<string> DeviceConfigFilePath;
|
|
|
|
|
|
- public static void ParameterInit()
|
|
|
+ public static void ParameterInit(IApp app)
|
|
|
{
|
|
|
- ProductName = AutoSaveParameterItem.Create("App.ProductName", "", true);
|
|
|
- ProductName.DisplayName = "产品名称";
|
|
|
-
|
|
|
-
|
|
|
- CompanyName = AutoSaveParameterItem.Create("App.ProductName", "", true);
|
|
|
- CompanyName.DisplayName = "公司名称";
|
|
|
-
|
|
|
-
|
|
|
- MainDllName = AutoSaveParameterItem.Create("App.MainDllname", "", true);
|
|
|
- {
|
|
|
- MainDllName.DisplayName = "主dll名称";
|
|
|
- };
|
|
|
-
|
|
|
- DefaultUserName = AutoSaveParameterItem.Create("App.DefualtUserName", "", true);
|
|
|
- DefaultUserName.DisplayName = "默认用户";
|
|
|
-
|
|
|
-
|
|
|
- ComputerTag = AutoSaveParameterItem.Create("App.ComputerTag", "", true);
|
|
|
- ComputerTag.DisplayName = "电脑标签";
|
|
|
- ComputerTag.IsReadOnly = true;
|
|
|
-
|
|
|
-
|
|
|
- RESTfulPort = AutoSaveParameterItem.Create("App.RESTfulPort", 7888);
|
|
|
- RESTfulPort.DisplayName = "网页端口";
|
|
|
-
|
|
|
- RPCPort = AutoSaveParameterItem.Create("App.RPCPort", 7880);
|
|
|
- RPCPort.DisplayName = "本地RPC端口";
|
|
|
-
|
|
|
-
|
|
|
- SingleModel = AutoSaveParameterItem.Create("App.SingleModel", true);
|
|
|
- SingleModel.DisplayName = "单例模式";
|
|
|
-
|
|
|
- LogLevel = AutoSaveParameterItem.Create("App.LogLevel", SCADA.CommonLib.LoggerHelper.LogLevel.All);
|
|
|
- LogLevel.DisplayName = "日志级别";
|
|
|
-
|
|
|
- DeviceConfigFilePath = AutoSaveParameterItem.Create("DeviceConfigFilePath", "DeviceCfg.Json");
|
|
|
- DeviceConfigFilePath.DisplayName = "设备配置文件";
|
|
|
-
|
|
|
CurrentDataBase = AutoSaveParameterItem.Create("App.DataBaseConfig", new DatabaseSelector()
|
|
|
{ CurrentDataBaseConfig = "Default" });
|
|
|
|
|
@@ -161,7 +98,6 @@ namespace SCADA_DAQ
|
|
|
if (dataBaseConfig.DBType == DatabaseType.Sqlite) //如果是sqlite数据库就检查数据库的状态
|
|
|
{
|
|
|
string dbInfo = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, dataBaseConfig.FilePath);
|
|
|
- //string dbInfo = Path.GetFullPath(dataBaseConfig.FilePath);
|
|
|
dilDb = (BaseDB)Activator.CreateInstance(dbType, Path.GetDirectoryName(dbInfo), Path.GetFileName(dataBaseConfig.FilePath),
|
|
|
dataBaseConfig.UserName,
|
|
|
dataBaseConfig.Password);
|
|
@@ -178,9 +114,9 @@ namespace SCADA_DAQ
|
|
|
dbInit(AlarmDBConfig, typeof(DILDB), out BaseDB alarmDB);
|
|
|
|
|
|
DAL = (DILDB)currentDB;
|
|
|
- GlobalEnv.Instance.GlobalDB = currentDB;
|
|
|
- GlobalEnv.Instance.AlarmDB = alarmDB;
|
|
|
- GlobalEnv.Instance.LocalAppDB = sysDB;
|
|
|
+ app.RuntimeInfo.GlobalDB = currentDB;
|
|
|
+ app.RuntimeInfo.AlarmDB = alarmDB;
|
|
|
+ app.RuntimeInfo.LocalAppDB = sysDB;
|
|
|
NewUser = new User(DAL)
|
|
|
{
|
|
|
UserName = "Admin",
|
|
@@ -188,8 +124,7 @@ namespace SCADA_DAQ
|
|
|
}
|
|
|
static Env()
|
|
|
{
|
|
|
- //XmlUserConfig.Create();
|
|
|
- //ParameterInit();
|
|
|
+
|
|
|
}
|
|
|
|
|
|
private static void CheckDataBase(BaseDB db, string databasepath, bool dataBaseNeedRest)
|
|
@@ -206,16 +141,16 @@ namespace SCADA_DAQ
|
|
|
{
|
|
|
if (File.Exists(databasepath))
|
|
|
{
|
|
|
- object dt = db.ExecuteScalar("PRAGMA integrity_check");
|
|
|
- if ($"{dt}".ToUpper() == "OK")
|
|
|
- {
|
|
|
- System.Diagnostics.Debug.WriteLine($"{databasepath} 数据库检测正常");
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- System.Diagnostics.Trace.TraceWarning($"检测到本地数据库已损坏,开始重置数据库");
|
|
|
- _ = ReleseDatabase();
|
|
|
- }
|
|
|
+ //object dt = db.ExecuteScalar("PRAGMA integrity_check");
|
|
|
+ //if ($"{dt}".ToUpper() == "OK")
|
|
|
+ //{
|
|
|
+ // System.Diagnostics.Debug.WriteLine($"{databasepath} 数据库检测正常");
|
|
|
+ //}
|
|
|
+ //else
|
|
|
+ //{
|
|
|
+ // System.Diagnostics.Trace.TraceWarning($"检测到本地数据库已损坏,开始重置数据库");
|
|
|
+ // _ = ReleseDatabase();
|
|
|
+ //}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -238,9 +173,9 @@ namespace SCADA_DAQ
|
|
|
{
|
|
|
res = new MemoryStream(LocalResource.LocalApp);
|
|
|
}
|
|
|
- else if (Path.GetFileName(databasepath).ToUpper() == "QWPLATFORM.DB")
|
|
|
+ else if (Path.GetFileName(databasepath).ToUpper() == "PLATFORM.DB")
|
|
|
{
|
|
|
- res = new MemoryStream(LocalResource.QwPlatform);
|
|
|
+ res = new MemoryStream(LocalResource.Platform);
|
|
|
}
|
|
|
if (res == null) return true;
|
|
|
using (res)
|