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); }
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); //失败 } }