Browse Source

添加Window测试记录修改

callm 3 years ago
parent
commit
6c39f8e412

+ 3 - 1
MaterialPrint/DataHelper.cs

@@ -11,7 +11,9 @@ namespace MaterialPrint
         //系统默认的的连接字符串
         private string ConnectionStrings = "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=11625)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
         //用户选择的数据库的连接字符串
-        public static string DBConnectionString;
+        private string DBConnectionString = "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=11625)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
+
+        //public static string DBConnectionString;
         public static OracleConnection connection = null;
         OracleCommand command = null;
         int ReconnectTime = 0;

+ 23 - 15
MaterialPrint/Form1.cs

@@ -1,4 +1,5 @@
 using LabelManager2;
+using Seagull.BarTender.Print;
 using System;
 using System.Drawing.Printing;
 using System.Windows.Forms;
@@ -8,9 +9,10 @@ namespace MaterialPrint
     public partial class Form1 : Form
     {
 
-        ApplicationClass lbl;
 
-        Document doc;
+        Engine engine = new Engine(true);
+
+        LabelFormatDocument format = null;
 
         public Form1()
         {
@@ -31,38 +33,41 @@ namespace MaterialPrint
                     int temp = i;
                     for (int j = 0; j < ((LastNum - i) / 8 > 0 ? 8 : (LastNum - i)); j++)
                     {
-                        switch (doc.Variables.FormVariables.Item(j + 1).Name)
+                        switch (format.SubStrings[j].Name)
                         {
                             case "RN1":
-                                doc.Variables.FormVariables.Item(j + 1).Value = (Prefix.Text + Date.Value.ToString("yyMMdd") + lpad(4, (temp).ToString()));
+                                format.SubStrings[j].Value = (Prefix.Text + Date.Value.ToString("yyMMdd") + lpad(4, (temp).ToString()));
                                 break;
                             case "RN2":
-                                doc.Variables.FormVariables.Item(j + 1).Value = (Prefix.Text + Date.Value.ToString("yyMMdd") + lpad(4, (temp + 1).ToString()));
+                                format.SubStrings[j].Value = (Prefix.Text + Date.Value.ToString("yyMMdd") + lpad(4, (temp + 1).ToString()));
                                 break;
                             case "RN3":
-                                doc.Variables.FormVariables.Item(j + 1).Value = (Prefix.Text + Date.Value.ToString("yyMMdd") + lpad(4, (temp + 2).ToString()));
+                                format.SubStrings[j].Value = (Prefix.Text + Date.Value.ToString("yyMMdd") + lpad(4, (temp + 2).ToString()));
                                 break;
                             case "RN4":
-                                doc.Variables.FormVariables.Item(j + 1).Value = (Prefix.Text + Date.Value.ToString("yyMMdd") + lpad(4, (temp + 3).ToString()));
+                                format.SubStrings[j].Value = (Prefix.Text + Date.Value.ToString("yyMMdd") + lpad(4, (temp + 3).ToString()));
                                 break;
                             case "RN5":
-                                doc.Variables.FormVariables.Item(j + 1).Value = (Prefix.Text + Date.Value.ToString("yyMMdd") + lpad(4, (temp + 4).ToString()));
+                                format.SubStrings[j].Value = (Prefix.Text + Date.Value.ToString("yyMMdd") + lpad(4, (temp + 4).ToString()));
                                 break;
                             case "RN6":
-                                doc.Variables.FormVariables.Item(j + 1).Value = (Prefix.Text + Date.Value.ToString("yyMMdd") + lpad(4, (temp + 5).ToString()));
+                                format.SubStrings[j].Value = (Prefix.Text + Date.Value.ToString("yyMMdd") + lpad(4, (temp + 5).ToString()));
                                 break;
                             case "RN7":
-                                doc.Variables.FormVariables.Item(j + 1).Value = (Prefix.Text + Date.Value.ToString("yyMMdd") + lpad(4, (temp + 6).ToString()));
+                                format.SubStrings[j].Value = (Prefix.Text + Date.Value.ToString("yyMMdd") + lpad(4, (temp + 6).ToString()));
                                 break;
                             case "RN8":
-                                doc.Variables.FormVariables.Item(j + 1).Value = (Prefix.Text + Date.Value.ToString("yyMMdd") + lpad(4, (temp + 7).ToString()));
+                                format.SubStrings[j].Value = (Prefix.Text + Date.Value.ToString("yyMMdd") + lpad(4, (temp + 7).ToString()));
                                 break;
                             default:
                                 break;
                         }
                     }
-                    doc.Printer.SwitchTo(PrinterList.Text);
-                    doc.PrintDocument(1);
+                    format.PrintSetup.PrinterName = PrinterList.Text;
+                    format.PrintSetup.IdenticalCopiesOfLabel = 1;
+                    format.Print();
+                    //doc.Printer.SwitchTo(PrinterList.Text);
+                    //doc.PrintDocument(1);
                 }
             }
             catch (Exception ex)
