Jelajahi Sumber

设备日志读取抓取

callm 2 tahun lalu
induk
melakukan
96d6701f50

+ 1 - 1
FileWatcher/AutoAnalysisDevice.Designer.cs

@@ -239,7 +239,7 @@
             // ATEFile
             // 
             this.ATEFile.EnableRaisingEvents = true;
-            this.ATEFile.Filter = "*.ini";
+            this.ATEFile.Filter = "*.txt";
             this.ATEFile.SynchronizingObject = this;
             // 
             // AutoAnalysisDevice

+ 83 - 31
FileWatcher/AutoAnalysisDevice.cs

@@ -90,7 +90,7 @@ namespace FileWatcher
             InitDB = new Thread(ConnectDB);
             //添加监控事件
             XmlWatcher.Changed += new FileSystemEventHandler(XmlWatcher_Created);
-            ATEFile.Created += new FileSystemEventHandler(XmlWatcher_Created);
+            ATEFile.Changed += new FileSystemEventHandler(XmlWatcher_Created);
             SetLoadingWindow stw = new SetLoadingWindow(InitDB, "正在启动程序");
             stw.StartPosition = FormStartPosition.CenterScreen;
             stw.ShowDialog();
@@ -120,6 +120,7 @@ namespace FileWatcher
                 istepcode = dt.Rows[0]["sc_stepcode"].ToString();
                 ibadgroup = dt.Rows[0]["st_badgroupcode"].ToString();
             }
+            StartWatch.PerformClick();
         }
 
         private void ConnectDB()
@@ -245,47 +246,98 @@ 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);
+                        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/", "");
-                        fp_path= fp_path.Replace("\"","");
-                        dh.ExecuteSql("insert into Devicetestinfo(dti_id,dti_prodcode,dti_area,dti_uptime,dti_downtime,dti_upqty,dti_okqty,dti_ngqty,dti_ipaddress,dti_filepath,dti_indate,dti_fpid)values(Devicetestinfo_seq.nextval,'" + 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");
+                        fp_path = fp_path.Replace("\"", "");
+                        dh.ExecuteSql("insert into Devicetestinfo(dti_id,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() + "',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");
                     }
                 }
             }
             else if (Device.Text == "ATE设备")
             {
-                try
+                StreamReader sR = new StreamReader(FileName, Encoding.Default);
+                Console.WriteLine(sR.CurrentEncoding);
+                DataTable filedt = new DataTable();
+                //文件内的行,用一个DataTable存储
+                int Rowindex = 0;
+                while ((nextLine = sR.ReadLine()) != null)
                 {
-                    StreamReader sR = File.OpenText(FileName);
-                    string filename = FileName;
-                    List<string> programname = new List<string>();
-                    List<string> data = new List<string>();
-                    Regex re = new Regex(@"\d+");
-                    if (filename.Substring(filename.LastIndexOf(".") + 1).ToUpper() == "INI")
+                    //DataTable用第一行的数据作为列名
+                    string[] title = nextLine.Split(',');
+                    DataRow dr = filedt.NewRow();
+                    for (int i = 0; i < title.Length; i++)
                     {
-                        while ((nextLine = sR.ReadLine()) != null)
-                        {
-                            programname.Add(nextLine);
-                        }
-                        string[] str = programname.ToArray();
-                        for (int i = str.Length - 4; i < str.Length; i++)
+                        if (Rowindex == 0)
                         {
-                            if (str[i].Contains("["))
-                            {
-                                data.Add(str[i]);
-                            }
-                            else
+                            switch (i)
                             {
-                                data.Add(re.Match(str[i]).Groups[0].Value);
+                                case 0:
+                                    filedt.Columns.Add("登录的账号");
+                                    break;
+                                case 1:
+                                    filedt.Columns.Add("工位固定号");
+                                    break;
+                                case 2:
+                                    filedt.Columns.Add("产品代码");
+                                    break;
+                                case 3:
+                                    filedt.Columns.Add("计划单号");
+                                    break;
+                                case 4:
+                                    filedt.Columns.Add("使用参数名");
+                                    break;
+                                case 5:
+                                    filedt.Columns.Add("通道");
+                                    break;
+                                case 6:
+                                    filedt.Columns.Add("开始时间");
+                                    break;
+                                case 7:
+                                    filedt.Columns.Add("结束时间");
+                                    break;
+                                case 8:
+                                    filedt.Columns.Add("上架数量");
+                                    break;
+                                case 9:
+                                    filedt.Columns.Add("合格数量");
+                                    break;
+                                case 10:
+                                    filedt.Columns.Add("不良数量");
+                                    break;
+                                case 11:
+                                    filedt.Columns.Add("文件路径");
+                                    break;
+                                default:
+                                    break;
                             }
                         }
-                        dh.ExecuteSql("insert into ATETESTDATA(atd_id,atd_name,atd_passqty,atd_ngqty,atd_lastqty,atd_ipaddress,atd_makecode,atd_makecode)values(ATETESTDATA_seq.nextval,'" + data.ToArray()[0] + "','" + data.ToArray()[1] + "','" + data.ToArray()[2] + "','" + data.ToArray()[3] + "','" + IPAddress + "','" + ma_code.Text + "',sysdate)", "insert");
+                        dr[filedt.Columns[i].ColumnName] = title[i];
                     }
+                    filedt.Rows.Add(dr);
+                    Rowindex = Rowindex + 1;
                 }
-                catch (Exception e)
+                sR.Close();
+                OperateResult.AppendText("文件修改" + filedt.Rows.Count + "\n");
+                for (int i = 0; i < filedt.Rows.Count; i++)
                 {
-                    OperateResult.AppendText("解析失败:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\n" + FileName + "\n" + e.Message + "\n");
+                    if (!dh.CheckExist("Devicetestinfo", "(dti_uptime)=to_date('" + filedt.Rows[i]["开始时间"].ToString() + "','yyyy/mm/dd hh24:mi:ss') and dti_ipaddress='" + IPAddress + "'"))
+                    {
+                        string filename = filedt.Rows[i]["文件路径"].ToString();
+                        Dictionary<string, object> dic = new Dictionary<string, object>
+                        {
+                            { "em_name", "管理员" },
+                            { "em_code", "ADMIN" },
+                            { "caller", "AGING" }
+                        };
+                        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/", "");
+                        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");
+                    }
                 }
             }
         }
