监视采集程序

This commit is contained in:
leomon 2023-06-07 18:11:03 +08:00
parent 7c7f753bb8
commit 85131b43d2
8 changed files with 146 additions and 21 deletions

View File

@ -81,6 +81,8 @@ namespace AIMS
PublicMethod.LastOperationSite = list[0];
}
PublicMethod.WriteLog("登录", PersonObj.Id.Value);
PublicMethod.StartCollectorDataProgram();
Hide();
//在这里为编辑器注册
new System.Threading.Thread(Reg).Start();

View File

@ -1379,6 +1379,7 @@ namespace AIMS.OperationAanesthesia
if (LastMonitorDataTime != null && LastMonitorDataTime.Value > dtTime) return;
try
{
PublicMethod.StartCollectorDataProgram();
LastMonitorDataTime = dtTime;
DateTime InsertTime = Convert.ToDateTime(dtTime.ToString("yyyy-MM-dd HH:mm:00.000"));
int date = 0;
@ -1636,6 +1637,8 @@ namespace AIMS.OperationAanesthesia
timerGetTextCollectorData.Tick -= new System.EventHandler(timerGetTextCollectorData_Tick);
timerGetTextCollectorData.Tick += new System.EventHandler(timerGetTextCollectorData_Tick);
timerGetTextCollectorData.Start();
PublicMethod.StartCollectorDataProgram();
}
private void DisposeTimer()

View File

@ -96,6 +96,7 @@
this.plPrint = new System.Windows.Forms.Panel();
this.plRefresh = new System.Windows.Forms.Panel();
this.lblRoom = new System.Windows.Forms.Label();
this.label11 = new System.Windows.Forms.Label();
this.label22 = new System.Windows.Forms.Label();
this.labOperatorName = new System.Windows.Forms.Label();
this.label19 = new System.Windows.Forms.Label();
@ -1083,6 +1084,7 @@
this.panel7.BackColor = System.Drawing.SystemColors.Control;
this.panel7.Controls.Add(this.panel21);
this.panel7.Controls.Add(this.lblRoom);
this.panel7.Controls.Add(this.label11);
this.panel7.Controls.Add(this.label22);
this.panel7.Controls.Add(this.labOperatorName);
this.panel7.Controls.Add(this.label19);
@ -1218,6 +1220,17 @@
this.lblRoom.TabIndex = 9;
this.lblRoom.Text = " ";
//
// label11
//
this.label11.AutoSize = true;
this.label11.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label11.Location = new System.Drawing.Point(448, 8);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(0, 20);
this.label11.TabIndex = 8;
this.toolTip1.SetToolTip(this.label11, "点击重新启动采集程序");
this.label11.Click += new System.EventHandler(this.label11_Click);
//
// label22
//
this.label22.AutoSize = true;
@ -2174,5 +2187,6 @@
private System.Windows.Forms.ComboBox cmbBGType;
private System.Windows.Forms.Panel PanelSave;
private System.Windows.Forms.Panel paneltop;
private System.Windows.Forms.Label label11;
}
}

View File

@ -13,8 +13,10 @@ using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Printing;
using System.IO;
using System.Linq;
using System.Windows.Forms;
@ -1494,8 +1496,10 @@ namespace AIMS.OperationAanesthesia
return;
if (LastMonitorDataTime != null && LastMonitorDataTime.Value.ToString("yyyy-MM-dd HH:mm") == dtTime.ToString("yyyy-MM-dd HH:mm")) return;
if (LastMonitorDataTime != null && LastMonitorDataTime.Value > dtTime) return;
try
{
PublicMethod.StartCollectorDataProgram();
LastMonitorDataTime = dtTime;
DateTime InsertTime = Convert.ToDateTime(dtTime.ToString("yyyy-MM-dd HH:mm:00.000"));
int date = 0;
@ -1612,7 +1616,9 @@ namespace AIMS.OperationAanesthesia
if (((TimeSpan)(DateTime.Now - _record.lastPageBegin)).TotalHours > 24 || NowRoom == null) return;
timerGetCollectorData_Tick();
if (State != AIMSExtension.EditState.BROWSE)
{
ShowMonitorDataToRight();
}
}
catch (Exception)
{
@ -1643,7 +1649,7 @@ namespace AIMS.OperationAanesthesia
{
DeviceCacheData deviceCacheData = lists[0];
NowPhysioData nowPhysioData = JsonConvert.DeserializeObject<NowPhysioData>(deviceCacheData.JsonData);
label11.Text = "最后采集时间:" + deviceCacheData.UpdateTime;
if (nowPhysioData.HR != null && nowPhysioData.HR.ToString() != string.Empty && nowPhysioData.HR.ToString() != "NaN" && nowPhysioData.HR.ToString() != "NULL")
{
double value = Double.Parse(nowPhysioData.HR.ToString());
@ -1691,6 +1697,7 @@ namespace AIMS.OperationAanesthesia
}
else
{
label11.Text = "当前无采集数据";
lblHR.Text = "--";
lblRESP.Text = "--";
lblSpo2.Text = "--";
@ -1753,6 +1760,8 @@ namespace AIMS.OperationAanesthesia
timerGetTextCollectorData.Tick -= new System.EventHandler(timerGetTextCollectorData_Tick);
timerGetTextCollectorData.Tick += new System.EventHandler(timerGetTextCollectorData_Tick);
timerGetTextCollectorData.Start();
PublicMethod.StartCollectorDataProgram();
}
private void DisposeTimer()
@ -2403,6 +2412,8 @@ namespace AIMS.OperationAanesthesia
ClearTimeText();
//关闭采集的服务
DisposeTimer();
label11.Text = "";
lblHR.Text = "--";
lblRESP.Text = "--";
lblSpo2.Text = "--";
@ -2560,5 +2571,14 @@ namespace AIMS.OperationAanesthesia
}
}
#endregion
private void label11_Click(object sender, EventArgs e)
{
DialogResult dialog = MessageBox.Show("是否重启采集程序!", "系统提示", MessageBoxButtons.YesNo);
if (dialog == DialogResult.Yes)
{
PublicMethod.StartCollectorDataProgram(true);
}
}
}
}

