/// <summary>
        /// 保存模板事件
        /// </summary>
        /// <param name="obj"></param>
        private void saveFlowTemplateBtnClicked(object obj)
        {
            int result = 0;

            if (obj == null)
            {
                result = -3;
            }
            else if (string.IsNullOrEmpty(obj.ToString()))
            {
                result = -3;
            }
            else if (string.IsNullOrEmpty(obj.ToString().Trim()))
            {
                result = -3;
            }
            else if (!ManagerPlant.flowManager.IsExistFlow())
            {
                result = -4;
            }
            if (result == -3)
            {
                //保存失败
                WindowTip windowTip = new WindowTip("请输入模板名后重试!");
                windowTip.ShowDialog();
                return;
            }
            if (result == -4)
            {
                //无流程可存
                WindowTip windowTip = new WindowTip("请添加流程后再新建!");
                windowTip.ShowDialog();
                return;
            }
            //写入到模板配置文件中
            result = ManagerPlant.flowManager.SaveTemplate(obj.ToString());
            if (result == 0)
            {
                //保存成功
                WindowTip windowTip = new WindowTip("新建成功!");
                windowTip.ShowDialog();
                //更新模板数据
                ((PageFlowViewModel)Model).UpdateTemplate();
            }
            else if (result == -1)
            {
                //已存在该名称
                WindowTip windowTip = new WindowTip("该名称模板已存在,请修改名称后重试!");
                windowTip.ShowDialog();
            }
            else if (result == -2)
            {
                //保存失败
                WindowTip windowTip = new WindowTip("新建失败!");
                windowTip.ShowDialog();
            }
        }
 private void startBtnClicked(object obj)
 {
     if (!ManagerPlant.flowManager.IsExistFlow())
     {
         WindowTip windowTip = new WindowTip("请添加流程后再开始运行测试!");
         windowTip.ShowDialog();
         return;
     }
     //打开调试加液位置界面
     ((WindowStartViewModel)Application.Current.MainWindow.DataContext).m_UIController.PageSourceCommand_Executed("PageDebugPos");
 }
        private void yuReBtnClick(object obj)
        {
            XmlDocument doc = new XmlDocument();

            doc.Load("Config/LayoutConfig.xml");
            XmlElement ele = doc.SelectSingleNode("LayoutPanel/YuRe") as XmlElement;

            if (ele == null)
            {
                WindowTip windowTip = new WindowTip("无法找到预热次数配置节点!");
                windowTip.ShowDialog();
                return;
            }

            string eleCountStr = ele.GetAttribute("Count");

            if (string.IsNullOrEmpty(eleCountStr))
            {
                WindowTip windowTip = new WindowTip("无法找到预热次数属性配置!");
                windowTip.ShowDialog();
                return;
            }
            int  eleCountInt = 0;
            bool tryResult   = Int32.TryParse(eleCountStr, out eleCountInt);

            if (!tryResult)
            {
                WindowTip windowTip = new WindowTip("请确认预热次数属性配置!");
                windowTip.ShowDialog();
                return;
            }

            ((PageAiKangViewModel)Model).YuReNum = "0";
            yuReThread = new Thread(() =>
            {
                for (int i = 0; i < eleCountInt;)
                {
                    ManagerPlant.sendDataManager.YuRe();
                    i++;
                    ((PageAiKangViewModel)Model).YuReNum = i.ToString();
                }
                App.Current.Dispatcher.Invoke((Action)(() =>
                {
                    WindowTip windowTip = new WindowTip("预热完成!");
                    windowTip.ShowDialog();
                }));
            });
            yuReThread.Start();
        }
        //连接爱康事件
        private void aiKangConnectBtnClicked(object obj)
        {
            bool connectResult = ManagerPlant.aiKangManager.Init(this);

            if (!connectResult)
            {
                WindowTip windowTip = new WindowTip("爱康平台连接失败,请检查后再尝试!");
                windowTip.ShowDialog();
            }
            else
            {
                WindowTip windowTip = new WindowTip("爱康平台连接成功!");
                windowTip.ShowDialog();
                //提示串口通信成功
                ((PageAiKangViewModel)Model).NextBtnVisibility = Visibility.Visible;
                ((PageAiKangViewModel)Model).YuReBtnVisibility = Visibility.Visible;
            }
        }
