Browse Source

修改文件监控项目

callm 1 year ago
parent
commit
d5eed8445c

BIN
FileWatcher/11.8.6/Spire.License.dll


BIN
FileWatcher/11.8.6/Spire.Pdf.dll


BIN
FileWatcher/11.8.6/Spire.XLS.dll


BIN
FileWatcher/3.8.6/Spire.Common.dll


BIN
FileWatcher/3.8.6/Spire.License.dll


BIN
FileWatcher/3.8.6/Spire.Pdf.dll


BIN
FileWatcher/3.8.6/Spire.XLS.dll


+ 5 - 5
FileWatcher/AutoAnalysisDevice.cs

@@ -125,7 +125,7 @@ namespace FileWatcher
 
         private void ConnectDB()
         {
-            DataHelper.DBConnectionString = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=N_MES;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.6.253)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
+            DataHelper.DBConnectionString = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=N_MES;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.101.253)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
             dh = new DataHelper();
         }
 
@@ -255,8 +255,8 @@ namespace FileWatcher
                         };
                         string fp_id;
                         string fp_path;
-                        UploadFilesToRemoteUrl("http://192.168.6.253:8099/mes/MEScommon/uploadFiles.action?_noc=1", filename, dic, out fp_path, out fp_id);
-                        fp_path = "http://192.168.6.253:8099/" + fp_path.Replace("/app/uas/webapps/", "");
+                        UploadFilesToRemoteUrl("http://192.168.101.253:8099/mes/MEScommon/uploadFiles.action?_noc=1", filename, dic, out fp_path, out fp_id);
+                        fp_path = "http://192.168.101.253:8099/" + fp_path.Replace("/app/uas/webapps/", "");
                         fp_path = fp_path.Replace("\"", "");
                         dh.ExecuteSql("insert into Devicetestinfo(dti_id,dti_account,dti_stepcode,dti_makecode,dti_prodcode,dti_area,dti_uptime,dti_downtime,dti_upqty,dti_okqty,dti_ngqty,dti_ipaddress,dti_filepath,dti_indate,dti_fpid,dti_type)values(Devicetestinfo_seq.nextval,'" + filedt.Rows[i]["登陆的账号"].ToString() + "','"+ filedt.Rows[i]["工位固定号"].ToString() + "','"+ filedt.Rows[i]["计划单号"].ToString() + "','" + filedt.Rows[i]["产品代码"].ToString() + "','" + filedt.Rows[i]["区域"].ToString() + "',to_date('" + filedt.Rows[i]["上架时间"].ToString() + "','yyyy/mm/dd hh24:mi:ss'),to_date('" + filedt.Rows[i]["下架时间"].ToString() + "','yyyy/mm/dd hh24:mi:ss'),'" + filedt.Rows[i]["上架数量"].ToString() + "','" + filedt.Rows[i]["合格数量"].ToString() + "','" + filedt.Rows[i]["不良数量"].ToString() + "','" + IPAddress + "','" + fp_path + "',sysdate,'" + fp_id + "','老化')", "insert");
                         OperateResult.AppendText("上传文件" + filename + "\n");
@@ -344,8 +344,8 @@ namespace FileWatcher
                         };
                         string fp_id;
                         string fp_path;
-                        UploadFilesToRemoteUrl("http://192.168.6.253:8099/mes/MEScommon/uploadFiles.action?_noc=1", filename, dic, out fp_path, out fp_id);
-                        fp_path = "http://192.168.6.253:8099/" + fp_path.Replace("/app/uas/webapps/", "");
+                        UploadFilesToRemoteUrl("http://192.168.101.253:8099/mes/MEScommon/uploadFiles.action?_noc=1", filename, dic, out fp_path, out fp_id);
+                        fp_path = "http://192.168.101.253:8099/" + fp_path.Replace("/app/uas/webapps/", "");
                         fp_path = fp_path.Replace("\"", "");
                         dh.ExecuteSql("insert into Devicetestinfo(dti_id,dti_prodcode,dti_uptime,dti_downtime,dti_upqty,dti_okqty,dti_ngqty,dti_ipaddress,dti_filepath,dti_indate,dti_fpid,dti_account,dti_stepcode,dti_makecode,dti_param,dti_route,dti_type)values(Devicetestinfo_seq.nextval,'" + filedt.Rows[i]["产品代码"].ToString() + "',to_date('" + filedt.Rows[i]["开始时间"].ToString() + "','yyyy/mm/dd hh24:mi:ss'),to_date('" + filedt.Rows[i]["结束时间"].ToString() + "','yyyy/mm/dd hh24:mi:ss'),'" + filedt.Rows[i]["上架数量"].ToString() + "','" + filedt.Rows[i]["合格数量"].ToString() + "','" + filedt.Rows[i]["不良数量"].ToString() + "','" + IPAddress + "','" + fp_path + "',sysdate,'" + fp_id + "','" + filedt.Rows[i]["登录的账号"].ToString() + "','" + filedt.Rows[i]["工位固定号"].ToString() + "','" + filedt.Rows[i]["计划单号"].ToString() + "','" + filedt.Rows[i]["使用参数名"].ToString() + "','" + filedt.Rows[i]["通道"].ToString() + "','ATE')", "insert");
                         OperateResult.AppendText("上传文件" + filename + "\n");

+ 29 - 0
FileWatcher/AutoAnalysisXml.Designer.cs

@@ -47,6 +47,8 @@
             this.Timer = new System.Windows.Forms.Timer(this.components);
             this.Device = new System.Windows.Forms.ComboBox();
             this.label3 = new System.Windows.Forms.Label();
+            this.MAC = new System.Windows.Forms.RadioButton();
+            this.SN = new System.Windows.Forms.RadioButton();
             ((System.ComponentModel.ISupportInitialize)(this.XmlWatcher)).BeginInit();
             this.SuspendLayout();
             // 
@@ -166,6 +168,7 @@
             this.Master.Name = "Master";
             this.Master.Size = new System.Drawing.Size(436, 32);
             this.Master.TabIndex = 15;
+            this.Master.Visible = false;
             // 
             // AutoStart
             // 
@@ -229,11 +232,35 @@
             this.label3.TabIndex = 19;
             this.label3.Text = "设备选择";
             // 
+            // MAC
+            // 
+            this.MAC.AutoSize = true;
+            this.MAC.Checked = true;
+            this.MAC.Location = new System.Drawing.Point(218, 473);
+            this.MAC.Name = "MAC";
+            this.MAC.Size = new System.Drawing.Size(77, 28);
+            this.MAC.TabIndex = 21;
+            this.MAC.TabStop = true;
+            this.MAC.Text = "MAC";
+            this.MAC.UseVisualStyleBackColor = true;
+            // 
+            // SN
+            // 
+            this.SN.AutoSize = true;
+            this.SN.Location = new System.Drawing.Point(334, 473);
+            this.SN.Name = "SN";
+            this.SN.Size = new System.Drawing.Size(65, 28);
+            this.SN.TabIndex = 22;
+            this.SN.Text = "SN";
+            this.SN.UseVisualStyleBackColor = true;
+            // 
             // AutoAnalysisXml
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 24F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.ClientSize = new System.Drawing.Size(1443, 640);
+            this.Controls.Add(this.SN);
+            this.Controls.Add(this.MAC);
             this.Controls.Add(this.Device);
             this.Controls.Add(this.label3);
             this.Controls.Add(this.BatchAnalysus);
@@ -281,6 +308,8 @@
         private System.Windows.Forms.Timer Timer;
         private System.Windows.Forms.ComboBox Device;
         private System.Windows.Forms.Label label3;
+        private System.Windows.Forms.RadioButton SN;
+        private System.Windows.Forms.RadioButton MAC;
     }
 }
 

+ 159 - 60
FileWatcher/AutoAnalysisXml.cs

@@ -7,6 +7,7 @@ using System.Threading;
 using System.Windows.Forms;
 using System.Xml;
 using System.Text;
+using System.Media;
 
 namespace FileWatcher
 {
@@ -57,8 +58,6 @@ namespace FileWatcher
         /// </summary>
         List<string> _FileName = new List<string>();
 
-        string master="WKS";
-
         ftpOperater ftp = new ftpOperater();
 
         public AutoAnalysisXml()
@@ -68,13 +67,12 @@ namespace FileWatcher
             StartPosition = FormStartPosition.CenterScreen;
         }
 
-        public AutoAnalysisXml(string iUserName, string iSource,string iMaster)
+        public AutoAnalysisXml(string iUserName, string iSource)
         {
             tipform = new Tip();
             InitializeComponent();
             iusercode = iUserName;
             isource = iSource.ToUpper();
-            master = iMaster;
             StartPosition = FormStartPosition.CenterScreen;
         }
 
@@ -90,6 +88,10 @@ namespace FileWatcher
             stw.StartPosition = FormStartPosition.CenterScreen;
             stw.ShowDialog();
             List<string> CacheInf = new List<string>();
+            DB = (DataTable)dh.ExecuteSql("select ms_pwd,ma_user,ma_address,ma_inneraddress from master where ma_user='MES'", "select");
+            Master.DataSource = DB;
+            Master.DisplayMember = "ma_user";
+            Master.ValueMember = "ma_user";
             //获取缓存信息
             try
             {
@@ -99,6 +101,14 @@ namespace FileWatcher
                 //AutoStart.Checked = (bool)BaseUtil.GetCacheData("AutoStart");
             }
             catch (Exception ex) { MessageBox.Show(ex.Message); }
