lx
2025-07-25 94ed3edb9e96c8bfa24d808dfc690cbd111a60e6
upload
已修改4个文件
已添加6个文件
621 ■■■■■ 文件已修改
ErrorAnalysis.Service/ErrorAnalysis.Service.csproj 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ErrorAnalysis.Service/ErrorRatioCalc.cs 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ErrorAnalysis.Service/Model/ReportModel.cs 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ErrorAnalysis.Service/Template/JobPlanReportTemp.docx 补丁 | 查看 | 原始文档 | blame | 历史
ErrorAnalysis.Service/WordReportHelper.cs 126 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ErrorAnalysis.UI/FrmMain.Designer.cs 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ErrorAnalysis.UI/FrmMain.cs 147 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ErrorAnalysis.UI/Report.Designer.cs 105 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ErrorAnalysis.UI/Report.cs 48 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ErrorAnalysis.UI/Report.resx 120 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ErrorAnalysis.Service/ErrorAnalysis.Service.csproj
@@ -7,7 +7,17 @@
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Aspose.Words" Version="21.8.0" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\ErrorAnalysis.Repository\ErrorAnalysis.Repository.csproj" />
  </ItemGroup>
  <ItemGroup>
    <None Update="Template\JobPlanReportTemp.docx">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </None>
  </ItemGroup>
</Project>
ErrorAnalysis.Service/ErrorRatioCalc.cs
@@ -86,10 +86,22 @@
                    {
                        if (wolProperty.Name.Contains("WLPu"))
                        {
                            //if (wolProperty.Name != "WLPu0")
                            //{
                            var interC = Utility.Interpolate(sw, 100, 0, 0, (double)wolProperty.GetValue(cWolRes));
                            var interO = Utility.Interpolate(sw, 0, 0, 100, (double)wolProperty.GetValue(oWolRes));
                            wolProperty.SetValue(cWolRes, interC);
                            wolProperty.SetValue(oWolRes, interO);
                            //}
                            //else
                            //{
                            //    var interC = Utility.Interpolate(sw, 100, 0, 0, (double)wolProperty.GetValue(cWolRes));
                            //    var interO = Utility.Interpolate(sw, 0, 0, 100, (double)wolProperty.GetValue(oWolRes));
                            //    var interVal = Utility.Interpolate(sw, 0, interC, 100, interO);
                            //    wolProperty.SetValue(cWolRes, interVal);
                            //    wolProperty.SetValue(oWolRes, interVal);
                            //}
                        }
                    }
                }
@@ -131,7 +143,7 @@
                    oRes = Utility.Interpolate(porosity, floorPorosity, floorO, ceilingPorosity, ceilingO);
                }
                var errorRatio = mergePDEV / (cRes - oRes);
                var errorRatio = mergePDEV /( cRes > oRes ? (cRes - oRes) : (oRes - cRes));
                return new ErrorRatio { Pass = 1, ErrorRatioValue = errorRatio };
            }
