Parcourir la source

优化SOP上传

callm il y a 1 mois
Parent
commit
c67eb59997

+ 13 - 11
UAS_MES_YDCY/FunctionCode/Query/Query_SOP_CY.Designer.cs

@@ -49,6 +49,7 @@ namespace UAS_MES_NEW.Query
             this.ChooseALL = new System.Windows.Forms.Button();
             this.GetSOP = new System.Windows.Forms.Button();
             this.button1 = new System.Windows.Forms.Button();
+            this.button2 = new System.Windows.Forms.Button();
             this.dataGridViewCheckBoxColumn1 = new System.Windows.Forms.DataGridViewCheckBoxColumn();
             this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.dataGridViewTextBoxColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
@@ -61,7 +62,6 @@ namespace UAS_MES_NEW.Query
             this.fp_path = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.psd_iskey = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.issend = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.button2 = new System.Windows.Forms.Button();
             ((System.ComponentModel.ISupportInitialize)(this.SendDGV)).BeginInit();
             this.SuspendLayout();
             // 
@@ -258,8 +258,20 @@ namespace UAS_MES_NEW.Query
             this.button1.TabIndex = 27;
             this.button1.Text = "PDF";
             this.button1.UseVisualStyleBackColor = true;
+            this.button1.Visible = false;
             this.button1.Click += new System.EventHandler(this.button1_Click);
             // 
+            // button2
+            // 
+            this.button2.Location = new System.Drawing.Point(666, 893);
+            this.button2.Name = "button2";
+            this.button2.Size = new System.Drawing.Size(160, 42);
+            this.button2.TabIndex = 28;
+            this.button2.Text = "excel";
+            this.button2.UseVisualStyleBackColor = true;
+            this.button2.Visible = false;
+            this.button2.Click += new System.EventHandler(this.button2_Click);
+            // 
             // dataGridViewCheckBoxColumn1
             // 
             this.dataGridViewCheckBoxColumn1.DataPropertyName = "CheckColumn";
@@ -379,16 +391,6 @@ namespace UAS_MES_NEW.Query
             this.issend.Visible = false;
             this.issend.Width = 200;
             // 
-            // button2
-            // 
-            this.button2.Location = new System.Drawing.Point(666, 893);
-            this.button2.Name = "button2";
-            this.button2.Size = new System.Drawing.Size(160, 42);
-            this.button2.TabIndex = 28;
-            this.button2.Text = "excel";
-            this.button2.UseVisualStyleBackColor = true;
-            this.button2.Click += new System.EventHandler(this.button2_Click);
-            // 
             // Query_SOP_CY
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 24F);

+ 42 - 75
UAS_MES_YDCY/FunctionCode/Query/Query_SOP_CY.cs

