浏览代码

斗牛MES新增219LOG日志读取过站

caosy 4 年之前
父节点
当前提交
d0e8a183d4

+ 2 - 2
UAS_MES_DN/App.config

@@ -39,7 +39,7 @@
         <value />
       </setting>
       <setting name="FTPAddress" serializeAs="String">
-        <value>ftp://10.8.0.82|vsftpd|vsftpd</value>
+        <value>ftp://192.168.11.188|vsftpd|vsftpd</value>
       </setting>
     </UAS_MES_NEW.Properties.Settings>
     <UAS_MES.Properties.Settings>
@@ -72,7 +72,7 @@
   <applicationSettings>
     <UAS_MES_NEW.Properties.Settings>
       <setting name="MES" serializeAs="String">
-        <value>Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=MES;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.8.0.97)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));</value>
+        <value>Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=MES;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=usoft.f3322.net)(PORT=11636)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));</value>
       </setting>
     </UAS_MES_NEW.Properties.Settings>
   </applicationSettings>

+ 8 - 8
UAS_MES_DN/CustomControl/CustomCheckBox/ReSetCheckBox.cs

@@ -17,14 +17,14 @@ namespace UAS_MES_NEW.CustomControl.CustomCheckBox
         {
             if (dh != null)
             {
-                if (dh.getFieldDataByCondition("Step", "st_ifreset", "st_code='" + User.CurrentStepCode + "'").ToString() == "-1")
-                {
-                    Checked = true;
-                }
-                else
-                {
-                    Checked = false;
-                }
+                //if (dh.getFieldDataByCondition("Step", "st_ifreset", "st_code='" + User.CurrentStepCode + "'").ToString() == "-1")
+                //{
+                //    Checked = true;
+                //}
+                //else
+                //{
+                //    Checked = false;
+                //}
             }
         }
     }

+ 67 - 0
UAS_MES_DN/DataOperate/ExcelHandler.cs

@@ -55,6 +55,73 @@ namespace UAS_MES_NEW.DataOperate
             return filePath;
         }
 
+
+        /// <summary>
+        /// 将CSV文件中内容读取到DataTable中
+        /// </summary>
+        /// <param name="path">CSV文件路径</param>
+        /// <param name="hasTitle">是否将CSV文件的第一行读取为DataTable的列名</param>
+        /// <returns></returns>
+        public static DataTable ReadFromCSV(string path, bool hasTitle = true)
+        {
+            DataTable dt = new DataTable();           //要输出的数据表
+            StreamReader sr = new StreamReader(path, System.Text.Encoding.GetEncoding("GB2312")); //文件读入流
+            bool bFirst = true;                       //指示是否第一次读取数据
+
+            //逐行读取
+            string line;
+            while ((line = sr.ReadLine()) != null)
+            {
+                if (line.EndsWith(","))
+                {
+                    line = line.Substring(0, line.Length - 1);
+                }
+                string[] elements = line.Replace("\r", "").Replace("\n", "").Replace("\t", "").Split(',');
+                string[] ele;
+                if (elements.Length > 1)
+                {
+                    ele = new string[] { elements[0], elements[1] };
+                }
+                else {
+                     ele = new string[] { };
+                }
+                //第一次读取数据时,要创建数据列
+                if (bFirst)
+                {
+                    for (int i = 0; i < 2; i++)
+                    {
+                        dt.Columns.Add();
+                    }
+                    bFirst = false;
+                }
+
+                //有标题行时,第一行当做标题行处理
+                if (hasTitle)
+                {
+                    for (int i = 0; i < dt.Columns.Count && i < ele.Length; i++)
+                    {
+                        dt.Columns[i].ColumnName = ele[i];
+                    }
+                    hasTitle = false;
+                }
+                else //读取一行数据
+                {
+                    if (ele.Length == 2)
+                    {
+                        dt.Rows.Add(ele);
+                    }
+                    else
+                    {
+                        //throw new Exception("CSV格式错误:表格各行列数不一致");
+                    }
+                }
+            }
+            sr.Close();
+
+            return dt;
+        }
+
+
         /// <summary>
         /// 导入Excel
         /// </summary>

+ 25 - 11
UAS_MES_DN/FunctionCode/Make/Make_TestCollection.cs