Exemplo n.º 5
0
        //连接串口事件
        private void balanceConnectBtnClicked(object obj)
        {
            SerialNum sn            = new SerialNum();
            bool      connectResult = ManagerPlant.serialPortManager.Connect();

            if (!connectResult)
            {
                //提示串口通信失败
                WindowTip windowTip = new WindowTip("天平串口连接失败,请检查后再尝试!");
                windowTip.ShowDialog();
            }
            else
            {
                ManagerPlant.serialPortManager.SendGetSerialNum(sn);
                Thread.Sleep(3000);
                if (!string.IsNullOrEmpty(sn.Num))
                {
                    //I4VAV"<SNR>"
                    if (sn.Num.Contains("I4"))
                    {
                        WindowTip windowTip = new WindowTip("天平串口连接成功!");
                        windowTip.ShowDialog();
                        //提示串口通信成功
                        ((PageBalanceExamineViewModel)Model).NextBtnVisibility = System.Windows.Visibility.Visible;
                    }
                    else
                    {
                        //提示串口通信失败
                        WindowTip windowTip = new WindowTip("天平串口验证传输失败,请检查后再尝试!");
                        windowTip.ShowDialog();
                    }
                }
                else
                {
                    //提示串口通信失败
                    WindowTip windowTip = new WindowTip("天平串口验证传输失败(超时),请检查后再尝试!");
                    windowTip.ShowDialog();
                }
            }
            sn.reset();
        }
        /// <summary>
        /// 保存模板
        /// </summary>
        /// <param name="obj"></param>
        private void saveTemplateBtnClick(object obj)
        {
            int result = 0;

            if (!ManagerPlant.flowManager.IsExistFlow())
            {
                WindowTip windowTip = new WindowTip("请先添加流程!");
                windowTip.ShowDialog();
                return;
            }
            //写入到模板配置文件中
            result = ManagerPlant.flowManager.UpdateTemplate();
            if (result == 0)
            {
                //保存成功
                WindowTip windowTip = new WindowTip("保存成功!");
                windowTip.ShowDialog();
                //更新模板数据
                ((PageFlowViewModel)Model).UpdateTemplate();
            }
            else if (result == -1)
            {
                //已存在该名称
                WindowTip windowTip = new WindowTip("该名称模板不存在!");
                windowTip.ShowDialog();
            }
            else if (result == -2)
            {
                //保存失败
                WindowTip windowTip = new WindowTip("保存失败!");
                windowTip.ShowDialog();
            }
            else if (result == -3)
            {
                //保存失败
                WindowTip windowTip = new WindowTip("不是模板流程,不能更新模板数据!");
                windowTip.ShowDialog();
            }
        }
        private void exportReportBtnClicked(object obj)
        {
            string folderPath = "";

            System.Windows.Forms.FolderBrowserDialog fbd = new System.Windows.Forms.FolderBrowserDialog();
            fbd.ShowDialog();
            if (!string.IsNullOrEmpty(fbd.SelectedPath))
            {
                folderPath = fbd.SelectedPath;
                if (string.IsNullOrEmpty(folderPath))
                {
                    MessageBox.Show("请正确选择需要保存到的目录!");
                    return;
                }
                List <DataModel> list = ((WindowMainViewModel)Model).SelectDataModelDict.Values.ToList();
                if (list.Count <= 0)
                {
                    MessageBox.Show("请正确选择需要打印报告的病人!");
                    return;
                }
                int counts = list.Count;
                int count  = 0;

                if (counts > 0)
                {
                    new Thread(() =>
                    {
                        foreach (DataModel dataTemp in list)
                        {
                            List <ProjectModel> projectModels = new List <ProjectModel>();
                            projectModels.AddRange(dataTemp.PList);
                            string date = "";
                            //创建word文档
                            while (dataTemp.PList.Count > 0)
                            {
                                DateTime dt         = DateTime.Now;
                                date                = dt.ToString("yyyy年MM月dd日HH时mm分ss秒");
                                string dateStr      = dt.ToString("yyyy-MM-dd HH:mm:ss");
                                dataTemp.ReportTime = dateStr;
                                WordUtil.CreateDocByTemplate(dataTemp, folderPath, date);
                                //Console.WriteLine(folderPath + "\\" + dataTemp.HospitalName + "\\" + dataTemp.PatientName + "_" + date + ".docx"+"  打印前" +DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss fff"));
                                //调用打印机打印
                                Thread.Sleep(3000);
                                PrintManager.Instance.Printword(folderPath + "\\" + dataTemp.HospitalName + "\\" + dataTemp.PatientName + "_" + date + ".docx");

                                //Console.WriteLine(folderPath + "\\" + dataTemp.HospitalName + "\\" + dataTemp.PatientName + "_" + date + ".docx" + "  打印后" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss fff"));
                            }
                            count++;
                            if (WindowTip.Instance != null)
                            {
                                WindowTip.Instance.model.UpdateValue(count, folderPath + "\\" + dataTemp.HospitalName + "\\" + dataTemp.PatientName + "_" + date + ".docx");
                            }
                            dataTemp.PList.AddRange(projectModels);
                        }

                        if (WindowTip.Instance != null)
                        {
                            App.Current.Dispatcher.Invoke((Action)(() =>
                            {
                                WindowTip.Instance.model.Vis = Visibility.Visible;
                                WindowTip.Instance.model.Message = "打印完成!";
                            }));
                        }
                    }).Start();
                    WindowTip wt = new WindowTip(counts);
                    wt.Owner = Application.Current.MainWindow;
                    wt.ShowDialog();
                }
                else
                {
                    MessageBox.Show("请添加数据后,在生成报告!");
                }
            }
        }