Browse Source

SOP功能调整

callm 1 year ago
parent
commit
03f54577e0

+ 263 - 0
FileWatcher/AutoMakeQTY.Designer.cs

@@ -0,0 +1,263 @@
+namespace FileWatcher
+{
+    partial class AutoMakeQTY
+    {
+        /// <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.components = new System.ComponentModel.Container();
+            this.XmlWatcher = new System.IO.FileSystemWatcher();
+            this.XmlFolder = new System.Windows.Forms.FolderBrowserDialog();
+            this.StartWatch = new System.Windows.Forms.Button();
+            this.StopWatch = new System.Windows.Forms.Button();
+            this.OperateResult = new System.Windows.Forms.RichTextBox();
+            this.Clean = new System.Windows.Forms.Button();
+            this.MakeCode_lable = new System.Windows.Forms.Label();
+            this.ma_code = new System.Windows.Forms.TextBox();
+            this.Timer = new System.Windows.Forms.Timer(this.components);
+            this.ATEFile = new System.IO.FileSystemWatcher();
+            this.Type = new System.Windows.Forms.ComboBox();
+            this.label1 = new System.Windows.Forms.Label();
+            this.AutoStart = new System.Windows.Forms.CheckBox();
+            this.ComPort = new FileWatcher.SerialPortCombox();
+            this.label2 = new System.Windows.Forms.Label();
+            this.label3 = new System.Windows.Forms.Label();
+            this.BaudRate = new System.Windows.Forms.TextBox();
+            ((System.ComponentModel.ISupportInitialize)(this.XmlWatcher)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.ATEFile)).BeginInit();
+            this.SuspendLayout();
+            // 
+            // XmlWatcher
+            // 
+            this.XmlWatcher.EnableRaisingEvents = true;
+            this.XmlWatcher.Filter = "*.log";
+            this.XmlWatcher.SynchronizingObject = this;
+            // 
+            // StartWatch
+            // 
+            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(290, 557);
+            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 = 0;
+            this.StartWatch.Text = "开始监控";
+            this.StartWatch.UseVisualStyleBackColor = true;
+            this.StartWatch.Click += new System.EventHandler(this.StartWatch_Click);
+            // 
+            // StopWatch
+            // 
+            this.StopWatch.Enabled = false;
+            this.StopWatch.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.StopWatch.Location = new System.Drawing.Point(498, 557);
+            this.StopWatch.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
+            this.StopWatch.Name = "StopWatch";
+            this.StopWatch.Size = new System.Drawing.Size(128, 56);
+            this.StopWatch.TabIndex = 1;
+            this.StopWatch.Text = "停止监控";
+            this.StopWatch.UseVisualStyleBackColor = true;
+            this.StopWatch.Click += new System.EventHandler(this.StopWatch_Click);
+            // 
+            // OperateResult
+            // 
+            this.OperateResult.Location = new System.Drawing.Point(892, 22);
+            this.OperateResult.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
+            this.OperateResult.Name = "OperateResult";
+            this.OperateResult.Size = new System.Drawing.Size(517, 535);
+            this.OperateResult.TabIndex = 7;
+            this.OperateResult.Text = "";
+            // 
+            // Clean
+            // 
+            this.Clean.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.Clean.Location = new System.Drawing.Point(1096, 580);
+            this.Clean.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
+            this.Clean.Name = "Clean";
+            this.Clean.Size = new System.Drawing.Size(112, 48);
+            this.Clean.TabIndex = 8;
+            this.Clean.Text = "清除";
+            this.Clean.UseVisualStyleBackColor = true;
+            this.Clean.Click += new System.EventHandler(this.Clean_Click);
+            // 
+            // MakeCode_lable
+            // 
+            this.MakeCode_lable.AutoSize = true;
+            this.MakeCode_lable.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.MakeCode_lable.Location = new System.Drawing.Point(34, 220);
+            this.MakeCode_lable.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.MakeCode_lable.Name = "MakeCode_lable";
+            this.MakeCode_lable.Size = new System.Drawing.Size(104, 38);
+            this.MakeCode_lable.TabIndex = 12;
+            this.MakeCode_lable.Text = "工单号";
+            this.MakeCode_lable.Visible = false;
+            // 
+            // ma_code
+            // 
+            this.ma_code.Location = new System.Drawing.Point(204, 220);
+            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 = 17;
+            this.ma_code.Visible = false;
+            // 
+            // Timer
+            // 
+            this.Timer.Interval = 60000;
+            // 
+            // ATEFile
+            // 
+            this.ATEFile.EnableRaisingEvents = true;
+            this.ATEFile.Filter = "*.txt";
+            this.ATEFile.SynchronizingObject = this;
+            // 
+            // Type
+            // 
+            this.Type.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+            this.Type.FormattingEnabled = true;
+            this.Type.Items.AddRange(new object[] {
+            "投入",
+            "产出"});
+            this.Type.Location = new System.Drawing.Point(204, 317);
+            this.Type.Name = "Type";
+            this.Type.Size = new System.Drawing.Size(436, 32);
+            this.Type.TabIndex = 18;
+            // 
+            // label1
+            // 
+            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(34, 311);
+            this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.label1.Name = "label1";
+            this.label1.Size = new System.Drawing.Size(75, 38);
+            this.label1.TabIndex = 19;
+            this.label1.Text = "类型";
+            this.label1.Visible = false;
+            // 
+            // AutoStart
+            // 
+            this.AutoStart.AutoSize = true;
+            this.AutoStart.Location = new System.Drawing.Point(678, 227);
+            this.AutoStart.Name = "AutoStart";
+            this.AutoStart.Size = new System.Drawing.Size(186, 28);
+            this.AutoStart.TabIndex = 20;
+            this.AutoStart.Text = "开机自动启动";
+            this.AutoStart.UseVisualStyleBackColor = true;
+            // 
+            // ComPort
+            // 
+            this.ComPort.Location = new System.Drawing.Point(204, 120);
+            this.ComPort.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
+            this.ComPort.Name = "ComPort";
+            this.ComPort.Size = new System.Drawing.Size(176, 40);
+            this.ComPort.TabIndex = 21;
+            // 
+            // label2
+            // 
+            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(34, 120);
+            this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.label2.Name = "label2";
+            this.label2.Size = new System.Drawing.Size(75, 38);
+            this.label2.TabIndex = 22;
+            this.label2.Text = "串口";
+            this.label2.Visible = false;
+            // 
+            // label3
+            // 
+            this.label3.AutoSize = true;
+            this.label3.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.label3.Location = new System.Drawing.Point(426, 120);
+            this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.label3.Name = "label3";
+            this.label3.Size = new System.Drawing.Size(104, 38);
+            this.label3.TabIndex = 23;
+            this.label3.Text = "波特率";
+            this.label3.Visible = false;
+            // 
+            // BaudRate
+            // 
+            this.BaudRate.Location = new System.Drawing.Point(564, 120);
+            this.BaudRate.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
+            this.BaudRate.Name = "BaudRate";
+            this.BaudRate.Size = new System.Drawing.Size(146, 35);
+            this.BaudRate.TabIndex = 24;
+            this.BaudRate.Visible = false;
+            // 
+            // AutoMakeQTY
+            // 
+            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.BaudRate);
+            this.Controls.Add(this.label3);
+            this.Controls.Add(this.label2);
+            this.Controls.Add(this.ComPort);
+            this.Controls.Add(this.AutoStart);
+            this.Controls.Add(this.label1);
+            this.Controls.Add(this.Type);
+            this.Controls.Add(this.ma_code);
+            this.Controls.Add(this.MakeCode_lable);
+            this.Controls.Add(this.Clean);
+            this.Controls.Add(this.OperateResult);
+            this.Controls.Add(this.StopWatch);
+            this.Controls.Add(this.StartWatch);
+            this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
+            this.MaximizeBox = false;
+            this.Name = "AutoMakeQTY";
+            this.Text = "UAS设备数据解析 2023-06-29  10:05";
+            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing);
+            this.Load += new System.EventHandler(this.Form1_Load);
+            ((System.ComponentModel.ISupportInitialize)(this.XmlWatcher)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.ATEFile)).EndInit();
+            this.ResumeLayout(false);
+            this.PerformLayout();
+
+        }
+
+        #endregion
+
+        private System.IO.FileSystemWatcher XmlWatcher;
+        private System.Windows.Forms.FolderBrowserDialog XmlFolder;
+        private System.Windows.Forms.Button StopWatch;
+        private System.Windows.Forms.Button StartWatch;
+        private System.Windows.Forms.RichTextBox OperateResult;
+        private System.Windows.Forms.Button Clean;
+        private System.Windows.Forms.Label MakeCode_lable;
+        private System.Windows.Forms.TextBox ma_code;
+        private System.Windows.Forms.Timer Timer;
+        private System.IO.FileSystemWatcher ATEFile;
+        private System.Windows.Forms.ComboBox Type;
+        private System.Windows.Forms.Label label1;
+        private System.Windows.Forms.CheckBox AutoStart;
+        private SerialPortCombox ComPort;
+        private System.Windows.Forms.Label label2;
+        private System.Windows.Forms.Label label3;
+        private System.Windows.Forms.TextBox BaudRate;
+    }
+}
+