@@ -20,6 +20,7 @@ namespace UAS_MES_NEW.Make
         DataHelper dh = null;
         DataTable dt = null;
         //当前工序的名称
+        ftpOperater ftp = null;
 
         string ErrorMessage = "";
         //用于保存是否之前输入的ms_sncode
@@ -72,14 +73,15 @@ namespace UAS_MES_NEW.Make
             ma_code.SetLockCheckBox(LockMakeCode);
             ControlLockTimer.Tick += ControlLockTimer_Tick;
             ControlLockTimer.Interval = 100;
-
+            ftp = new ftpOperater();
             labelname = System.Windows.Forms.Application.StartupPath + @"\badsn.lab";
 
             thread = new Thread(NewPrint);
             SetLoadingWindow stw = new SetLoadingWindow(thread, "初始化打印程序");
             BaseUtil.SetFormCenter(stw);
             stw.ShowDialog();
-
+            if (User.CurrentStepCode == "BZ_TEST")
+                AutoBadCode.Checked = true;
             //工单号放大镜配置
             ma_code.TableName = "make left join product on ma_prodcode=pr_code";
             ma_code.SelectField = "ma_code # 工单号,ma_prodcode # 产品编号,ma_qty # 工单数量,pr_spec # 产品规格,ma_softversion # 软件版本,ma_salecode # 销售单号,pr_sendchecktype # 产品送检方式";