ErrorAnalysis.Service/Model/ReportModel.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,45 @@
using Aspose.Words;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ErrorAnalysis.Service.Model
{
    public class ReportModel
    {
        public string BIT { get; set; }
        public string CasingOD { get; set; }
        public string CasingID { get; set; }
        public string ScreenOD { get; set; }
        public string ScreenID { get; set; }
        public string TubeOD { get; set; }
        public string TubeID { get; set; }
        public string GravelFillPercent { get; set; }
        public string CementBond { get; set; }
        public string BHSalinity { get; set; }
        public string OilSalinity { get; set; }
        public string GasSalinity { get; set; }
        public string CasingFluid { get; set; }
        public string CasingHoldUp { get; set; }
        public string ScreenFluid { get; set; }
        public string ScreenHoldUp { get; set; }
        public string TubeFluid { get; set; }
        public string TubeHoldUp { get; set; }
        public string Lithology { get; set; }
        public string Porosity { get; set; }
        public string WaterSaturation { get; set; }
        public string ReserviorSalinity { get; set; }
        public string VSH { get; set; }
        public string SoPrecisionRequired { get; set; }
        public string Pass { get; set; }
        public string DepthAveraging { get; set; }
        public string TargetLoggingInterval { get; set; }
        public string Speed { get; set; }
        public string Duration { get; set; }
    }
}
ErrorAnalysis.Service/Template/JobPlanReportTemp.docx
Binary files differ
ErrorAnalysis.Service/WordReportHelper.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,126 @@
using Aspose.Words;
using Aspose.Words.Tables;
using Aspose.Words.Drawing;
using SkiaSharp;
using static System.Net.Mime.MediaTypeNames;
using ErrorAnalysis.Service.Model;
namespace ErrorAnalysis.Service
{
    public class WordReportHelper
    {
        /// <summary>
        /// æŠ¥å‘Šç±»åž‹æžšä¸¾å€¼pdf和word
        /// </summary>
        public enum ReportType
        {
            Pdf,
            Word
        }
        /// <summary>
        /// é™æ€æž„造函数
        /// </summary>
        static WordReportHelper()
        {
            new License().SetLicense(new MemoryStream(Convert.FromBase64String("PExpY2Vuc2U+CiAgPERhdGE+CiAgICA8TGljZW5zZWRUbz5TdXpob3UgQXVuYm94IFNvZnR3YXJlIENvLiwgTHRkLjwvTGljZW5zZWRUbz4KICAgIDxFbWFpbFRvPnNhbGVzQGF1bnRlYy5jb208L0VtYWlsVG8+CiAgICA8TGljZW5zZVR5cGU+RGV2ZWxvcGVyIE9FTTwvTGljZW5zZVR5cGU+CiAgICA8TGljZW5zZU5vdGU+TGltaXRlZCB0byAxIGRldmVsb3BlciwgdW5saW1pdGVkIHBoeXNpY2FsIGxvY2F0aW9uczwvTGljZW5zZU5vdGU+CiAgICA8T3JkZXJJRD4yMDA2MDIwMTI2MzM8L09yZGVySUQ+CiAgICA8VXNlcklEPjEzNDk3NjAwNjwvVXNlcklEPgogICAgPE9FTT5UaGlzIGlzIGEgcmVkaXN0cmlidXRhYmxlIGxpY2Vuc2U8L09FTT4KICAgIDxQcm9kdWN0cz4KICAgICAgPFByb2R1Y3Q+QXNwb3NlLlRvdGFsIGZvciAuTkVUPC9Qcm9kdWN0PgogICAgPC9Qcm9kdWN0cz4KICAgIDxFZGl0aW9uVHlwZT5FbnRlcnByaXNlPC9FZGl0aW9uVHlwZT4KICAgIDxTZXJpYWxOdW1iZXI+OTM2ZTVmZDEtODY2Mi00YWJmLTk1YmQtYzhkYzBmNTNhZmE2PC9TZXJpYWxOdW1iZXI+CiAgICA8U3Vic2NyaXB0aW9uRXhwaXJ5PjIwMjEwODI3PC9TdWJzY3JpcHRpb25FeHBpcnk+CiAgICA8TGljZW5zZVZlcnNpb24+My4wPC9MaWNlbnNlVmVyc2lvbj4KICAgIDxMaWNlbnNlSW5zdHJ1Y3Rpb25zPmh0dHBzOi8vcHVyY2hhc2UuYXNwb3NlLmNvbS9wb2xpY2llcy91c2UtbGljZW5zZTwvTGljZW5zZUluc3RydWN0aW9ucz4KICA8L0RhdGE+CiAgPFNpZ25hdHVyZT5wSkpjQndRdnYxV1NxZ1kyOHFJYUFKSysvTFFVWWRrQ2x5THE2RUNLU0xDQ3dMNkEwMkJFTnh5L3JzQ1V3UExXbjV2bTl0TDRQRXE1aFAzY2s0WnhEejFiK1JIWTBuQkh1SEhBY01TL1BSeEJES0NGbWg1QVFZRTlrT0FxSzM5NVBSWmJRSGowOUNGTElVUzBMdnRmVkp5cUhjblJvU3dPQnVqT1oyeDc4WFE9PC9TaWduYXR1cmU+CjwvTGljZW5zZT4=")));
        }
        public static bool Create(string outPath, ReportModel model, ReportType reportType = ReportType.Pdf)
        {
            string filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Template", "JobPlanReportTemp.docx");
            Document doc = new Document(filePath);
            var section = doc.FirstSection;
            var tables = section.Body.Tables;
            foreach (Table table in tables) SetContentTable(doc, table, model);
            section.Body.Paragraphs.RemoveAt(section.Body.Paragraphs.Count - 1);
            DocumentBuilder builder = new DocumentBuilder(doc);
            var lastSection = doc.LastSection;
            var pageWidth = lastSection.PageSetup.PageWidth - lastSection.PageSetup.LeftMargin - lastSection.PageSetup.RightMargin;
            builder.MoveToSection(doc.IndexOf(lastSection));
            builder.MoveToDocumentEnd();
            var coImg = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "co.png");
            var erImg = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "er.png");
            AddImageToDocument(builder, pageWidth, coImg);
            var para = builder.InsertParagraph();
            var run = new Run(doc);
            para.ParagraphFormat.Alignment = ParagraphAlignment.Left;
            run.Font.Bold = true;
            run.Font.Size = 14;
            run.Text = "ERROR RATE PLOT";
            para.AppendChild(run);
            AddImageToDocument(builder, pageWidth, erImg);
            doc.Save(outPath, reportType == ReportType.Word ? SaveFormat.Docx : SaveFormat.Pdf);
            return true;
        }
        /// <summary>
        /// è®¾ç½®å†…容表格
        /// </summary>
        /// <param name="doc">文档</param>
        /// <param name="table">表格</param>
        /// <param name="model">模型</param>
        private static void SetContentTable(Document doc, Table table, object model)
        {
            var properties = model?.GetType().GetProperties();
            foreach (Row row in table.Rows)
            {
                var cells = row.Cells;
                foreach (Cell cell in cells)
                {
                    var cellText = cell.GetText().Replace(ControlChar.Cell, "").Replace(ControlChar.ParagraphBreak, "");
                    if (cellText.StartsWith("$"))
                    {
                        var property = properties.FirstOrDefault(p => p.Name == cellText.Trim().Replace("$", ""));
                        if (property != null)
                        {
                            var valStr = property.GetValue(model).ToString();
                            cell.FirstParagraph.RemoveAllChildren();
                            cell.FirstParagraph.AppendChild(new Run(doc, valStr));
                            cell.FirstParagraph.ParagraphFormat.Alignment = ParagraphAlignment.Right;
                        }
                    }
                }
            }
        }
        /// <summary>
        /// å‘文档中添加图像。
        /// </summary>
        /// <param name="builder">文档构建器。</param>
        /// <param name="pageWidth">页面宽度。</param>
        /// <param name="imagePath">图像路径。</param>
        private static void AddImageToDocument(DocumentBuilder builder, double pageWidth, string imagePath)
        {
            using (FileStream picStream = new FileStream(imagePath, FileMode.Open, FileAccess.Read))
            {
                SKBitmap image;
                using (var skData = SKData.Create(picStream))
                {
                    image = SKBitmap.Decode(skData);
                }
                int originalWidth = image.Width;
                int originalHeight = image.Height;
                int height = (int)(originalHeight * (pageWidth / originalWidth));
                picStream.Seek(0, SeekOrigin.Begin);
                builder.InsertImage(image, pageWidth, height);
            }
        }
    }
}
ErrorAnalysis.UI/FrmMain.Designer.cs
@@ -394,7 +394,6 @@
            txtAnalysisResult.ReadOnly = true;
            txtAnalysisResult.Size = new Size(317, 182);
            txtAnalysisResult.TabIndex = 1;
            txtAnalysisResult.Text = "A total of 6 passes are recommended to maintain a 15% error rate. With the tool operating at 1.5 ft/hr, the estimated total job duration is 10 hours.";
            // 
            // btnReport
            // 