+ 351 - 0
FileWatcher/AutoMakeQTY.cs

@@ -0,0 +1,351 @@
+using Microsoft.Win32;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.IO;
+using System.Threading;
+using System.Windows.Forms;
+using System.Xml;
+using System.Text;
+using System.Net;
+using System.Net.Sockets;
+using System.Text.RegularExpressions;
+using System.IO.Ports;
+using static System.Windows.Forms.VisualStyles.VisualStyleElement;
+using System.Windows.Media.Media3D;
+using System.Runtime.InteropServices;
+
+namespace FileWatcher
+{
+    public partial class AutoMakeQTY : Form
+    {
+
+        DataHelper dh;
+
+        DataTable dt;
+
+        DataTable DB;
+
+        /// <summary>
+        /// 用户编号
+        /// </summary>
+        string iusercode;
+        /// <summary>
+        /// 岗位资源
+        /// </summary>
+        string isource;
+
+        Thread InitDB;
+        /// <summary>
+        /// 线别
+        /// </summary>
+        string ilinecode;
+        /// <summary>
+        /// 不良代码组
+        /// </summary>
+        string ibadgroup;
+        /// <summary>
+        /// 当前工序
+        /// </summary>
+        string istepcode;
+        StringBuilder sql = new StringBuilder();
+        /// <summary>
+        /// 缓存的文件
+        /// </summary>
+        public static string CachePath = Environment.GetEnvironmentVariable("windir").Substring(0, 1) + @":/UAS_MES/XmlAnalysor/Cache.xml";
+        /// <summary>
+        /// 缓存的文件夹
+        /// </summary>
+        public static string CachePathFolder = Environment.GetEnvironmentVariable("windir").Substring(0, 1) + @":/UAS_MES/XmlAnalysor/";
+        /// <summary>
+        /// 需要解析的文件名
+        /// </summary>
+        List<string> _FileName = new List<string>();
+
+        string master = "HUAG";
+
+        ftpOperater ftp = new ftpOperater();
+
+        public AutoMakeQTY()
+        {
+            InitializeComponent();
+            StartPosition = FormStartPosition.CenterScreen;
+        }
+
+        string IPAddress = "";
+
+        private void Form1_Load(object sender, EventArgs e)
+        {
+            CheckForIllegalCrossThreadCalls = false;
+            FormBorderStyle = FormBorderStyle.FixedSingle;
+            InitDB = new Thread(ConnectDB);
+            //添加监控事件
+            XmlWatcher.Changed += new FileSystemEventHandler(XmlWatcher_Created);
+            //ATEFile.Changed += new FileSystemEventHandler(XmlWatcher_Created);
+            SetLoadingWindow stw = new SetLoadingWindow(InitDB, "正在启动程序");
+            stw.StartPosition = FormStartPosition.CenterScreen;
+            stw.ShowDialog();
+            List<string> CacheInf = new List<string>();
+
+            IPHostEntry IpEntry = Dns.GetHostEntry(Dns.GetHostName());
+            for (int i = 0; i < IpEntry.AddressList.Length; i++)
+            {
+                if (IpEntry.AddressList[i].AddressFamily == AddressFamily.InterNetwork)
+                    IPAddress = IpEntry.AddressList[i].ToString();
+            }
+            //获取缓存信息
+            try
+            {
+                Type.Text = BaseUtil.GetCacheData("Type").ToString();
+                ComPort.Text = BaseUtil.GetCacheData("ComPort").ToString();
+                BaudRate.Text = BaseUtil.GetCacheData("BaudRate").ToString();
+            }
+            catch (Exception ex) { MessageBox.Show(ex.Message); }
+            //获取岗位资源相关信息
+            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();
+            }
+            StartWatch.PerformClick();
+        }
+
+        private void ConnectDB()
+        {
+            dh = new DataHelper();
+        }
+        SerialPort serialPort1 = new SerialPort();
+        bool GetData = true;
+        private void getSerialData()
+        {
+            if (serialPort1.IsOpen)
+            {
+                try
+                {
+                    while (GetData)
+                    {
+                        try
+                        {
+                            int len = serialPort1.BytesToRead;
+                            Byte[] readBuffer = new Byte[len];
+                            serialPort1.Read(readBuffer, 0, len); //将数据读入缓存
+                            string weigh = Encoding.Default.GetString(readBuffer);
+                            if (weigh != "")
+                            {
+                                OperateResult.AppendText(weigh + "\n");
+                            }
+                        }
+                        catch (Exception)
+                        {
+                            GetData = false;
+                        }
+                    }
+                }
+                catch (IOException ex) { MessageBox.Show(ex.Message); }
+            }
+            else OperateResult.AppendText(">>端口已被占用,请关闭其他窗口\n");
+        }
+
+        Thread thread;
+
+        private void StartWatch_Click(object sender, EventArgs e)
+        {
+            BaseUtil.SetCacheData("Type", Type.Text);
+            BaseUtil.SetCacheData("ComPort", ComPort.Text);
+            BaseUtil.SetCacheData("BaudRate", BaudRate.Text);
+            Timer.Interval = 1000 * 60;
+            Timer.Start();
+            //设置按钮不可点击
+            StartWatch.Enabled = false;
+            ma_code.Enabled = false;
+            StopWatch.Enabled = true;
+            thread = new Thread(getSerialData);
+            try
+            {
+                serialPort1.PortName = BaudRate.Text;
+                serialPort1.BaudRate = int.Parse(BaudRate.Text);
+                serialPort1.Open();
+                GetData = true;
+                thread.Start();
+            }
+            catch (Exception mes)
+            {
+                if (BaudRate.Text == "" || BaudRate.Text == "")
+                    OperateResult.AppendText(">>请先维护波特率和串口\n");
+                else
+                    OperateResult.AppendText(">>" + mes.Message + "\n");
+            }
+            OperateResult.AppendText("开始执行监控\n");
+
+        }
+
+        private void XmlWatcher_Created(object sender, FileSystemEventArgs e)
+        {
+            OperateResult.AppendText("文件修改:" + e.FullPath + "\n");
+            TxtHandleProcess(e.FullPath);
+        }
+
+        string nextLine;
+        private void TxtHandleProcess(string FileName)
+        {
+            List<string> badcode = new List<string>();
+            List<string> badlocation = new List<string>();
+            List<string> badprod = new List<string>();
+
+        }
+
+        private void StopWatch_Click(object sender, EventArgs e)
+        {
+            XmlWatcher.EnableRaisingEvents = false;
+            StartWatch.Enabled = true;
+            ma_code.Enabled = true;
+
+            StopWatch.Enabled = false;
+            OperateResult.AppendText("停止执行监控\n");
+        }
+
+        private void Clean_Click(object sender, EventArgs e)
+        {
+            OperateResult.Clear();
+        }
+
+
+        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
+        {
+            string ExitConfirm = MessageBox.Show(this, "确认退出?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
+            if (ExitConfirm != "Yes")
+            {
+                WindowState = FormWindowState.Minimized;
+                e.Cancel = true;
+            }
+        }
+
+        private void AutoStart_CheckedChanged(object sender, EventArgs e)
+        {
+            SetAutoRun();
+        }
+
+        private void SetAutoRun()
+        {
+            if (AutoStart.Checked) //设置开机自启动  
+            {
+                string path = Application.ExecutablePath;
+                RegistryKey rk = Registry.LocalMachine;
+                RegistryKey rk2 = rk.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run");
+                rk2.SetValue("FileWatcher.exe", path);
+                rk2.Close();
+                rk.Close();
+            }
+            else //取消开机自启动  
+            {
+                string path = Application.ExecutablePath;
+                RegistryKey rk = Registry.LocalMachine;
+                RegistryKey rk2 = rk.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run");
+                rk2.DeleteValue("FileWatcher.exe", false);
+                rk2.Close();
+                rk.Close();
+            }
+        }
+
+        /// <summary>
+        /// 请求上传图片到阿里云
+        /// </summary>
+        /// <param name="url">上传地址</param>
+        /// <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)
+        {
+            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 "";
+        }
+    }
+}