@@ -83,10 +88,13 @@ namespace MaterialPrint
 
         private void Form1_Load(object sender, EventArgs e)
         {
+            Console.WriteLine("4181231".Substring(0,3));
+            return;
             try
             {
-                lbl = new ApplicationClass();
-                doc = lbl.Documents.Open(System.Windows.Forms.Application.StartupPath + @"\SN.lab");
+                //lbl = new ApplicationClass();
+                format = engine.Documents.Open(System.Windows.Forms.Application.StartupPath + @"\SN.btw");
+                //doc = lbl.Documents.Open(System.Windows.Forms.Application.StartupPath + @"\SN.btw");
 
                 PrintDocument print = new PrintDocument();
                 string sDefault = print.PrinterSettings.PrinterName;//默认打印机名

+ 2 - 0
MaterialPrint/Form2.cs

@@ -110,6 +110,8 @@ namespace MaterialPrint
 
         private void Form1_Load(object sender, EventArgs e)
         {
+            Console.WriteLine("4181231".Substring(0, 3));
+            return;
             try
             {
                 lbl = new ApplicationClass();

+ 4 - 0
MaterialPrint/MaterialPrint.csproj

@@ -53,6 +53,10 @@
       <SpecificVersion>False</SpecificVersion>
       <HintPath>bin\Debug\Oracle.ManagedDataAccess.dll</HintPath>
     </Reference>
+    <Reference Include="Seagull.BarTender.Print, Version=10.1.4.1, Culture=neutral, PublicKeyToken=109ff779a1b4cbc7, processorArchitecture=x86">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\UAS_MES_PW\Tool\Seagull.BarTender.Print.dll</HintPath>
+    </Reference>
     <Reference Include="System" />
     <Reference Include="System.Core" />
     <Reference Include="System.Xml.Linq" />

+ 1 - 1
MaterialPrint/Program.cs

@@ -16,7 +16,7 @@ namespace MaterialPrint
         {
             Application.EnableVisualStyles();
             Application.SetCompatibleTextRenderingDefault(false);
-            Application.Run(new Form1());
+            Application.Run(new ReadTestInfo());
         }
     }
 }

+ 68 - 1
MaterialPrint/ReadTestInfo.Designer.cs

@@ -28,20 +28,87 @@
         /// </summary>
         private void InitializeComponent()
         {
+            this.SN = new System.Windows.Forms.TextBox();
+            this.label1 = new System.Windows.Forms.Label();
+            this.ResultView = new System.Windows.Forms.DataGridView();
+            this.itemname = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.testresult = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            ((System.ComponentModel.ISupportInitialize)(this.ResultView)).BeginInit();
             this.SuspendLayout();
             // 
+            // SN
+            // 
+            this.SN.Font = new System.Drawing.Font("微软雅黑", 15.875F);
+            this.SN.Location = new System.Drawing.Point(174, 36);
+            this.SN.Name = "SN";
+            this.SN.Size = new System.Drawing.Size(914, 63);
+            this.SN.TabIndex = 1;
+            this.SN.KeyDown += new System.Windows.Forms.KeyEventHandler(this.SN_KeyDown);
+            // 
+            // label1
+            // 
+            this.label1.AutoSize = true;
+            this.label1.Font = new System.Drawing.Font("微软雅黑", 15.875F);
+            this.label1.Location = new System.Drawing.Point(9, 38);
+            this.label1.Name = "label1";
+            this.label1.Size = new System.Drawing.Size(154, 57);
+            this.label1.TabIndex = 2;
+            this.label1.Text = "序列号";
+            // 
+            // ResultView
+            // 
+            this.ResultView.AllowUserToAddRows = false;
+            this.ResultView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+            this.ResultView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
+            this.itemname,
+            this.testresult});
+            this.ResultView.Location = new System.Drawing.Point(12, 127);
+            this.ResultView.Name = "ResultView";
+            this.ResultView.RowTemplate.Height = 37;
+            this.ResultView.Size = new System.Drawing.Size(1320, 716);
+            this.ResultView.TabIndex = 3;
+            this.ResultView.CellPainting += new System.Windows.Forms.DataGridViewCellPaintingEventHandler(this.ResultView_CellPainting);
+            // 
+            // itemname
+            // 
+            this.itemname.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCells;
+            this.itemname.DataPropertyName = "itemname";
+            this.itemname.HeaderText = "测试项目";
+            this.itemname.Name = "itemname";
+            this.itemname.Width = 151;
+            // 
+            // testresult
+            // 
+            this.testresult.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCells;
+            this.testresult.DataPropertyName = "testresult";
+            this.testresult.HeaderText = "测试结果";
+            this.testresult.Name = "testresult";
+            this.testresult.Width = 151;
+            // 
             // ReadTestInfo
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 24F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.ClientSize = new System.Drawing.Size(687, 506);
+            this.ClientSize = new System.Drawing.Size(1344, 855);
+            this.Controls.Add(this.ResultView);
+            this.Controls.Add(this.label1);
+            this.Controls.Add(this.SN);
             this.Name = "ReadTestInfo";
+            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
             this.Text = "ReadTestInfo";
+            this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
             this.Load += new System.EventHandler(this.ReadTestInfo_Load);
+            ((System.ComponentModel.ISupportInitialize)(this.ResultView)).EndInit();
             this.ResumeLayout(false);
+            this.PerformLayout();
 
         }
 
         #endregion