@@ -405,6 +404,7 @@
            btnReport.TabIndex = 4;
            btnReport.Text = "Report";
            btnReport.UseVisualStyleBackColor = true;
            btnReport.Click += btnReport_Click;
            // 
            // label24
            // 
@@ -955,7 +955,7 @@
            tpFormation.Controls.Add(label16);
            tpFormation.Location = new Point(4, 26);
            tpFormation.Name = "tpFormation";
            tpFormation.Size = new Size(747, 283);
            tpFormation.Size = new Size(847, 283);
            tpFormation.TabIndex = 2;
            tpFormation.Text = "Formation";
            tpFormation.UseVisualStyleBackColor = true;
@@ -1110,7 +1110,7 @@
            tpPlan.Controls.Add(panel1);
            tpPlan.Location = new Point(4, 26);
            tpPlan.Name = "tpPlan";
            tpPlan.Size = new Size(747, 283);
            tpPlan.Size = new Size(847, 283);
            tpPlan.TabIndex = 3;
            tpPlan.Text = "Plan";
            tpPlan.UseVisualStyleBackColor = true;
ErrorAnalysis.UI/FrmMain.cs
@@ -21,6 +21,7 @@
        private List<COModelTable> _models;
        private Dictionary<string, string> _filters;
        private COModelTable _model;
        private ReportModel _reportModel;
        public FrmMain()
        {
@@ -85,7 +86,6 @@
                });
            }
        }
        private void btnAnalysis_Click(object sender, EventArgs e)
        {
            var curModels = GetFilterResult();
@@ -136,11 +136,22 @@
                return;
            }
            if (!decimal.TryParse(nudOilDensity.Value.ToString(), out decimal oilDensity) || nudOilDensity.Value <= 0)
            {
                MessageBox.Show("Please select a oil density");
                return;
            }
            if (curModels.Count == 1)
                _model = curModels[0];
            _model = curModels.FirstOrDefault(m => m.GravelFillPercent == nudGravelFIllPercent.Value.ToString());
            _model = curModels.FirstOrDefault(m => m.GravelFillPercent == nudGravelFIllPercent.Value.ToString() && m.OilDensity == oilDensity);
            if (_model == null)
                _model = curModels.First();
            nudOilDensity.Value = _model.OilDensity.Value;
            nudGravelFIllPercent.Value = Convert.ToDecimal(_model.GravelFillPercent);
            if (cmbTargetLoggingIntervalUnit.Text == "ft")
                targetLoggingInterval = UnitConvert.Ft2M(targetLoggingInterval);