@@ -373,18 +375,30 @@ namespace UAS_MES_NEW.Make
                     }
                     else
                     {
-                        if (AutoBadCode.Checked)
+                        if (this.AutoBadCode.Checked)
                         {
-                            string str = BaseUtil.GetDataFromDevice("DEVICES");
-                            str = str.Replace("LIST OF DEVICES ATTACHED", "").Replace("\n", "");
-                            if (!(str.Length == 0))
+                            if (BaseUtil.GetDataFromDevice("DEVICES").Replace("LIST OF DEVICES ATTACHED", "").Replace("\n", "").Length > 0U)
                             {
-                                Console.WriteLine("有链接");
+                                if (BaseUtil.GetDataFromDevice("GETFILE").Contains("ERROR"))
+                                {
+                                    OperateResult.AppendText(">>获取测试日志失败,请重试\n", Color.Red, (Control)this.ms_sncode);
+                                    return;
+                                }
+                                DataTable dataTable = ExcelHandler.ReadFromCSV("C:\\UAS_MES\\unknown_Fail.csv");
+                                for (int index = 0; index < 13; ++index)
+                                {
+                                    if (dataTable.Rows[index]["TestResult"].ToString() == "NG")
+                                    {
+                                        this.OperateResult.AppendText(">>测试日志出现NG项,无法通过\n", Color.Red, (Control)this.ms_sncode);
+                                        return;
+                                    }
+                                }
+                                ftp.UpLoadFile("C:\\UAS_MES", "unknown_Fail.csv", "/log/", this.ms_sncode.Text + ".csv");
                                 BaseUtil.GetDataFromDevice("RESET");
                             }
                             else
                             {
-                                OperateResult.AppendText(">>无设备链接,无法恢复出厂设置,采集失败\n", Color.Red, ms_sncode);
+                                this.OperateResult.AppendText(">>无设备链接,无法恢复出厂设置,采集失败\n", Color.Red, (Control)this.ms_sncode);
                                 return;
                             }
                         }
@@ -853,15 +867,15 @@ namespace UAS_MES_NEW.Make
             if (!PrintFile.Exists)
             {
                 MessageBox.Show("打印文件不存在");
-                return ;
+                return;
             }
             doc = lbl.Documents.Open(labelname, true);
             if (doc == null)
             {
                 MessageBox.Show("标签文件打开失败");
-                return ;
+                return;
             }
-            for (int j = 1; j < doc.Variables.FormVariables.Count+1; j++)
+            for (int j = 1; j < doc.Variables.FormVariables.Count + 1; j++)
             {
                 switch (doc.Variables.FormVariables.Item(j).Name)
                 {

+ 173 - 0
UAS_MES_DN/FunctionCode/Special/Special_GetSNLog.Designer.cs

@@ -0,0 +1,173 @@
+namespace UAS_MES_NEW.Special
+{
+    partial class Special_GetSNLog
+    {
+        /// <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()
+        {
+            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Special_GetSNLog));
+            this.Pallet_label = new System.Windows.Forms.Label();
+            this.button1 = new System.Windows.Forms.Button();
+            this.OperatResult = new UAS_MES_NEW.CustomControl.RichText.RichTextAutoBottom();
+            this.SNCODE = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.EnterTextBox();
+            this.Split = new UAS_MES_NEW.CustomControl.ButtonUtil.NormalButton();
+            this.dataGridView1 = new System.Windows.Forms.DataGridView();
+            this.TestResult = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.button2 = new System.Windows.Forms.Button();
+            ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
+            this.SuspendLayout();
+            // 
+            // Pallet_label
+            // 
+            this.Pallet_label.AutoSize = true;
+            this.Pallet_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.Pallet_label.Location = new System.Drawing.Point(18, 131);
+            this.Pallet_label.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
+            this.Pallet_label.Name = "Pallet_label";
+            this.Pallet_label.Size = new System.Drawing.Size(48, 21);
+            this.Pallet_label.TabIndex = 1;
+            this.Pallet_label.Text = "SN号";
+            // 
+            // button1
+            // 
+            this.button1.Location = new System.Drawing.Point(267, 207);
+            this.button1.Name = "button1";
+            this.button1.Size = new System.Drawing.Size(75, 23);
+            this.button1.TabIndex = 4;
+            this.button1.Text = "button1";
+            this.button1.UseVisualStyleBackColor = true;
+            this.button1.Visible = false;
+            this.button1.Click += new System.EventHandler(this.button1_Click);
+            // 
+            // OperatResult
+            // 
+            this.OperatResult.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.OperatResult.Location = new System.Drawing.Point(378, 60);
+            this.OperatResult.Margin = new System.Windows.Forms.Padding(2);
+            this.OperatResult.Name = "OperatResult";
+            this.OperatResult.Size = new System.Drawing.Size(204, 310);
+            this.OperatResult.TabIndex = 3;
+            this.OperatResult.Text = "";
+            // 
+            // SNCODE
+            // 
+            this.SNCODE.AllPower = null;
+            this.SNCODE.BackColor = System.Drawing.Color.White;
+            this.SNCODE.ID = null;
+            this.SNCODE.Location = new System.Drawing.Point(91, 133);
+            this.SNCODE.Margin = new System.Windows.Forms.Padding(2);
+            this.SNCODE.Name = "SNCODE";
+            this.SNCODE.Power = null;
+            this.SNCODE.Size = new System.Drawing.Size(148, 21);
+            this.SNCODE.Str = null;
+            this.SNCODE.Str1 = null;
+            this.SNCODE.Str2 = null;
+            this.SNCODE.TabIndex = 2;
+            // 
+            // Split
+            // 
+            this.Split.AllPower = null;
+            this.Split.BackColor = System.Drawing.Color.Transparent;
+            this.Split.DownImage = ((System.Drawing.Image)(resources.GetObject("Split.DownImage")));
+            this.Split.Image = null;
+            this.Split.IsShowBorder = true;
+            this.Split.Location = new System.Drawing.Point(267, 133);
+            this.Split.Margin = new System.Windows.Forms.Padding(2);
+            this.Split.MoveImage = ((System.Drawing.Image)(resources.GetObject("Split.MoveImage")));
+            this.Split.Name = "Split";
+            this.Split.NormalImage = ((System.Drawing.Image)(resources.GetObject("Split.NormalImage")));
+            this.Split.Power = null;
+            this.Split.Size = new System.Drawing.Size(56, 22);
+            this.Split.TabIndex = 0;
+            this.Split.Text = "获取";
+            this.Split.UseVisualStyleBackColor = false;
+            this.Split.Click += new System.EventHandler(this.Split_Click);
+            // 
+            // dataGridView1
+            // 
+            this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+            this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
+            this.TestResult});
+            this.dataGridView1.Location = new System.Drawing.Point(22, 299);
+            this.dataGridView1.Name = "dataGridView1";
+            this.dataGridView1.RowTemplate.Height = 23;
+            this.dataGridView1.Size = new System.Drawing.Size(341, 201);
+            this.dataGridView1.TabIndex = 5;
+            this.dataGridView1.Visible = false;
+            // 
+            // TestResult
+            // 
+            this.TestResult.DataPropertyName = "TestResult";
+            this.TestResult.HeaderText = "TestResult";
+            this.TestResult.Name = "TestResult";
+            // 
+            // button2
+            // 
+            this.button2.Location = new System.Drawing.Point(41, 207);
+            this.button2.Name = "button2";
+            this.button2.Size = new System.Drawing.Size(75, 23);
+            this.button2.TabIndex = 6;
+            this.button2.Text = "button2";
+            this.button2.UseVisualStyleBackColor = true;
+            this.button2.Visible = false;
+            this.button2.Click += new System.EventHandler(this.button2_Click);
+            // 
+            // Special_GetSNLog
+            // 
+            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.ClientSize = new System.Drawing.Size(692, 527);
+            this.Controls.Add(this.button2);
+            this.Controls.Add(this.dataGridView1);
+            this.Controls.Add(this.button1);
+            this.Controls.Add(this.OperatResult);
+            this.Controls.Add(this.SNCODE);
+            this.Controls.Add(this.Pallet_label);
+            this.Controls.Add(this.Split);
+            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
+            this.Margin = new System.Windows.Forms.Padding(2);
+            this.Name = "Special_GetSNLog";
+            this.Tag = "Special!GetSNLog";
+            this.Text = "获取LOG文件";
+            this.Load += new System.EventHandler(this.Special_BoxSplit_Load);
+            ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
+            this.ResumeLayout(false);
+            this.PerformLayout();
+
+        }
+
+        #endregion
+
+        private CustomControl.ButtonUtil.NormalButton Split;
+        private System.Windows.Forms.Label Pallet_label;
+        private CustomControl.TextBoxWithIcon.EnterTextBox SNCODE;
+        private CustomControl.RichText.RichTextAutoBottom OperatResult;
+        private System.Windows.Forms.Button button1;
+        private System.Windows.Forms.DataGridView dataGridView1;
+        private System.Windows.Forms.Button button2;
+        private System.Windows.Forms.DataGridViewTextBoxColumn TestResult;
+    }
+}