@@ -351,7 +403,7 @@ namespace FileWatcher
                 string path = Application.ExecutablePath;
                 RegistryKey rk = Registry.LocalMachine;
                 RegistryKey rk2 = rk.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run");
-                rk2.SetValue("UAS自动过站解析器.exe", path);
+                rk2.SetValue("FileWatcher.exe", path);
                 rk2.Close();
                 rk.Close();
             }
@@ -360,7 +412,7 @@ namespace FileWatcher
                 string path = Application.ExecutablePath;
                 RegistryKey rk = Registry.LocalMachine;
                 RegistryKey rk2 = rk.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run");
-                rk2.DeleteValue("UAS自动过站解析器.exe", false);
+                rk2.DeleteValue("FileWatcher.exe", false);
                 rk2.Close();
                 rk.Close();
             }
@@ -388,7 +440,7 @@ namespace FileWatcher
         /// <param name="filepath">本地文件路径</param>
         /// <param name="dic">上传的数据信息</param>
         /// <returns></returns>
-        public string UploadFilesToRemoteUrl(string url1, string filepath, Dictionary<string, object> dic,out string fp_path,out string fp_id)
+        public string UploadFilesToRemoteUrl(string url1, string filepath, Dictionary<string, object> dic, out string fp_path, out string fp_id)
         {
             fp_id = "";
             fp_path = "";
@@ -461,11 +513,11 @@ namespace FileWatcher
                 List<Dictionary<string, object>> dic2 = null;
                 dic1 = BaseUtil.ToDictionary(Content);
                 dic2 = dic1["data"] as List<Dictionary<string, object>>;
-            
+
                 if (dic2[0]["filepath"] != null)
                 {
                     fp_id = dic2[0]["filepath"].ToString();
-                    fp_path= dic2[0]["path"].ToString();
+                    fp_path = dic2[0]["path"].ToString();
                 }
                 if (response.StatusCode == HttpStatusCode.OK)
                 {

+ 96 - 0
FileWatcher/BaseUtil.cs

@@ -1,12 +1,16 @@
 using System;
 using System.Collections.Generic;
 using System.IO;
+using System.Net;
+using System.Text;
 using System.Text.RegularExpressions;
 using System.Web.Script.Serialization;
 using System.Xml;
 
 namespace FileWatcher
 {
+
+
     class BaseUtil
     {
         public static void CreateXml(string iSN, string iTestResult)
@@ -28,6 +32,98 @@ namespace FileWatcher
             }
         }
 
+        public static string UploadFilesToRemoteUrl(string url1, string filepath, Dictionary<string, object> dic, out string fp_path, out string fp_id)
+        {
+            fp_id = "";
+            fp_path = "";
+            try
+            {
+                ServicePointManager.DefaultConnectionLimit = 50;
+
+                string boundary = DateTime.Now.Ticks.ToString("x");
+
+                byte[] boundarybytes = System.Text.Encoding.UTF8.GetBytes("--" + boundary + "\r\n");
+
+                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url1);
+                request.Method = "POST";
+                request.Timeout = 10 * 10000;
+                request.ContentType = "multipart/form-data; boundary=" + boundary;
+
+                Stream rs = request.GetRequestStream();
+
+                var endBoundaryBytes = Encoding.UTF8.GetBytes("--" + boundary + "--\r\n");
+
+                string formdataTemplate = "Content-Disposition: form-data; name=\"{0}\"\r\n" + "\r\n" + "{1}" + "\r\n";
+                if (dic != null)
+                {
+                    foreach (string key in dic.Keys)
+                    {
+                        rs.Write(boundarybytes, 0, boundarybytes.Length);
+
+                        string formitem = string.Format(formdataTemplate, key, dic[key]);
+
+                        byte[] formitembytes = System.Text.Encoding.UTF8.GetBytes(formitem);
+
+                        rs.Write(formitembytes, 0, formitembytes.Length);
+                    }
+
+                }
+
+                string headerTemplate = "Content-Disposition: form-data; name=\"{0}\"; filename=\"{1}\"\r\n\r\n";
+                {
+                    rs.Write(boundarybytes, 0, boundarybytes.Length);
+
+                    var header = string.Format(headerTemplate, "file", Path.GetFileName(filepath));
+
+                    var headerbytes = System.Text.Encoding.UTF8.GetBytes(header);
+
+                    rs.Write(headerbytes, 0, headerbytes.Length);
+
+                    using (var fileStream = new FileStream(filepath, FileMode.Open, FileAccess.Read))
+                    {
+                        var buffer = new byte[1024];
+
+                        var bytesRead = 0;
+
+                        while ((bytesRead = fileStream.Read(buffer, 0, buffer.Length)) != 0)
+                        {
+                            rs.Write(buffer, 0, bytesRead);
+                        }
+                    }
+                    var cr = Encoding.UTF8.GetBytes("\r\n");
+
+                    rs.Write(cr, 0, cr.Length);
+                }
+
+                rs.Write(endBoundaryBytes, 0, endBoundaryBytes.Length);
+
+                var response = request.GetResponse() as HttpWebResponse;
+
+                StreamReader newReader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
+                string Content = newReader.ReadToEnd();
+                Dictionary<string, object> dic1 = new Dictionary<string, object>();
+                List<Dictionary<string, object>> dic2 = null;
+                dic1 = BaseUtil.ToDictionary(Content);
+                dic2 = dic1["data"] as List<Dictionary<string, object>>;
+
+                if (dic2[0]["filepath"] != null)
+                {
+                    fp_id = dic2[0]["filepath"].ToString();
+                    fp_path = dic2[0]["path"].ToString();
+                }
+                if (response.StatusCode == HttpStatusCode.OK)
+                {
+                    Console.WriteLine(fp_id);
+                    return fp_id;
+                }
+            }
+            catch (Exception e)
+            {   
+                Console.WriteLine(e.Message + e.StackTrace);
+            }
+            return "";
+        }
+
         public static Dictionary<string, object> ToDictionary(string JsonData)
         {
             object Data = null;

+ 3 - 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.101.253)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
+        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)));";
         //用户选择的数据库的连接字符串