+            for (int i = 0; i < DB.Rows.Count; i++)
+            {
+                if (Master.Text == DB.Rows[i]["ma_user"].ToString())
+                {
+                    DataHelper.DBConnectionString = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=DGW;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=81.71.42.91)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
+                    dh = new DataHelper();
+                }
+            }
             //获取岗位资源相关信息
             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)
@@ -111,7 +121,6 @@ namespace FileWatcher
 
         private void ConnectDB()
         {
-            DataHelper.DBConnectionString = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=" + master + ";Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=81.71.42.91)(PORT=11678)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
             dh = new DataHelper();
         }
 
@@ -130,15 +139,15 @@ namespace FileWatcher
                     return;
                 }
             }
-            //for (int i = 0; i < DB.Rows.Count; i++)
-            //{
-            //    if (Master.Text == DB.Rows[i]["ma_user"].ToString())
-            //    {
-            //        DataHelper.DBConnectionString = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=DGW;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=81.71.42.91)(PORT=11678)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
-            //        dh = new DataHelper();
-            //        LogicHandler.dh = new DataHelper();
-            //    }
-            //}
+            for (int i = 0; i < DB.Rows.Count; i++)
+            {
+                if (Master.Text == DB.Rows[i]["ma_user"].ToString())
+                {
+                    DataHelper.DBConnectionString = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=DGW;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=81.71.42.91)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
+                    dh = new DataHelper();
+                    LogicHandler.dh = new DataHelper();
+                }
+            }
             //存在工单必须是已下放状态
             if ((!dh.CheckExist("make", "ma_statuscode='STARTED' and ma_code='" + ma_code.Text + "'") || ma_code.Text == "") && Device.Text == "AOI设备")
             {
@@ -153,8 +162,6 @@ namespace FileWatcher
             //BaseUtil.SetCacheData("BackUpFolderPath", BackUpFolderPath.Text);
             //BaseUtil.SetCacheData("Master", Master.Text);
             //BaseUtil.SetCacheData("AutoStart", AutoStart.Checked);
-            Timer.Interval = 1000 * 10;
-            Timer.Start();
             //设置按钮不可点击
             StartWatch.Enabled = false;
             ChooseFolder.Enabled = false;
@@ -173,32 +180,32 @@ namespace FileWatcher
 
         private void XmlWatcher_Created(object sender, FileSystemEventArgs e)
         {
-            //while (true)
-            //{
-            //    try
-            //    {
-            //        using (Stream stream = File.Open(e.FullPath, FileMode.Open, FileAccess.Read, FileShare.Read))
-            //        {
-            //            if (stream != null)
-            //                break;
-            //        }
-            //    }
-            //    catch (Exception ex)
-            //    {
-            //        Console.WriteLine(ex.Message);
-            //    }
-            //}
-            //switch (e.Name.Substring(e.Name.LastIndexOf(".") + 1).ToUpper())
-            //{
-            //    case "TXT":
-            //        TxtHandleProcess(e.FullPath);
-            //        break;
-            //    case "XML":
-            //        XmlHandleProcess(e.FullPath);
-            //        break;
-            //    default:
-            //        break;
-            //}
+            while (true)
+            {
+                try
+                {
+                    using (Stream stream = File.Open(e.FullPath, FileMode.Open, FileAccess.Read, FileShare.Read))
+                    {
+                        if (stream != null)
+                            break;
+                    }
+                }
+                catch (Exception ex)
+                {
+                    Console.WriteLine(ex.Message);
+                }
+            }
+            switch (e.Name.Substring(e.Name.LastIndexOf(".") + 1).ToUpper())
+            {
+                case "TXT":
+                    TxtHandleProcess(e.FullPath);
+                    break;
+                case "XML":
+                    XmlHandleProcess(e.FullPath);
+                    break;
+                default:
+                    break;
+            }
         }
         string nextLine;
         private void TxtHandleProcess(string FileName)
@@ -260,7 +267,7 @@ namespace FileWatcher
                         {
                             Result = "NG";
                             //只添加一条记录
-                            if (badcode.Count == 0 && filedt.Rows[i]["w_ng_name"].ToString() != "")
+                            if (badcode.Count == 0)
                             {
                                 badcode.Add(filedt.Rows[i]["w_ng_name"].ToString());
                                 badlocation.Add(filedt.Rows[i]["c_subboard_number"].ToString());
@@ -312,7 +319,7 @@ namespace FileWatcher
                 {
                     OperateResult.AppendText(oErrMessage + "\n");
                     tipform.startthread(oErrMessage, Result);
-                    //File.Delete(FileName);
+                    File.Delete(FileName);
                 }
             }
             else if (Device.Text == "测试设备")
@@ -324,26 +331,123 @@ namespace FileWatcher
                     {
                         string folderpath = FileName.Substring(0, FileName.LastIndexOf(@"\"));
                         string SN = FileName.Substring(FileName.LastIndexOf(@"\") + 1).Replace("-", "/").ToUpper().Replace(".TXT", "");
-                        if (SN.Length == 12)
+                        if (MAC.Checked)
                         {
-                            string ms_sncode = dh.getFieldDataByCondition("steppassed", "sp_sncode", "substr(sp_sncode,0,12)='" + SN + "' order by sp_id desc").ToString();
-                            string ms_makecode = dh.getFieldDataByCondition("steppassed", "sp_makecode", "substr(sp_sncode,0,12)='" + SN + "' order by sp_id desc").ToString();
+                            string Result = "";
                             string makecode = ma_code.Text;
-                            string ftppath = "/"+master+"/" + 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://81.71.42.91:8099/ftp" + ftppath + SN + ".txt" + "' from dual ", "insert").ToString());
-                            if (num > 0)
+                            string oErrMessage = "";
+                            string oMSID = "";
+                            string ms_sncode = dh.getFieldDataByCondition("makeserial", "ms_sncode", "substr(ms_sncode,0,12)='" + SN + "' order by ms_id").ToString();
+                            isource = "SMT_01_TEST01";
+                            iusercode = "SMT_01_TEST01";
+                            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();
+                            }
+                            if (LogicHandler.CheckStepSNAndMacode(ma_code.Text, isource, ms_sncode, iusercode, out makecode, out oMSID, out oErrMessage))
+                            {
+                                ma_code.Text = makecode;
+                                if (LogicHandler.SetStepResult(makecode, isource, ms_sncode, "自动过站采集", "OK", iusercode, out oErrMessage))
+                                {
+                                    try
+                                    {
+                                        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://81.71.42.91:8099/ftp" + ftppath + SN + ".txt" + "' from makeserial where substr(ms_sncode,0,12)='" + SN + "'", "insert").ToString());
+                                        if (num > 0)
+                                        {
+                                            OperateResult.AppendText("序列号:" + SN + "上传成功\n");
+                                            File.Delete(FileName);
+                                        }
+                                        else
+                                        {
+                                            OperateResult.AppendText("序列号: " + SN + "前工段未扫描\n");
+                                            MessageBox.Show("序列号: " + ms_sncode + "前工段未扫描", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
+                                        }
+                                    }
+                                    catch (Exception ex)
+                                    {
+                                        Console.WriteLine(ex.Message);
+                                    }
+                                }
+                                else
+                                {
+                                    OperateResult.AppendText(oErrMessage + "\n");
+                                    tipform.startthread(oErrMessage, Result);
+
+                                }
+                                tipform.startthread("序列号 " + ms_sncode + "通过检测", Result);
+                            }
+                            else
                             {
-                                OperateResult.AppendText("序列号:" + ms_sncode + "上传成功\n");
                                 File.Delete(FileName);
+                                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();
+                            isource = "SMT_01_TEST01";
+                            iusercode = "SMT_01_TEST01";
+                            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();
+                            }
+                            if (LogicHandler.CheckStepSNAndMacode(ma_code.Text, isource, ms_sncode, iusercode, out makecode, out oMSID, out oErrMessage))
+                            {
+                                ma_code.Text = makecode;
+                                if (LogicHandler.SetStepResult(makecode, isource, ms_sncode, "自动过站采集", "OK", iusercode, out oErrMessage))
+                                {
+                                    try
+                                    {
+                                        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://81.71.42.91:8099/ftp" + ftppath + SN + ".txt" + "' from makeserial where ms_sncode='" + SN + "'", "insert").ToString());
+                                        if (num > 0)
+                                        {
+                                            OperateResult.AppendText("序列号:" + SN + "上传成功\n");
+                                            File.Delete(FileName);
+                                        }
+                                        else
+                                        {
+                                            OperateResult.AppendText("序列号: " + SN + "前工段未扫描\n");
+                                            MessageBox.Show("序列号: " + ms_sncode + "前工段未扫描", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
+                                        }
+                                    }
+                                    catch (Exception ex)
+                                    {
+                                        Console.WriteLine(ex.Message);
+                                    }
+                                   
+                                }
+                                else
+                                {
+                                    OperateResult.AppendText(oErrMessage + "\n");
+                                    tipform.startthread(oErrMessage, Result);
+
+                                }
+                                tipform.startthread("序列号 " + ms_sncode + "通过检测", Result);
                             }
                             else
                             {
-                                OperateResult.AppendText("序列号: " + ms_sncode + "上传失败\n");
-                                //MessageBox.Show("序列号: " + ms_sncode + "前工段未扫描", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
+                                File.Delete(FileName);
+                                OperateResult.AppendText(oErrMessage + "\n");
+                                tipform.startthread(oErrMessage, Result);
                             }
                         }
                     }
+                    OperateResult.AppendText("解析成功:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\n" + FileName + "\n");
                 }
                 catch (Exception e)
                 {
@@ -400,7 +504,6 @@ namespace FileWatcher
                 }
             }
             myReader.Close();
-            //获取文件名的序列号,如SA123456.xml,如果开头为-表示无条码需要自动获取
             string sncode = FileName.Substring(0, 1) == "-" ? "" : FileName.Split('.')[0];
             string makecode = "";
             //获取序列号ID最大的工单号,所有序列号都测试为良品
@@ -653,11 +756,7 @@ namespace FileWatcher
 
         private void Timer_Tick(object sender, EventArgs e)
         {
-            var AllXmls = Directory.GetFiles(FolderPath.Text, "*.txt");
-            foreach (var Xml in AllXmls)
-            {
-                TxtHandleProcess(Xml);
-            }
+            dh.ExecuteSql("select sysdate from dual", "select");
         }
     }
 }

+ 2 - 2
FileWatcher/DataHelper.cs

@@ -9,9 +9,9 @@ namespace FileWatcher
    public class DataHelper
     {
         //系统默认的的连接字符串
-        private string ConnectionStrings = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=N_MES;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.6.253)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
+        private string ConnectionStrings = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=DGW;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=81.71.42.91)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
         //用户选择的数据库的连接字符串
-        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=192.168.6.253)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
+        public static string DBConnectionString= "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=DGW;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=81.71.42.91)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
         public static OracleConnection connection = null;
         OracleCommand command = null;
         int ReconnectTime = 0;

+ 17 - 18
FileWatcher/FileWatcher.csproj

@@ -50,6 +50,9 @@
     <Prefer32Bit>false</Prefer32Bit>
   </PropertyGroup>
   <ItemGroup>
+    <Reference Include="Aspose.Cells">
+      <HintPath>tool\Aspose.Cells.dll</HintPath>
+    </Reference>
     <Reference Include="Microsoft.Office.Interop.Excel, Version=10.0.4504.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
       <SpecificVersion>False</SpecificVersion>
       <EmbedInteropTypes>True</EmbedInteropTypes>
@@ -75,26 +78,8 @@
       <HintPath>tool\Oracle.ManagedDataAccess.dll</HintPath>
     </Reference>
     <Reference Include="PresentationCore" />
-    <Reference Include="Spire.Common">
-      <HintPath>tool\Spire.Common.dll</HintPath>
-    </Reference>
-    <Reference Include="Spire.License, Version=1.4.0.40, Culture=neutral, PublicKeyToken=b1144360237c8b3f, processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>tool\Spire.License.dll</HintPath>
-    </Reference>
-    <Reference Include="Spire.Pdf, Version=7.8.9.0, Culture=neutral, PublicKeyToken=663f351905198cb3, processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>tool\Spire.Pdf.dll</HintPath>
-    </Reference>
-    <Reference Include="Spire.XLS, Version=11.8.6.0, Culture=neutral, PublicKeyToken=663f351905198cb3, processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>tool\Spire.XLS.dll</HintPath>
-    </Reference>
     <Reference Include="System" />
     <Reference Include="System.Core" />
-    <Reference Include="System.Net.Http">
-      <HintPath>..\..\..\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.2\System.Net.Http.dll</HintPath>
-    </Reference>
     <Reference Include="System.Web" />
     <Reference Include="System.Web.Extensions" />
     <Reference Include="System.Xml.Linq" />
@@ -105,6 +90,10 @@
     <Reference Include="System.Drawing" />
     <Reference Include="System.Windows.Forms" />
     <Reference Include="System.Xml" />
+    <Reference Include="UMESDLLService, Version=1.0.0.0, Culture=neutral, processorArchitecture=x86">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\UAS_MesInterface(LGDZ)\bin\Debug\UMESDLLService.dll</HintPath>
+    </Reference>
   </ItemGroup>
   <ItemGroup>
     <Compile Include="AutoAnalysisDevice.cs">
@@ -192,6 +181,12 @@
     </Compile>
     <Compile Include="Program.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="首件仪上传.cs">
+      <SubType>Form</SubType>
+    </Compile>
+    <Compile Include="首件仪上传.Designer.cs">
+      <DependentUpon>首件仪上传.cs</DependentUpon>
+    </Compile>
     <Compile Include="测试记录解析DCW.cs">
       <SubType>Form</SubType>
     </Compile>
@@ -244,10 +239,14 @@
       <DependentUpon>Resources.resx</DependentUpon>
       <DesignTime>True</DesignTime>
     </Compile>
+    <EmbeddedResource Include="首件仪上传.resx">
+      <DependentUpon>首件仪上传.cs</DependentUpon>
+    </EmbeddedResource>
     <EmbeddedResource Include="测试记录解析DCW.resx">
       <DependentUpon>测试记录解析DCW.cs</DependentUpon>
     </EmbeddedResource>
     <None Include="app.config" />
+    <None Include="packages.config" />
     <None Include="Properties\Settings.settings">
       <Generator>SettingsSingleFileGenerator</Generator>
       <LastGenOutput>Settings.Designer.cs</LastGenOutput>

+ 63 - 30
FileWatcher/Form4.cs

@@ -8,9 +8,12 @@ using System.Data;
 using System.Drawing;
 using System.IO;
 using System.Linq;
+using System.Net;
 using System.Text;
+using System.Text.RegularExpressions;
 using System.Threading;
 using System.Windows.Forms;
+using UMESDLLService;
 
 namespace FileWatcher
 {
@@ -35,42 +38,72 @@ namespace FileWatcher
         {
 
         }
-        DataHelper dh = new DataHelper();
+        //DataHelper dh = new DataHelper();
         private void Form4_Load(object sender, EventArgs e)
         {
-            //DirectoryInfo folder = new DirectoryInfo(@"C:\\Users\\callm\\Desktop\\照片\\");
-            //foreach (FileInfo file in folder.GetFiles("*.*", SearchOption.AllDirectories))
+            //Regex re = new Regex("\\d+.\\d+");
+            //Console.WriteLine(re.Match(".   67.9\u001bENTER").Value);
+            ////Regex re = new Regex("\\d+.\\w+");
+            //Console.WriteLine(re.Match("2540.0").Value); ;
+            ////WebClient wc = new WebClient();
+            string json = "";
+            string json1 = "";
+            MESHelper mes = new MESHelper();
+            mes.GetMEIOrNetCodeRange(null, "354904108016523", "", out json1, out json);
+            //mes.GetMobileAllInfo("F45112235030001",  out json1, out json);
+            //Console.WriteLine(mes.CheckRoutePassed("S558B231013033559", "IMEI-01", out json));
+            //Console.WriteLine(mes.GetMEIOrNetCodeRange(null, "352977841215497", null, out json1, out json));
+
+            Console.WriteLine(json);
+
+            //mes.CheckRoutePassed( "204295638R002314", "ZZ_01_ATI", out json);
+
+            //Console.WriteLine(mes.SetMobileData("F5KKX2335053623", "F5KKX2335053623", "IMEI-01","IMEI-01","OK","","", out json));
+            //Console.WriteLine(json);
+            //string[] sss = new string[] { "F5KKX2335069950", "F5KKX2335069028", "F5KKX2335021555", "F5KKX2335111850", "F5KKX2335019799", "F5KKX2335111166", "F5KKX2335110438", "F5KKX2335045369" };
+
+            //for (int i = 0; i < sss.Length; i++)
             //{
-            //    Dictionary<string, object> dic = new Dictionary<string, object>
-            //            {
-            //                { "em_name", "管理员" },
-            //                { "em_code", "ADMIN" },
-            //                { "caller", "AGING" }
-            //            };
-            //    string fp_id;
-            //    string fp_path;
-            //    BaseUtil.UploadFilesToRemoteUrl("http://192.168.6.253:8099/mes/MEScommon/uploadFiles.action?_noc=1", file.FullName, dic, out fp_path, out fp_id);
+            //    string rr = "";
+            //    string sn = sss[i];
+            //    mes.GetMEIOrNetCodeRange(sn, "", "", out rr, out json);
+            //    string[] str = rr.Split('^');
+            //    string IMEI1 = str[0].Replace("IMEI1:", "");
+            //    string IMEI2 = str[1].Replace("IMEI2:", "");
+            //    string PSN = str[4].Replace("PSN:", "");
+            //    mes.SetIMEIInfo(sn, IMEI1, IMEI2, "", "", "", "", "", "", out json);
+
+            //    mes.GetAddressRangeByMO(sn, out rr, out json);
+
+            //    string[] str1 = rr.Split('^');
+            //    string MAC = str1[1].Replace("BT:", "");
+            //    mes.SetAddressInfo(sn, "", MAC, "", "", "", out json);
+
+            //    mes.SetMobileData(sn, sn, "IMEI-01", "zhangz", "OK", "", "", out json);
+            //    Console.WriteLine(json);
             //}
-            //var myThread = new Thread(() => SaveFileToJPG(@"C:\Users\callm\Desktop\导入数据\1.xlsx"));
-            //myThread.Start();
-            //var myThread1 = new Thread(() => SaveFileToJPG(@"C:\Users\callm\Desktop\导入数据\2.xlsx"));
-            //myThread1.Start();
-            //var myThread2 = new Thread(() => SaveFileToJPG(@"C:\Users\callm\Desktop\导入数据\3.xlsx"));
-            //myThread2.Start();
-            //var myThread3 = new Thread(() => SaveFileToJPG(@"C:\Users\callm\Desktop\导入数据\4.xlsx"));
-            //myThread3.Start();
-            //var myThread4 = new Thread(() => SaveFileToJPG(@"C:\Users\callm\Desktop\导入数据\5.xlsx"));
-            //myThread4.Start();
-            //var myThread5 = new Thread(() => SaveFileToJPG(@"C:\Users\callm\Desktop\导入数据\6.xlsx"));
-            //myThread5.Start();
-            //var myThread6 = new Thread(() => SaveFileToJPG(@"C:\Users\callm\Desktop\导入数据\7.xlsx"));
-            //myThread6.Start();
-            //var myThread7 = new Thread(() => SaveFileToJPG(@"C:\Users\callm\Desktop\导入数据\8.xlsx"));
-            //myThread7.Start();
-            //var myThread8 = new Thread(() => SaveFileToJPG(@"C:\Users\callm\Desktop\导入数据\9.xlsx"));
-            //myThread8.Start();
         }
 
+        public static string ToUrlEncode(string strCode)
+        {
+            StringBuilder sb = new StringBuilder();
+            byte[] byStr = System.Text.Encoding.UTF8.GetBytes(strCode); //默认是System.Text.Encoding.Default.GetBytes(str)  
+            System.Text.RegularExpressions.Regex regKey = new System.Text.RegularExpressions.Regex("^[A-Za-z0-9]+$");
+            for (int i = 0; i < byStr.Length; i++)
+            {
+                string strBy = Convert.ToChar(byStr[i]).ToString();
+                if (regKey.IsMatch(strBy))
+                {
+                    //是字母或者数字则不进行转换    
+                    sb.Append(strBy);
+                }
+                else
+                {
+                    sb.Append(@"%" + Convert.ToString(byStr[i], 16));
+                }
+            }
+            return (sb.ToString());
+        }
         private void textBox4_TextChanged(object sender, EventArgs e)
         {
 

+ 21 - 126
FileWatcher/Form5.Designer.cs

@@ -30,23 +30,13 @@
         {
             this.textBox1 = new System.Windows.Forms.TextBox();
             this.label1 = new System.Windows.Forms.Label();
-            this.label2 = new System.Windows.Forms.Label();
-            this.label3 = new System.Windows.Forms.Label();
-            this.label4 = new System.Windows.Forms.Label();
-            this.label12 = new System.Windows.Forms.Label();
             this.label13 = new System.Windows.Forms.Label();
             this.textBox5 = new System.Windows.Forms.TextBox();
             this.button1 = new System.Windows.Forms.Button();
-            this.radioButton1 = new System.Windows.Forms.RadioButton();
-            this.radioButton2 = new System.Windows.Forms.RadioButton();
-            this.radioButton3 = new System.Windows.Forms.RadioButton();
             this.textBox2 = new System.Windows.Forms.TextBox();
             this.label5 = new System.Windows.Forms.Label();
-            this.dataGridView1 = new System.Windows.Forms.DataGridView();
-            this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.Column3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
+            this.label3 = new System.Windows.Forms.Label();
+            this.label4 = new System.Windows.Forms.Label();
             this.SuspendLayout();
             // 
             // textBox1
@@ -65,54 +55,18 @@
             this.label1.TabIndex = 1;
             this.label1.Text = "工单号";
             // 
-            // label2
-            // 
-            this.label2.AutoSize = true;
-            this.label2.Location = new System.Drawing.Point(476, 111);
-            this.label2.Name = "label2";
-            this.label2.Size = new System.Drawing.Size(130, 24);
-            this.label2.TabIndex = 2;
-            this.label2.Text = "可选放大镜";
-            // 
-            // label3
-            // 
-            this.label3.AutoSize = true;
-            this.label3.Location = new System.Drawing.Point(89, 160);
-            this.label3.Name = "label3";
-            this.label3.Size = new System.Drawing.Size(106, 24);
-            this.label3.TabIndex = 3;
-            this.label3.Text = "产品编号";
-            // 
-            // label4
-            // 
-            this.label4.AutoSize = true;
-            this.label4.Location = new System.Drawing.Point(371, 160);
-            this.label4.Name = "label4";
-            this.label4.Size = new System.Drawing.Size(106, 24);
-            this.label4.TabIndex = 4;
-            this.label4.Text = "产品名称";
-            // 
-            // label12
-            // 
-            this.label12.AutoSize = true;
-            this.label12.Location = new System.Drawing.Point(476, 216);
-            this.label12.Name = "label12";
-            this.label12.Size = new System.Drawing.Size(130, 24);
-            this.label12.TabIndex = 31;
-            this.label12.Text = "可选放大镜";
-            // 
             // label13
             // 
             this.label13.AutoSize = true;
-            this.label13.Location = new System.Drawing.Point(89, 208);
+            this.label13.Location = new System.Drawing.Point(89, 258);
             this.label13.Name = "label13";
             this.label13.Size = new System.Drawing.Size(106, 24);
             this.label13.TabIndex = 30;
-            this.label13.Text = "岗位资源";
+            this.label13.Text = "人员编号";
             // 
             // textBox5
             // 
-            this.textBox5.Location = new System.Drawing.Point(210, 205);
+            this.textBox5.Location = new System.Drawing.Point(210, 255);
             this.textBox5.Name = "textBox5";
             this.textBox5.Size = new System.Drawing.Size(243, 35);
             this.textBox5.TabIndex = 29;
@@ -126,39 +80,6 @@
             this.button1.Text = "保存";
             this.button1.UseVisualStyleBackColor = true;
             // 
-            // radioButton1
-            // 
-            this.radioButton1.AutoSize = true;
-            this.radioButton1.Location = new System.Drawing.Point(82, 286);
-            this.radioButton1.Name = "radioButton1";
-            this.radioButton1.Size = new System.Drawing.Size(89, 28);
-            this.radioButton1.TabIndex = 34;
-            this.radioButton1.TabStop = true;
-            this.radioButton1.Text = "设备";
-            this.radioButton1.UseVisualStyleBackColor = true;
-            // 
-            // radioButton2
-            // 
-            this.radioButton2.AutoSize = true;
-            this.radioButton2.Location = new System.Drawing.Point(260, 286);
-            this.radioButton2.Name = "radioButton2";
-            this.radioButton2.Size = new System.Drawing.Size(89, 28);
-            this.radioButton2.TabIndex = 35;
-            this.radioButton2.TabStop = true;
-            this.radioButton2.Text = "夹具";
-            this.radioButton2.UseVisualStyleBackColor = true;
-            // 
-            // radioButton3
-            // 
-            this.radioButton3.AutoSize = true;
-            this.radioButton3.Location = new System.Drawing.Point(445, 286);
-            this.radioButton3.Name = "radioButton3";
-            this.radioButton3.Size = new System.Drawing.Size(89, 28);
-            this.radioButton3.TabIndex = 36;
-            this.radioButton3.TabStop = true;
-            this.radioButton3.Text = "辅料";
-            this.radioButton3.UseVisualStyleBackColor = true;
-            // 
             // textBox2
             // 
             this.textBox2.Location = new System.Drawing.Point(210, 30);
@@ -175,58 +96,41 @@
             this.label5.TabIndex = 38;
             this.label5.Text = "扫码框";
             // 
-            // dataGridView1
-            // 
-            this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
-            this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
-            this.Column1,
-            this.Column3,
-            this.Column2});
-            this.dataGridView1.Location = new System.Drawing.Point(64, 335);
-            this.dataGridView1.Name = "dataGridView1";
-            this.dataGridView1.RowTemplate.Height = 37;
-            this.dataGridView1.Size = new System.Drawing.Size(498, 368);
-            this.dataGridView1.TabIndex = 39;
-            // 
-            // Column1
-            // 
-            this.Column1.HeaderText = "编号";
-            this.Column1.Name = "Column1";
-            // 
-            // Column3
+            // label3
             // 
-            this.Column3.HeaderText = "名称";
-            this.Column3.Name = "Column3";
+            this.label3.AutoSize = true;
+            this.label3.Location = new System.Drawing.Point(89, 160);
+            this.label3.Name = "label3";
+            this.label3.Size = new System.Drawing.Size(106, 24);
+            this.label3.TabIndex = 3;
+            this.label3.Text = "产品编号";
             // 
-            // Column2
+            // label4
             // 
-            this.Column2.HeaderText = "类型";
-            this.Column2.Name = "Column2";
+            this.label4.AutoSize = true;
+            this.label4.Location = new System.Drawing.Point(89, 210);
+            this.label4.Name = "label4";
+            this.label4.Size = new System.Drawing.Size(106, 24);
+            this.label4.TabIndex = 4;
+            this.label4.Text = "产品名称";
             // 
             // Form5
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 24F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.ClientSize = new System.Drawing.Size(647, 820);
-            this.Controls.Add(this.dataGridView1);
             this.Controls.Add(this.label5);
             this.Controls.Add(this.textBox2);
-            this.Controls.Add(this.radioButton3);
-            this.Controls.Add(this.radioButton2);
-            this.Controls.Add(this.radioButton1);
             this.Controls.Add(this.button1);
-            this.Controls.Add(this.label12);
             this.Controls.Add(this.label13);
             this.Controls.Add(this.textBox5);
             this.Controls.Add(this.label4);
             this.Controls.Add(this.label3);
-            this.Controls.Add(this.label2);
             this.Controls.Add(this.label1);
             this.Controls.Add(this.textBox1);
             this.Name = "Form5";
             this.Text = "Form4";
             this.Load += new System.EventHandler(this.Form4_Load);
-            ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
             this.ResumeLayout(false);
             this.PerformLayout();
 
@@ -236,21 +140,12 @@
 
         private System.Windows.Forms.TextBox textBox1;
         private System.Windows.Forms.Label label1;
-        private System.Windows.Forms.Label label2;
-        private System.Windows.Forms.Label label3;
-        private System.Windows.Forms.Label label4;
-        private System.Windows.Forms.Label label12;
         private System.Windows.Forms.Label label13;
         private System.Windows.Forms.TextBox textBox5;
         private System.Windows.Forms.Button button1;
-        private System.Windows.Forms.RadioButton radioButton1;
-        private System.Windows.Forms.RadioButton radioButton2;
-        private System.Windows.Forms.RadioButton radioButton3;
         private System.Windows.Forms.TextBox textBox2;
         private System.Windows.Forms.Label label5;
-        private System.Windows.Forms.DataGridView dataGridView1;
-        private System.Windows.Forms.DataGridViewTextBoxColumn Column1;
-        private System.Windows.Forms.DataGridViewTextBoxColumn Column3;
-        private System.Windows.Forms.DataGridViewTextBoxColumn Column2;
+        private System.Windows.Forms.Label label3;
+        private System.Windows.Forms.Label label4;
     }
 }