+ 79 - 0
UAS_MES_DN/FunctionCode/Special/Special_GetSNLog.cs

@@ -0,0 +1,79 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Windows.Forms;
+using UAS_MES_NEW.DataOperate;
+using UAS_MES_NEW.Entity;
+using UAS_MES_NEW.PublicMethod;
+
+namespace UAS_MES_NEW.Special
+{
+    public partial class Special_GetSNLog : Form
+    {
+        DataHelper dh;
+        ftpOperater ftp = null;
+        LogStringBuilder sql = new LogStringBuilder();
+
+        public Special_GetSNLog()
+        {
+            InitializeComponent();
+        }
+
+        private void Special_BoxSplit_Load(object sender, EventArgs e)
+        {
+            dh = SystemInf.dh;
+             ftp = new ftpOperater();
+        }
+
+        private void Split_Click(object sender, EventArgs e)
+        {
+            if (!dh.CheckExist("makeserial", "ms_sncode = '" + SNCODE.Text + "' or MS_FIRSTSN = '" + SNCODE.Text + "'"))
+            {
+                OperatResult.AppendText(">>SN号" + SNCODE.Text + "不存在\n", Color.Red, SNCODE);
+                return;
+            }
+            try
+            {
+                string sn = dh.getFieldDataByCondition("makeserial", "ms_firstsn", "ms_sncode = '" + SNCODE.Text + "' or MS_FIRSTSN = '" + SNCODE.Text + "'").ToString();
+                string address = ftp.Download(sn+".csv");
+                if (address.Length == 0)
+                {
+                    OperatResult.AppendText(">>SN号" + SNCODE.Text + "不存在LOG文件\n", Color.Red, SNCODE);
+                    return;
+                }
+                OperatResult.AppendText(">>SN号" + SNCODE.Text + "LOG文件下载至"+ address + "\n", Color.Green, SNCODE);
+                return;
+            }
+            catch (Exception ex)
+            {
+                OperatResult.AppendText(ex.Message+"\n", Color.Red, SNCODE);
+                return;
+            }
+        }
+
+        private void button1_Click(object sender, EventArgs e)
+        {
+            ftp.UpLoadFile(Environment.GetEnvironmentVariable("windir").Substring(0, 1) + @":\" + @"SNLog", "1.csv","/log/", SNCODE.Text +".csv");
+            MessageBox.Show("OK");
+        }
+
+        private void button2_Click(object sender, EventArgs e)
+        {
+           DataTable dt =  ExcelHandler.ReadFromCSV(@"C:\UAS_MES\unknown_Fail.csv", true);
+            for (int i = 0; i < 13; i++)
+            {
+                if (dt.Rows[i]["TestResult"].ToString() == "NG")
+                {
+                    MessageBox.Show("NG");
+                    break;
+                }
+            }
+            MessageBox.Show("OK");
+            BaseUtil.FillDgvWithDataTable(dataGridView1, dt);
+        }
+    }
+}

+ 165 - 0
UAS_MES_DN/FunctionCode/Special/Special_GetSNLog.resx

@@ -0,0 +1,165 @@
+<?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>
+  <assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
+  <data name="Split.DownImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+    <value>
+        iVBORw0KGgoAAAANSUhEUgAAAEUAAAAWCAYAAACWl1FwAAAABGdBTUEAALGPC/xhBQAAABl0RVh0U29m
+        dHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAFcSURBVFhH5di7UsJAFMbxtDT6QMI76IAFT0npIE0K
+        GcRORxHklpAIBHLfbILV8XxeNsMznJ35F5vu+82kWYuILD4N7oq75roCw27sb/x5WBdc27btntY64o/i
+        DnZjPxy4S6A0R6PHO1WUNHc9ep4uxIXd2D8eP/XZowWUThBG+n3p0stsKbbJ0qFDFFfscQuUbpzm9Pqx
+        Eh8c4PGLkuX0Nl+LDw4GJckUTRaO+OBQo+SKpitXfHAwKClfZuuN+OBgUDJV0NzxxAeHM5TFxhffGUpe
+        aFp5n+KDg0FRfHH8nfjgUKPoktztXnxwMCgFX7xdID441ChlRf7+ID44GBTNl21wFB8capSqot0xFB8c
+        /lE6Wa70IU5oH0Ziw/5cFebpoPUwHPbL04nCJKUgisWF3dgPB3gABc9v7fvBoBcnaVKdvkha2I39cPjx
+        oPrhusndcPinpIXd2N8gIusbTaFspKtR2SQAAAAASUVORK5CYII=
+</value>
+  </data>
+  <data name="Split.MoveImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+    <value>
+        iVBORw0KGgoAAAANSUhEUgAAAEUAAAAWCAYAAACWl1FwAAAABGdBTUEAALGPC/xhBQAAABl0RVh0U29m
+        dHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAFzSURBVFhH5djNSgJRGMZxL2P2gTfQFbZvHSEZFBEW
+        CEIQBEIgVFiS9qXWoDmp4/fHzDmjM2a+vU/QqUVX0DvwXxxn9fwYXJwYEcXWNzIWt83dcq7AsBv7LXgA
+        ZI0r71/aaqjCJf8o7sFu7IcDFwdK4vimrv1oSZXRnArdQFzYjf3pQkOzRxIoVWc6X5X6M7ruBGIr9mbU
+        9MIVe9hAcXvBO125WnxwgMcXSpcPF20tPjgYlI5eUK6lxAcHg9Lmw3nTFx8cDEpLLSjr+OKDg0FpqojO
+        Gp744GBQ3vyITutT8cHBoDheRCe1ifjgYFBe+ZCxJ+KDg0GpT0NKv4zFBweDUpuEdFQdiQ8OBsXmw2Fl
+        JD44/KCM53TwNBQfHAzKMx/2Hgfig8M3SrXYUasUfz67DwOxYf9dV5urg+RWzta4aEnxn83OfV9c2I39
+        cIAHUOJceTNbUfmW94GX0sJu7IcDPH5fXCe4EvfXxe5/D7ux3yKi2CfkPhTy27lqkwAAAABJRU5ErkJg
+        gg==
+</value>
+  </data>
+  <data name="Split.NormalImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+    <value>
+        iVBORw0KGgoAAAANSUhEUgAAAEUAAAAWCAYAAACWl1FwAAAABGdBTUEAALGPC/xhBQAAABl0RVh0U29m
+        dHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAGVSURBVFhH5di7agJRFIXhDSKoYBQEC8FCECwEQRBE
+        4uUVEtTiPKVlom2wttM6IfF+15njXHRnL19jD/zFmanWV8zAEDNTp9OJS6/Sm2QUht3YH4cHtdvtF6k7
+        mUwG1tqd3FR3YTf2w0FKUVOu6XT68Xgw3+8PtWH/bDYbCkeLGo1Gz/d9JwzvrL0gCKx49KlerxtIBUGo
+        PjjAg2q1mqDc2fN99cEBHlStVk0oB+t56oMDPKhSqZggDNm1N/XBAR5ULpeNvGD46rrqgwM8qFQqGV8O
+        56ujPjjAg4rFosFL5ni5qA8O8KBCoWBuns/701l9cIAH5fN5QfF4dzipDw7woFwuZ+zN483+oD44wIOy
+        2azB52i13asPDvCgTCZjHGt5sdmqDw7woHQ6bRzX8ny1UR8c4EHJZNJc5fC7XKsPDvCgRCLR2x9Pzt9q
+        zT+Lpdqw/3A6W/HoUywWa32Nx8OL4zwffM8X6sJu7IcDPCgajaak7udoNNjsdgc81BZ2Yz8c4PH8cR2J
+        ROJSU3qXjMKwG/vjzEz/skOI3Zqgv7AAAAAASUVORK5CYII=
+</value>
+  </data>
+  <metadata name="TestResult.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="TestResult.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+</root>

+ 2 - 2
UAS_MES_DN/Login.cs

@@ -93,8 +93,8 @@ namespace UAS_MES_NEW
             //设置选中数据库的链接
             string DBUser = DB.SelectedValue.ToString().Split('#')[0];
             string Address = DB.SelectedValue.ToString().Split('#')[1];
-            //DataHelper.DBConnectionString = "Password=select!#%*(;User ID=" + DBUser + ";Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.8.0.97)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
-            DataHelper.DBConnectionString = "Password=select!#%*(;User ID=" + DBUser + ";Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=" + Address + ")(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
+            DataHelper.DBConnectionString = "Password=select!#%*(;User ID=" + DBUser + ";Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=usoft.f3322.net)(PORT=11636)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
+            //DataHelper.DBConnectionString = "Password=select!#%*(;User ID=" + DBUser + ";Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=" + Address + ")(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
             SystemInf.CurrentDB = DBUser;
             //设置屏幕的宽高信息
             SystemInf.ScreenWidth = Screen.PrimaryScreen.WorkingArea.Width;

+ 4 - 4
UAS_MES_DN/Properties/Settings.settings

@@ -23,11 +23,11 @@
     <Setting Name="BaudRate" Type="System.String" Scope="User">
       <Value Profile="(Default)" />
     </Setting>
-    <Setting Name="FTPAddress" Type="System.String" Scope="User">
-      <Value Profile="(Default)">ftp://10.8.0.82|vsftpd|vsftpd</Value>
-    </Setting>
     <Setting Name="MES" Type="System.String" Scope="Application">
-      <Value Profile="(Default)">Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=MES;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.11.188)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));</Value>
+      <Value Profile="(Default)">Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=MES;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=usoft.f3322.net)(PORT=11636)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));</Value>
+    </Setting>
+    <Setting Name="FTPAddress" Type="System.String" Scope="User">
+      <Value Profile="(Default)">ftp://192.168.11.188|vsftpd|vsftpd</Value>
     </Setting>
   </Settings>
 </SettingsFile>