+ 132 - 0
FileWatcher/AutoMakeQTY.resx

@@ -0,0 +1,132 @@
+<?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>
+  <metadata name="XmlWatcher.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>17, 17</value>
+  </metadata>
+  <metadata name="XmlFolder.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>164, 17</value>
+  </metadata>
+  <metadata name="Timer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>296, 17</value>
+  </metadata>
+  <metadata name="ATEFile.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>435, 17</value>
+  </metadata>
+</root>

+ 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=172.22.100.2)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
+        private string ConnectionStrings = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=N_MES;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.1.81.208)(PORT=11660)))(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=172.22.100.2)(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=10.1.81.208)(PORT=11660)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
         public static OracleConnection connection = null;
         OracleCommand command = null;
         int ReconnectTime = 0;

+ 28 - 10
FileWatcher/FileWatcher.csproj

@@ -96,6 +96,12 @@
     </Reference>
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="AutoMakeQTY.cs">
+      <SubType>Form</SubType>
+    </Compile>
+    <Compile Include="AutoMakeQTY.Designer.cs">
+      <DependentUpon>AutoMakeQTY.cs</DependentUpon>
+    </Compile>
     <Compile Include="AutoAnalysisDevice.cs">
       <SubType>Form</SubType>
     </Compile>
@@ -128,11 +134,11 @@
     <Compile Include="Form2.Designer.cs">
       <DependentUpon>Form2.cs</DependentUpon>
     </Compile>