+ 118 - 6
FileWatcher/Form5.cs

@@ -1,11 +1,8 @@
 using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
-using System.Drawing;
-using System.Linq;
-using System.Text;
 using System.Windows.Forms;
+using Aspose.Cells.Rendering;
+using Aspose.Cells;
+using System.Drawing.Imaging;
 
 namespace FileWatcher
 {
@@ -31,11 +28,126 @@ namespace FileWatcher
 
         }
 
+        public void ExportRangeAsJpg()
+        {
+            Workbook book = new Workbook(@"C:\\Users\\callm\\Desktop\\新建文件夹\\99001-91A1C2079.xls");
+
+            for (int i = 0; i < book.Worksheets.Count; i++)
+            {
+                Worksheet sheet = book.Worksheets[i];
+                Console.WriteLine(sheet.CodeName);
+                Console.WriteLine(sheet.Name);
+                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.PrintingPage = PrintingPageType.IgnoreBlank;
+                SheetRender sr = new SheetRender((Aspose.Cells.Worksheet)sheet, imgOptions);
+                sr.ToImage(0, sheet.Name + ".png");
+            }
+        }
+
+
         private void Form4_Load(object sender, EventArgs e)
         {
+            ExportRangeAsJpg();
+            return;
+            CheckForIllegalCrossThreadCalls = false;
+            //Workbook workbook = new Workbook();
+            //workbook.LoadFromFile(@"C:\Users\callm\Desktop\新建文件夹\99001-91A1C2079.xls");
+            //workbook.ConverterSetting.JPEGQuality = 100;
+            //workbook.ConverterSetting.XDpi = 600;
+            //workbook.ConverterSetting.YDpi = 600;
+            //List<Worksheet> list = new List<Worksheet>();
+            //List<string> filename = new List<string>();
+            //OperatResult.AppendText("一共Sheet: " + workbook.Worksheets.Count + "\n");
+            //try
+            //{
+            //    IFont font1 = workbook.CreateFont();
+            //    for (int i = 0; i < workbook.Worksheets.Count; i++)
+            //    {
+            //        OperatResult.AppendText("正在解析Sheet" + workbook.Worksheets[i].Name + "\n");
+            //        for (int k = 0; k < workbook.Worksheets[i].TextBoxes.Count; k++)
+            //        {
+            //            if (workbook.Worksheets[i].TextBoxes[k].RichText.Text.Length > 1)
+            //            {
+            //                workbook.Worksheets[i].TextBoxes[k].RichText.Text = workbook.Worksheets[i].TextBoxes[k].RichText.Text;
+            //            }
+            //        }
+            //        Workbook bw = new Workbook();
+            //        Worksheet she = bw.CreateEmptySheet();
+            //        she.Name = workbook.Worksheets[i].Name;
+            //        she.CopyFrom(workbook.Worksheets[i]);
+            //        var myThread = new Thread(() => SaveFileToJPG(she));
+            //        myThread.Start();
+            //        //filename.Add(she.Name + ".jpg");
+            //    }
+            //}
+            //catch (Exception ex)
+            //{
+            //    OperatResult.AppendText(ex.Message + "\n");
+            //}
 
         }
 