+ 12 - 12
UAS_MES_DN/Properties/Settings.Designer.cs → UAS_MES_DN/Properties/Settings1.Designer.cs

@@ -107,9 +107,20 @@ namespace UAS_MES_NEW.Properties {
             }
         }
         
+        [global::System.Configuration.ApplicationScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=MES;Pooling=false" +
+            ";Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=usoft.f3322" +
+            ".net)(PORT=11636)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));")]
+        public string MES {
+            get {
+                return ((string)(this["MES"]));
+            }
+        }
+        
         [global::System.Configuration.UserScopedSettingAttribute()]
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
-        [global::System.Configuration.DefaultSettingValueAttribute("ftp://10.8.0.82|vsftpd|vsftpd")]
+        [global::System.Configuration.DefaultSettingValueAttribute("ftp://192.168.11.188|vsftpd|vsftpd")]
         public string FTPAddress {
             get {
                 return ((string)(this["FTPAddress"]));
@@ -118,16 +129,5 @@ namespace UAS_MES_NEW.Properties {
                 this["FTPAddress"] = value;
             }
         }
-        
-        [global::System.Configuration.ApplicationScopedSettingAttribute()]
-        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
-        [global::System.Configuration.DefaultSettingValueAttribute("Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=MES;Pooling=false" +
-            ";Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.11." +
-            "188)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));")]
-        public string MES {
-            get {
-                return ((string)(this["MES"]));
-            }
-        }
     }
 }

