Bläddra i källkod

优化报告导出速度,取消处理加载没用到的图片,优化内存

zhangjiaxin 3 år sedan
förälder
incheckning
bae8d566b8

+ 2 - 2
Bin/x64/Debug/Config/ProData/ReportTemplateConfig.xml

@@ -1,7 +1,7 @@
 <XmlConfig>
   <M_SY>
     <str_tb_ZBT>Inclusion Analysis </str_tb_ZBT>
-    <str_tb_FBT>XXX大学</str_tb_FBT>
+    <str_tb_FBT>XXX实验室</str_tb_FBT>
     <str_tb_YPBH>0001</str_tb_YPBH>
     <str_tb_CKBZ>GB/T30834-2014</str_tb_CKBZ>
     <b_ck_ypsm>True</b_ck_ypsm>
@@ -17,7 +17,7 @@
     <b_ck_klcc_xsmk>True</b_ck_klcc_xsmk>
     <index_cb_klcc_jsfs>0</index_cb_klcc_jsfs>
     <index_cb_klcc_ljb>0</index_cb_klcc_ljb>
-    <index_cb_klcc_klfw>1</index_cb_klcc_klfw>
+    <index_cb_klcc_klfw>0</index_cb_klcc_klfw>
     <b_cb_jzwfl_xsmk>True</b_cb_jzwfl_xsmk>
     <index_cb_jzwfl_xstx>4</index_cb_jzwfl_xstx>
     <index_cb_jzwfl_jsfs>0</index_cb_jzwfl_jsfs>

+ 1 - 1
Bin/x64/Debug/Config/ProData/lj.psf

@@ -1,2 +1,2 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<XMLData FileMark="626" Name="LiJi1" Sizes="0,0.5,1,1.5,2,5,10,20,30,40" Version="1.1.1" />
+<XMLData FileMark="626" Name="LiJi1" Sizes="0,0.5,1,1.5,2,5,10,20,30" Version="1.1.1" />

+ 45 - 48
OTSIncAReportApp/Control_Grids/ParticlesGridDevidePage.cs

@@ -1412,7 +1412,7 @@ namespace OTSIncAReportGrids
         /// <summary>
         /// 在帧图上标记颗粒的位置矩形,并保存到FIELD_FILES_MARK文件夹中
         /// </summary>