-    <Compile Include="SOP.cs">
+    <Compile Include="Form4.cs">
       <SubType>Form</SubType>
     </Compile>
-    <Compile Include="SOP.Designer.cs">
-      <DependentUpon>SOP.cs</DependentUpon>
+    <Compile Include="Form4.Designer.cs">
+      <DependentUpon>Form4.cs</DependentUpon>
     </Compile>
     <Compile Include="Form5.cs">
       <SubType>Form</SubType>
@@ -140,11 +146,17 @@
     <Compile Include="Form5.Designer.cs">
       <DependentUpon>Form5.cs</DependentUpon>
     </Compile>
-    <Compile Include="Form4.cs">
+    <Compile Include="SerialPortCombox.cs">
+      <SubType>UserControl</SubType>
+    </Compile>
+    <Compile Include="SerialPortCombox.Designer.cs">
+      <DependentUpon>SerialPortCombox.cs</DependentUpon>
+    </Compile>
+    <Compile Include="SOP.cs">
       <SubType>Form</SubType>
     </Compile>
-    <Compile Include="Form4.Designer.cs">
-      <DependentUpon>Form4.cs</DependentUpon>
+    <Compile Include="SOP.Designer.cs">
+      <DependentUpon>SOP.cs</DependentUpon>
     </Compile>
     <Compile Include="ftpOperater.cs" />
     <Compile Include="LoadingCircle.cs">