+        //private void SaveFileToJPG(Worksheet sheet)
+        //{
+        //    try
+        //    {
+        //        //DataHelper dh = new DataHelper();
+        //        OperatResult.AppendText("解析图片【" + sheet.Name + ".jpg】添加水印" + "\n");
+              
+        //        ExcelPicture picture = sheet.Pictures.Add(@"图片\电子受控章.png");
+        //        picture.Width = 113;
+        //        picture.Height = 38;
+        //        picture.LeftColumn = 20;
+        //        picture.TopRowOffset = 20;
+        //        ExcelPicture picture1 = sheet.Pictures.Add(@"图片\签名.png");
+        //        picture1.Width = 100;
+        //        picture1.Height = 38;
+        //        picture1.LeftColumn = 15;
+        //        picture1.TopRowOffset = 600;
+        //        sheet.SaveToImage(@"C:\Users\callm\Desktop\" + "新建文件夹"+ @"\" + sheet.Name + ".jpg");
+        //        OperatResult.AppendText("解析图片【" + sheet.Name + ".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("上传文件【" + sheet.Name + ".jpg" + "】\n");
+        //    }
+        //    catch (Exception ex)
+        //    {
+        //        OperatResult.AppendText(ex.Message + ex.StackTrace);
+        //    }
+        //}
+
+        //private void SaveFileToPDF(Worksheet sheet)
+        //{
+        //    //if (!Directory.Exists(Application.StartupPath + @"\" + pr_code.Text))
+        //    //{
+        //    //    Directory.CreateDirectory(Application.StartupPath + @"\" + pr_code.Text);
+        //    //}
+        //    sheet.SaveToPdf(@"C:\Users\callm\Desktop\" + "新建文件夹" + @"\" + sheet.Name + ".pdf");
+        //    OperatResult.AppendText("解析PDF【" + sheet.Name + ".pdf】" + "\n");
+        //    Dictionary<string, object> dic = new Dictionary<string, object>();
+        //    dic.Add("em_name", "管理员");
+        //    dic.Add("em_code", "ADMIN");
+        //    dic.Add("caller", "ProductSOP");
+        //    OperatResult.AppendText("上传文件【" + sheet.Name + ".pdf" + "】\n");
+        //}
+
+        private void ExcelDocViewer(string fileName)
+        {
+            try
+            {
+                System.Diagnostics.Process.Start(fileName);
+            }
+            catch { }
+        }
+
         private void textBox4_TextChanged(object sender, EventArgs e)
         {
 

+ 0 - 9
FileWatcher/Form5.resx

@@ -117,13 +117,4 @@
   <resheader name="writer">
     <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
   </resheader>
-  <metadata name="Column1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
-  <metadata name="Column3.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
-  <metadata name="Column2.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
 </root>

+ 1 - 1
FileWatcher/Login.cs

@@ -18,7 +18,7 @@ namespace FileWatcher
         private void CheckLogin_Click(object sender, EventArgs e)
         {
             string ErrMessage = "";
-            DataHelper.DBConnectionString = "Password=select!#%*(;User ID=" + Master.Text + ";Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.6.253)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
+            DataHelper.DBConnectionString = "Password=select!#%*(;User ID=" + Master.Text + ";Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.101.253)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
             //重新执行一遍构造函数使得重置之后的链接字符串生效
             dh = new DataHelper();
             AutoAnalysisXmlByStep.dh = dh;

+ 1 - 1
FileWatcher/Program.cs

@@ -45,7 +45,7 @@ namespace FileWatcher
                 Application.EnableVisualStyles();
                 Application.SetCompatibleTextRenderingDefault(false);
                 if (principal.IsInRole(WindowsBuiltInRole.Administrator))
-                    Application.Run(new AutoAnalysisDevice());
+                    Application.Run(new AutoAnalysisXml());
                 else
                 {
                     //创建启动对象

+ 0 - 14
FileWatcher/SOP.Designer.cs

@@ -42,7 +42,6 @@
             this.label4 = new System.Windows.Forms.Label();
             this.pr_detail = new System.Windows.Forms.Label();
             this.JPG = new System.Windows.Forms.RadioButton();
-            this.PDF = new System.Windows.Forms.RadioButton();
             this.pr_spec = new System.Windows.Forms.RichTextBox();
             this.SuspendLayout();
             // 
@@ -175,17 +174,6 @@
             this.JPG.Text = "图片";
             this.JPG.UseVisualStyleBackColor = true;
             // 
-            // PDF
-            // 
-            this.PDF.AutoSize = true;
-            this.PDF.Location = new System.Drawing.Point(382, 534);
-            this.PDF.Name = "PDF";
-            this.PDF.Size = new System.Drawing.Size(77, 28);
-            this.PDF.TabIndex = 18;
-            this.PDF.TabStop = true;
-            this.PDF.Text = "PDF";
-            this.PDF.UseVisualStyleBackColor = true;
-            // 
             // pr_spec
             // 
             this.pr_spec.Enabled = false;
@@ -202,7 +190,6 @@
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.ClientSize = new System.Drawing.Size(1945, 934);
             this.Controls.Add(this.pr_spec);
-            this.Controls.Add(this.PDF);
             this.Controls.Add(this.JPG);
             this.Controls.Add(this.pr_detail);
             this.Controls.Add(this.label4);
@@ -241,7 +228,6 @@
         private System.Windows.Forms.Label label4;
         private System.Windows.Forms.Label pr_detail;
         private System.Windows.Forms.RadioButton JPG;
-        private System.Windows.Forms.RadioButton PDF;
         private System.Windows.Forms.RichTextBox pr_spec;
     }
 }

+ 17 - 54
FileWatcher/SOP.cs

@@ -2,13 +2,15 @@
 using System.IO;
 using System.Text;
 using System.Windows.Forms;
-using Spire.Xls;
 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;
 
 namespace FileWatcher
 {
@@ -55,11 +57,7 @@ namespace FileWatcher
             {
                 pr_code.Text = dt.Rows[0]["ps_prodcode"].ToString();
             }
-            Workbook workbook = new Workbook();
-            workbook.LoadFromFile(FilePath.Text);
-            workbook.ConverterSetting.JPEGQuality = 100;
-            workbook.ConverterSetting.XDpi = 600;
-            workbook.ConverterSetting.YDpi = 600;
+            Workbook workbook = new Workbook(FilePath.Text);
             List<Worksheet> list = new List<Worksheet>();
             List<string> filename = new List<string>();
             dh.ExecuteSql("update ProductSOP set ps_attachsop='' where ps_prodcode='" + pr_code.Text + "'", "update");
@@ -69,29 +67,13 @@ namespace FileWatcher
                 for (int i = 0; i < workbook.Worksheets.Count; i++)
                 {
                     OperatResult.AppendText("正在解析Sheet" + workbook.Worksheets[i].Name + "\n");
-                    for (int k = 0; k < workbook.Worksheets[i].TextBoxes.Count; k++)
-                    {
-                        if (workbook.Worksheets[i].TextBoxes[k].RichText.Text.Length > 1)
-                        {
-                            workbook.Worksheets[i].TextBoxes[k].RichText.Text = workbook.Worksheets[i].TextBoxes[k].RichText.Text;
-                        }
-                    }
-                    Workbook bw = new Workbook();
-                    Worksheet she = bw.CreateEmptySheet();
-                    she.Name = workbook.Worksheets[i].Name;
-                    she.CopyFrom(workbook.Worksheets[i]);
+                    Worksheet she = workbook.Worksheets[i];
                     if (JPG.Checked)
                     {
                         var myThread = new Thread(() => SaveFileToJPG(she));
                         myThread.Start();
                         filename.Add(she.Name + ".jpg");
                     }
-                    else
-                    {
-                        var myThread = new Thread(() => SaveFileToPDF(she));
-                        myThread.Start();
-                        filename.Add(she.Name + ".pdf");
-                    }
                 }
             }
             catch (Exception ex)
@@ -100,26 +82,6 @@ namespace FileWatcher
             }
         }
 
