| | |
| | | |
| | | public void WriteToCSV(string path) |
| | | { |
| | | try |
| | | Dispatcher.BeginInvoke(new Action(() => |
| | | { |
| | | |
| | | FileInfo fi = new FileInfo(path); |
| | | if (!fi.Directory.Exists) |
| | | try |
| | | { |
| | | fi.Directory.Create(); //文件不存在,创建文件 |
| | | } |
| | | |
| | | using (FileStream fs = new FileStream(path, FileMode.Create, FileAccess.Write)) |
| | | using (StreamWriter sw = new StreamWriter(fs, System.Text.Encoding.UTF8)) |
| | | { |
| | | string title = "项目名称,测试参数,测试值,上限,下限,单位,结果"; |
| | | sw.WriteLine(title); |
| | | |
| | | if (Datasource != null && Datasource.Count > 0) |
| | | FileInfo fi = new FileInfo(path); |
| | | if (!fi.Directory.Exists) |
| | | { |
| | | foreach (var data in Datasource) |
| | | fi.Directory.Create(); //文件不存在,创建文件 |
| | | } |
| | | |
| | | using (FileStream fs = new FileStream(path, FileMode.Create, FileAccess.Write)) |
| | | using (StreamWriter sw = new StreamWriter(fs, System.Text.Encoding.UTF8)) |
| | | { |
| | | string title = "项目名称,测试参数,测试值,上限,下限,单位,结果"; |
| | | sw.WriteLine(title); |
| | | |
| | | if (Datasource != null && Datasource.Count > 0) |
| | | { |
| | | sw.WriteLine($"{data.Name},{data.Step},{data.Value},{data.LimitUp},{data.LimitDown},{data.Unit},{data.Result}"); |
| | | foreach (var data in Datasource) |
| | | { |
| | | sw.WriteLine($"{data.Name},{data.Step},{data.Value},{data.LimitUp},{data.LimitDown},{data.Unit},{data.Result}"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | TsExecution.logger.Error("Write CSV File Failed.", ex); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | TsExecution.logger.Error("Write CSV File Failed.", ex); |
| | | } |
| | | })); |
| | | } |
| | | |
| | | public void ShowPausePanel() |