@@ -193,6 +205,9 @@
     <Compile Include="测试记录解析DCW.Designer.cs">
       <DependentUpon>测试记录解析DCW.cs</DependentUpon>
     </Compile>
+    <EmbeddedResource Include="AutoMakeQTY.resx">
+      <DependentUpon>AutoMakeQTY.cs</DependentUpon>
+    </EmbeddedResource>
     <EmbeddedResource Include="AutoAnalysisDevice.resx">
       <DependentUpon>AutoAnalysisDevice.cs</DependentUpon>
     </EmbeddedResource>
@@ -208,14 +223,17 @@
     <EmbeddedResource Include="Form2.resx">
       <DependentUpon>Form2.cs</DependentUpon>
     </EmbeddedResource>
-    <EmbeddedResource Include="SOP.resx">
-      <DependentUpon>SOP.cs</DependentUpon>
+    <EmbeddedResource Include="Form4.resx">
+      <DependentUpon>Form4.cs</DependentUpon>
     </EmbeddedResource>
     <EmbeddedResource Include="Form5.resx">
       <DependentUpon>Form5.cs</DependentUpon>
     </EmbeddedResource>
-    <EmbeddedResource Include="Form4.resx">
-      <DependentUpon>Form4.cs</DependentUpon>
+    <EmbeddedResource Include="SerialPortCombox.resx">
+      <DependentUpon>SerialPortCombox.cs</DependentUpon>
+    </EmbeddedResource>
+    <EmbeddedResource Include="SOP.resx">
+      <DependentUpon>SOP.cs</DependentUpon>
     </EmbeddedResource>
     <EmbeddedResource Include="Login.resx">
       <DependentUpon>Login.cs</DependentUpon>