+        private System.Windows.Forms.TextBox SN;
+        private System.Windows.Forms.Label label1;
+        private System.Windows.Forms.DataGridView ResultView;
+        private System.Windows.Forms.DataGridViewTextBoxColumn itemname;
+        private System.Windows.Forms.DataGridViewTextBoxColumn testresult;
     }
 }

+ 79 - 14
MaterialPrint/ReadTestInfo.cs

@@ -13,6 +13,9 @@ namespace MaterialPrint
 {
     public partial class ReadTestInfo : Form
     {
+
+        DataHelper dh = new DataHelper();
+
         public ReadTestInfo()
         {
             InitializeComponent();
@@ -25,6 +28,7 @@ namespace MaterialPrint
             TestItem.Add("Keypad", "按键测试");
             TestItem.Add("Battery", "电池测试");
             TestItem.Add("FrontCameraRec", "前摄像头摄像");
+            TestItem.Add("FrontCamera", "前摄像头拍照");
             TestItem.Add("Brightness", "背光测试");
             TestItem.Add("Display", "显示屏测试");
             TestItem.Add("ExtDisplay", "外接显示器");
@@ -47,30 +51,91 @@ namespace MaterialPrint
             TestItem.Add("Gyrometer", "陀螺仪测试");
             TestItem.Add("Light", "光感测试");
             TestItem.Add("Compass", "指南针");
+
         }
 
 
-        public static void GetWriteInfo(string FilePath, out Dictionary<string, string> Dic)
+        public void GetWriteInfo(string FilePath)
         {
-            Dic = new Dictionary<string, string>();
-            string txt = "";
+            Dictionary<string, string> Dic = new Dictionary<string, string>();
             StreamReader sr = new StreamReader(FilePath);
+            DataTable dt = new DataTable();
+            dt.Columns.Add("itemname");
+            dt.Columns.Add("testresult");
             while (!sr.EndOfStream)
             {
                 string str = sr.ReadLine();
-                txt += str + "\n";
+                string Value = Regex.Match(str, @"\d{4}/\d{2}/\d{2} \d{2}:\d{2}:\d{2}.\d{3}\t\[Info] - (PASS|FAIL)\t\S+").Value;
+                if (Value != "")
+                {
+                    if (Dic.ContainsKey(Value.Split('\t')[2]))
+                        Dic.Remove(Value.Split('\t')[2]);
+                    Dic.Add(Value.Split('\t')[2], Value);
+                }
+            }
+            ResultView.DataSource = dt;
+
+            foreach (var item in Dic)
+            {
+                string time = item.Value.Split('\t')[0];
+                string result = item.Value.Split('\t')[1].Contains("PASS") ? "PASS" : "FAIL";
+                string itemname = TestItem.ContainsKey(item.Key) ? TestItem[item.Key] : item.Key;
+                DataRow dr = dt.NewRow();
+                dr["itemname"] = itemname;
+                dr["testresult"] = item.Value;
+                dt.Rows.Add(dr);
+                string sql = "insert into steptestdetail (std_id,std_sn,std_date,std_class,std_testresult,std_itemname)values";
+                sql += "(steptestdetail_seq.nextval,'" + SN.Text + "',to_timestamp('" + item.Value.Split('\t')[0] + "',";
+                sql += "'yyyy-mm-dd hh24:mi:ss.ff6'),'" + item.Key + "','" + result + "','" + itemname + "')";
+                dh.ExecuteSql(sql, "insert");
             }
-            Dic.Add("atd_sncode", FilePath.Substring(FilePath.LastIndexOf("\\") + 1).Replace(".txt", ""));
-            Dic.Add("atd_software", Regex.Match(txt, "Program Name,\\S+").Value.Replace("Program Name,", ""));
-            Dic.Add("atd_pot", Regex.Match(txt, "Board Segment,\\S+").Value.Replace("Board Segment,", ""));
-            Dic.Add("atd_size", Regex.Match(txt, "Baord Size \\(L x W\\) \\[mm\\],\\S+").Value.Replace("Baord Size (L x W) [mm],", ""));
-            Dic.Add("atd_pot1set", Regex.Match(txt, "Pot-1 Set Temp. \\[deg],\\S+").Value.Replace("Pot-1 Set Temp. [deg],", ""));
-            Dic.Add("atd_pot2set", Regex.Match(txt, "Pot-2 Set Temp. \\[deg],\\S+").Value.Replace("Pot-2 Set Temp. [deg],", ""));
-            Dic.Add("atd_pot1avgtemp", Regex.Match(txt, "Pot-1 Avg. Temp. \\[deg],\\S+").Value.Replace("Pot-1 Avg. Temp. [deg],", ""));
-            Dic.Add("atd_pot2avgtemp", Regex.Match(txt, "Pot-2 Avg. Temp. \\[deg],\\S+").Value.Replace("Pot-2 Avg. Temp. [deg],", ""));
-            Dic.Add("atd_boardtime", Regex.Match(txt, "Machine Duration \\[s],\\S+").Value.Replace("Machine Duration [s],", ""));
+            MessageBox.Show("测试记录保存成功");
+        }
 
-            //开始时间
+        private void SN_KeyDown(object sender, KeyEventArgs e)
+        {
+            if (e.KeyData == Keys.Enter)
+            {
+                if (dh.CheckExist("makeserial", "ms_sncode='" + SN.Text + "' or ms_firstsn='" + SN.Text + "'"))
+                {
+                    GetWriteInfo(@"C:\TEST_TOOL\SFTClassicLog.txt");
+                }
+                else
+                {
+                    MessageBox.Show("序列号" + SN.Text + "不存在");
+                }
+            }
+        }
+
+        private void ResultView_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
+        {
+            if (e.ColumnIndex >= 0)
+            {
+                if (ResultView.Columns[e.ColumnIndex].Name == "testresult")
+                {
+                    if (e.RowIndex >= 0)
+                    {
+                        if (ResultView.Rows[e.RowIndex].Cells["testresult"].Value != null && (ResultView.Rows[e.RowIndex].Cells["testresult"].Value.ToString().Contains("PASS")))
+                        {
+                            e.Graphics.FillRectangle(Brushes.ForestGreen, e.CellBounds);
+                            Rectangle border = e.CellBounds;
+                            border.Width -= 1;
+                            e.Graphics.DrawRectangle(Pens.Black, border);
+                            e.PaintContent(e.CellBounds);
+                            e.Handled = true;
+                        }
+                        else
+                        {
+                            e.Graphics.FillRectangle(Brushes.OrangeRed, e.CellBounds);
+                            Rectangle border = e.CellBounds;
+                            border.Width -= 1;
+                            e.Graphics.DrawRectangle(Pens.Black, border);
+                            e.PaintContent(e.CellBounds);
+                            e.Handled = true;
+                        }
+                    }
+                }
+            }
         }
     }
 }

+ 12 - 0
MaterialPrint/ReadTestInfo.resx

@@ -117,4 +117,16 @@
   <resheader name="writer">
     <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
   </resheader>
+  <metadata name="itemname.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>
+  <metadata name="itemname.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>