@@ -97,8 +97,48 @@ namespace UAS_MES_NEW.Query
                     Worksheet she = workbook.Worksheets[i];
                     if (JPG.Checked)
                     {
-                        var myThread = new Thread(() => SaveFileToJPG(she));
-                        myThread.Start();
+                        try
+                        {
+                            DataHelper dh = new DataHelper();
+                            if (!Directory.Exists(Application.StartupPath + @"\" + ps_prodcode.Text))
+                            {
+                                Directory.CreateDirectory(Application.StartupPath + @"\" + ps_prodcode.Text);
+                            }
+                            string sheetname = she.Name;
+                            sheetname = sheetname.Replace("01", "1");
+                            sheetname = sheetname.Replace("02", "2");
+                            sheetname = sheetname.Replace("03", "3");
+                            sheetname = sheetname.Replace("04", "4");
+                            sheetname = sheetname.Replace("05", "5");
+                            sheetname = sheetname.Replace("06", "6");
+                            sheetname = sheetname.Replace("07", "7");
+                            sheetname = sheetname.Replace("08", "8");
+                            sheetname = sheetname.Replace("09", "9");
+                           
+                            ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();
+                            imgOptions.ImageFormat = ImageFormat.Png;
+                            imgOptions.OnePagePerSheet = true;
+                            imgOptions.CheckWorkbookDefaultFont = false;
+                            imgOptions.DefaultFont = "宋体";
+                            imgOptions.PrintingPage = PrintingPageType.IgnoreBlank;
+                            imgOptions.SetDesiredSize(1565, 1043);
+                            SheetRender sr = new SheetRender((Aspose.Cells.Worksheet)she, imgOptions);
+                            sr.ToImage(0, Application.StartupPath + @"\" + ps_prodcode.Text + @"\" + sheetname + ".jpg");
+                            //// 创建一个图片
+                            OperatResult.AppendText("解析图片【" + sheetname + ".jpg】" + "\n");
+                            Dictionary<string, object> dic = new Dictionary<string, object>();
+                            dic.Add("em_name", "管理员");
+                            dic.Add("em_code", "ADMIN");
+                            dic.Add("caller", "ProductSOP");
+                            OperatResult.AppendText("上传文件【" + sheetname + ".jpg" + "】\n");
+                            string fp_id = UploadFilesToRemoteUrl("http://192.168.0.85:8099/mes/MEScommon/uploadFiles.action?_noc=1", Application.StartupPath + @"\" + ps_prodcode.Text + @"\" + sheetname + ".jpg", dic);
+                            string ps_id = dh.getFieldDataByCondition("ProductSOP", "ps_id", "ps_prodcode='" + ps_prodcode.Text + "'").ToString();
+                            dh.ExecuteSql("insert into ProductSOPdetail(psd_id,psd_psid,psd_attach) select ProductSOPdetail_seq.nextval,ps_id,'" + sheetname + ".jpg" + ";" + fp_id + "' from ProductSOP where ps_prodcode='" + ps_prodcode.Text + "'", "insert");
+                        }
+                        catch (Exception ex)
+                        {
+                            OperatResult.AppendText(ex.Message + ex.StackTrace);
+                        }
                         filename.Add(she.Name + ".jpg");
                     }
                 }
@@ -109,79 +149,6 @@ namespace UAS_MES_NEW.Query
             }
         }
 
-        private void SaveFileToJPG(Worksheet sheet)
-        {
-            try
-            {
-                DataHelper dh = new DataHelper();
-                //OperatResult.AppendText("解析图片【" + sheet.Name + ".jpg】添加水印" + "\n");
-                if (!Directory.Exists(Application.StartupPath + @"\" + ps_prodcode.Text))
-                {
-                    Directory.CreateDirectory(Application.StartupPath + @"\" + ps_prodcode.Text);
-                }
-                string sheetname = sheet.Name;
-                sheetname = sheetname.Replace("01", "1");
-                sheetname = sheetname.Replace("02", "2");
-                sheetname = sheetname.Replace("03", "3");
-                sheetname = sheetname.Replace("04", "4");
-                sheetname = sheetname.Replace("05", "5");
-                sheetname = sheetname.Replace("06", "6");
-                sheetname = sheetname.Replace("07", "7");
-                sheetname = sheetname.Replace("08", "8");
-                sheetname = sheetname.Replace("09", "9");
-                //if (sheetname.Contains("-"))
-                //{
-                //    sheetname = sheetname.Split('-')[0];
-                //}
-                int width = 0;
-                int height = 0;
-                //Console.WriteLine(sheet.Name);
-                //for (int i = 0; i < sheet.Cells.Columns.Count; i++)
-                //{
-                //    width +=(int) sheet.Cells.Columns[i].Width;
-                //}
-                //for (int i = 0; i < sheet.Cells.Rows.Count; i++)
-                //{
-                //    height += (int)sheet.Cells.Rows[i].Height;
-                //}
-                //Console.WriteLine("width:"+width);
-                //Console.WriteLine("height:"+height);
-                //sheet.Pictures.Add(0, 18, @"图片\电子受控章.png");
-                //sheet.Pictures.Add(0, 15, @"图片\签名.png");
-                //sheet.PageSetup.LeftMargin = 0;
-                //sheet.PageSetup.RightMargin = 0;
-                //sheet.PageSetup.BottomMargin = 0;
-                //sheet.PageSetup.TopMargin = 0;
-                ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();
-                imgOptions.ImageFormat = ImageFormat.Png;
-                imgOptions.OnePagePerSheet = true;
-                imgOptions.CheckWorkbookDefaultFont = false;
-                imgOptions.DefaultFont = "宋体";
-                imgOptions.PrintingPage = PrintingPageType.IgnoreBlank;
-                imgOptions.SetDesiredSize(1565, 1043);
-                SheetRender sr = new SheetRender((Aspose.Cells.Worksheet)sheet, imgOptions);
-                sr.ToImage(0, Application.StartupPath + @"\" + ps_prodcode.Text + @"\" + sheetname + ".jpg");
-                //// 创建一个图片
-                OperatResult.AppendText("解析图片【" + sheetname + ".jpg】" + "\n");
-                Dictionary<string, object> dic = new Dictionary<string, object>();
-                dic.Add("em_name", "管理员");
-                dic.Add("em_code", "ADMIN");
-                dic.Add("caller", "ProductSOP");
-                OperatResult.AppendText("上传文件【" + sheetname + ".jpg" + "】\n");
-                //string fp_id = UploadFilesToRemoteUrl("http://192.168.0.85:8099/mes/MEScommon/uploadFiles.action?_noc=1", Application.StartupPath + @"\" + ps_prodcode.Text + @"\" + sheetname + ".jpg", dic);
-                //string ps_id = dh.getFieldDataByCondition("ProductSOP", "ps_id", "ps_prodcode='" + ps_prodcode.Text + "'").ToString();
-                //dh.ExecuteSql("insert into ProductSOPdetail(psd_id,psd_psid,psd_attach) select ProductSOPdetail_seq.nextval,ps_id,'" + sheetname + ".jpg" + ";" + fp_id + "' from ProductSOP where ps_prodcode='" + ps_prodcode.Text + "'", "insert");
-                //if (fp_id != "")
-                //{
-                //    dh.ExecuteSql("update ProductSOP set ps_attachsop=ps_attachsop||" + fp_id + "||';' where ps_prodcode='" + pr_code.Text + "'", "update");
-                //}
-            }
-            catch (Exception ex)
-            {
-                OperatResult.AppendText(ex.Message + ex.StackTrace);
-            }
-        }
-
         /// <summary>
         /// 请求上传图片到阿里云
         /// </summary>

+ 0 - 15
UAS_MES_YDCY/FunctionCode/Query/Query_SOP_CY.resx

@@ -135,19 +135,4 @@
   <metadata name="issend.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>
-  <metadata name="CheckColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
-  <metadata name="fp_name.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
-  <metadata name="fp_path.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
-  <metadata name="psd_iskey.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
-  <metadata name="issend.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
 </root>

BIN
UAS_MES_YDCY/Tool/Aspose.Pdf.dll


+ 8 - 3
UAS_MES_YDCY/UAS_MES_YDCY.csproj

@@ -75,8 +75,12 @@
     <StartupObject>UAS_MES_NEW.Program</StartupObject>
   </PropertyGroup>
   <ItemGroup>
-    <Reference Include="Aspose.Cells">
-      <HintPath>Tool\Aspose.Cells.dll</HintPath>
+    <Reference Include="Aspose.Cells, Version=18.4.0.0, Culture=neutral, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\UAS_MES_BG\Tool\Aspose.Cells.dll</HintPath>
+    </Reference>
+    <Reference Include="Aspose.Pdf">
+      <HintPath>Tool\Aspose.Pdf.dll</HintPath>
     </Reference>
     <Reference Include="DevComponents.DotNetBar2, Version=6.7.2.0, Culture=neutral, PublicKeyToken=bd7258ab2241255c, processorArchitecture=MSIL">
       <SpecificVersion>False</SpecificVersion>
@@ -177,7 +181,8 @@
     <Reference Include="System.Drawing" />
     <Reference Include="System.Windows.Forms" />
     <Reference Include="System.Xml" />
-    <Reference Include="ZeroAndOne_ApiN">
+    <Reference Include="ZeroAndOne_ApiN, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
       <HintPath>Tool\ZeroAndOne_ApiN.dll</HintPath>
     </Reference>
   </ItemGroup>