+ 0 - 95
FileWatcher/Form3.Designer.cs

@@ -1,95 +0,0 @@
-namespace FileWatcher
-{
-    partial class Form3
-    {
-        /// <summary>
-        /// Required designer variable.
-        /// </summary>
-        private System.ComponentModel.IContainer components = null;
-
-        /// <summary>
-        /// Clean up any resources being used.
-        /// </summary>
-        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
-        protected override void Dispose(bool disposing)
-        {
-            if (disposing && (components != null))
-            {
-                components.Dispose();
-            }
-            base.Dispose(disposing);
-        }
-
-        #region Windows Form Designer generated code
-
-        /// <summary>
-        /// Required method for Designer support - do not modify
-        /// the contents of this method with the code editor.
-        /// </summary>
-        private void InitializeComponent()
-        {
-            this.button1 = new System.Windows.Forms.Button();
-            this.textBox1 = new System.Windows.Forms.TextBox();
-            this.richTextBox1 = new System.Windows.Forms.RichTextBox();
-            this.richTextBox2 = new System.Windows.Forms.RichTextBox();
-            this.SuspendLayout();
-            // 
-            // button1
-            // 
-            this.button1.Location = new System.Drawing.Point(487, 60);
-            this.button1.Name = "button1";
-            this.button1.Size = new System.Drawing.Size(105, 40);
-            this.button1.TabIndex = 4;
-            this.button1.Text = "获取";
-            this.button1.UseVisualStyleBackColor = true;
-            this.button1.Click += new System.EventHandler(this.button1_Click);
-            // 
-            // textBox1
-            // 
-            this.textBox1.Location = new System.Drawing.Point(53, 60);
-            this.textBox1.Name = "textBox1";
-            this.textBox1.Size = new System.Drawing.Size(392, 35);
-            this.textBox1.TabIndex = 3;
-            this.textBox1.Text = "C:\\Users\\callm\\Desktop\\";
-            // 
-            // richTextBox1
-            // 
-            this.richTextBox1.Location = new System.Drawing.Point(-43, -88);
-            this.richTextBox1.Name = "richTextBox1";
-            this.richTextBox1.Size = new System.Drawing.Size(100, 96);
-            this.richTextBox1.TabIndex = 5;
-            this.richTextBox1.Text = "";
-            // 
-            // richTextBox2
-            // 
-            this.richTextBox2.Location = new System.Drawing.Point(53, 160);
-            this.richTextBox2.Name = "richTextBox2";
-            this.richTextBox2.Size = new System.Drawing.Size(379, 372);
-            this.richTextBox2.TabIndex = 6;
-            this.richTextBox2.Text = "";
-            // 
-            // Form3
-            // 
-            this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 24F);
-            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.ClientSize = new System.Drawing.Size(686, 624);
-            this.Controls.Add(this.richTextBox2);
-            this.Controls.Add(this.richTextBox1);
-            this.Controls.Add(this.button1);
-            this.Controls.Add(this.textBox1);
-            this.Name = "Form3";
-            this.Text = "Form3";
-            this.Load += new System.EventHandler(this.Form3_Load);
-            this.ResumeLayout(false);
-            this.PerformLayout();
-
-        }
-
-        #endregion
-
-        private System.Windows.Forms.Button button1;
-        private System.Windows.Forms.TextBox textBox1;
-        private System.Windows.Forms.RichTextBox richTextBox1;
-        private System.Windows.Forms.RichTextBox richTextBox2;
-    }
-}

+ 3 - 3
FileWatcher/Login.cs

@@ -18,9 +18,9 @@ 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=10.98.0.21)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
+            DataHelper.DBConnectionString = "Password=select!#%*(;User ID=N_MES;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.1.81.208)(PORT=11660)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
             //重新执行一遍构造函数使得重置之后的链接字符串生效
-            dh = new DataHelper();
+            //dh = new DataHelper();
             AutoAnalysisXmlByStep.dh = dh;
             if (LogicHandler.CheckUserLogin(UserName.Text, PassWord.Text, out ErrMessage))
             {
@@ -52,4 +52,4 @@ namespace FileWatcher
             }
         }
     }
-}
+}   

+ 1 - 1
FileWatcher/Program.cs

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

+ 27 - 3
FileWatcher/SOP.Designer.cs