-        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.101.253)(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 OracleConnection connection = null;
         OracleCommand command = null;
         int ReconnectTime = 0;
@@ -508,6 +508,7 @@ namespace FileWatcher
         public object ExecuteSql(string SQL, string Type, params object[] names)
         {
             object result = null;
+            //Console.WriteLine(SQL);
             command = new OracleCommand(SQL, connection);
             Reconnect(command);
             //用来拼接参数的

+ 56 - 13
FileWatcher/FileWatcher.csproj

@@ -11,6 +11,22 @@
     <AssemblyName>FileWatcher</AssemblyName>
     <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
     <FileAlignment>512</FileAlignment>
+    <PublishUrl>publish\</PublishUrl>
+    <Install>true</Install>
+    <InstallFrom>Disk</InstallFrom>
+    <UpdateEnabled>false</UpdateEnabled>
+    <UpdateMode>Foreground</UpdateMode>
+    <UpdateInterval>7</UpdateInterval>
+    <UpdateIntervalUnits>Days</UpdateIntervalUnits>
+    <UpdatePeriodically>false</UpdatePeriodically>
+    <UpdateRequired>false</UpdateRequired>
+    <MapFileExtensions>true</MapFileExtensions>
+    <ApplicationRevision>0</ApplicationRevision>
+    <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
+    <IsWebBootstrapper>false</IsWebBootstrapper>
+    <UseApplicationTrust>false</UseApplicationTrust>
+    <BootstrapperEnabled>true</BootstrapperEnabled>
+    <TargetFrameworkProfile />
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <PlatformTarget>AnyCPU</PlatformTarget>
@@ -21,6 +37,7 @@
     <DefineConstants>DEBUG;TRACE</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
+    <Prefer32Bit>false</Prefer32Bit>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
     <PlatformTarget>AnyCPU</PlatformTarget>
@@ -30,6 +47,7 @@
     <DefineConstants>TRACE</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
+    <Prefer32Bit>false</Prefer32Bit>
   </PropertyGroup>
   <ItemGroup>
     <Reference Include="Microsoft.Office.Interop.Excel, Version=10.0.4504.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
@@ -41,7 +59,16 @@
       <HintPath>..\TestProject\tool\Newtonsoft.Json.dll</HintPath>
     </Reference>
     <Reference Include="NPOI">
-      <HintPath>..\UAS-MES\Tool\NPOI.dll</HintPath>
+      <HintPath>tool\NPOI.dll</HintPath>
+    </Reference>
+    <Reference Include="NPOI.OOXML">
+      <HintPath>tool\NPOI.OOXML.dll</HintPath>
+    </Reference>
+    <Reference Include="NPOI.OpenXml4Net">
+      <HintPath>tool\NPOI.OpenXml4Net.dll</HintPath>
+    </Reference>
+    <Reference Include="NPOI.OpenXmlFormats">
+      <HintPath>tool\NPOI.OpenXmlFormats.dll</HintPath>
     </Reference>
     <Reference Include="Oracle.ManagedDataAccess, Version=4.121.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342, processorArchitecture=MSIL">
       <SpecificVersion>False</SpecificVersion>
@@ -78,9 +105,6 @@
     <Reference Include="System.Drawing" />
     <Reference Include="System.Windows.Forms" />
     <Reference Include="System.Xml" />
-    <Reference Include="UMES.DLLService">
-      <HintPath>..\UAS_MesInterface(ODLF)\bin\Debug\UMES.DLLService.dll</HintPath>
-    </Reference>
   </ItemGroup>
   <ItemGroup>
     <Compile Include="AutoAnalysisDevice.cs">
@@ -154,12 +178,6 @@
       <DependentUpon>SetLoadingWindow.cs</DependentUpon>
     </Compile>
     <Compile Include="TcpServer.cs" />
-    <Compile Include="测试记录解析DCW.cs">
-      <SubType>Form</SubType>
-    </Compile>
-    <Compile Include="测试记录解析DCW.Designer.cs">
-      <DependentUpon>测试记录解析DCW.cs</DependentUpon>
-    </Compile>
     <Compile Include="测试记录解析.cs">
       <SubType>Form</SubType>
     </Compile>
@@ -174,6 +192,12 @@
     </Compile>
     <Compile Include="Program.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="测试记录解析DCW.cs">
+      <SubType>Form</SubType>
+    </Compile>
+    <Compile Include="测试记录解析DCW.Designer.cs">
+      <DependentUpon>测试记录解析DCW.cs</DependentUpon>
+    </Compile>
     <EmbeddedResource Include="AutoAnalysisDevice.resx">
       <DependentUpon>AutoAnalysisDevice.cs</DependentUpon>
     </EmbeddedResource>
@@ -204,9 +228,6 @@
     <EmbeddedResource Include="SetLoadingWindow.resx">
       <DependentUpon>SetLoadingWindow.cs</DependentUpon>
     </EmbeddedResource>
-    <EmbeddedResource Include="测试记录解析DCW.resx">
-      <DependentUpon>测试记录解析DCW.cs</DependentUpon>
-    </EmbeddedResource>
     <EmbeddedResource Include="测试记录解析.resx">
       <DependentUpon>测试记录解析.cs</DependentUpon>
     </EmbeddedResource>
@@ -221,7 +242,12 @@
     <Compile Include="Properties\Resources.Designer.cs">
       <AutoGen>True</AutoGen>
       <DependentUpon>Resources.resx</DependentUpon>
+      <DesignTime>True</DesignTime>
     </Compile>
+    <EmbeddedResource Include="测试记录解析DCW.resx">
+      <DependentUpon>测试记录解析DCW.cs</DependentUpon>
+    </EmbeddedResource>
+    <None Include="app.config" />
     <None Include="Properties\Settings.settings">
       <Generator>SettingsSingleFileGenerator</Generator>
       <LastGenOutput>Settings.Designer.cs</LastGenOutput>
@@ -237,6 +263,23 @@
     <Content Include="tool\XlsCrt2.DLL" />
     <Content Include="tool\XlsxCrt.dll" />
   </ItemGroup>
+  <ItemGroup>
+    <BootstrapperPackage Include=".NETFramework,Version=v4.0">
+      <Visible>False</Visible>
+      <ProductName>Microsoft .NET Framework 4 %28x86 和 x64%29</ProductName>
+      <Install>true</Install>
+    </BootstrapperPackage>
+    <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
+      <Visible>False</Visible>
+      <ProductName>.NET Framework 3.5 SP1</ProductName>
+      <Install>false</Install>
+    </BootstrapperPackage>
+    <BootstrapperPackage Include="Microsoft.Windows.Installer.4.5">
+      <Visible>False</Visible>
+      <ProductName>Windows Installer 4.5</ProductName>
+      <Install>true</Install>
+    </BootstrapperPackage>
+  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
        Other similar extension points exist, see Microsoft.Common.targets.

+ 120 - 199
FileWatcher/Form4.Designer.cs

@@ -28,266 +28,195 @@
         /// </summary>
         private void InitializeComponent()
         {
-            this.textBox1 = new System.Windows.Forms.TextBox();
-            this.label1 = new System.Windows.Forms.Label();
+            this.label6 = new System.Windows.Forms.Label();
             this.label2 = new System.Windows.Forms.Label();
+            this.label1 = new System.Windows.Forms.Label();
+            this.FolderPath = new System.Windows.Forms.TextBox();
             this.label3 = new System.Windows.Forms.Label();
             this.label4 = new System.Windows.Forms.Label();
-            this.label5 = new System.Windows.Forms.Label();
-            this.pictureBox1 = new System.Windows.Forms.PictureBox();
-            this.label6 = new System.Windows.Forms.Label();
-            this.textBox2 = new System.Windows.Forms.TextBox();
+            this.textBox1 = new System.Windows.Forms.TextBox();
             this.label7 = new System.Windows.Forms.Label();
+            this.textBox2 = new System.Windows.Forms.TextBox();
             this.label8 = new System.Windows.Forms.Label();
             this.textBox3 = new System.Windows.Forms.TextBox();
-            this.label11 = new System.Windows.Forms.Label();
             this.label9 = new System.Windows.Forms.Label();
-            this.textBox4 = new System.Windows.Forms.TextBox();
-            this.dataGridView1 = new System.Windows.Forms.DataGridView();
-            this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.Column3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.label10 = 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.StartWatch = new System.Windows.Forms.Button();
             this.button1 = new System.Windows.Forms.Button();
-            ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
-            ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
+            this.textBox4 = new System.Windows.Forms.TextBox();
+            this.label5 = new System.Windows.Forms.Label();
             this.SuspendLayout();
             // 
-            // textBox1
+            // label6
             // 
-            this.textBox1.Location = new System.Drawing.Point(210, 100);
-            this.textBox1.Name = "textBox1";
-            this.textBox1.Size = new System.Drawing.Size(243, 35);
-            this.textBox1.TabIndex = 0;
+            this.label6.AutoSize = true;
+            this.label6.Location = new System.Drawing.Point(89, 135);
+            this.label6.Name = "label6";
+            this.label6.Size = new System.Drawing.Size(106, 24);
+            this.label6.TabIndex = 7;
+            this.label6.Text = "稽查内容";
+            // 
+            // label2
+            // 
+            this.label2.AutoSize = true;
+            this.label2.Location = new System.Drawing.Point(250, 59);
+            this.label2.Name = "label2";
+            this.label2.Size = new System.Drawing.Size(0, 24);
+            this.label2.TabIndex = 2;
             // 
             // label1
             // 
             this.label1.AutoSize = true;
-            this.label1.Location = new System.Drawing.Point(89, 103);
+            this.label1.Location = new System.Drawing.Point(89, 59);
             this.label1.Name = "label1";
-            this.label1.Size = new System.Drawing.Size(82, 24);
+            this.label1.Size = new System.Drawing.Size(106, 24);
             this.label1.TabIndex = 1;
-            this.label1.Text = "工单号";
+            this.label1.Text = "单据编号";
             // 
-            // label2
+            // FolderPath
             // 
-            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 = "可选放大镜";
+            this.FolderPath.Enabled = false;
+            this.FolderPath.Location = new System.Drawing.Point(270, 132);
+            this.FolderPath.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
+            this.FolderPath.Name = "FolderPath";
+            this.FolderPath.Size = new System.Drawing.Size(295, 35);
+            this.FolderPath.TabIndex = 8;
             // 
             // label3
             // 
             this.label3.AutoSize = true;
-            this.label3.Location = new System.Drawing.Point(89, 187);
+            this.label3.Location = new System.Drawing.Point(89, 301);
             this.label3.Name = "label3";
             this.label3.Size = new System.Drawing.Size(106, 24);
-            this.label3.TabIndex = 3;
-            this.label3.Text = "产品编号";
+            this.label3.TabIndex = 9;
+            this.label3.Text = "上传附件";
             // 
             // label4
             // 
             this.label4.AutoSize = true;
-            this.label4.Location = new System.Drawing.Point(371, 187);
+            this.label4.Location = new System.Drawing.Point(89, 243);
             this.label4.Name = "label4";
-            this.label4.Size = new System.Drawing.Size(106, 24);
-            this.label4.TabIndex = 4;
-            this.label4.Text = "产品名称";
+            this.label4.Size = new System.Drawing.Size(130, 24);
+            this.label4.TabIndex = 10;
+            this.label4.Text = "指定处理人";
             // 
-            // label5
-            // 
-            this.label5.AutoSize = true;
-            this.label5.Location = new System.Drawing.Point(12, 787);
-            this.label5.Name = "label5";
-            this.label5.Size = new System.Drawing.Size(286, 24);
-            this.label5.TabIndex = 5;
-            this.label5.Text = "人员名称 : 当前岗位  :";
-            // 
-            // pictureBox1
-            // 
-            this.pictureBox1.Location = new System.Drawing.Point(692, 83);
-            this.pictureBox1.Name = "pictureBox1";
-            this.pictureBox1.Size = new System.Drawing.Size(179, 207);
-            this.pictureBox1.TabIndex = 6;
-            this.pictureBox1.TabStop = false;
-            // 
-            // label6
-            // 
-            this.label6.AutoSize = true;
-            this.label6.Location = new System.Drawing.Point(724, 43);
-            this.label6.Name = "label6";
-            this.label6.Size = new System.Drawing.Size(106, 24);
-            this.label6.TabIndex = 7;
-            this.label6.Text = "人员照片";
-            // 
-            // textBox2
+            // textBox1
             // 
-            this.textBox2.Location = new System.Drawing.Point(210, 468);
-            this.textBox2.Name = "textBox2";
-            this.textBox2.Size = new System.Drawing.Size(243, 35);
-            this.textBox2.TabIndex = 8;
+            this.textBox1.Enabled = false;
+            this.textBox1.Location = new System.Drawing.Point(270, 243);
+            this.textBox1.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
+            this.textBox1.Name = "textBox1";
+            this.textBox1.Size = new System.Drawing.Size(295, 35);
+            this.textBox1.TabIndex = 11;
             // 
             // label7
             // 
             this.label7.AutoSize = true;
-            this.label7.Location = new System.Drawing.Point(89, 474);
+            this.label7.Location = new System.Drawing.Point(89, 519);
             this.label7.Name = "label7";
             this.label7.Size = new System.Drawing.Size(106, 24);
-            this.label7.TabIndex = 9;
-            this.label7.Text = "不良现象";
+            this.label7.TabIndex = 12;
+            this.label7.Text = "上传附件";
+            // 
+            // textBox2
+            // 
+            this.textBox2.Enabled = false;
+            this.textBox2.Location = new System.Drawing.Point(270, 369);
+            this.textBox2.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
+            this.textBox2.Name = "textBox2";
+            this.textBox2.Size = new System.Drawing.Size(295, 35);
+            this.textBox2.TabIndex = 14;
             // 
             // label8
             // 
             this.label8.AutoSize = true;
-            this.label8.Location = new System.Drawing.Point(89, 410);
+            this.label8.Location = new System.Drawing.Point(89, 369);
             this.label8.Name = "label8";
-            this.label8.Size = new System.Drawing.Size(58, 24);
-            this.label8.TabIndex = 11;
-            this.label8.Text = "位号";
+            this.label8.Size = new System.Drawing.Size(130, 24);
+            this.label8.TabIndex = 13;
+            this.label8.Text = "变更处理人";
             // 
             // textBox3
             // 
-            this.textBox3.Location = new System.Drawing.Point(210, 404);
+            this.textBox3.Enabled = false;
+            this.textBox3.Location = new System.Drawing.Point(270, 448);
+            this.textBox3.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
             this.textBox3.Name = "textBox3";
-            this.textBox3.Size = new System.Drawing.Size(243, 35);
-            this.textBox3.TabIndex = 10;
-            this.textBox3.Text = "手填(先设置非必填)";
-            this.textBox3.TextChanged += new System.EventHandler(this.textBox3_TextChanged);
-            // 
-            // label11
-            // 
-            this.label11.AutoSize = true;
-            this.label11.Location = new System.Drawing.Point(89, 349);
-            this.label11.Name = "label11";
-            this.label11.Size = new System.Drawing.Size(502, 24);
-            this.label11.TabIndex = 24;
-            this.label11.Text = "炉前目检,其他工序不填写位号,数量默认是1";
+            this.textBox3.Size = new System.Drawing.Size(295, 35);
+            this.textBox3.TabIndex = 16;
             // 
             // label9
             // 
             this.label9.AutoSize = true;
-            this.label9.Location = new System.Drawing.Point(89, 543);
+            this.label9.Location = new System.Drawing.Point(89, 448);
             this.label9.Name = "label9";
-            this.label9.Size = new System.Drawing.Size(58, 24);
-            this.label9.TabIndex = 26;
-            this.label9.Text = "数量";
-            // 
-            // textBox4
-            // 
-            this.textBox4.Location = new System.Drawing.Point(210, 537);
-            this.textBox4.Name = "textBox4";
-            this.textBox4.Size = new System.Drawing.Size(243, 35);
-            this.textBox4.TabIndex = 25;
-            this.textBox4.Text = "默认值1";
-            this.textBox4.TextChanged += new System.EventHandler(this.textBox4_TextChanged);
-            // 
-            // dataGridView1
-            // 
-            this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
-            this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
-            this.Column1,
-            this.Column2,
-            this.Column3});
-            this.dataGridView1.Location = new System.Drawing.Point(944, 83);
-            this.dataGridView1.Name = "dataGridView1";
-            this.dataGridView1.RowTemplate.Height = 37;
-            this.dataGridView1.Size = new System.Drawing.Size(450, 368);
-            this.dataGridView1.TabIndex = 27;
-            // 
-            // Column1
-            // 
-            this.Column1.HeaderText = "现象";
-            this.Column1.Name = "Column1";
-            // 
-            // Column2
-            // 
-            this.Column2.HeaderText = "位号";
-            this.Column2.Name = "Column2";
-            // 
-            // Column3
+            this.label9.Size = new System.Drawing.Size(106, 24);
+            this.label9.TabIndex = 15;
+            this.label9.Text = "改善措施";
             // 
-            this.Column3.HeaderText = "数量";
-            this.Column3.Name = "Column3";
+            // StartWatch
             // 
-            // label10
+            this.StartWatch.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.StartWatch.Location = new System.Drawing.Point(186, 649);
+            this.StartWatch.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
+            this.StartWatch.Name = "StartWatch";
+            this.StartWatch.Size = new System.Drawing.Size(128, 56);
+            this.StartWatch.TabIndex = 17;
+            this.StartWatch.Text = "保存";
+            this.StartWatch.UseVisualStyleBackColor = true;
             // 
-            this.label10.AutoSize = true;
-            this.label10.Location = new System.Drawing.Point(476, 474);
-            this.label10.Name = "label10";
-            this.label10.Size = new System.Drawing.Size(130, 24);
-            this.label10.TabIndex = 28;
-            this.label10.Text = "可选放大镜";
-            // 
-            // label12
-            // 
-            this.label12.AutoSize = true;
-            this.label12.Location = new System.Drawing.Point(476, 266);
-            this.label12.Name = "label12";
-            this.label12.Size = new System.Drawing.Size(130, 24);
-            this.label12.TabIndex = 31;
-            this.label12.Text = "可选放大镜";
-            // 
-            // label13
+            // button1
             // 
-            this.label13.AutoSize = true;
-            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.button1.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.button1.Location = new System.Drawing.Point(369, 649);
+            this.button1.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
+            this.button1.Name = "button1";
+            this.button1.Size = new System.Drawing.Size(128, 56);
+            this.button1.TabIndex = 18;
+            this.button1.Text = "确认处理";
+            this.button1.UseVisualStyleBackColor = true;
             // 
-            // textBox5
+            // textBox4
             // 
-            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;
+            this.textBox4.Enabled = false;
+            this.textBox4.Location = new System.Drawing.Point(270, 188);
+            this.textBox4.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
+            this.textBox4.Name = "textBox4";
+            this.textBox4.Size = new System.Drawing.Size(295, 35);
+            this.textBox4.TabIndex = 20;
             // 
-            // button1
+            // label5
             // 
-            this.button1.Location = new System.Drawing.Point(210, 629);
-            this.button1.Name = "button1";
-            this.button1.Size = new System.Drawing.Size(137, 48);
-            this.button1.TabIndex = 32;
-            this.button1.Text = "保存";
-            this.button1.UseVisualStyleBackColor = true;
+            this.label5.AutoSize = true;
+            this.label5.Location = new System.Drawing.Point(89, 191);
+            this.label5.Name = "label5";
+            this.label5.Size = new System.Drawing.Size(58, 24);
+            this.label5.TabIndex = 19;
+            this.label5.Text = "地点";
             // 
             // Form4
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 24F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.ClientSize = new System.Drawing.Size(1419, 820);
+            this.Controls.Add(this.textBox4);
+            this.Controls.Add(this.label5);
             this.Controls.Add(this.button1);
-            this.Controls.Add(this.label12);
-            this.Controls.Add(this.label13);
-            this.Controls.Add(this.textBox5);
-            this.Controls.Add(this.label10);
-            this.Controls.Add(this.dataGridView1);
+            this.Controls.Add(this.StartWatch);
+            this.Controls.Add(this.textBox3);
             this.Controls.Add(this.label9);
-            this.Controls.Add(this.textBox4);
-            this.Controls.Add(this.label11);
+            this.Controls.Add(this.textBox2);
             this.Controls.Add(this.label8);
-            this.Controls.Add(this.textBox3);
             this.Controls.Add(this.label7);
-            this.Controls.Add(this.textBox2);
-            this.Controls.Add(this.label6);
-            this.Controls.Add(this.pictureBox1);
-            this.Controls.Add(this.label5);
+            this.Controls.Add(this.textBox1);
             this.Controls.Add(this.label4);
             this.Controls.Add(this.label3);
+            this.Controls.Add(this.FolderPath);
+            this.Controls.Add(this.label6);
             this.Controls.Add(this.label2);
             this.Controls.Add(this.label1);
-            this.Controls.Add(this.textBox1);
             this.Name = "Form4";
             this.Text = "Form4";
             this.Load += new System.EventHandler(this.Form4_Load);
-            ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
-            ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
             this.ResumeLayout(false);
             this.PerformLayout();
 
@@ -295,29 +224,21 @@
 
         #endregion
 
-        private System.Windows.Forms.TextBox textBox1;
-        private System.Windows.Forms.Label label1;
+        private System.Windows.Forms.Label label6;
         private System.Windows.Forms.Label label2;
+        private System.Windows.Forms.Label label1;
+        private System.Windows.Forms.TextBox FolderPath;
         private System.Windows.Forms.Label label3;
         private System.Windows.Forms.Label label4;
-        private System.Windows.Forms.Label label5;
-        private System.Windows.Forms.PictureBox pictureBox1;
-        private System.Windows.Forms.Label label6;
-        private System.Windows.Forms.TextBox textBox2;
+        private System.Windows.Forms.TextBox textBox1;
         private System.Windows.Forms.Label label7;
+        private System.Windows.Forms.TextBox textBox2;
         private System.Windows.Forms.Label label8;
         private System.Windows.Forms.TextBox textBox3;
-        private System.Windows.Forms.Label label11;
         private System.Windows.Forms.Label label9;
-        private System.Windows.Forms.TextBox textBox4;
-        private System.Windows.Forms.DataGridView dataGridView1;
-        private System.Windows.Forms.DataGridViewTextBoxColumn Column1;
-        private System.Windows.Forms.DataGridViewTextBoxColumn Column2;
-        private System.Windows.Forms.DataGridViewTextBoxColumn Column3;
-        private System.Windows.Forms.Label label10;
-        private System.Windows.Forms.Label label12;
-        private System.Windows.Forms.Label label13;
-        private System.Windows.Forms.TextBox textBox5;
+        private System.Windows.Forms.Button StartWatch;
         private System.Windows.Forms.Button button1;
+        private System.Windows.Forms.TextBox textBox4;
+        private System.Windows.Forms.Label label5;
     }
 }

