Esempio n. 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);

            SysVar.dtNow = DateTime.Parse(fileInfo.LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss"));
            //有最新文件,开始上传数据
            //if (DateTime.Compare(SysVar.dtNow, SysVar.dtOld) > 0)
            if (File.Exists(testFile))
            {
                //SysVar.dtOld = SysVar.dtNow;
                DataProcess dp = new DataProcess(reportFile, sourceFile, testFile, dataFile);
                rtn = dp.uploadInfo(0, "");
            }
            else
            {
                rtn = false;
                // XtraMessageBox.Show("测试数据没有生成,请重新测试,如果还是不成功请联系管理员!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                LogHelper.WriteLog("测试数据没有生成,请重新测试,如果还是不成功请联系管理员!");
            }
            return(rtn);
        }
Esempio n. 2
0
        private int SourceProcess(FileInfo file)
        {
            string filename = file.Name;

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

            if (fileDetail.Length == 2)
            {
                verifyCode = fileDetail[0];
                string fileType = fileDetail[1];
                //文件有问题,删除文件
                if (fileType != "bak")
                {
                    File.Delete(file.FullName);
                    return(-1);
                }
                DataProcess dpN = new DataProcess();
                string      msg = dpN.validCode(verifyCode);
                //校验码有问题,删除文件
                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);

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