View File

@ -1002,6 +1002,7 @@ namespace AIMS.OperationAanesthesia
// return;
//}
PublicMethod.StartCollectorDataProgram();
LastMonitorDataTime = dtTime;
DateTime InsertTime = Convert.ToDateTime(dtTime.ToString("yyyy-MM-dd HH:mm:00.000"));
int date = 0;
@ -1231,6 +1232,8 @@ namespace AIMS.OperationAanesthesia
timerGetTextCollectorData.Tick -= new System.EventHandler(timerGetTextCollectorData_Tick);
timerGetTextCollectorData.Tick += new System.EventHandler(timerGetTextCollectorData_Tick);
timerGetTextCollectorData.Start();
PublicMethod.StartCollectorDataProgram();
}
private void DisposeTimer()

View File

@ -345,7 +345,15 @@ namespace AIMS.OperationAanesthesia
if (isMainOpen == false)
{
frmAnasRecord.ShowDialog();
if (frmAnasRecord.State == AIMSExtension.EditState.BROWSE)
{
frmAnasRecord.Show();
frmAnasRecord.BringToFront();
frmAnasRecord.TopMost = true;
}
else
frmAnasRecord.ShowDialog();
FillDgv();
}
else

View File

@ -22,26 +22,57 @@ namespace AIMS
[STAThread]
static void Main(string[] args)
{
if (PublicMethod.FindProcess("AIMSAutoUpdate"))
{
return;
}
BindExceptionHandler();
/**
*
* 使使
*/
//获得当前登录的Windows用户标示
System.Security.Principal.WindowsIdentity identity = System.Security.Principal.WindowsIdentity.GetCurrent();
//创建Windows用户主题
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
//Process instance = RunningInstance();
//if (instance == null)
//{
UpdateProgram(args);
Task.Factory.StartNew(() => { PreLoad(); });
Application.Run(new FormLogin());
//}
//else
//{
// /*1.2 已经有一个实例在运行*/
// HandleRunningInstance(instance);
//}
System.Security.Principal.WindowsPrincipal principal = new System.Security.Principal.WindowsPrincipal(identity);
//判断当前登录用户是否为管理员
if (principal.IsInRole(System.Security.Principal.WindowsBuiltInRole.Administrator))
{
//如果是管理员,则直接运行
if (PublicMethod.FindProcess("AIMSAutoUpdate"))
{
return;
}
BindExceptionHandler();
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
//Process instance = RunningInstance();
//if (instance == null)
//{
UpdateProgram(args);
Task.Factory.StartNew(() => { PreLoad(); });
Application.Run(new FormLogin());
//}
//else
//{
// /*1.2 已经有一个实例在运行*/
// HandleRunningInstance(instance);
//}
}
else
{
//创建启动对象
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
//设置运行文件
startInfo.FileName = System.Windows.Forms.Application.ExecutablePath;
//设置启动参数
startInfo.Arguments = String.Join(" ", args);
//设置启动动作,确保以管理员身份运行
startInfo.Verb = "runas";
//如果不是管理员则启动UAC
System.Diagnostics.Process.Start(startInfo);
//退出
System.Windows.Forms.Application.Exit();
}
}
static void PreLoad()
{
@ -175,5 +206,6 @@ namespace AIMS
[DllImport("User32.dll")]
private static extern bool SetForegroundWindow(System.IntPtr hWnd);
#endregion
}
}

View File

@ -2,8 +2,10 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Reflection.Emit;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System.Text;
@ -608,5 +610,46 @@ namespace AIMSExtension
//错误
return false;
}
public static void StartCollectorDataProgram(bool isKill = false)
{
try
{
//判断监护仪程序是否存在进程
//没有的话重新启动
//判断文件是否存在
if (isKill == true)
{
System.Diagnostics.Process[] myProcesses = System.Diagnostics.Process.GetProcesses();
foreach (System.Diagnostics.Process myProcess in myProcesses)
{
if (myProcess.ProcessName == "DataCollector2")
{
myProcess.CloseMainWindow();
myProcess.Kill();
myProcess.WaitForExit();
myProcess.Close();
continue;
}
}
}
if (Directory.Exists(@"C:\采集程序"))
{
if (!PublicMethod.FindProcess("DataCollector2"))
{
Process myprocess = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo(@"C:\采集程序\DataCollector.exe");
myprocess.StartInfo = startInfo;
myprocess.StartInfo.UseShellExecute = false;
myprocess.Start();
}
}
}
catch (Exception ex)
{
PublicMethod.WriteLog(ex);
}
}
}
}