@@ -158,7 +169,9 @@
                Plot(result);
                double totalTime = Math.Round((targetLoggingInterval / calcSpeed / 60), 2);
                txtAnalysisResult.Text = $"A total of {result.ErrorRatios.Count} passes are recommended to maintain a {Math.Round(result.ErrorRatios.Min(r => r.ErrorRatioValue) * 100, 2)}% error rate. With the tool operating at {speed} {cmbSpeedUnit.Text}, the estimated total job duration is {totalTime.ToString()} hours.";
                var errorRate = Math.Round(result.ErrorRatios.Min(r => r.ErrorRatioValue) * 100, 2);
                txtAnalysisResult.Text = $"A total of {result.ErrorRatios.Count} passes are recommended to maintain a {errorRate}% error rate. With the tool operating at {speed} {cmbSpeedUnit.Text}, the estimated total job duration is {totalTime.ToString()} hours.";
                _reportModel = CreateReportModel(totalTime.ToString(), result.ErrorRatios.Count.ToString(), Math.Round(UnitConvert.MMin2FtHr(calcSpeed), 2).ToString(), errorRate.ToString());
            }
            else
            {
@@ -172,9 +185,19 @@
                Plot(result);
                double totalTime = Math.Round((targetLoggingInterval / speed / 60), 2);
                txtAnalysisResult.Text = $"A total of {result.ErrorRatios.Count} passes are recommended to maintain a {Math.Round(result.ErrorRatios.Min(r => r.ErrorRatioValue) * 100, 2)}% error rate. With the tool operating at {Math.Round(UnitConvert.MMin2FtHr(speed), 2)} ft/hr, the estimated total job duration is {totalTime.ToString()} hours.";
                var errorRate = Math.Round(result.ErrorRatios.Min(r => r.ErrorRatioValue) * 100, 2);
                var speedFr = Math.Round(UnitConvert.MMin2FtHr(speed), 2);
                txtAnalysisResult.Text = $"A total of {result.ErrorRatios.Count} passes are recommended to maintain a {errorRate}% error rate. With the tool operating at {speedFr} ft/hr, the estimated total job duration is {totalTime.ToString()} hours.";
                _reportModel = CreateReportModel(totalTime.ToString(), result.ErrorRatios.Count.ToString(), speedFr.ToString(), errorRate.ToString());
            }
        }
        private void btnReport_Click(object sender, EventArgs e)
        {
            new Report(_reportModel).ShowDialog();
        }
        #endregion