-        public void SaveMarkParticleRectangleOnFieldFile()
+        public void SaveMarkParticleRectangleOnFieldFile(DataTable dataTable)
         {
             string str_path_FIELD_FILES = result.FilePath + "\\FIELD_FILES\\";
             string str_path_FIELD_FILES_MARK = result.FilePath + "\\FIELD_FILES_MARK\\";
@@ -1442,65 +1442,62 @@ namespace OTSIncAReportGrids
                     //找出所有的用户库文件,在这个目录中
                     if (nextifile.Name.Contains(".bmp") == true || nextifile.Name.Contains(".BMP") == true)
                     {
-                        Image img = Image.FromFile(nextifile.FullName);
-                        Bitmap ls_fieldbp = new Bitmap(img.Width, img.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
-                        using (Graphics g = Graphics.FromImage(ls_fieldbp))
-                        {
-                            g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
-                            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
-                            g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
-                            g.DrawImage(img, 0, 0);
-                        }
-
-                        img.Dispose();
-                        img = null;
-
                         //确认对应的帧图名
                         string str_fieldid = Path.GetFileNameWithoutExtension(nextifile.Name);
                         str_fieldid = str_fieldid.Substring(5, str_fieldid.Length - 5);//减去field字符长度
-
-                        //循环将颗粒,进行标记到bitmap图上
-                        DataRow[] drlist = dt_AllParticle.Select("  fieldid = " + str_fieldid);
-                        for (int i_row = 0; i_row < drlist.Count(); i_row++)
+                        if (dataTable.Select(" fieldid = " + str_fieldid).Count() > 0)
                         {
-                            //
-                            //string str_fieldid = drlist[i_row]["fieldid"].ToString();
-                            string str_particleid = drlist[i_row]["particleid"].ToString();
-                            string str_stdtypeid = drlist[i_row]["typeid"].ToString();
-                            string str_offset_rect_X = drlist[i_row]["RectLeft"].ToString();
-                            string str_offset_rect_Y = drlist[i_row]["RectTop"].ToString();
-                            string str_offset_rect_Width = drlist[i_row]["RectWidth"].ToString();
-                            string str_offset_rect_Height = drlist[i_row]["RectHeight"].ToString();
-
-                            //确定需要标记颗粒的定位
-                            Rectangle offset_rect = new Rectangle(Convert.ToInt32(str_offset_rect_X), Convert.ToInt32(str_offset_rect_Y),
-                    Convert.ToInt32(str_offset_rect_Width), Convert.ToInt32(str_offset_rect_Height));
-
-                            //向帧图进行标记颗粒位置
-                            Graphics g = Graphics.FromImage(ls_fieldbp);
-                            g.DrawRectangle(new Pen(Color.Aquamarine), offset_rect);
-
-                            //判断是否超出了图像外面,是的话,让文字在左侧显示,默认在右侧显示
-                            int ls_offsetx = offset_rect.X + offset_rect.Width;
-                            if (ls_offsetx > ls_fieldbp.Width - 10)
+                            Image img = Image.FromFile(nextifile.FullName);
+                            Bitmap ls_fieldbp = new Bitmap(img.Width, img.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
+                            using (Graphics g = Graphics.FromImage(ls_fieldbp))
                             {
-                                ls_offsetx = offset_rect.X - 10;
+                                g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
+                                g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
+                                g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
+                                g.DrawImage(img, 0, 0);
                             }
-                            g.DrawString(str_fieldid + "" + str_particleid.ToString(),
-                                new Font("黑体", 8), new SolidBrush(Color.Aqua), new PointF(ls_offsetx, offset_rect.Y));
 
-                            //保存带有标记的帧图
-                            ls_fieldbp.Save(str_path_FIELD_FILES_MARK + str_fieldid.ToString() + ".bmp");
+                            img.Dispose();
+                            img = null;
 
-                            //ls_fieldbp.Dispose();
-                        }
+                            //循环将颗粒,进行标记到bitmap图上
+                            DataRow[] drlist = dt_AllParticle.Select("  fieldid = " + str_fieldid);
+                            for (int i_row = 0; i_row < drlist.Count(); i_row++)
+                            {
+                                //string str_fieldid = drlist[i_row]["fieldid"].ToString();
+                                string str_particleid = drlist[i_row]["particleid"].ToString();
+                                string str_stdtypeid = drlist[i_row]["typeid"].ToString();
+                                string str_offset_rect_X = drlist[i_row]["RectLeft"].ToString();
+                                string str_offset_rect_Y = drlist[i_row]["RectTop"].ToString();
+                                string str_offset_rect_Width = drlist[i_row]["RectWidth"].ToString();
+                                string str_offset_rect_Height = drlist[i_row]["RectHeight"].ToString();
+
+                                //确定需要标记颗粒的定位
+                                Rectangle offset_rect = new Rectangle(Convert.ToInt32(str_offset_rect_X), Convert.ToInt32(str_offset_rect_Y),
+                        Convert.ToInt32(str_offset_rect_Width), Convert.ToInt32(str_offset_rect_Height));
+
+                                //向帧图进行标记颗粒位置
+                                Graphics g = Graphics.FromImage(ls_fieldbp);
+                                g.DrawRectangle(new Pen(Color.Aquamarine), offset_rect);
+
+                                //判断是否超出了图像外面,是的话,让文字在左侧显示,默认在右侧显示
+                                int ls_offsetx = offset_rect.X + offset_rect.Width;
+                                if (ls_offsetx > ls_fieldbp.Width - 10)
+                                {
+                                    ls_offsetx = offset_rect.X - 10;
+                                }
+                                g.DrawString(str_fieldid + "" + str_particleid.ToString(),
+                                    new Font("黑体", 8), new SolidBrush(Color.Aqua), new PointF(ls_offsetx, offset_rect.Y));
 
+                                //保存带有标记的帧图
+                                ls_fieldbp.Save(str_path_FIELD_FILES_MARK + str_fieldid.ToString() + ".bmp");
 
+                                //ls_fieldbp.Dispose();
+                            }
+                        }
                     }
                 }
-
             }
-
             //
             GC.Collect();
             GC.WaitForPendingFinalizers();
@@ -1508,7 +1505,7 @@ namespace OTSIncAReportGrids
 
         private void testToolStripMenuItem1_Click(object sender, EventArgs e)
         {
-            SaveMarkParticleRectangleOnFieldFile();
+            //SaveMarkParticleRectangleOnFieldFile();
             MessageBox.Show("导出完成!");
         }
 

+ 5 - 75
OTSIncAReportApp/OTSTemplateDesigner/Export_ReportTemplate.cs