-        private void SaveFileToPDF(Worksheet sheet)
-        {
-            if (!Directory.Exists(Application.StartupPath + @"\" + pr_code.Text))
-            {
-                Directory.CreateDirectory(Application.StartupPath + @"\" + pr_code.Text);
-            }
-            sheet.SaveToPdf(Application.StartupPath + @"\" + pr_code.Text + @"\" + sheet.Name + ".pdf");
-            OperatResult.AppendText("解析PDF【" + sheet.Name + ".pdf】" + "\n");
-            Dictionary<string, object> dic = new Dictionary<string, object>();
-            dic.Add("em_name", "管理员");
-            dic.Add("em_code", "ADMIN");
-            dic.Add("caller", "ProductSOP");
-            OperatResult.AppendText("上传文件【" + sheet.Name + ".pdf" + "】\n");
-            string fp_id = UploadFilesToRemoteUrl("http://192.168.101.253:8099/mes/MEScommon/uploadFiles.action?_noc=1", Application.StartupPath + @"\" + pr_code.Text + @"\" + sheet.Name + ".pdf", dic);
-            if (fp_id != "")
-            {
-                dh.ExecuteSql("update ProductSOP set ps_attachsop=ps_attachsop||" + fp_id + "||';' where ps_prodcode='" + pr_code.Text + "'", "update");
-            }
-        }
-
         private void SaveFileToJPG(Worksheet sheet)
         {
             try
@@ -130,17 +92,18 @@ namespace FileWatcher
                 {
                     Directory.CreateDirectory(Application.StartupPath + @"\" + pr_code.Text);
                 }
-                ExcelPicture picture = sheet.Pictures.Add(@"图片\电子受控章.png");
-                picture.Width = 113;
-                picture.Height = 38;
-                picture.LeftColumn = 20;
-                picture.TopRowOffset = 20;
-                ExcelPicture picture1 = sheet.Pictures.Add(@"图片\签名.png");
-                picture1.Width = 100;
-                picture1.Height = 38;
-                picture1.LeftColumn = 15;
-                picture1.TopRowOffset = 600;
-                sheet.SaveToImage(Application.StartupPath + @"\" + pr_code.Text + @"\" + sheet.Name + ".jpg");
+                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.PrintingPage = PrintingPageType.IgnoreBlank;
+                SheetRender sr = new SheetRender((Aspose.Cells.Worksheet)sheet, imgOptions);
+                sr.ToImage(0, Application.StartupPath + @"\" + pr_code.Text + @"\" + sheet.Name + ".jpg");
                 OperatResult.AppendText("解析图片【" + sheet.Name + ".jpg】" + "\n");
                 Dictionary<string, object> dic = new Dictionary<string, object>();
                 dic.Add("em_name", "管理员");

BIN
FileWatcher/UMESDLLService.dll


+ 3 - 3
FileWatcher/ftpOperater.cs

@@ -21,9 +21,9 @@ namespace FileWatcher
 
         public ftpOperater()
         {
-            //string[] FTPInf = "ftp://81.71.42.91|vsftpd|uas321vsftpd2021".Split('|');
+            string[] FTPInf = "ftp://81.71.42.91|vsftpd|uas321vsftpd2021".Split('|');
             //睿德FTP
-            string[] FTPInf = "ftp://192.168.6.253|vsftpd|vsftpd4cd69014ep".Split('|');
+            //string[] FTPInf = "ftp://81.71.42.91|ftpuser2|Az789***".Split('|');
             this.ftpServerIP = FTPInf[0];
             this.ftpUser = FTPInf[1];
             this.ftpPwd = FTPInf[2];
@@ -77,7 +77,7 @@ namespace FileWatcher
                     }
                     fs.Close();
                 }
-                Thread.Sleep(1000);
+                Thread.Sleep(2000);
             }
             catch (Exception ex)
             {

+ 4 - 0
FileWatcher/packages.config

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="Aspose.Cells" version="23.10.0" targetFramework="net40" />
+</packages>

BIN
FileWatcher/tool/Aspose.Cells.dll


BIN
FileWatcher/tool/Aspose.Cells18.4.0,0.dll


BIN
FileWatcher/tool/UMES.DLLService.dll


BIN
FileWatcher/tool/UMESDLLService.dll


+ 64 - 83
FileWatcher/测试记录解析.cs

@@ -50,12 +50,39 @@ namespace FileWatcher
         /// <param name="path">文件夹路径</param>
         /// <param name="extName">扩展名可以多个 例如 .mp3.wma.rm</param>
         /// <returns>List<FileInfo></returns>
-        public List<FileInfo> getFile(string path, string extName)
+
+        public static List<FileInfo> getFile(string path, string extName, List<FileInfo> lst)
         {
-            getdir(path, extName);
-            return lst;
+            try
+            {
+                string[] directories = Directory.GetDirectories(path);
+                DirectoryInfo directoryInfo = new DirectoryInfo(path);
+                FileInfo[] files = directoryInfo.GetFiles();
+                if (files.Length != 0 || directories.Length != 0)
+                {
+                    FileInfo[] array = files;
+                    foreach (FileInfo fileInfo in array)
+                    {
+                        if (extName.ToLower().IndexOf(fileInfo.Extension.ToLower()) >= 0)
+                        {
+                            lst.Add(fileInfo);
+                        }
+                    }
+                    string[] array2 = directories;
+                    foreach (string path2 in array2)
+                    {
+                        getFile(path2, extName, lst);
+                    }
+                }
+                return lst;
+            }
+            catch (Exception ex)
+            {
+                throw ex;
+            }
         }
 
+
         /// <summary>
         /// 私有方法,递归获取指定类型文件,包含子文件夹
         /// </summary>
@@ -65,73 +92,73 @@ namespace FileWatcher
         {
             try
             {
-                string[] dir = Directory.GetDirectories(path); //文件夹列表   
-                DirectoryInfo fdir = new DirectoryInfo(path);
-                FileInfo[] file = fdir.GetFiles();
-                //FileInfo[] file = Directory.GetFiles(path); //文件列表   
-                if (file.Length != 0 || dir.Length != 0) //当前目录文件或文件夹不为空                   
+                string[] directories = Directory.GetDirectories(path);
+                DirectoryInfo directoryInfo = new DirectoryInfo(path);
+                FileInfo[] files = directoryInfo.GetFiles();
+                if (files.Length != 0 || directories.Length != 0)
                 {
-                    string SN = "";
-                    string folderpath = "";
-                    foreach (FileInfo f in file) //显示当前目录所有文件   
+                    string text = "";
+                    string text2 = "";
+                    FileInfo[] array = files;
+                    foreach (FileInfo fileInfo in array)
                     {
-                        folderpath = f.FullName.Substring(0, f.FullName.LastIndexOf(@"\"));
-                        SN = folderpath.Substring(folderpath.LastIndexOf(@"\") + 1);
-                        if (f.FullName.Contains("SN_"))
+                        text2 = fileInfo.FullName.Substring(0, fileInfo.FullName.LastIndexOf("\\"));
+                        text = text2.Substring(text2.LastIndexOf("\\") + 1);
+                        if (fileInfo.FullName.Contains("SN_"))
                         {
-                            StreamReader sr = new StreamReader(f.FullName);
-                            while (!sr.EndOfStream)
+                            StreamReader streamReader = new StreamReader(fileInfo.FullName);
+                            while (!streamReader.EndOfStream)
                             {
-                                string val = sr.ReadLine();
-                                string type = val.Split(':')[0].Trim();
-                                string value = val.Split(':')[1].Trim();
-                                dh.ExecuteSql("insert into windowsninfo(ws_id,ws_sncode,ws_type,ws_value,ws_indate)values(windowsninfo_seq.nextval,'" + SN + "','" + type + "','" + value + "',sysdate)", "insert");
+                                string text3 = streamReader.ReadLine();
+                                string text4 = text3.Split(':')[0].Trim();
+                                string text5 = text3.Split(':')[1].Trim();
+                                dh.ExecuteSql("insert into windowsninfo(ws_id,ws_sncode,ws_type,ws_value,ws_indate)values(windowsninfo_seq.nextval,'" + text + "','" + text4 + "','" + text5 + "',sysdate)", "insert");
                             }
-                            sr.Close();
+                            streamReader.Close();
                         }
                         try
                         {
-                            string ftppath = "/" + DateTime.Now.ToString("yyyy-MM-dd") + "/" + folderpath.Substring(folderpath.LastIndexOf(@"\") + 1) + "/";
-                            ftp.UpLoadFile(folderpath, f.Name, ftppath, BackUpFolderPath.Text);
+                            string uploadFolder = "/" + DateTime.Now.ToString("yyyy-MM-dd") + "/" + text2.Substring(text2.LastIndexOf("\\") + 1) + "/";
+                            ftp.UpLoadFile(text2, fileInfo.Name, uploadFolder, BackUpFolderPath.Text);
                         }
                         catch (Exception ex)
                         {
                             Console.WriteLine(ex.Message);
                         }
-                        OperateResult.AppendText(f.Name + "解析成功");
                     }
-                    foreach (FileInfo f in file) //显示当前目录所有文件   
+                    FileInfo[] array2 = files;
+                    foreach (FileInfo fileInfo2 in array2)
                     {
                         try
                         {
-                            if (!Directory.Exists(BackUpFolderPath.Text + @"\" + SN + @"\"))
+                            if (!Directory.Exists(BackUpFolderPath.Text + "\\" + text + "\\"))
                             {
-                                Directory.CreateDirectory(BackUpFolderPath.Text + @"\" + SN + @"\");
+                                Directory.CreateDirectory(BackUpFolderPath.Text + "\\" + text + "\\");
                             }
-                            File.Move(f.FullName, BackUpFolderPath.Text + @"\" + SN + @"\" + f.Name);
+                            File.Move(fileInfo2.FullName, BackUpFolderPath.Text + "\\" + text + "\\" + fileInfo2.Name);
                         }
-                        catch (Exception ex)
+                        catch (Exception ex2)
                         {
-                            Console.WriteLine(ex.Message);
+                            Console.WriteLine(ex2.Message);
                         }
                     }
                     try
                     {
-                        Directory.Delete(folderpath);
+                        Directory.Delete(text2);
                     }
                     catch (Exception)
                     {
-
                     }
-                    foreach (string d in dir)
+                    string[] array3 = directories;
+                    foreach (string path2 in array3)
                     {
-                        getdir(d, extName);//递归   
+                        getdir(path2, extName);
                     }
                 }
             }
-            catch (Exception ex)
+            catch (Exception ex4)
             {
-                Console.WriteLine(ex.Message);
+                Console.WriteLine(ex4.Message);
             }
         }
 
@@ -139,7 +166,6 @@ namespace FileWatcher
         {
             try
             {
-                getFile(FolderPath.Text, ".log");
             }
             catch (Exception ex)
             {
@@ -147,42 +173,6 @@ namespace FileWatcher
             }
         }
 
-        /// <summary>
-        /// 获得目录下所有文件或指定文件类型文件(包含所有子文件夹)
-        /// </summary>
-        /// <param name="path">文件夹路径</param>
-        /// <param name="extName">扩展名可以多个 例如 .mp3.wma.rm</param>
-        /// <returns>List<FileInfo></returns>
-        public static List<FileInfo> getFile(string path, string extName, List<FileInfo> lst)
-        {
-            try
-            {
-                string[] dir = Directory.GetDirectories(path); //文件夹列表  
-                DirectoryInfo fdir = new DirectoryInfo(path);
-                FileInfo[] file = fdir.GetFiles();
-                //FileInfo[] file = Directory.GetFiles(path); //文件列表  
-                if (file.Length != 0 || dir.Length != 0) //当前目录文件或文件夹不为空          
-                {
-                    foreach (FileInfo f in file) //显示当前目录所有文件  
-                    {
-                        if (extName.ToLower().IndexOf(f.Extension.ToLower()) >= 0)
-                        {
-                            lst.Add(f);
-                        }
-                    }
-                    foreach (string d in dir)
-                    {
-                        getFile(d, extName, lst);//递归  
-                    }
-                }
-                return lst;
-            }
-            catch (Exception ex)
-            {
-                throw ex;
-            }
-        }
-
         private void ChooseFolder_Click(object sender, EventArgs e)
         {
             FolderBrowserDialog folder = new FolderBrowserDialog();
@@ -207,16 +197,7 @@ namespace FileWatcher
 
         private void Start_Click(object sender, EventArgs e)
         {
-            if (Start.Text == "开始监控")
-            {
-                timer1.Start();
-                Start.Text = "停止监控";
-            }
-            else
-            {
-                timer1.Stop();
-                Start.Text = "开始监控";
-            }
+            timer1.Start();
         }
     }
 }

+ 151 - 0
FileWatcher/首件仪上传.Designer.cs

@@ -0,0 +1,151 @@
+namespace FileWatcher
+{
+    partial class 首件仪上传
+    {
+        /// <summary>
+        /// 必需的设计器变量。
+        /// </summary>
+        private System.ComponentModel.IContainer components = null;
+
+        /// <summary>
+        /// 清理所有正在使用的资源。
+        /// </summary>
+        /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
+        protected override void Dispose(bool disposing)
+        {
+            if (disposing && (components != null))
+            {
+                components.Dispose();
+            }
+            base.Dispose(disposing);
+        }
+
+        #region Windows 窗体设计器生成的代码
+
+        /// <summary>
+        /// 设计器支持所需的方法 - 不要修改
+        /// 使用代码编辑器修改此方法的内容。
+        /// </summary>
+        private void InitializeComponent()
+        {
+            this.OperateResult = new System.Windows.Forms.RichTextBox();
+            this.Start = new System.Windows.Forms.Button();
+            this.ChooseFolder = new System.Windows.Forms.Button();
+            this.FolderPath = new System.Windows.Forms.TextBox();
+            this.label1 = new System.Windows.Forms.Label();
+            this.label2 = new System.Windows.Forms.Label();
+            this.ma_code = new System.Windows.Forms.TextBox();
+            this.SuspendLayout();
+            // 
+            // OperateResult
+            // 
+            this.OperateResult.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
+            | System.Windows.Forms.AnchorStyles.Left) 
+            | System.Windows.Forms.AnchorStyles.Right)));
+            this.OperateResult.Location = new System.Drawing.Point(38, 15);
+            this.OperateResult.Margin = new System.Windows.Forms.Padding(6);
+            this.OperateResult.Name = "OperateResult";
+            this.OperateResult.Size = new System.Drawing.Size(1336, 600);
+            this.OperateResult.TabIndex = 0;
+            this.OperateResult.Text = "";
+            // 
+            // Start
+            // 
+            this.Start.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
+            this.Start.Location = new System.Drawing.Point(623, 788);
+            this.Start.Name = "Start";
+            this.Start.Size = new System.Drawing.Size(141, 40);
+            this.Start.TabIndex = 1;
+            this.Start.Text = "上传文件";
+            this.Start.UseVisualStyleBackColor = true;
+            this.Start.Click += new System.EventHandler(this.Start_Click);
+            // 
+            // ChooseFolder
+            // 
+            this.ChooseFolder.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
+            this.ChooseFolder.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.ChooseFolder.Location = new System.Drawing.Point(669, 720);
+            this.ChooseFolder.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
+            this.ChooseFolder.Name = "ChooseFolder";
+            this.ChooseFolder.Size = new System.Drawing.Size(156, 48);
+            this.ChooseFolder.TabIndex = 14;
+            this.ChooseFolder.Text = "选择文件夹";
+            this.ChooseFolder.UseVisualStyleBackColor = true;
+            this.ChooseFolder.Click += new System.EventHandler(this.ChooseFolder_Click);
+            // 
+            // FolderPath
+            // 
+            this.FolderPath.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
+            this.FolderPath.Enabled = false;
+            this.FolderPath.Location = new System.Drawing.Point(201, 726);
+            this.FolderPath.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
+            this.FolderPath.Name = "FolderPath";
+            this.FolderPath.Size = new System.Drawing.Size(436, 35);
+            this.FolderPath.TabIndex = 13;
+            // 
+            // label1
+            // 
+            this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
+            this.label1.AutoSize = true;
+            this.label1.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.label1.Location = new System.Drawing.Point(31, 720);
+            this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.label1.Name = "label1";
+            this.label1.Size = new System.Drawing.Size(104, 38);
+            this.label1.TabIndex = 12;
+            this.label1.Text = "文件夹";
+            // 
+            // label2
+            // 
+            this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
+            this.label2.AutoSize = true;
+            this.label2.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.label2.Location = new System.Drawing.Point(80, 654);
+            this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.label2.Name = "label2";
+            this.label2.Size = new System.Drawing.Size(104, 38);
+            this.label2.TabIndex = 15;
+            this.label2.Text = "工单号";
+            // 
+            // ma_code
+            // 
+            this.ma_code.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
+            this.ma_code.Location = new System.Drawing.Point(201, 660);
+            this.ma_code.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
+            this.ma_code.Name = "ma_code";
+            this.ma_code.Size = new System.Drawing.Size(436, 35);
+            this.ma_code.TabIndex = 16;
+            // 
+            // 首件仪上传
+            // 
+            this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 24F);
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.ClientSize = new System.Drawing.Size(1402, 845);
+            this.Controls.Add(this.ma_code);
+            this.Controls.Add(this.label2);
+            this.Controls.Add(this.ChooseFolder);
+            this.Controls.Add(this.FolderPath);
+            this.Controls.Add(this.label1);
+            this.Controls.Add(this.Start);
+            this.Controls.Add(this.OperateResult);
+            this.Margin = new System.Windows.Forms.Padding(6);
+            this.Name = "首件仪上传";
+            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
+            this.Text = "测试文件监控";
+            this.Load += new System.EventHandler(this.Form1_Load);
+            this.ResumeLayout(false);
+            this.PerformLayout();
+
+        }
+
+        #endregion
+        private System.Windows.Forms.RichTextBox OperateResult;
+        private System.Windows.Forms.Button Start;
+        private System.Windows.Forms.Button ChooseFolder;
+        private System.Windows.Forms.TextBox FolderPath;
+        private System.Windows.Forms.Label label1;
+        private System.Windows.Forms.Label label2;
+        private System.Windows.Forms.TextBox ma_code;
+    }
+}
+

+ 224 - 0
FileWatcher/首件仪上传.cs

@@ -0,0 +1,224 @@
+using Microsoft.Win32;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Diagnostics;
+using System.IO;
+using System.Net;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Threading;
+using System.Windows.Forms;
+
+namespace FileWatcher
+{
+    public partial class 首件仪上传 : Form
+    {
+
+        DataHelper dh = new DataHelper();
+
+        ftpOperater ftp = new ftpOperater();
+
+        public 首件仪上传()
+        {
+            InitializeComponent();
+        }
+
+        private void Form1_Load(object sender, EventArgs e)
+        {
+            OperateResult.AppendText("连接上服务器\n");
+            //timer1.Start();
+        }
+
+        public void DoLog(string Message)
+        {
+            try
+            {
+                StreamWriter sw = File.AppendText(DateTime.Now.ToString("yyyy-MM-dd") + ".txt");
+                sw.WriteLine("\n【时间】" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + Message + "\n");
+                sw.Close();
+            }
+            catch (Exception) { }
+        }
+
+        /// <summary>
+        /// 私有变量
+        /// </summary>
+        private List<FileInfo> lst = new List<FileInfo>();
+        /// <summary>
+        /// 获得目录下所有文件或指定文件类型文件(包含所有子文件夹)
+        /// </summary>
+        /// <param name="path">文件夹路径</param>
+        /// <param name="extName">扩展名可以多个 例如 .mp3.wma.rm</param>
+        /// <returns>List<FileInfo></returns>
+        public List<FileInfo> getFile(string path, string extName)
+        {
+            getdir(path, extName);
+            return lst;
+        }
+
+        /// <summary>
+        /// 私有方法,递归获取指定类型文件,包含子文件夹
+        /// </summary>
+        /// <param name="path"></param>
+        /// <param name="extName"></param>
+        private void getdir(string path, string extName)
+        {
+            try
+            {
+                string[] dir = Directory.GetDirectories(path); //文件夹列表   
+                DirectoryInfo fdir = new DirectoryInfo(path);
+                FileInfo[] file = fdir.GetFiles();
+                //FileInfo[] file = Directory.GetFiles(path); //文件列表   
+                if (file.Length != 0 || dir.Length != 0) //当前目录文件或文件夹不为空                   
+                {
+                    string SN = "";
+                    string folderpath = "";
+                    foreach (FileInfo f in file) //显示当前目录所有文件   
+                    {
+                        string filename = f.FullName;
+                        if (filename.Substring(filename.LastIndexOf(".") + 1).ToUpper() == "INI")
+                        {
+                            folderpath = f.FullName.Substring(0, f.FullName.LastIndexOf(@"\"));
+                            SN = f.Name.Split('.')[0].ToUpper().Split('_')[0];
+                            //if (SN.Length == 12)
+                            //{
+                            try
+                            {
+                                string ftppath = "/" + DateTime.Now.ToString("yyyy-MM-dd") + "/";
+                                ftp.UpLoadFile(folderpath, f.Name, ftppath, "");
+                                int dt = int.Parse(dh.ExecuteSql("insert into STEPTESTDETAIL (std_id,std_sn,std_makecode,std_indate,std_class)values( STEPTESTDETAIL_seq.nextval,'" + SN + "','" + ma_code.Text + "',sysdate,'http://81.71.42.91:8099/ftp" + ftppath + f.Name + "')", "insert").ToString());
+                                if (dt > 0)
+                                {
+                                    OperateResult.AppendText("序列号:" + SN + "上传成功\n");
+                                }
+                                //else
+                                //{
+                                //    OperateResult.AppendText("序列号: " + SN + "前工段未扫描\n");
+                                //    MessageBox.Show("序列号: " + SN + "前工段未扫描", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
+                                //}
+                            }
+                            catch (Exception ex)
+                            {
+                                Console.WriteLine(ex.Message);
+                            }
+                            File.Delete(f.FullName);
+                            //}
+                        }
+                    }
+                }
+            }
+            catch (Exception ex)
+            {
+                Console.WriteLine(ex.Message);
+            }
+        }
+
+        private void timer1_Tick(object sender, EventArgs e)
+        {
+            try
+            {
+                getFile(FolderPath.Text, ".txt");
+            }
+            catch (Exception ex)
+            {
+                Console.WriteLine(ex.Message);
+            }
+        }
+
+        /// <summary>
+        /// 获得目录下所有文件或指定文件类型文件(包含所有子文件夹)
+        /// </summary>
+        /// <param name="path">文件夹路径</param>
+        /// <param name="extName">扩展名可以多个 例如 .mp3.wma.rm</param>
+        /// <returns>List<FileInfo></returns>
+        public static List<FileInfo> getFile(string path, string extName, List<FileInfo> lst)
+        {
+            try
+            {
+                string[] dir = Directory.GetDirectories(path); //文件夹列表  
+                DirectoryInfo fdir = new DirectoryInfo(path);
+                FileInfo[] file = fdir.GetFiles();
+                //FileInfo[] file = Directory.GetFiles(path); //文件列表  
+                if (file.Length != 0 || dir.Length != 0) //当前目录文件或文件夹不为空          
+                {
+                    foreach (FileInfo f in file) //显示当前目录所有文件  
+                    {
+                        if (extName.ToLower().IndexOf(f.Extension.ToLower()) >= 0)
+                        {
+                            lst.Add(f);
+                        }
+                    }
+                    foreach (string d in dir)
+                    {
+                        getFile(d, extName, lst);//递归  
+                    }
+                }
+                return lst;
+            }
+            catch (Exception ex)
+            {
+                throw ex;
+            }
+        }
+
+        private void ChooseFolder_Click(object sender, EventArgs e)
+        {
+            FolderBrowserDialog folder = new FolderBrowserDialog();
+            folder.Description = "选择监控文件夹";
+            DialogResult result = folder.ShowDialog();
+            if (result == DialogResult.OK)
+            {
+                FolderPath.Text = folder.SelectedPath;
+            }
+        }
+
+        private void ChooseBackUpFolder_Click(object sender, EventArgs e)
+        {
+            FolderBrowserDialog folder = new FolderBrowserDialog();
+            folder.Description = "选择备份文件夹";
+            DialogResult result = folder.ShowDialog();
+            if (result == DialogResult.OK)
+            {
+                // BackUpFolderPath.Text = folder.SelectedPath;
+            }
+        }
+
+        private void Start_Click(object sender, EventArgs e)
+        {
+            if (!dh.CheckExist("make", "ma_code='" + ma_code.Text + "'"))
+            {
+                OperateResult.AppendText("工单" + ma_code.Text + "不存在\n");
+                return;
+            }
+            //ftp.UpLoadFile(text2, fileInfo.Name, uploadFolder, BackUpFolderPath.Text);
+            string[] files = Directory.GetFiles(FolderPath.Text);
+            foreach (var file in files)
+            {
+                string text2 = file.Substring(0, file.LastIndexOf("\\"));
+                string text = file.Substring(file.LastIndexOf("\\") + 1);
+
+                for (int i = 0; i < text.Length; i++)
+                {
+                    if (Regex.IsMatch(text.ToString(), @"[\u4E00-\u9FA5]+$"))
+                    {
+                        OperateResult.AppendText("文件名不允许包含\n");
+                        return;
+                    }
+                }
+                if (!dh.CheckExist("SMTCHECKFIRST", "scf_filepath='" + text + "'"))
+                {
+                    dh.ExecuteSql("insert into SMTCHECKFIRST(scf_id,scf_indate,scf_filepath,scd_makecode)values(" +
+                    "SMTCHECKFIRST_seq.nextval,sysdate,'http://81.71.42.91:8099/ftp/" + DateTime.Now.ToString("yyyy-MM-dd") + "/" + text + "','" + ma_code.Text + "')", "insert");
+                    string uploadFolder = "/CheckFirst/" + DateTime.Now.ToString("yyyy-MM-dd") + "/";
+                    ftp.UpLoadFile(text2, text, uploadFolder, "");
+                    OperateResult.AppendText("文件【" + text + "】上传成功\n");
+                }
+                else
+                {
+                    OperateResult.AppendText("文件【" + text + "】已存在\n");
+                }
+            }
+        }
+    }
+}

+ 120 - 0
FileWatcher/首件仪上传.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>