Beispiel #1
0
        private bool GetReport()
        {
            bool rtn = false;
            //string reportFile = System.Windows.Forms.Application.StartupPath + "/report.xlsm";
            //string sourceFile = System.Windows.Forms.Application.StartupPath + "/clarity.xls";
            string   reportFile = "c:/clasp32/data" + "/test.xlsm";
            string   sourceFile = "c:/clasp32/data" + "/clarity.xls";
            string   dataFile   = System.Windows.Forms.Application.StartupPath + "/data.xml";
            string   testFile   = ConfigurationManager.AppSettings["sourceAddress"];
            FileInfo fileInfo   = new FileInfo(testFile);

            if (File.Exists(testFile))
            {
                //SysVar.dtOld = SysVar.dtNow;
                DataProcess dp = new DataProcess(reportFile, sourceFile, testFile, dataFile);
                rtn = dp.uploadInfo(0, "", Patient.w_deviceCode);
            }
            else
            {
                rtn = false;
                // XtraMessageBox.Show("测试数据没有生成,请重新测试,如果还是不成功请联系管理员!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                LogHelper.WriteLog("测试数据没有生成,请重新测试,如果还是不成功请联系管理员!");
            }
            return(rtn);
        }
Beispiel #2
0
 private void DoTherapy()
 {
     try
     {
         bool start = false;
         Task.Factory.StartNew(() =>
         {
             if (startClasp())
             {
                 start = true;
                 Thread.Sleep(500);
                 this.BeginInvoke(updateTxt, "启动并校验检测仪。。。。");
                 th.TestLaunch(true);
                 Thread.Sleep(15000);
                 th.CloseBandTest();
                 Thread.Sleep(3000);
             }
         }).ContinueWith(x =>
         {
             if (start)
             {
                 th.TestToStart();
                 DataProcess dp = new DataProcess();
                 int rtn        = dp.setUsed(Patient.w_code);
                 LogHelper.WriteLog(Patient.w_deviceSN + "-" + Patient.w_code + "执行结果为" + rtn);
                 if (operatorStatus == 4)
                 {
                     this.BeginInvoke(updateTxt, "校验结束,可以开始调理。。。。");
                 }
             }
             else
             {
                 updateStatus("-1");
                 disconnectDevice();
             }
         });
     }
     catch (Exception ex)
     {
         string haha = ex.ToString();
         LogHelper.WriteLog(haha);
         //XtraMessageBox.Show(ex.ToString(), "错误");
         this.BeginInvoke(updateTxt, ex.ToString());
     }
 }
Beispiel #3
0
        private void connectRemoteDevice()
        {
            string result = "";
            string cmd    = @"usbrcd.exe -connect " + usbPort;

            CmdHelper.RunCmd(cmd, out result);
            List <string> msgList = GetResult(result);

            if (msgList[0] == "USB device connected")
            {
                operatorStatus             = 3;
                this.btnConnect.Enabled    = false;
                this.btnDisconnect.Enabled = true;
                this.BeginInvoke(updateTxt, "远程设备连接成功。。。。");
                checkCOM(Patient.w_deviceSN);
                DataProcess dp        = new DataProcess();
                int         orderType = dp.getTL(Patient.w_code);
                startTest(orderType);  //1检测,2理疗
            }
            else
            {
                LogHelper.WriteLog(usbPort + "----" + msgList[0]);
            }
        }
Beispiel #4
0
        private int SourceProcess(FileInfo file)
        {
            string filename = file.Name;

            string[] fileDetail = filename.Split('.');
            string   verifyCode = "";
            string   userName   = "";
            string   deviceCode = "";

            if (fileDetail.Length == 4)
            {
                verifyCode = fileDetail[0];
                userName   = fileDetail[1];
                deviceCode = fileDetail[2];
                string fileType = fileDetail[3];
                //文件有问题,删除文件
                if (fileType != "bak")
                {
                    File.Delete(file.FullName);
                    return(-1);
                }
                DataProcess dpN = new DataProcess();
                string      msg = dpN.validCode(verifyCode, userName, deviceCode);
                //校验码有问题,删除文件
                if (msg.Length > 0)
                {
                    if (msg != "验证时出错")
                    {
                        File.Delete(file.FullName);
                    }
                    return(-1);
                }
            }
            else
            {
                File.Delete(file.FullName);
                return(-1); //文件有问题
            }

            //开始处理文件
            string testFile = System.Windows.Forms.Application.StartupPath + "/WaitedSource/clarity.xls";

            if (File.Exists(testFile))
            {
                File.Delete(testFile);
            }
            string tempSource = file.FullName;

            copyStream(testFile, tempSource);

            string      reportFile = "c:/clasp32/data" + "/test.xlsm";
            string      sourceFile = "c:/clasp32/data" + "/clarity.xls";
            string      dataFile   = System.Windows.Forms.Application.StartupPath + "/data.xml";
            DataProcess dp         = new DataProcess(reportFile, sourceFile, testFile, dataFile);
            bool        rtn        = dp.uploadInfo(1, verifyCode, deviceCode);

            if (File.Exists(testFile))
            {
                File.Delete(testFile);
            }
            if (rtn)
            {
                File.Delete(file.FullName);
                return(1); //成功
            }
            else
            {
                return(0); //失败
            }
        }