+ 6 - 0
UAS_MES_DN/PublicMethod/BaseUtil.cs

@@ -1484,6 +1484,12 @@ namespace UAS_MES_NEW.PublicMethod
                     value = p.StandardOutput.ReadToEnd().Replace(":", "").ToUpper();
                     p.Close();
                     break;
+                case "GETFILE":
+                    p.StartInfo.Arguments = @"pull /sdcard/factory/unknown_Fail.csv C:\UAS_MES ";
+                    p.Start();
+                    value = p.StandardOutput.ReadToEnd().Replace(":", "").ToUpper();
+                    p.Close();
+                    break;
                 default:
                     break;
             }

+ 66 - 14
UAS_MES_DN/PublicMethod/ftpOperater.cs

@@ -13,7 +13,7 @@ namespace UAS_MES_NEW.PublicMethod
         //从配置文件读取FTP信息
         public static string FTPAddress = Properties.Settings.Default.Properties["FTPAddress"].DefaultValue.ToString().Split('|')[0];
 
-        public static string DownLoadTo = Environment.GetEnvironmentVariable("windir").Substring(0, 1) + @":\" + @"打印标签\";
+        public static string DownLoadTo = Environment.GetEnvironmentVariable("windir").Substring(0, 1) + @":\" + @"SNLog";
 
         private string FTPInf;
         private string ftpServerIP;
