Browse Source

添加PDF功能

callm 4 days ago
parent
commit
7376fe5a2d

+ 66 - 80
FileWatcher/AutoAnalysisXml.cs

@@ -7,6 +7,8 @@ using System.Threading;
 using System.Windows.Forms;
 using System.Xml;
 using System.Text;
+using System.Media;
+using NPOI.SS.Formula.Functions;
 
 namespace FileWatcher
 {
@@ -103,7 +105,7 @@ namespace FileWatcher
             {
                 if (Master.Text == DB.Rows[i]["ma_user"].ToString())
                 {
-                    DataHelper.DBConnectionString = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=HUAG;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=113.98.196.181)(PORT=1520)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
+                    DataHelper.DBConnectionString = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=GHKJ;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=113.98.196.181)(PORT=1520)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
                     dh = new DataHelper();
                 }
             }
@@ -308,116 +310,100 @@ namespace FileWatcher
                         {
                             string Result = "";
                             string makecode = ma_code.Text;
-                            string oErrMessage = "";
-                            string oMSID = "";
-                            string ms_sncode = dh.getFieldDataByCondition("makeserial", "ms_sncode", "substr(ms_sncode,0,12)='" + SN + "' order by ms_id").ToString();
-                            isource = sc_code.Text;
-                            iusercode = em_code.Text;
-                            DataTable dt = (DataTable)dh.ExecuteSql("select sc_linecode,sc_stepcode,st_badgroupcode from source left join step on sc_stepcode=st_code where sc_code='" + isource + "'", "select");
-                            if (dt.Rows.Count > 0)
+
+                            string ms_sncode = dh.getFieldDataByCondition("steppassed", "sp_sncode", "substr(sp_sncode,0,12)='" + SN + "' order by sp_id").ToString();
+                            if (ms_sncode == "")
                             {
-                                ilinecode = dt.Rows[0]["sc_linecode"].ToString();
-                                istepcode = dt.Rows[0]["sc_stepcode"].ToString();
-                                ibadgroup = dt.Rows[0]["st_badgroupcode"].ToString();
+                                OperateResult.AppendText("序列号: " + SN + "前工段未扫描\n");
                             }
-                            if (LogicHandler.CheckStepSNAndMacode("", isource, ms_sncode, iusercode, out makecode, out oMSID, out oErrMessage))
+                            else
                             {
+                                isource = sc_code.Text;
+                                iusercode = em_code.Text;
+                                DataTable dt = (DataTable)dh.ExecuteSql("select sc_linecode,sc_stepcode,st_badgroupcode from source left join step on sc_stepcode=st_code where sc_code='" + isource + "'", "select");
+                                if (dt.Rows.Count > 0)
+                                {
+                                    ilinecode = dt.Rows[0]["sc_linecode"].ToString();
+                                    istepcode = dt.Rows[0]["sc_stepcode"].ToString();
+                                    ibadgroup = dt.Rows[0]["st_badgroupcode"].ToString();
+                                }
                                 ma_code.Text = makecode;
-                                if (LogicHandler.SetStepResult(makecode, isource, ms_sncode, "自动过站采集", "OK", iusercode, out oErrMessage))
+                                try
                                 {
-                                    try
+                                    string ftppath = "/" + DateTime.Now.ToString("yyyy-MM-dd") + "/";
+                                    OperateResult.AppendText("开始上传日志:" + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss fff") + "\n");
+                                    ftp.UpLoadFile(folderpath, SN + ".txt", ftppath, "");
+                                    OperateResult.AppendText("上传日志结束:" + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss fff") + "\n");
+                                    int num = int.Parse(dh.ExecuteSql("insert into STEPTESTDETAIL (std_id,std_sn,std_makecode,std_indate,std_class)select STEPTESTDETAIL_seq.nextval,ms_sncode,ms_makecode,sysdate,'http://113.98.196.181:8099/ftp" + ftppath + SN + ".txt" + "' from makeserial where substr(ms_sncode,0,12)='" + SN + "'", "insert").ToString());
+                                    if (num > 0)
                                     {
-                                        string ftppath = "/" + DateTime.Now.ToString("yyyy-MM-dd") + "/";
-                                        ftp.UpLoadFile(folderpath, SN + ".txt", ftppath, "");
-                                        int num = int.Parse(dh.ExecuteSql("insert into STEPTESTDETAIL (std_id,std_sn,std_makecode,std_indate,std_class)select STEPTESTDETAIL_seq.nextval,ms_sncode,ms_makecode,sysdate,'http://113.98.196.181:8099/ftp" + ftppath + SN + ".txt" + "' from makeserial where substr(ms_sncode,0,12)='" + SN + "'", "insert").ToString());
-                                        if (num > 0)
-                                        {
-                                            OperateResult.AppendText("序列号:" + SN + "上传成功\n");
-                                            if (BackUpFolderPath.Text != "")
-                                                File.Move(filename, BackUpFolderPath.Text + "/" + SN + ".txt");
-                                        }
-                                        else
-                                        {
-                                            OperateResult.AppendText("序列号: " + SN + "前工段未扫描\n");
-                                            MessageBox.Show("序列号: " + ms_sncode + "前工段未扫描", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
-                                        }
+                                        OperateResult.AppendText("序列号:" + SN + "上传成功\n");
+                                        if (BackUpFolderPath.Text != "")
+                                            File.Move(filename, BackUpFolderPath.Text + "/" + SN + ".txt");
+                                        //SafeDeleteFile(FileName);
                                     }
-                                    catch (Exception ex)
+                                    else
                                     {
-                                        Console.WriteLine(ex.Message);
+                                        OperateResult.AppendText("序列号: " + SN + "前工段未扫描\n");
+                                        MessageBox.Show("序列号: " + ms_sncode + "前工段未扫描", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
                                     }
                                 }
-                                else
+                                catch (Exception ex)
                                 {
-                                    OperateResult.AppendText(oErrMessage + "\n");
-                                    tipform.startthread(oErrMessage, Result);
-
+                                    Console.WriteLine(ex.Message);
                                 }
                                 tipform.startthread("序列号 " + ms_sncode + "通过检测", Result);
                             }
-                            else
-                            {
-                                OperateResult.AppendText(oErrMessage + "\n");
-                                tipform.startthread(oErrMessage, Result);
-                            }
                         }
                         else
                         {
                             string Result = "";
                             string makecode = ma_code.Text;
-                            string oErrMessage = "";
-                            string oMSID = "";
-                            string ms_sncode = dh.getFieldDataByCondition("makeserial", "ms_sncode", "ms_sncode='" + SN + "' order by ms_id").ToString();
+                            string ms_sncode = dh.getFieldDataByCondition("steppassed", "sp_sncode", "sp_sncode='" + SN + "' order by sp_id").ToString();
                             isource = sc_code.Text;
                             iusercode = em_code.Text;
-                            DataTable dt = (DataTable)dh.ExecuteSql("select sc_linecode,sc_stepcode,st_badgroupcode from source left join step on sc_stepcode=st_code where sc_code='" + isource + "'", "select");
-                            if (dt.Rows.Count > 0)
+                            if (ms_sncode == "")
                             {
-                                ilinecode = dt.Rows[0]["sc_linecode"].ToString();
-                                istepcode = dt.Rows[0]["sc_stepcode"].ToString();
-                                ibadgroup = dt.Rows[0]["st_badgroupcode"].ToString();
+                                OperateResult.AppendText("序列号: " + SN + "前工段未扫描\n");
                             }
-                            if (LogicHandler.CheckStepSNAndMacode("", isource, ms_sncode, iusercode, out makecode, out oMSID, out oErrMessage))
+                            else
                             {
+                                DataTable dt = (DataTable)dh.ExecuteSql("select sc_linecode,sc_stepcode,st_badgroupcode from source left join step on sc_stepcode=st_code where sc_code='" + isource + "'", "select");
+                                if (dt.Rows.Count > 0)
+                                {
+                                    ilinecode = dt.Rows[0]["sc_linecode"].ToString();
+                                    istepcode = dt.Rows[0]["sc_stepcode"].ToString();
+                                    ibadgroup = dt.Rows[0]["st_badgroupcode"].ToString();
+                                }
                                 ma_code.Text = makecode;
-                                if (LogicHandler.SetStepResult(makecode, isource, ms_sncode, "自动过站采集", "OK", iusercode, out oErrMessage))
+                                try
                                 {
-                                    try
-                                    {
-                                        string ftppath = "/" + DateTime.Now.ToString("yyyy-MM-dd") + "/";
-                                        OperateResult.AppendText("开始上传日志:"+DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss fff") + "\n");
-                                        ftp.UpLoadFile(folderpath, SN + ".txt", ftppath, "");
-                                        OperateResult.AppendText("结束上传日志"+DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss fff") + "\n");
-                                        int num = int.Parse(dh.ExecuteSql("insert into STEPTESTDETAIL (std_id,std_sn,std_makecode,std_indate,std_class)select STEPTESTDETAIL_seq.nextval,ms_sncode,ms_makecode,sysdate,'http://113.98.196.181:8099/ftp" + ftppath + SN + ".txt" + "' from makeserial where ms_sncode='" + SN + "'", "insert").ToString());
-                                        if (num > 0)
-                                        {
-                                            OperateResult.AppendText("序列号:" + SN + "上传成功\n");
-                                            if (BackUpFolderPath.Text != "")
-                                                File.Move(filename, BackUpFolderPath.Text + "/" + SN + ".txt");
-                                        }
-                                        else
-                                        {
-                                            OperateResult.AppendText("序列号: " + SN + "前工段未扫描\n");
-                                            MessageBox.Show("序列号: " + ms_sncode + "前工段未扫描", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
-                                        }
-                                    }
-                                    catch (Exception ex)
-                                    {
-                                        Console.WriteLine(ex.Message);
-                                    }
+                                    string ftppath = "/" + DateTime.Now.ToString("yyyy-MM-dd") + "/";
+                                    OperateResult.AppendText("开始上传日志:" + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss fff") + "\n");
+                                    ftp.UpLoadFile(folderpath, SN + ".txt", ftppath, "");
+                                    OperateResult.AppendText("上传日志结束:" + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss fff") + "\n");
+                                    int num = int.Parse(dh.ExecuteSql("insert into STEPTESTDETAIL (std_id,std_sn,std_makecode,std_indate,std_class)select STEPTESTDETAIL_seq.nextval,ms_sncode,ms_makecode,sysdate,'http://113.98.196.181:8099/ftp" + ftppath + SN + ".txt" + "' from makeserial where ms_sncode='" + SN + "'", "insert").ToString());
+                                    OperateResult.AppendText("序列号:" + SN + "上传成功\n");
+                                    if (BackUpFolderPath.Text != "")
+                                        File.Move(filename, BackUpFolderPath.Text + "/" + SN + ".txt");
+                                    //if (num > 0)
+                                    //{
+                                       
+                                    //    //SafeDeleteFile(FileName);
+                                    //}
+                                    //else
+                                    //{
+                                    //    OperateResult.AppendText("序列号: " + SN + "前工段未扫描\n");
+                                    //    MessageBox.Show("序列号: " + ms_sncode + "前工段未扫描", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
+                                    //}
                                 }
-                                else
+                                catch (Exception ex)
                                 {
-                                    OperateResult.AppendText(oErrMessage + "\n");
-                                    tipform.startthread(oErrMessage, Result);
+                                    Console.WriteLine(ex.Message);
                                 }
+
                                 tipform.startthread("序列号 " + ms_sncode + "通过检测", Result);
                             }
-                            else
-                            {
-                                OperateResult.AppendText(oErrMessage + "\n");
-                                tipform.startthread(oErrMessage, Result);
-                            }
                         }
                         OperateResult.AppendText("解析成功:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\n" + FileName + "\n");
                     }

+ 2 - 2
FileWatcher/DataHelper.cs

@@ -41,9 +41,9 @@ namespace FileWatcher
         ////用户选择的数据库的连接字符串
         //public static string DBConnectionString = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=N_MES;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=172.22.100.2)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
 
-        private string ConnectionStrings = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=HUAG;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=113.98.196.181)(PORT=1520)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
+        private string ConnectionStrings = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=GHKJ;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=113.98.196.181)(PORT=1520)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
         //用户选择的数据库的连接字符串
-        public static string DBConnectionString = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=HUAG;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=113.98.196.181)(PORT=1520)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
+        public static string DBConnectionString = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=GHKJ;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=113.98.196.181)(PORT=1520)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
 
 
         public static OracleConnection connection = null;

+ 3 - 0
FileWatcher/FileWatcher.csproj

@@ -68,6 +68,9 @@
     <Reference Include="Aspose.Cells">
       <HintPath>tool\Aspose.Cells.dll</HintPath>
     </Reference>
+    <Reference Include="Aspose.Pdf">
+      <HintPath>tool\Aspose.Pdf.dll</HintPath>
+    </Reference>
     <Reference Include="EPPlus, Version=8.0.5.0, Culture=neutral, PublicKeyToken=ea159fdaa78159a1, processorArchitecture=MSIL">
       <HintPath>..\packages\EPPlus.8.0.5\lib\net35\EPPlus.dll</HintPath>
     </Reference>

+ 0 - 3
FileWatcher/SOP.cs

@@ -5,14 +5,11 @@ using System.Windows.Forms;
 using System.Net;
 using System.Collections.Generic;
 using System.Threading;
-using System.Net.Sockets;
 using System.Data;
 using System.Web.Script.Serialization;
 using Aspose.Cells.Rendering;
 using Aspose.Cells;
 using System.Drawing.Imaging;
-using System.Drawing;
-using System.Windows.Media;
 
 namespace FileWatcher
 {

BIN
FileWatcher/tool/Aspose.Pdf.dll