@@ -120,16 +120,12 @@ namespace OTSIncAReportApp.OTSTemplateDesigner
         public bool InsertReportTemplateTable_ParticlesGridDevidePage()
         {
             //------------------加载模块,获取数据-------------------------------------------------
+            //if (m_otsreport_export.m_ReportApp.im_ParticlesGridDevidePage!=null)
             m_otsreport_export.m_ReportApp.im_ParticlesGridDevidePage = new ParticlesGridDevidePage(m_otsreport_export.m_ReportApp);
-            //DataGridView gv_dt_ParticlesGridDevidePage_element = new DataGridView();
-            //DataTable dt_ParticlesGridDevidePage_element = new DataTable();
-            //m_otsreport_export.m_ReportApp.m_CTablesWindow.Controls.Add(m_otsreport_export.m_ReportApp.im_ParticlesGridDevidePage);
-            //m_otsreport_export.m_ReportApp.im_ParticlesGridDevidePage.GetDataTableAndGridView(out dt_ParticlesGridDevidePage_element, out gv_dt_ParticlesGridDevidePage_element);
-            
+
             //根据sql条件,查询获取颗粒信息数据
-            DataTable dt_ParticlesGridDevidePage = new DataTable();
             ParticleData fielddata = new ParticleData(m_otsreport_export.m_ReportApp.resultFilesList[m_otsreport_export.m_ReportApp.WorkingResult].FilePath);
-            dt_ParticlesGridDevidePage = fielddata.GetInfoForPartucleDevidePage(0, 200, "fieldid,particleid", "");
+            DataTable dt_ParticlesGridDevidePage = fielddata.GetInfoForPartucleDevidePage(0, 200, "fieldid,particleid", "");
 
             string str_resultPath = m_otsreport_export.m_ReportApp.resultFilesList[m_otsreport_export.m_ReportApp.WorkingResult].FilePath;
             //------------------加载模块,获取数据结束----------------------------------------------
@@ -322,7 +318,7 @@ namespace OTSIncAReportApp.OTSTemplateDesigner
 
             #region 插入-帧图图像部份
             //首先生成标记颗粒的帧图图像文件
-            m_otsreport_export.m_ReportApp.im_ParticlesGridDevidePage.SaveMarkParticleRectangleOnFieldFile();
+            m_otsreport_export.m_ReportApp.im_ParticlesGridDevidePage.SaveMarkParticleRectangleOnFieldFile(dt_ParticlesGridDevidePage);
 
             string str_path_FIELD_FILES_MARK = str_resultPath + "\\FIELD_FILES_MARK\\";
             DirectoryInfo theFolder = new DirectoryInfo(str_path_FIELD_FILES_MARK);
@@ -1007,14 +1003,7 @@ namespace OTSIncAReportApp.OTSTemplateDesigner
         #endregion
 
         #region 其它部份
-        ///// <summary>
-        ///// 获取夹杂物总数量,报告中暂时固定导出100数量,如果需要导出全部颗粒,到颗粒列表中导出Excel使用
-        ///// </summary>
-        ///// <returns></returns>
-        //public int GetReportTemplateTable_ParticlesNumber()
-        //{
-        //    return 100;
-        //}
+     
 
         /// <summary>
         /// 输入颗粒的所在帧图id,颗粒id,颗粒类型id,获取对应的XRay能谱数据图
@@ -1185,65 +1174,6 @@ namespace OTSIncAReportApp.OTSTemplateDesigner
             }
         }
 
-
-        /// <summary>
-        /// 传入DataTable和想要找到的列名,返回对应列的索引
-        /// </summary>
-        /// <param name="in_dt"></param>
-        /// <param name="in_str"></param>
-        /// <returns></returns>
-        private int GetDataTableColumnsIndexByName(DataTable in_dt, string in_str)
-        {
-            int i_ret = -1;
-            for (int i = 0; i < in_dt.Columns.Count; i++)
-            {
-                if (in_dt.Columns[i].ColumnName.IndexOf(in_str) > -1)
-                {
-                    //找到
-                    i_ret = i;
-                    break;
-                }
-            }
-            return i_ret;
-        }
-
-        /// <summary>
-        /// 传入DataTable和想要的元素第几个排列,返回对应的列的索引
-        /// </summary>
-        /// <param name="in_dt"></param>
-        /// <param name="in_str"></param>
-        /// <returns></returns>
-        private int GetDataTableColumnsIndexByElementNumber(DataTable in_dt, int in_elementorder)
-        {
-            int i_ret = -1;
-
-            int i_findcount = 0;//第几次找到的记数
-            //首先遍历所有的datatable中的元素
-            for (int i = 0; i < in_dt.Columns.Count; i++)
-            {
-                //然后遍历该列是否是元素名,要显示的元素名
-                for (int k = 0; k < m_otsreport_export.m_mbszclass.M_KLLBXX.list_str_tb_lllb_sxys.Count; k++)
-                {
-                    if (in_dt.Columns[i].ColumnName.ToString().ToUpper() == m_otsreport_export.m_mbszclass.M_KLLBXX.list_str_tb_lllb_sxys[k].ToUpper())
-                    {
-                        //找到了
-                        if (i_findcount == in_elementorder)
-                        {
-                            //并且达到了想找的第几个序列,返回对应的列的索引
-                            i_ret = i;
-                            return i_ret;
-                        }
-                        else
-                        {
-                            //否则,找到的索引号增长
-                            i_findcount++;
-                        }
-                    }
-                }
-            }
-
-            return i_ret;
-        }
         #endregion
 
     }