+ 168 - 3
FileWatcher/Form4.cs

@@ -1,10 +1,15 @@
-using System;
+using NPOI.HSSF.UserModel;
+using NPOI.SS.UserModel;
+using NPOI.XSSF.UserModel;
+using System;
 using System.Collections.Generic;
 using System.ComponentModel;
 using System.Data;
 using System.Drawing;
+using System.IO;
 using System.Linq;
 using System.Text;
+using System.Threading;
 using System.Windows.Forms;
 
 namespace FileWatcher
@@ -30,15 +35,175 @@ namespace FileWatcher
         {
 
         }
-
+        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))
+            //{
+            //    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);
+            //}
+            //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();
         }
 
         private void textBox4_TextChanged(object sender, EventArgs e)
         {
 
         }
+
+        private void SaveFileToJPG(string filename)
+        {
+            DataHelper dh = new DataHelper();
+            DataTable dt = ExcelToDataTable(filename, true);
+            for (int i = 0; i < dt.Rows.Count; i++)
+            {
+                string sql = "insert into deviceproduct(dp_id,dp_prodcode,dp_decode)values(deviceproduct_seq.nextval,'" + dt.Rows[i]["dp_prodcode"].ToString() + "','" + dt.Rows[i]["de_code"].ToString() + "')";
+                dh.ExecuteSql(sql, "insert");
+            }
+        }
+
+        public static DataTable ExcelToDataTable(string filePath, bool isColumnName)
+        {
+            DataTable dataTable = null;
+            FileStream fs = null;
+            DataColumn column = null;
+            DataRow dataRow = null;
+            IWorkbook workbook = null;
+            ISheet sheet = null;
+            IRow row = null;
+            ICell cell = null;
+            int startRow = 0;
+            try
+            {
+                using (fs = File.OpenRead(filePath))
+                {
+                    // 2007版本
+                    if (filePath.IndexOf(".xlsx") > 0)
+                    {
+                        workbook = new XSSFWorkbook(fs);
+                    }
+                    // 2003版本
+                    else if (filePath.IndexOf(".xls") > 0)
+                    {
+                        workbook = new HSSFWorkbook(fs);
+                    }
+                    if (workbook != null)
+                    {
+                        sheet = workbook.GetSheetAt(0);//读取第一个sheet,当然也可以循环读取每个sheet
+                        dataTable = new DataTable();
+                        if (sheet != null)
+                        {
+                            int rowCount = sheet.LastRowNum;//总行数
+                            if (rowCount > 0)
+                            {
+                                IRow firstRow = sheet.GetRow(0);//第一行
+                                int cellCount = firstRow.LastCellNum;//列数
+
+                                //构建datatable的列
+                                if (isColumnName)
+                                {
+                                    startRow = 1;//如果第一行是列名,则从第二行开始读取
+                                    for (int i = firstRow.FirstCellNum; i < cellCount; ++i)
+                                    {
+                                        cell = firstRow.GetCell(i);
+                                        if (cell != null)
+                                        {
+                                            if (cell.StringCellValue != null)
+                                            {
+                                                column = new DataColumn(cell.StringCellValue);
+                                                dataTable.Columns.Add(column);
+                                            }
+                                        }
+                                    }
+                                }
+                                else
+                                {
+                                    for (int i = firstRow.FirstCellNum; i < cellCount; ++i)
+                                    {
+                                        column = new DataColumn("column" + (i + 1));
+                                        dataTable.Columns.Add(column);
+                                    }
+                                }
+                                //填充行
+                                for (int i = startRow; i <= rowCount; ++i)
+                                {
+                                    row = sheet.GetRow(i);
+                                    if (row == null) continue;
+
+                                    dataRow = dataTable.NewRow();
+                                    for (int j = row.FirstCellNum; j < cellCount; ++j)
+                                    {
+                                        cell = row.GetCell(j);
+                                        if (cell == null)
+                                        {
+                                            dataRow[j] = "";
+                                        }
+                                        else
+                                        {
+                                            //CellType(Unknown = -1,Numeric = 0,String = 1,Formula = 2,Blank = 3,Boolean = 4,Error = 5,)
+                                            switch (cell.CellType)
+                                            {
+                                                case CellType.Blank:
+                                                    dataRow[j] = "";
+                                                    break;
+                                                case CellType.Numeric:
+                                                    short format = cell.CellStyle.DataFormat;
+                                                    //对时间格式(2015.12.5、2015/12/5、2015-12-5等)的处理
+                                                    if (format == 14 || format == 31 || format == 57 || format == 58)
+                                                        dataRow[j] = cell.DateCellValue;
+                                                    else
+                                                        dataRow[j] = cell.NumericCellValue;
+                                                    break;
+                                                case CellType.String:
+                                                    dataRow[j] = cell.StringCellValue;
+                                                    break;
+                                                case CellType.Formula:
+                                                    dataRow[j] = cell.StringCellValue;
+                                                    break;
+                                            }
+                                        }
+                                    }
+                                    dataTable.Rows.Add(dataRow);
+                                }
+                            }
+                        }
+                    }
+                }
+                return dataTable;
+            }
+            catch (Exception)
+            {
+                if (fs != null)
+                {
+                    fs.Close();
+                }
+                return null;
+            }
+        }
     }
 }

