136 lines
4.9 KiB
C#
136 lines
4.9 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.ComponentModel;
|
||
using System.Data;
|
||
using System.Drawing;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using System.Windows.Forms;
|
||
using EAS.Services;
|
||
using EAS;
|
||
using SOH.BLL;
|
||
using SOH.Entities;
|
||
using SOH.Kernel;
|
||
using SOH.Window;
|
||
using ICSharpCode.SharpZipLib;
|
||
using System.IO;
|
||
using System.Reflection;
|
||
|
||
namespace SOH.JianYan
|
||
{
|
||
[ModuleAttribute(ModuleID = "237D8268-C33F-41F4-96F6-D5725A74CC7B", ModuleName = "仪器管理")]
|
||
public partial class frmYiQiAnZhuang : baseChildForm
|
||
{
|
||
public frmYiQiAnZhuang()
|
||
{
|
||
InitializeComponent();
|
||
}
|
||
|
||
private void btn_add_Click(object sender, EventArgs e)
|
||
{
|
||
if (ofd_db.ShowDialog() == DialogResult.OK)
|
||
{
|
||
string filepath = ofd_db.FileName;
|
||
string jypath = Path.GetTempPath();
|
||
jypath += Guid.NewGuid().ToString("N");
|
||
Directory.CreateDirectory(jypath);
|
||
try
|
||
{
|
||
if (!ZipHelper.UnZip(filepath, jypath, "69c64c33"))
|
||
{
|
||
MessageBox.Show("LIS仪器安装包不正确!");
|
||
return;
|
||
}
|
||
string[] paths= Directory.GetDirectories(jypath);
|
||
if(paths.Length==0)
|
||
{
|
||
MessageBox.Show("LIS仪器安装包不正确!");
|
||
return;
|
||
}
|
||
string lisfoder = paths[0];
|
||
string[] lisfiles = Directory.GetFiles(lisfoder);
|
||
var lisdecs = lisfiles.Where(t => t.Replace(lisfoder + "\\", "").StartsWith("SOH.JianYan.DEC") && t.EndsWith(".exe")).ToArray();
|
||
if (lisdecs.Length > 1)
|
||
{
|
||
MessageBox.Show("LIS仪器安装包不正确!");
|
||
return;
|
||
}
|
||
else if (lisdecs.Length == 0)
|
||
{
|
||
MessageBox.Show("LIS仪器安装包不正确!");
|
||
return;
|
||
}
|
||
var lisdecfile = lisdecs[0];
|
||
try
|
||
{
|
||
var dectype = Assembly.LoadFrom(lisdecfile);
|
||
var jyattrs = dectype.GetCustomAttributes(typeof(JianYanAttribute), false);
|
||
if (jyattrs.Count() == 0)
|
||
{
|
||
MessageBox.Show("LIS仪器安装包不正确!");
|
||
return;
|
||
}
|
||
JianYanAttribute jyattr = jyattrs[0] as JianYanAttribute;
|
||
|
||
string yq = jyattr.YQ;
|
||
string yqmc = jyattr.YQMC;
|
||
int jylx = jyattr.YQDL;
|
||
string asstyep = jyattr.YQType;
|
||
string filename = new FileInfo(lisdecfile).Name;
|
||
jyattr = null;
|
||
dectype = null;
|
||
jyattrs = null;
|
||
GC.Collect();
|
||
GC.Collect(1);
|
||
frm_YiQiAdd add = new frm_YiQiAdd();
|
||
add.init(yq,yqmc,lisfoder,filename,jylx,asstyep);
|
||
|
||
if (add.ShowDialog() == DialogResult.OK)
|
||
{
|
||
frmYiQiAnZhuang_Load(null, null);
|
||
}
|
||
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MessageBox.Show("LIS仪器安装包不正确!");
|
||
return;
|
||
}
|
||
}
|
||
catch
|
||
{
|
||
MessageBox.Show("LIS仪器安装包不正确!");
|
||
}
|
||
}
|
||
}
|
||
|
||
private void frmYiQiAnZhuang_Load(object sender, EventArgs e)
|
||
{
|
||
string pcname = System.Net.Dns.GetHostName();
|
||
var vser = ServiceContainer.GetService<IJianYan>();
|
||
var yqs = vser.getYQ();
|
||
jyyiqiBindingSource.DataSource = yqs;
|
||
}
|
||
|
||
private void btn_jy_Click(object sender, EventArgs e)
|
||
{
|
||
if(dgv_yiqi.SelectedRows.Count==0)
|
||
{
|
||
MessageBox.Show("请选择要禁用的仪器!");
|
||
return;
|
||
}
|
||
if(MessageBox.Show("你确定要禁用你选择的仪器吗?","提示",MessageBoxButtons.YesNo,MessageBoxIcon.Asterisk)==DialogResult.Yes)
|
||
{
|
||
var vser = ServiceContainer.GetService<IJianYan>();
|
||
jy_yiqi yq = dgv_yiqi.SelectedRows[0].DataBoundItem as jy_yiqi;
|
||
SOH.Data.OperationResult or = vser.yiqizhuxiao(yq.yq);
|
||
MessageBox.Show(or.Message);
|
||
if(or.State==1)
|
||
{
|
||
frmYiQiAnZhuang_Load(null, null);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|