@@ -251,10 +274,10 @@
                    cmb.Text = currentItems[0];
            }
            holdCmbInit();
            LinkageModelProperty();
        }
        private void LinkageModelProperty()
        private void holdCmbInit()
        {
            cmbCasingHoldUp.Items.Clear();
            _filters.Remove("CasingFluid");
@@ -264,34 +287,10 @@
            _filters.Remove("TubeFluid");
            cmbLithology.Items.Clear();
            _filters.Remove("Lithology");
            var curModels = GetFilterResult();
            if (curModels.Count == 0)
                return;
            var gravelFills = curModels.Select(x => x.GravelFillPercent).Distinct().ToArray();
            if (gravelFills.Length == 1)
                nudGravelFIllPercent.Value = Convert.ToDecimal(gravelFills[0]);
            var cementBonds = curModels.Select(x => x.CementBond).Distinct().ToArray();
            if (cementBonds.Length == 1)
                nudCementBond.Value = Convert.ToDecimal(cementBonds[0]);
            var bhSalinities = curModels.Select(x => x.BHSalinity).Distinct().ToArray();
            if (bhSalinities.Length == 1)
                nudBHSalinity.Value = Convert.ToDecimal(bhSalinities[0]);
            var oilDensities = curModels.Select(x => x.OilDensity).Distinct().ToArray();
            if (oilDensities.Length == 1)
                nudOilDensity.Value = Convert.ToDecimal(oilDensities[0]);
            var reservoirSalinities = curModels.Select(x => x.ReservoirSalinity).Distinct().ToArray();
            if (reservoirSalinities.Length == 1)
                nudReservoirSalinity.Value = Convert.ToDecimal(reservoirSalinities[0]);
            var vshs = curModels.Select(x => x.VSH).Distinct().ToArray();
            if (vshs.Length == 1)
                nudVSH.Value = Convert.ToDecimal(vshs[0]);
            var casingFulids = curModels.Select(x => x.CasingFluid == "0" ? "water" : x.CasingFluid == "100" ? "oil" : x.CasingFluid == "200" ? "gas" : "none").Distinct().ToArray();
@@ -334,10 +333,44 @@
                nudTubeHoldUp.Enabled = true;
                cmbTubeHoldUp.Items.AddRange(tubeFluids);
            }
        }
        private void LinkageModelProperty()
        {
            var curLithology = cmbLithology.Text;
            cmbLithology.Items.Clear();
            _filters.Remove("Lithology");
            var curModels = GetFilterResult();
            if (curModels.Count == 0)
                return;
            var gravelFills = curModels.Select(x => x.GravelFillPercent).Distinct().ToArray();
            if (gravelFills.Length == 1)
                nudGravelFIllPercent.Value = Convert.ToDecimal(gravelFills[0]);
            var cementBonds = curModels.Select(x => x.CementBond).Distinct().ToArray();
            if (cementBonds.Length == 1)
                nudCementBond.Value = Convert.ToDecimal(cementBonds[0]);
            var bhSalinities = curModels.Select(x => x.BHSalinity).Distinct().ToArray();
            if (bhSalinities.Length == 1)
                nudBHSalinity.Value = Convert.ToDecimal(bhSalinities[0]);
            var oilDensities = curModels.Select(x => x.OilDensity).Distinct().ToArray();
            if (oilDensities.Length == 1)
                nudOilDensity.Value = Convert.ToDecimal(oilDensities[0]);
            var reservoirSalinities = curModels.Select(x => x.ReservoirSalinity).Distinct().ToArray();
            if (reservoirSalinities.Length == 1)
                nudReservoirSalinity.Value = Convert.ToDecimal(reservoirSalinities[0]);
            var vshs = curModels.Select(x => x.VSH).Distinct().ToArray();
            if (vshs.Length == 1)
                nudVSH.Value = Convert.ToDecimal(vshs[0]);
            var lithology = curModels.Select(x => x.Lithology).Distinct().ToArray();
            var curLithology = cmbLithology.Text;
            cmbLithology.Items.AddRange(lithology);
            if (cmbLithology.Items.Contains(curLithology))
            cmbLithology.Text = curLithology;
            if (lithology.Length == 1)
@@ -396,6 +429,7 @@
                }
            }
            LinkageModelProperty();
            //foreach (var cmb in allCmb)
            //{
            //    if (cmb.Name != control.Name)
