|
@@ -40,6 +40,7 @@ namespace XdCxRhDW
|
|
|
public partial class MainForm : DevExpress.XtraBars.Ribbon.RibbonForm
|
|
|
{
|
|
|
Dictionary<string, Type> ctrlTypes = new Dictionary<string, Type>();
|
|
|
+ string errmsg;
|
|
|
public MainForm()
|
|
|
{
|
|
|
InitializeComponent();
|
|
@@ -61,6 +62,8 @@ namespace XdCxRhDW
|
|
|
ctrlTypes.Add("信号仿真", typeof(SignalEmulation));
|
|
|
ctrlTypes.Add("服务状态", typeof(CtrlSvrs));
|
|
|
ctrlTypes.Add("服务日志", typeof(CtrlSvrLog));
|
|
|
+ DxHelper.WaitHelper.UpdateSplashMessage("正在检查数据库环境...");
|
|
|
+ errmsg = CheckDb();
|
|
|
|
|
|
}
|
|
|
private string text;
|
|
@@ -68,8 +71,9 @@ namespace XdCxRhDW
|
|
|
{
|
|
|
this.text = this.Text;
|
|
|
this.HtmlText = $"<size=12>{this.text}";
|
|
|
- if (!CheckDb())
|
|
|
+ if (!string.IsNullOrWhiteSpace(errmsg))
|
|
|
{
|
|
|
+ MsgBoxHelper.ShowError(errmsg);
|
|
|
Application.Exit();
|
|
|
return;
|
|
|
}
|
|
@@ -116,7 +120,7 @@ namespace XdCxRhDW
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- int interval = 10000;
|
|
|
+ int interval = 30000;
|
|
|
CpuMonitor sys = new CpuMonitor();
|
|
|
const int GB_DIV = 1024 * 1024 * 1024;
|
|
|
while (true)
|
|
@@ -131,24 +135,51 @@ namespace XdCxRhDW
|
|
|
});
|
|
|
|
|
|
}
|
|
|
- private bool CheckDb()
|
|
|
+ private string CheckDb()
|
|
|
{
|
|
|
- RHDWContext db = new RHDWContext();
|
|
|
- string notExistTableName = db.CheckTableExist();
|
|
|
- if (!string.IsNullOrWhiteSpace(notExistTableName))
|
|
|
+ using (RHDWContext db = new RHDWContext())
|
|
|
{
|
|
|
- db.Dispose();
|
|
|
- MsgBoxHelper.ShowError($"Database.db数据库中不存在表{notExistTableName}");
|
|
|
- return false;
|
|
|
+ if (File.Exists(db.DbFile))
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ using (FileStream fs = new FileStream(db.DbFile, FileMode.Open))
|
|
|
+ {
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ return $"数据库文件[{db.DbFile}]可能无法写入,请修改其只读属性";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
- var errmsg = db.CheckTableField();
|
|
|
- if (!string.IsNullOrWhiteSpace(errmsg))
|
|
|
+ using (RHDWLogContext db = new RHDWLogContext())
|
|
|
{
|
|
|
- db.Dispose();
|
|
|
- MsgBoxHelper.ShowError(errmsg);
|
|
|
- return false;
|
|
|
+ if (File.Exists(db.DbFile))
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ using (FileStream fs = new FileStream(db.DbFile, FileMode.Open))
|
|
|
+ {
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ return $"数据库文件[{db.DbFile}]可能无法写入,请修改其只读属性";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ using (RHDWContext db = new RHDWContext())
|
|
|
+ {
|
|
|
+ string notExistTableName = db.CheckTableExist();
|
|
|
+ if (!string.IsNullOrWhiteSpace(notExistTableName))
|
|
|
+ {
|
|
|
+ db.Dispose();
|
|
|
+ return $"Database.db数据库中不存在表{notExistTableName}";
|
|
|
+ }
|
|
|
+ return db.CheckTableField();
|
|
|
}
|
|
|
- return true;
|
|
|
}
|
|
|
private void StartWebApi()
|
|
|
{
|