@@ -34,22 +34,70 @@ namespace UAS_MES_NEW.PublicMethod
         }
 
         #region
-        public void UpLoadFile(string filepath, string filename, string UploadFolder)
+        public void UpLoadFile(string filepath, string filename, string UploadFolder,string upfilename)
         {
-            //上传之前判断文件是否存在
-            string[] filelist = GetFileList();
-            if (filelist != null)
-                for (int i = 0; i < filelist.Length; i++)
+            ////上传之前判断文件是否存在
+            //string[] filelist = GetFileList();
+            //if (filelist != null)
+            //    for (int i = 0; i < filelist.Length; i++)
+            //    {
+            //        if (filelist[i] == filename)
+            //        {
+            //            string upload = MessageBox.Show("已存在同名文件,是否覆盖", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
+            //            if (upload.ToString() != "Yes")
+            //            {
+            //                return;
+            //            }
+            //        }
+            //    }
+            FtpWebRequest reqFTP;
+            FtpCheckDirectoryExist(UploadFolder);
+            reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(ftpServerIP + UploadFolder + upfilename));
+            reqFTP.UseBinary = true;
+            reqFTP.Credentials = new NetworkCredential(ftpUser, ftpPwd);
+            reqFTP.Method = WebRequestMethods.Ftp.UploadFile;
+            FileInfo file = new FileInfo(filepath + "/" + filename);
+            const int BufferSize = 2048;
+            byte[] content = new byte[BufferSize - 1 + 1];
+            int dataRead;
+            using (FileStream fs = file.OpenRead())
+            {
+                //把上传的文件写入流
+                using (Stream rs = reqFTP.GetRequestStream())
                 {
-                    if (filelist[i] == filename)
+                    do
                     {
-                        string upload = MessageBox.Show("已存在同名文件,是否覆盖", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
-                        if (upload.ToString() != "Yes")
-                        {
-                            return;
-                        }
-                    }
+                        //每次读文件流的2KB
+                        dataRead = fs.Read(content, 0, BufferSize);
+                        rs.Write(content, 0, dataRead);
+                    } while (!(dataRead < BufferSize));
+                    rs.Close();
                 }
+                fs.Close();
+            }
+            Thread.Sleep(1000);
+            File.Delete(filepath + "/" + filename);
+        }
+
+
+
+
+        public void UpLoadFile(string filepath, string filename, string UploadFolder)
+        {
+            ////上传之前判断文件是否存在
+            //string[] filelist = GetFileList();
+            //if (filelist != null)
+            //    for (int i = 0; i < filelist.Length; i++)
+            //    {
+            //        if (filelist[i] == filename)
+            //        {
+            //            string upload = MessageBox.Show("已存在同名文件,是否覆盖", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
+            //            if (upload.ToString() != "Yes")
+            //            {
+            //                return;
+            //            }
+            //        }
+            //    }
             FtpWebRequest reqFTP;
             FtpCheckDirectoryExist(UploadFolder);
             reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(ftpServerIP + UploadFolder + filename));
