tx
2025-04-09 fa7510e1ed63df0366787fa4ed1b3db6426d2b46
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
using DevExpress.XtraEditors;
using Eventech.Model;
using System.IO;
using System.Windows.Forms;
 
namespace TProduct.WinFrmUI.TPump
{
    /// <summary>
    /// 性能测试
    /// </summary>
    public partial class FeatTestViewMainPage
    {
        private void barBtn导出测试报告_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            ExportReport();
        }
        public void ExportReport()
        { 
            SetTestReportInfoDlg dlg = new SetTestReportInfoDlg();
            dlg.SetBindingData(this._testProject);
            if (dlg.ShowDialog() != DialogResult.OK)
                return;
 
            var file_path = dlg.GetFilePah();
 
            TProduct.DataFile.PumpReport.TestReportFileExcelBase file_helepr = null;
            var tempalte = TProduct.UserSetting.Setting.Export.TemplatePumpFeatReport;
            if (tempalte == 0)
            {
                if (TProduct.CorpConfig.Instance.CorpFlag == Model.eCorpFlag.LIFU)
                {
                    file_helepr = new TProduct.DataFile.PumpReport.TestReportFileLIFU1();
                }
                else
                {
                    MessageBox.Show("还未定义企业模板,如需此功能, 请与上海义维联系");
                    return;
                }
            }
            else if (tempalte == 1)
            {
                file_helepr = new TProduct.DataFile.PumpReport.TestReportFileT1();
            }
            else if (tempalte == 2)
            {
                file_helepr = new TProduct.DataFile.PumpReport.TestReportFileT2();
            }
            else if (tempalte == 3)
            {
                file_helepr = new TProduct.DataFile.PumpReport.TestReportFileT3();
            }
            else
            {
                return;
            }
 
            var user_name = new BLL.LoginUser().GetRealNameByID(this._testProject.CreateUserID);
            file_helepr.SetPumpGraph(GetFeatChartImage());
            file_helepr.RecordDataSortType = dlg.RecordSortType;
            file_helepr.SetMaxEtaPt(this._chartMainCtrl.GetMaxEtaPt());
            file_helepr.SetBindingData(
                this._currentPump,
                this._currentPart,
                this._testProject,
                this._testItems, _testJudgeResults,
                user_name
                );
 
            if (file_helepr.Create(file_path, (info, type) =>
            {
                MessageBox.Show(info);
            }) == null)
            {
                TProduct.WinFrmUI.FileMessageBox.Show(file_path, TProduct.UserSetting.Localization.Current);
            }
 
        }
 
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bbi导出性能曲线图_CAD_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            ExportChart_Cad();
        }
        public void ExportChart_Cad()
        {
            if (_featTestItem == null)
                return;
            TProduct.PumpGraph.Dxf.LxpFeatChart chartCad =
                  PumpGraph.Dxf.LxpFeatChart.Build(TProduct.UserSetting.Setting.Export.TemplatePumpChartCad);
            chartCad.SetCoordinate(new LxpCoordinateParas(_featTestItem.CoordinateParas));
            chartCad.SetFeatPointRecords(this._currentPump, this._allRecords);
            chartCad.SetRatedParas(this._ratedParas, this._testJudgeItems);
            //chartImg.SetDefaultColor();
            chartCad.InitialTemplate(TProduct.DataFolderParas.FullPath, Eventech.Model.eLocalizationType.zhCN, null);
            SaveFileDialog saveFileDlg = new SaveFileDialog();
            saveFileDlg.Filter = "dwg 文件(*.dwg)|*.dwg";
            if (saveFileDlg.ShowDialog() != DialogResult.OK)
                return;
 
            var ret = chartCad.CreateDxf(saveFileDlg.FileName);
 
            TProduct.WinFrmUI.FileMessageBox.Show(saveFileDlg.FileName);
        }
 
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bbi导出性能曲线图_图片_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            ExportChart_Image();
        }
        public void ExportChart_Image()
        {
            if (_featTestItem == null)
                return;
            SaveFileDialog saveFileDlg = new SaveFileDialog();
            saveFileDlg.Filter = "图片文件(*.png)|*.png";
            if (saveFileDlg.ShowDialog() != DialogResult.OK)
                return;
            var chartImg = GetFeatChartImage();
            var img = chartImg.CreateImage();
            img.Save(saveFileDlg.FileName);
            TProduct.WinFrmUI.FileMessageBox.Show(saveFileDlg.FileName);
        }
 
 
        private TProduct.PumpGraph.Picture.LxpFeatChart GetFeatChartImage()
        {
            var chartImg =
                TProduct.PumpGraph.Picture.LxpFeatChart.Build(
                    TProduct.UserSetting.Setting.Export.TemplatePumpChartImage);
 
            chartImg.SetCoordinate(new LxpCoordinateParas(_featTestItem.CoordinateParas));
            chartImg.SetFeatPointRecords(this._currentPump, this._allRecords);
            chartImg.SetRatedParas(this._ratedParas, this._testJudgeItems);
            chartImg.SetDockType(PumpGraph.Picture.FeatChart.eDockType.单独导出, 0, 0);
            chartImg.SetExtendCurveInfoQH(_chartMainCtrl.GetExtendCurveInfoQH());
            chartImg.SetDefaultColor();
            chartImg.IsDispCurveName = TProduct.UserSetting.Setting.PumpChartImageDisp.IsDispCurveName;
            if (!string.IsNullOrEmpty(TProduct.UserSetting.Setting.PumpChartImageDisp.ColorQH))
            {
                chartImg.SetColorQH(
                    System.Drawing.ColorTranslator.FromHtml(TProduct.UserSetting.Setting.PumpChartImageDisp.ColorQH));
            }
            if (!string.IsNullOrEmpty(TProduct.UserSetting.Setting.PumpChartImageDisp.ColorQE))
            {
                chartImg.SetColorQE(
                    System.Drawing.ColorTranslator.FromHtml(TProduct.UserSetting.Setting.PumpChartImageDisp.ColorQE));
            }
            if (!string.IsNullOrEmpty(TProduct.UserSetting.Setting.PumpChartImageDisp.ColorQP))
            {
                chartImg.SetColorQP(
                    System.Drawing.ColorTranslator.FromHtml(TProduct.UserSetting.Setting.PumpChartImageDisp.ColorQP));
            }
            return chartImg;
        }
 
 
        private void bbi导出性能曲线图_XML_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            ExportChart_XML();
        }
        public void ExportChart_XML()
        {
            SaveFileDialog saveFileDlg = new SaveFileDialog();
            saveFileDlg.Filter = "XML 文件(*.xml)|*.xml";
            if (saveFileDlg.ShowDialog() != DialogResult.OK)
                return;
            var strXmlPath = saveFileDlg.FileName;
            string fileName = Path.GetFileName(strXmlPath);
            for (int i = 0; i < InvalidFileNameChar.Length; i++)
            {
                if (fileName.Contains(InvalidFileNameChar[i].ToString()))
                {
                    XtraMessageBox.Show(string.Format("{0},含有特殊符号,{1},",
                        "不能作为文件名,请修改",
                         InvalidFileNameChar[i]));
                    return;
                }
            }
 
            TProduct.DataFile.YwGeneralFile.FileV1 fileXML_helepr = null;
            fileXML_helepr = new TProduct.DataFile.YwGeneralFile.FileV1();
 
            fileXML_helepr.SetBindingData(
                this._currentPump,
                this._currentPart,
                this._testProject);
 
            if (fileXML_helepr.CreatXmlFile(strXmlPath, (info, type) =>
            {
                MessageBox.Show("失败");
            }) == null)
            {
                //MessageBox.Show("生成成功");
                TProduct.WinFrmUI.FileMessageBox.Show(strXmlPath, TProduct.UserSetting.Localization.Current);
            }
 
        }
 
        string InvalidFileNameChar = "/:*?\"<>|";
        private bool CheckInvalidFileName(string fileName)
        {
            for (int i = 0; i < InvalidFileNameChar.Length; i++)
            {
                if (fileName.Contains(InvalidFileNameChar[i].ToString()))
                {
                    XtraMessageBox.Show(string.Format("{0},含有特殊符号,{1},",
                        "不能作为文件名,请修改",
                         InvalidFileNameChar[i]));
                    return false;
                }
            }
            return true;
        }
    }
}