@@ -43,6 +43,8 @@
             this.pr_detail = new System.Windows.Forms.Label();
             this.JPG = new System.Windows.Forms.RadioButton();
             this.pr_spec = new System.Windows.Forms.RichTextBox();
+            this.textBox1 = new System.Windows.Forms.TextBox();
+            this.label5 = new System.Windows.Forms.Label();
             this.SuspendLayout();
             // 
             // richTextBox1
@@ -77,7 +79,7 @@
             // 
             // ChooseFile
             // 
-            this.ChooseFile.Location = new System.Drawing.Point(218, 611);
+            this.ChooseFile.Location = new System.Drawing.Point(218, 666);
             this.ChooseFile.Name = "ChooseFile";
             this.ChooseFile.Size = new System.Drawing.Size(160, 42);
             this.ChooseFile.TabIndex = 8;
@@ -87,7 +89,7 @@
             // 
             // UploadSOP
             // 
-            this.UploadSOP.Location = new System.Drawing.Point(424, 611);
+            this.UploadSOP.Location = new System.Drawing.Point(424, 666);
             this.UploadSOP.Name = "UploadSOP";
             this.UploadSOP.Size = new System.Drawing.Size(160, 42);
             this.UploadSOP.TabIndex = 9;
@@ -125,7 +127,7 @@
             // 
             // SendSop
             // 
-            this.SendSop.Location = new System.Drawing.Point(640, 611);
+            this.SendSop.Location = new System.Drawing.Point(640, 666);
             this.SendSop.Name = "SendSop";
             this.SendSop.Size = new System.Drawing.Size(160, 42);
             this.SendSop.TabIndex = 13;
@@ -184,11 +186,31 @@
             this.pr_spec.TabIndex = 19;
             this.pr_spec.Text = "";
             // 
+            // textBox1
+            // 
+            this.textBox1.Enabled = false;
+            this.textBox1.Location = new System.Drawing.Point(218, 585);
+            this.textBox1.Name = "textBox1";
+            this.textBox1.Size = new System.Drawing.Size(582, 35);
+            this.textBox1.TabIndex = 21;
+            // 
+            // label5
+            // 
+            this.label5.AutoSize = true;
+            this.label5.Font = new System.Drawing.Font("微软雅黑", 12F);
+            this.label5.Location = new System.Drawing.Point(19, 580);
+            this.label5.Name = "label5";
+            this.label5.Size = new System.Drawing.Size(82, 41);
+            this.label5.TabIndex = 20;
+            this.label5.Text = "线别";
+            // 
             // SOP
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 24F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.ClientSize = new System.Drawing.Size(1945, 934);
+            this.Controls.Add(this.textBox1);
+            this.Controls.Add(this.label5);
             this.Controls.Add(this.pr_spec);
             this.Controls.Add(this.JPG);
             this.Controls.Add(this.pr_detail);
@@ -229,5 +251,7 @@
         private System.Windows.Forms.Label pr_detail;
         private System.Windows.Forms.RadioButton JPG;
         private System.Windows.Forms.RichTextBox pr_spec;
+        private System.Windows.Forms.TextBox textBox1;
+        private System.Windows.Forms.Label label5;
     }
 }

+ 5 - 4
FileWatcher/SOP.cs