@@ -310,8 +358,11 @@ namespace UAS_MES_NEW.PublicMethod
             FtpWebRequest reqFTP;
             try
             {
+                //不存在文件的话进行创建
+                if (!Directory.Exists(DownLoadTo))
+                    Directory.CreateDirectory(DownLoadTo);
                 FileStream outputStream = new FileStream(DownLoadTo + @"\" + fileName, FileMode.Create);
-                reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(ftpServerIP + "/" + fileName));
+                reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(ftpServerIP + "/log/" + fileName));
                 reqFTP.Method = WebRequestMethods.Ftp.DownloadFile;
                 reqFTP.UseBinary = true;
                 reqFTP.Credentials = new NetworkCredential(ftpUser, ftpPwd);
@@ -337,6 +388,7 @@ namespace UAS_MES_NEW.PublicMethod
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message);
+                File.Delete(DownLoadTo + @"\" + fileName);
                 return "";
             }
         }

+ 11 - 2
UAS_MES_DN/UAS_MES_DN.csproj

@@ -982,6 +982,12 @@
     <Compile Include="FunctionCode\SMT\SMT_WaringSetting.Designer.cs">
       <DependentUpon>SMT_WaringSetting.cs</DependentUpon>
     </Compile>
+    <Compile Include="FunctionCode\Special\Special_GetSNLog.cs">
+      <SubType>Form</SubType>
+    </Compile>
+    <Compile Include="FunctionCode\Special\Special_GetSNLog.Designer.cs">
+      <DependentUpon>Special_GetSNLog.cs</DependentUpon>
+    </Compile>
     <Compile Include="FunctionCode\Special\Special_BoxSplit.cs">
       <SubType>Form</SubType>
     </Compile>
@@ -1151,7 +1157,7 @@
       <DesignTime>True</DesignTime>
       <DependentUpon>Resources.resx</DependentUpon>
     </Compile>
-    <Compile Include="Properties\Settings.Designer.cs">
+    <Compile Include="Properties\Settings1.Designer.cs">
       <AutoGen>True</AutoGen>
       <DesignTimeSharedInput>True</DesignTimeSharedInput>
       <DependentUpon>Settings.settings</DependentUpon>
@@ -1555,6 +1561,9 @@
     <EmbeddedResource Include="FunctionCode\SMT\SMT_WaringSetting.resx">
       <DependentUpon>SMT_WaringSetting.cs</DependentUpon>
     </EmbeddedResource>
+    <EmbeddedResource Include="FunctionCode\Special\Special_GetSNLog.resx">
+      <DependentUpon>Special_GetSNLog.cs</DependentUpon>
+    </EmbeddedResource>
     <EmbeddedResource Include="FunctionCode\Special\Special_BoxSplit.resx">
       <DependentUpon>Special_BoxSplit.cs</DependentUpon>
     </EmbeddedResource>
@@ -1652,7 +1661,7 @@
     <None Include="packages.config" />
     <None Include="Properties\Settings.settings">
       <Generator>SettingsSingleFileGenerator</Generator>
-      <LastGenOutput>Settings.Designer.cs</LastGenOutput>
+      <LastGenOutput>Settings1.Designer.cs</LastGenOutput>
     </None>
   </ItemGroup>
   <ItemGroup>