+ 0 - 9
FileWatcher/Form4.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="Column2.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>
 </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.101.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.6.253)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
             //重新执行一遍构造函数使得重置之后的链接字符串生效
             dh = new DataHelper();
             AutoAnalysisXmlByStep.dh = dh;

+ 3 - 3
FileWatcher/Program.cs

@@ -45,7 +45,7 @@ namespace FileWatcher
                 Application.EnableVisualStyles();
                 Application.SetCompatibleTextRenderingDefault(false);
                 if (principal.IsInRole(WindowsBuiltInRole.Administrator))
-                    Application.Run(new Login());
+                    Application.Run(new AutoAnalysisDevice());
                 else
                 {
                     //创建启动对象
@@ -116,9 +116,9 @@ namespace FileWatcher
             if (ex != null)
             {
                 sb.AppendLine(ex.Message);
-                //sb.AppendLine("【异常方法】:" + ex.StackTrace);
+                sb.AppendLine("【异常方法】:" + ex.StackTrace);
             }
-            //else { sb.AppendLine("【未处理异常】:" + backStr); }
+            else { sb.AppendLine("【未处理异常】:" + backStr); }
             return sb.ToString();
         }
     }

+ 26 - 34
FileWatcher/Properties/Resources.Designer.cs

@@ -1,69 +1,61 @@
 //------------------------------------------------------------------------------
 // <auto-generated>
 //     此代码由工具生成。
