public override bool TransferFile(string path) { // K1xxx 表示零件层信息 ->QFile // K2xxx 表示参数层信息 ->QCharacteristic // K0xxx 表示测量数据 -> QDataItem QFile qf = new QFile(); qf[1001] = "excel[0][1]"; QCharacteristic qc = new QCharacteristic(); qc[2001] = "k2001"; qf.Charactericstics.Add(qc); QDataItem dataItem = new QDataItem(); dataItem.SetValue("excel[x][y]"); dataItem.date = DateTime.Parse("2018-1-1 15:00:00"); dataItem[0006] = ""; qc.data.Add(dataItem); qf.ToDMode(); qf.SaveToFile("d:\\abcd.dfq"); return(true); }
public bool SaveDFQ(QFile qf, string path) { if (File.Exists(path) && AddTimeToNew) { path = Funs.AppendTimeToFileName(path); } try { if (qf.SaveToFile(path)) { AddSuccessedFile(path); } else { AddFailedFile(path, "保存失败"); return(false); } } catch (Exception e1) { AddFailedFile(path, e1.Message); return(false); } return(true); }
/// <summary> /// 将一个qf保存至outfile. 其中outfile为完整路径。 /// </summary> /// <param name="qf"></param> /// <param name="outfile"></param> /// <returns></returns> public bool SaveDfq(QFile qf, string outfile) { outfile = ProcessOutputFileNameIfRepeated(outfile); string outdir = Path.GetDirectoryName(outfile); if (!Directory.Exists(outdir)) { Directory.CreateDirectory(outdir); } TransLog log = null; try { if (qf.SaveToFile(outfile)) { LastOutputDfqFile = outfile; log = new TransLog(CurrentInFile, outfile, "保存成功", LogType.Success); } else { LastOutputDfqFile = null; log = new TransLog(CurrentInFile, outfile, "保存失败,原因路径不存在,或者没有写入权限。", LogType.Fail); } } catch (Exception ex) { log = new TransLog(CurrentInFile, outfile, "保存失败,原因:" + ex.Message, LogType.Fail); } if (log.LogType != LogType.Success) { LogList.Add(log); } return(log.LogType == LogType.Success); }