@@ -92,8 +92,8 @@ namespace FileWatcher
                 {
                     Directory.CreateDirectory(Application.StartupPath + @"\" + pr_code.Text);
                 }
-                //sheet.Pictures.Add(0, 18, @"图片\电子受控章.png");
-                //sheet.Pictures.Add(0, 15, @"图片\签名.png");
+                sheet.Pictures.Add(0, 18, @"图片\电子受控章.png");
+                sheet.Pictures.Add(0, 15, @"图片\签名.png");
                 sheet.PageSetup.LeftMargin = 0;
                 sheet.PageSetup.RightMargin = 0;
                 sheet.PageSetup.BottomMargin = 0;
@@ -110,7 +110,7 @@ namespace FileWatcher
                 dic.Add("em_code", "ADMIN");
                 dic.Add("caller", "ProductSOP");
                 OperatResult.AppendText("上传文件【" + sheet.Name + ".jpg" + "】\n");
-                string fp_id = UploadFilesToRemoteUrl("http://10.98.0.21:8099/mes/MEScommon/uploadFiles.action?_noc=1", Application.StartupPath + @"\" + pr_code.Text + @"\" + sheet.Name + ".jpg", dic);
+                string fp_id = UploadFilesToRemoteUrl("http://mes.ubtob.net:8099/mes/MEScommon/uploadFiles.action?_noc=1", Application.StartupPath + @"\" + pr_code.Text + @"\" + sheet.Name + ".jpg", dic);
                 if (fp_id != "")
                 {
                     dh.ExecuteSql("update ProductSOP set ps_attachsop=ps_attachsop||" + fp_id + "||';' where ps_prodcode='" + pr_code.Text + "'", "update");
@@ -284,7 +284,7 @@ namespace FileWatcher
                     {
                         Dictionary<string, string> dic1 = new Dictionary<string, string>();
                         path = dt.Rows[i]["fp_path"].ToString();
-                        path = encryptBASE64(path.Replace("/app/uas/webapps/postattach", pathroot)).Replace("\\s*|\r|\n|\t", "");
+                        path = encryptBASE64(path.Replace("/app/mes/webapps/postattach", pathroot)).Replace("\\s*|\r|\n|\t", "");
                         dic1.Add("path", path);
                         dic1.Add("filename", dt.Rows[i]["fp_name"].ToString().Replace(" ", "").Replace("(", "").Replace(")", ""));
                         dic1.Add("ps_prodcode", pr_code.Text);
@@ -314,6 +314,7 @@ namespace FileWatcher
 
         public string encryptBASE64(string key)
         {
+            Console.WriteLine(key);
             byte[] bytes = Encoding.Default.GetBytes(key);
             return Convert.ToBase64String(bytes);
         }

+ 62 - 0
FileWatcher/SerialPortCombox.Designer.cs

@@ -0,0 +1,62 @@
+namespace FileWatcher
+{
+    partial class SerialPortCombox
+    {
+        /// <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 组件设计器生成的代码
+
+        /// <summary> 
+        /// 设计器支持所需的方法 - 不要修改
+        /// 使用代码编辑器修改此方法的内容。
+        /// </summary>
+        private void InitializeComponent()
+        {
+            this.ComCombox = new System.Windows.Forms.ComboBox();
+            this.SuspendLayout();
+            // 
+            // ComCombox
+            // 
+            this.ComCombox.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.ComCombox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+            this.ComCombox.FormattingEnabled = true;
+            this.ComCombox.Location = new System.Drawing.Point(0, 0);
+            this.ComCombox.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
+            this.ComCombox.Name = "ComCombox";
+            this.ComCombox.Size = new System.Drawing.Size(279, 32);
+            this.ComCombox.TabIndex = 0;
+            // 
+            // SerialPortCombox
+            // 
+            this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 24F);
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.Controls.Add(this.ComCombox);
+            this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
+            this.Name = "SerialPortCombox";
+            this.Size = new System.Drawing.Size(279, 40);
+            this.Load += new System.EventHandler(this.SerialPortCombox_Load);
+            this.ResumeLayout(false);
+
+        }
+
+        #endregion
+
+        private System.Windows.Forms.ComboBox ComCombox;
+    }
+}

+ 43 - 0
FileWatcher/SerialPortCombox.cs

@@ -0,0 +1,43 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Drawing;
+using System.Data;
+using System.Linq;
+using System.Text;
+using System.Windows.Forms;
+using System.IO.Ports;
+
+namespace FileWatcher
+{
+    public partial class SerialPortCombox : UserControl
+    {
+        public SerialPortCombox()
+        {
+            InitializeComponent();
+        }
+
+        public override string Text
+        {
+            get
+            {
+                return ComCombox.Text;
+            }
+
+            set
+            {
+                ComCombox.Text = value;
+            }
+        }
+
+        private void SerialPortCombox_Load(object sender, EventArgs e)
+        {
+          string[] str= SerialPort.GetPortNames();
+            for (int i = 0; i < str.Length; i++)
+            {
+                Console.WriteLine(str[i]);
+            }
+            ComCombox.Items.AddRange(SerialPort.GetPortNames());
+        }
+    }
+}

+ 0 - 0
FileWatcher/Form3.resx → FileWatcher/SerialPortCombox.resx


+ 1 - 0
FileWatcher/TcpServer.cs

@@ -126,6 +126,7 @@ namespace FileWatcher
 
         public void Send(string Command)
         {
+            Console.WriteLine(  Command);
             foreach (Socket item in socket)
             {
                 item.Send(Encoding.Default.GetBytes(Command));