@@ -411,15 +445,6 @@
            //    }
            //}
            var lithology = curModels.Select(x => x.Lithology).Distinct().ToArray();
            cmbLithology.Items.Clear();
            cmbLithology.Items.AddRange(lithology);
            if (_filters.ContainsKey("Lithology") && lithology.Contains(_filters["Lithology"]))
                cmbLithology.Text = _filters["Lithology"];
            else
                _filters.Remove("Lithology");
        }
        private void cmbLithology_SelectedIndexChanged(object sender, EventArgs e)
        {
@@ -447,7 +472,6 @@
            }
        }
        #endregion
        private List<COModelTable> GetFilterResult()
        {
            var type = typeof(COModelTable);
@@ -457,7 +481,6 @@
            return result;
        }
        private void Plot(ErrorRatioResult errorResult)
        {
            pnlCOPic.Controls.Clear();
@@ -523,5 +546,43 @@
            plotView.Dock = DockStyle.Fill;
            pnlErrorRatioPic.Controls.Add(plotView);
        }
        private ReportModel CreateReportModel(string duration, string pass, string speed, string soPrecision)
        {
            return new ReportModel
            {
                BHSalinity = nudBHSalinity.Value.ToString(),
                BIT = cmbBit.Text,
                CasingFluid = cmbCasingHoldUp.Text,
                CasingHoldUp = nudCasingHoldUp.Value.ToString(),
                CasingID = cmbCasingID.Text,
                CasingOD = cmbCasingOD.Text,
                CementBond = nudCementBond.Text,
                DepthAveraging = nudDepth.Value.ToString(),
                Duration = duration,
                GasSalinity = nudGasDensity.Value.ToString(),
                GravelFillPercent = nudGravelFIllPercent.Value.ToString(),
                Lithology = cmbLithology.Text,
                OilSalinity = nudOilDensity.Value.ToString(),
                Pass = pass,
                Porosity = nudPorosity.Value.ToString(),
                ReserviorSalinity = nudReservoirSalinity.Value.ToString(),
                ScreenFluid = cmbScreenHoldUp.Text,
                ScreenHoldUp = nudScreenHoldUp.Value.ToString(),
                ScreenID = cmbScreenID.Text,
                ScreenOD = cmbScreenOD.Text,
                SoPrecisionRequired = soPrecision,
                Speed = speed,
                TargetLoggingInterval = nudTargetLoggingInterval.Value.ToString(),
                TubeFluid = cmbTubeHoldUp.Text,
                TubeHoldUp = nudTubeHoldUp.Value.ToString(),
                TubeID = cmbTubeID.Text,
                TubeOD = cmbTubeOD.Text,
                VSH = nudVSH.Value.ToString(),
                WaterSaturation = nudSw.Value.ToString()
            };
        }
    }
}
ErrorAnalysis.UI/Report.Designer.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,105 @@
namespace ErrorAnalysis.UI
{
    partial class Report
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }
        #region Windows Form Designer generated code
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            btnExport = new Button();
            btnCancel = new Button();
            rdoWord = new RadioButton();
            rdoPdf = new RadioButton();
            SuspendLayout();
            //
            // btnExport
            //
            btnExport.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
            btnExport.Location = new Point(147, 52);
            btnExport.Name = "btnExport";
            btnExport.Size = new Size(75, 23);
            btnExport.TabIndex = 1;
            btnExport.Text = "Export";
            btnExport.UseVisualStyleBackColor = true;
            btnExport.Click += btnExport_Click;
            //
            // btnCancel
            //
            btnCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
            btnCancel.Location = new Point(66, 52);
            btnCancel.Name = "btnCancel";
            btnCancel.Size = new Size(75, 23);
            btnCancel.TabIndex = 2;
            btnCancel.Text = "Cancel";
            btnCancel.UseVisualStyleBackColor = true;
            btnCancel.Click += btnCancel_Click;
            //
            // rdoWord
            //
            rdoWord.AutoSize = true;
            rdoWord.Location = new Point(109, 12);
            rdoWord.Name = "rdoWord";
            rdoWord.Size = new Size(65, 21);
            rdoWord.TabIndex = 4;
            rdoWord.Text = "WORD";
            rdoWord.UseVisualStyleBackColor = true;
            //
            // rdoPdf
            //
            rdoPdf.AutoSize = true;
            rdoPdf.Checked = true;
            rdoPdf.Location = new Point(31, 12);
            rdoPdf.Name = "rdoPdf";
            rdoPdf.Size = new Size(48, 21);
            rdoPdf.TabIndex = 3;
            rdoPdf.TabStop = true;
            rdoPdf.Text = "PDF";
            rdoPdf.UseVisualStyleBackColor = true;
            //
            // Report
            //
            AutoScaleDimensions = new SizeF(7F, 17F);
            AutoScaleMode = AutoScaleMode.Font;
            ClientSize = new Size(226, 81);
            Controls.Add(rdoWord);
            Controls.Add(rdoPdf);
            Controls.Add(btnCancel);
            Controls.Add(btnExport);
            MaximizeBox = false;
            MinimizeBox = false;
            Name = "Report";
            StartPosition = FormStartPosition.CenterScreen;
            Text = "Report";
            ResumeLayout(false);
            PerformLayout();
        }
        #endregion
        private Button btnExport;
        private Button btnCancel;
        private RadioButton rdoWord;
        private RadioButton rdoPdf;
    }
}
ErrorAnalysis.UI/Report.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,48 @@
using ErrorAnalysis.Service;
using ErrorAnalysis.Service.Model;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ErrorAnalysis.UI
{
    public partial class Report : Form
    {
        ReportModel _reportModel;
        public Report(ReportModel model)
        {
            _reportModel = model;
            InitializeComponent();
        }
        private void btnExport_Click(object sender, EventArgs e)
        {
            btnExport.Enabled = false;
            var saveFileDialog = new SaveFileDialog();
            saveFileDialog.Filter = rdoPdf.Checked ? "Report |*.pdf" : "Report |*.docx";
            saveFileDialog.FilterIndex = 1;
            saveFileDialog.FileName = "JobPlanReport";
            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                WordReportHelper.Create(saveFileDialog.FileName, _reportModel, rdoPdf.Checked ? WordReportHelper.ReportType.Pdf : WordReportHelper.ReportType.Word);
                MessageBox.Show("Export success!");
                Dispose();
                Close();
            }
            btnExport.Enabled = true;
        }
        private void btnCancel_Click(object sender, EventArgs e)
        {
            Dispose();
            Close();
        }
    }
}
ErrorAnalysis.UI/Report.resx
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
  <!--
    Microsoft ResX Schema
    Version 2.0
    The primary goals of this format is to allow a simple XML format
    that is mostly human readable. The generation and parsing of the
    various data types are done through the TypeConverter classes
    associated with the data types.
    Example:
    ... ado.net/XML headers & schema ...
    <resheader name="resmimetype">text/microsoft-resx</resheader>
    <resheader name="version">2.0</resheader>
    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
        <value>[base64 mime encoded serialized .NET Framework object]</value>
    </data>
    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
        <comment>This is a comment</comment>
    </data>
    There are any number of "resheader" rows that contain simple
    name/value pairs.
    Each data row contains a name, and value. The row also contains a
    type or mimetype. Type corresponds to a .NET class that support
    text/value conversion through the TypeConverter architecture.
    Classes that don't support this are serialized and stored with the
    mimetype set.
    The mimetype is used for serialized objects, and tells the
    ResXResourceReader how to depersist the object. This is currently not
    extensible. For a given mimetype the value must be set accordingly:
    Note - application/x-microsoft.net.object.binary.base64 is the format
    that the ResXResourceWriter will generate, however the reader can
    read any of the formats listed below.
    mimetype: application/x-microsoft.net.object.binary.base64
    value   : The object must be serialized with
            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
            : and then encoded with base64 encoding.
    mimetype: application/x-microsoft.net.object.soap.base64
    value   : The object must be serialized with
            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
            : and then encoded with base64 encoding.
    mimetype: application/x-microsoft.net.object.bytearray.base64
    value   : The object must be serialized into a byte array
            : using a System.ComponentModel.TypeConverter
            : and then encoded with base64 encoding.
    -->
  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
    <xsd:element name="root" msdata:IsDataSet="true">
      <xsd:complexType>
        <xsd:choice maxOccurs="unbounded">
          <xsd:element name="metadata">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" />
              </xsd:sequence>
              <xsd:attribute name="name" use="required" type="xsd:string" />
              <xsd:attribute name="type" type="xsd:string" />
              <xsd:attribute name="mimetype" type="xsd:string" />
              <xsd:attribute ref="xml:space" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="assembly">
            <xsd:complexType>
              <xsd:attribute name="alias" type="xsd:string" />
              <xsd:attribute name="name" type="xsd:string" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="data">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
              </xsd:sequence>
              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
              <xsd:attribute ref="xml:space" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="resheader">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
              </xsd:sequence>
              <xsd:attribute name="name" type="xsd:string" use="required" />
            </xsd:complexType>
          </xsd:element>
        </xsd:choice>
      </xsd:complexType>
    </xsd:element>
  </xsd:schema>
  <resheader name="resmimetype">
    <value>text/microsoft-resx</value>
  </resheader>
  <resheader name="version">
    <value>2.0</value>
  </resheader>
  <resheader name="reader">
    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
  </resheader>
  <resheader name="writer">
    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
  </resheader>
</root>