-//     运行时版本: 4.0.30319.42000
+//     运行时版本:4.0.30319.42000
 //
-//     对此文件的更改可能导致不正确的行为,如果
-//     重新生成代码,则所做更改将丢失。
+//     对此文件的更改可能导致不正确的行为,并且如果
+//     重新生成代码,这些更改将会丢失。
 // </auto-generated>
 //------------------------------------------------------------------------------
 
-namespace FileWatcher.Properties
-{
-
-
+namespace FileWatcher.Properties {
+    using System;
+    
+    
     /// <summary>
-    ///   强类型资源类,用于查找本地化字符串等。
+    ///   一个强类型资源类,用于查找本地化字符串等。
     /// </summary>
     // 此类是由 StronglyTypedResourceBuilder
     // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
-    // 若要添加或除成员,请编辑 .ResX 文件,然后重新运行 ResGen
+    // 若要添加或除成员,请编辑 .ResX 文件,然后重新运行 ResGen
     // (以 /str 作为命令选项),或重新生成 VS 项目。
-    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
     [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
-    internal class Resources
-    {
-
+    internal class Resources {
+        
         private static global::System.Resources.ResourceManager resourceMan;
-
+        
         private static global::System.Globalization.CultureInfo resourceCulture;
-
+        
         [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
-        internal Resources()
-        {
+        internal Resources() {
         }
-
+        
         /// <summary>
-        ///   返回此类使用的缓存 ResourceManager 实例。
+        ///   返回此类使用的缓存 ResourceManager 实例。
         /// </summary>
         [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
-        internal static global::System.Resources.ResourceManager ResourceManager
-        {
-            get
-            {
-                if ((resourceMan == null))
-                {
+        internal static global::System.Resources.ResourceManager ResourceManager {
+            get {
+                if (object.ReferenceEquals(resourceMan, null)) {
                     global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("FileWatcher.Properties.Resources", typeof(Resources).Assembly);
                     resourceMan = temp;
                 }
                 return resourceMan;
             }
         }
-
+        
         /// <summary>
-        ///   覆盖当前线程的 CurrentUICulture 属性
-        ///   使用此强类型资源类的资源查找。
+        ///   重写当前线程的 CurrentUICulture 属性,对
+        ///   使用此强类型资源类的所有资源查找执行重写
         /// </summary>
         [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
-        internal static global::System.Globalization.CultureInfo Culture
-        {
-            get
-            {
+        internal static global::System.Globalization.CultureInfo Culture {
+            get {
                 return resourceCulture;
             }
-            set
-            {
+            set {
                 resourceCulture = value;
             }
         }

+ 13 - 17
FileWatcher/Properties/Settings.Designer.cs

@@ -1,28 +1,24 @@
 //------------------------------------------------------------------------------
 // <auto-generated>
-//     This code was generated by a tool.
-//     Runtime Version:4.0.30319.42000
+//     此代码由工具生成。
+//     运行时版本:4.0.30319.42000
 //
-//     Changes to this file may cause incorrect behavior and will be lost if
-//     the code is regenerated.
+//     对此文件的更改可能会导致不正确的行为,并且如果
+//     重新生成代码,这些更改将会丢失。
 // </auto-generated>
 //------------------------------------------------------------------------------
 
-namespace FileWatcher.Properties
-{
-
-
+namespace FileWatcher.Properties {
+    
+    
     [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
-    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
-    internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
-    {
-
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.6.0.0")]
+    internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
+        
         private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
-
-        public static Settings Default
-        {
-            get
-            {
+        
+        public static Settings Default {
+            get {
                 return defaultInstance;
             }
         }

+ 4 - 5
FileWatcher/SOP.cs

@@ -68,15 +68,12 @@ 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)
                         {
-                            //OperatResult.AppendText(workbook.Worksheets[i].TextBoxes[k].ID + " " + workbook.Worksheets[i].TextBoxes[k].Name + " " + workbook.Worksheets[i].TextBoxes[k].RichText.GetFont(0).FontName + " " + workbook.Worksheets[i].TextBoxes[k].RichText.GetFont(0).Size);
                             workbook.Worksheets[i].TextBoxes[k].RichText.Text = workbook.Worksheets[i].TextBoxes[k].RichText.Text;
-                            workbook.Worksheets[i].TextBoxes[k].Width = workbook.Worksheets[i].TextBoxes[k].Width * 2;
-                            workbook.Worksheets[i].TextBoxes[k].Height = workbook.Worksheets[i].TextBoxes[k].Height * 2;
-                            workbook.Worksheets[i].TextBoxes[k].HAlignment = CommentHAlignType.Center;
                         }
                     }
                     Workbook bw = new Workbook();
@@ -127,6 +124,8 @@ namespace FileWatcher
         {
             try
             {
+                DataHelper dh = new DataHelper();
+                OperatResult.AppendText("解析图片【" + sheet.Name + ".jpg】添加水印" + "\n");
                 if (!Directory.Exists(Application.StartupPath + @"\" + pr_code.Text))
                 {
                     Directory.CreateDirectory(Application.StartupPath + @"\" + pr_code.Text);
@@ -156,7 +155,7 @@ namespace FileWatcher
             }
             catch (Exception ex)
             {
-                Console.WriteLine(ex.Message);
+                OperatResult.AppendText(ex.Message + ex.StackTrace);
             }
         }
 

+ 3 - 0
FileWatcher/app.config

@@ -0,0 +1,3 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>

TEMPAT SAMPAH
FileWatcher/tool/Analysis.dll


TEMPAT SAMPAH
FileWatcher/tool/CheckBoxComboBox.dll


TEMPAT SAMPAH
FileWatcher/tool/DataHelper.dll


TEMPAT SAMPAH
FileWatcher/tool/ICSharpCode.SharpZipLib.dll


TEMPAT SAMPAH
FileWatcher/tool/NPOI.OOXML.dll


TEMPAT SAMPAH
FileWatcher/tool/NPOI.OpenXml4Net.dll


TEMPAT SAMPAH
FileWatcher/tool/NPOI.OpenXmlFormats.dll


TEMPAT SAMPAH
FileWatcher/tool/NPOI.dll


TEMPAT SAMPAH
FileWatcher/tool/Seagull.BarTender.Print.dll


TEMPAT SAMPAH
FileWatcher/tool/System.Data.SQLite.dll


+ 0 - 1
FileWatcher/测试记录解析DCW.cs

@@ -8,7 +8,6 @@ using System.Net;
 using System.Text;
 using System.Threading;
 using System.Windows.Forms;
-using UMES.DLLService;
 
 namespace FileWatcher
 {