private void btnExport_Click(object sender, RoutedEventArgs e) { List <Model.TB_StandardInfo> checkedStandList = GetCheckedStand(); if (checkedStandList.Count == 0) { DSJL.Tools.MessageBoxTool.ShowConfirmMsgBox("请选择要导出的测试参考值!"); return; } if (DSJL.Tools.ShowFileDialogTool.ShowSaveFileDialog(out exportPath, "", "dsf", "等速肌力参考值导出") == false) { return; } exportPath = exportPath.Substring(0, exportPath.LastIndexOf("\\") + 1); Console.WriteLine("export path is:{0}", exportPath); ProgressWindow window = new ProgressWindow(); window.WindowTilte = "导出参考值进度"; window.MaxValue = checkedStandList.Count; window.MinValue = 0; window.CancleMessage = "确定取消导出吗?"; window.onCancling += Window_onCancling; window.Owner = this; Task task = new Task(() => { int progress = 0; foreach (var item in checkedStandList) { if (isCancleExport) { break; } //1、查询测试信息 List <Model.TestInfoModel> testInfoModelList = Caches.Util.AthTestInfoModelUtil.AthTestUtil(refeBLL.GetStandTestInfoModelList(item.ID)); if (testInfoModelList.Count == 0) { continue; } Model.TestInfoModel avgTestInfoModel = GetAvgTestInfoModel(testInfoModelList); string testInfoModelJson = Newtonsoft.Json.JsonConvert.SerializeObject(avgTestInfoModel); // Console.WriteLine(testInfoModelJson); //2、计算平均值 List <List <XElement> > paramList = DSJL.Export.GenerateCompareResportXml.ComputeAvg(testInfoModelList); string paramJson = Newtonsoft.Json.JsonConvert.SerializeObject(paramList); // Console.WriteLine(paramJson); Dictionary <DataPointsType, List <List <double> > > dataPointsDict = StandardChartCache.GetStandardDataPoints(item, testInfoModelList); List <List <double> > oddavgsd = dataPointsDict[DataPointsType.ODDAvgSD]; List <List <double> > evenavgsd = dataPointsDict[DataPointsType.EVENAVGSD]; string oddavgsdjson = Newtonsoft.Json.JsonConvert.SerializeObject(oddavgsd); string evenavgsdjson = Newtonsoft.Json.JsonConvert.SerializeObject(evenavgsd); // Console.WriteLine(oddavgsdjson); // Console.WriteLine(evenavgsdjson); //3、写入文件 Model.TB_StandardInfo parentStandModel = standList.Find(x => x.ID == item.Stand_ParentID); Model.ExportStandModel exportStandModel = new Model.ExportStandModel(); exportStandModel.ParentName = parentStandModel.Stand_Name; exportStandModel.StandName = item.Stand_Name; exportStandModel.TestModel = avgTestInfoModel; exportStandModel.ParamList = paramList; exportStandModel.OddAvgSD = oddavgsd; exportStandModel.EvenAvgSD = evenavgsd; string standJson = Newtonsoft.Json.JsonConvert.SerializeObject(exportStandModel); standJson = DSJL.Tools.DES.Encrypt(standJson, "cissdsjl"); string filename = string.Format("{0}{1}.dsf", exportPath, item.Stand_Name); StreamWriter sw = new StreamWriter(filename); sw.Write(standJson); sw.Close(); progress++; Dispatcher.BeginInvoke(new Action(() => { window.CurrentValue = progress; })); } DSJL.Tools.MessageBoxTool.ShowConfirmMsgBox("导出完成!"); Dispatcher.BeginInvoke(new Action(() => { window.Close(); this.Close(); })); }); task.Start(); window.ShowDialog(); }
public void UpdateChart() { chart1.Series.Clear(); chart2.Series.Clear(); if (CurrentStandardInfo == null || modelList == null || modelList?.Count == 0) { return; } Task task = new Task(() => { if (CurrentStandardInfo.Tag == -1)//导入的参考值 { Model.ExportStandModel standModel = Stand.StandConfig.GetStandModel(CurrentStandardInfo.StandFileName); List <List <double> > oddavgsd = standModel.OddAvgSD; List <List <double> > evenavgsd = standModel.EvenAvgSD; DataSeriesCollection oddAvgSDCollection = GetAvgSDSeriseCollection(oddavgsd); DataSeriesCollection evenAvgSDCollection = GetAvgSDSeriseCollection(evenavgsd); Dispatcher.Invoke(new Action(() => { for (int i = 0; i < 5; i++) { var oddItem = oddAvgSDCollection[i]; chart1.Series.Add(oddItem); var evenItem = evenAvgSDCollection[i]; chart2.Series.Add(evenItem); } })); } else { Dictionary <DataPointsType, List <List <double> > > dataDict = null; if (dataPointsDict.Keys.Contains(CurrentStandardInfo.ID)) { dataDict = dataPointsDict[CurrentStandardInfo.ID]; if (dataDict[DataPointsType.ODD].Count != modelList.Count) { dataDict = StandardChartCache.GetStandardDataPoints(CurrentStandardInfo, modelList); dataPointsDict[CurrentStandardInfo.ID] = dataDict; } } else { dataDict = StandardChartCache.GetStandardDataPoints(CurrentStandardInfo, modelList); dataPointsDict.Add(CurrentStandardInfo.ID, dataDict); } if (!oddAvgSDSeriseDict.Keys.Contains(CurrentStandardInfo.ID)) { List <List <double> > oddavgsd = dataDict[DataPointsType.ODDAvgSD]; List <List <double> > evenavgsd = dataDict[DataPointsType.EVENAVGSD]; oddAvgSDSeriseDict.Add(CurrentStandardInfo.ID, GetAvgSDSeriseCollection(oddavgsd)); evenAvgSDSeriseDict.Add(CurrentStandardInfo.ID, GetAvgSDSeriseCollection(evenavgsd)); } Dispatcher.Invoke(new Action(() => { for (int i = 0; i < 5; i++) { var oddItem = oddAvgSDSeriseDict[CurrentStandardInfo.ID][i]; chart1.Series.Add(oddItem); var evenItem = evenAvgSDSeriseDict[CurrentStandardInfo.ID][i]; chart2.Series.Add(evenItem); } })); } }); task.Start(); }