实例介绍
【实例简介】
【实例截图】
【核心代码】
Imports System.IO Imports System.Data.SqlClient Imports System.Text Public Class UpDataToServer ''' <summary> ''' 文件说明: ''' 本模块功能实现数据自动上传到服务器上的数据库中,安装电脑为服务器 ''' 上传文件夹均自动生成,前提条件:临时文件夹,上传文件夹,备份文件 ''' 夹中各站别的文件名称必须保持一致。 ''' 杨垒 2010-12-20 ''' </summary> ''' <remarks></remarks> #Region "Private Field" Private DbMes As New YLeeFramework.ylDbSql("192.168.0.237", "LightMasterMes", "sa", "lm2011") Private DbNbosa As New YLeeFramework.ylDbSql("192.168.0.237", "NBOSA", "sa", "lm2011") Private DeviceName As String = "E:" Private UpFilePath As String = DeviceName & "\ProductFile\UpLoad\" Private BackupFilePath As String = DeviceName & "\ProductFile\BackupFile\" Private TempFilePath As String = DeviceName & "\ProductFile\TempFile\" Private ErrorFilePath As String = DeviceName & "\ProductFile\ErrorFile\" Private StartTime As DateTime Private UpFileTime As DateTime Private UpdateBatchSize As Integer = 20000 Private Const FileNameLength = 65 #End Region #Region "Excute Exception" Private Overloads Sub ExcuteException(ByVal Exc As Exception) Dim ErrMsg As String = "错误信息:" & Exc.Message & "---" & Exc.ToString & "---" & Exc.Source.ToString Dim ComputerName As String = My.Computer.Name Dim ErrRaiseTime As String = Now.ToString 'Dim SqlInsert As String = "Insert Into Ex_UpFileErrMsg (ComputerName,ErrorMsg,ErrRaiseTime) Values ('" & ComputerName & "','" & ErrMsg & "','" & ErrRaiseTime & "')" 'DbMes.ExecuteNonQuery(SqlInsert) End Sub Private Overloads Sub ExcuteException(ByVal DicAnalogFileCount As Dictionary(Of String, Integer)) Dim ComputerName As String = My.Computer.Name Dim UpFileTime As String = Now.ToString Dim UpFileSign As String = "数据上传" For Each StationNameKey As String In DicAnalogFileCount.Keys If DicAnalogFileCount(StationNameKey) > 0 Then 'Dim SqlInsert As String = "Insert Into Ex_UpFileOverMsg (StationName,ComputerName,UpCount,UpTime,UpSign) Values ('" & StationNameKey & "','" & ComputerName & "','" & DicAnalogFileCount(StationNameKey) & "','" & UpFileTime & "','" & UpFileSign & "')" 'DbMes.ExecuteNonQuery(SqlInsert) End If Next End Sub Private Overloads Sub ExcuteException(ByVal ErrorMsg As String) Dim ComputerName As String = My.Computer.Name Dim ErrRaiseTime As String = Now.ToString 'Dim SqlInsert As String = "Insert Into Ex_UpFileErrMsg (ComputerName,ErrorMsg,ErrRaiseTime) Values ('" & ComputerName & "','" & ErrorMsg & "','" & ErrRaiseTime & "')" 'DbMes.ExecuteNonQuery(SqlInsert) End Sub #End Region #Region "Service Event" Protected Overrides Sub OnStart(ByVal args() As String) ' Add code here to start your service. This method should set things ' in motion so your service can do its work. StartTime = My.Computer.Clock.LocalTime Try If Me.TimerUpData Is Nothing Then Me.TimerUpData = New System.Timers.Timer End If Me.TimerUpData.Interval = 1000 Me.TimerUpData.Enabled = True Catch ex As Exception Me.ExcuteException(ex) End Try End Sub Protected Overrides Sub OnStop() ' Add code here to perform any tear-down necessary to stop your service. Try If Me.TimerUpData IsNot Nothing Then Me.TimerUpData.Enabled = False End If Catch ex As Exception Me.ExcuteException(ex) End Try End Sub Private Sub TimerUpData_Elapsed(ByVal sender As System.Object, ByVal e As System.Timers.ElapsedEventArgs) Handles TimerUpData.Elapsed Me.UpFileTime = My.Computer.Clock.LocalTime Dim DuraUpFile As Integer = DateDiff(DateInterval.Second, Me.StartTime, Me.UpFileTime) If DuraUpFile >= 300 Then Me.StartTime = My.Computer.Clock.LocalTime Me.TimerUpData.Stop() Me.UpLocalDataToServer() Me.TimerUpData.Start() End If End Sub #End Region #Region "Up Data To Server" #Region "Base File Excute" Private Sub ValidateIsDirectoryExists(ByVal FilePath As String) If My.Computer.FileSystem.DirectoryExists(FilePath) = False Then My.Computer.FileSystem.CreateDirectory(FilePath) End If End Sub '处理每行中的每个字段,若不符合给进行处理 Private Function ExcuteFields(ByVal FileLine As String, ByVal FieldsLength() As Integer, ByVal StationName As String) As String() Try Dim Fields() As String = FileLine.Trim.Split(",") For Index As Integer = 0 To FieldsLength.Length - 1 If String.IsNullOrEmpty(Fields(Index)) = True Then Fields(Index) = "NULL" Me.CreateErrorLineFile(FileLine, StationName) Else Fields(Index) = Fields(Index).Trim.ToUpper End If If Fields(Index).Length > FieldsLength(Index) Then Fields(Index) = Fields(Index).Substring(0, FieldsLength(Index)) 'Me.CreateErrorLineFile(FileLine, StationName) End If Next Return Fields Catch ex As Exception Me.ExcuteException(ex) Return Nothing End Try End Function '出现错误的行给提取出来并生成一个文件 Private Sub CreateErrorLineFile(ByVal ErrorLine As String, ByVal StationName As String) Try Dim BaseFilePath As String = "E:\ProductFile\ErrorFile\" If My.Computer.FileSystem.DirectoryExists(BaseFilePath) = False Then My.Computer.FileSystem.CreateDirectory(BaseFilePath) End If Dim FilePath As String = BaseFilePath & StationName & "\" If My.Computer.FileSystem.FileExists(FilePath) = False Then My.Computer.FileSystem.CreateDirectory(FilePath) End If Dim FileName As String = FilePath & StationName & "-" & Now.ToShortDateString & ".txt" Using SR As StreamWriter = File.AppendText(FileName) SR.WriteLine(ErrorLine) SR.Flush() End Using Catch ex As Exception Me.ExcuteException(ex) End Try End Sub Private Function GetStationName(ByVal DirectionFilePath As String) As String Try Dim Pos As Integer = DirectionFilePath.LastIndexOf("\") Dim StationName As String = DirectionFilePath.Substring(Pos 1, DirectionFilePath.Length - Pos - 1) Return StationName Catch ex As Exception Me.ExcuteException(ex) Return "NULL" End Try End Function Private Function GetFileList(ByVal DirectoryName As String) As List(Of String) Dim FileList As New List(Of String) Try For Each FileName As String In My.Computer.FileSystem.GetFiles(DirectoryName & "\") FileList.Add(FileName) Next Return FileList Catch ex As Exception Me.ExcuteException(ex) Return Nothing End Try End Function Private Sub DeleteFile(ByVal FileList As List(Of String)) Try For Each FileName As String In FileList If My.Computer.FileSystem.FileExists(FileName) Then My.Computer.FileSystem.DeleteFile(FileName) End If Next Catch ex As Exception Me.ExcuteException(ex) End Try End Sub #End Region #Region "Up Each Station File" Private Sub MoveErrorFile(ByVal SourceFileName As String, ByVal StationName As String) Try Dim ErrPath As String = ErrorFilePath & StationName & "\" If My.Computer.FileSystem.DirectoryExists(ErrPath) = False Then My.Computer.FileSystem.CreateDirectory(ErrPath) End If Dim FileName As String = My.Computer.FileSystem.GetName(SourceFileName) My.Computer.FileSystem.MoveFile(FileName, ErrPath & FileName, True) Catch ex As Exception Me.ExcuteException(ex) End Try End Sub Private Sub BulkUpdataToServer(ByVal ListFile As List(Of String), ByVal Conn As SqlConnection, ByVal Ds As DataSet, ByVal DesTableName As String, ByVal UpdateRowsCount As Integer) Try Conn.Open() Using Bulk As SqlBulkCopy = New SqlBulkCopy(Conn) Bulk.BatchSize = Me.UpdateBatchSize Bulk.DestinationTableName = DesTableName Bulk.BulkCopyTimeout = 600 Bulk.WriteToServer(Ds.Tables(DesTableName)) End Using Conn.Close() Conn.Dispose() Me.DeleteFile(ListFile) Catch ex As Exception Me.ExcuteException(ex) End Try End Sub Private Function UpdateFile_Apd(ByVal ListFile As List(Of String), ByVal StationName As String) As Integer Dim UpdateRows As Integer = 0 Dim FieldsLength() As Integer = New Integer() {"15", "15", "15", "25", "25", "15", "15", "25", "15", "15", "15", "15", "25", "25", "25", "15", "8"} Dim FileName As String = String.Empty Dim SR As StreamReader = Nothing Try For Count As Integer = ListFile.Count - 1 To 0 Step -1 FileName = ListFile.Item(Count).ToString.Trim If My.Computer.FileSystem.GetName(FileName).Length > FileNameLength Then Me.MoveErrorFile(FileName, StationName) Else SR = New StreamReader(FileName, System.Text.Encoding.Default) SR.ReadLine() Dim MyLine As String = SR.ReadLine While Not String.IsNullOrEmpty(MyLine) Dim Fields() As String = Me.ExcuteFields(MyLine, FieldsLength, StationName) If Fields.Length = 17 Then UpdateRows = 1 Fields(5) = StrConv(Fields(5), VbStrConv.Narrow) If Fields(0).Trim.Length > 7 Then Dim SqlInsert As String = "Insert Into APD(SN,ProductType,ProductStaion,ProductDate,ProductLot,WorkerID,OrderID,BadReason,Vbr,Iop,Icc,RL,StartTime,EndTime,Duration,ProductOrderID,Result) values ('" & Fields(0).Trim & "','" & Fields(1).Trim & "', " & _ "'" & Fields(2).Trim & "','" & Fields(3).Trim & "','" & Fields(4).Trim & "','" & Fields(5).Trim & "','" & Fields(6).Trim & "'," & _ "'" & Fields(7).Trim & "','" & Fields(8).Trim & "','" & Fields(9).Trim & "','" & Fields(10).Trim & "','" & Fields(11).Trim & "'," & _ "'" & Fields(12).Trim & "','" & Fields(13).Trim & "','" & Fields(14).Trim & "','" & Fields(15).Trim & "','" & Fields(16).Trim & "')" DbNbosa.ExecuteNonQuery(SqlInsert) End If End If MyLine = SR.ReadLine End While SR.Close() End If Next Me.DeleteFile(ListFile) Return UpdateRows Catch ex As SqlException SR.Close() Me.MoveErrorFile(FileName, StationName) Return UpdateRows End Try End Function Private Function UpdateFile_PT(ByVal ListFile As List(Of String), ByVal StationName As String) As Integer Dim UpdateRows As Integer = 0 Dim FieldsLength() As Integer = New Integer() {"15", "15", "15", "25", "25", "15", "15", "25", "15", "15", "15", "15", "15", "15"} Dim FileName As String = String.Empty Dim SR As StreamReader = Nothing Try For Count As Integer = ListFile.Count - 1 To 0 Step -1 FileName = ListFile.Item(Count).ToString.Trim If My.Computer.FileSystem.GetName(FileName).Length > FileNameLength Then Me.MoveErrorFile(FileName, StationName) Else SR = New StreamReader(FileName, System.Text.Encoding.Default) SR.ReadLine() Dim MyLine As String = SR.ReadLine While Not String.IsNullOrEmpty(MyLine) Dim Fields() As String = Me.ExcuteFields(MyLine, FieldsLength, StationName) Dim FieldList As List(Of String) = Fields.ToList() If Fields.Length = 12 Then FieldList.Add("NULL") FieldList.Add("NULL") ElseIf Fields.Length = 13 Then FieldList.Add("NULL") End If Fields = FieldList.ToArray() If Fields.Length = 14 Then UpdateRows = 1 If Fields(0).Trim.Length > 7 Then Dim SqlInsert As String = "Insert Into PT_Align(SN,ProductType,ProductStation,ProductDate,ProductLot,WorkerID,DepartmentID,FlowCardID,Icc,Iop,ComputerName,Result,Field1,Field2) values ('" & Fields(0).Trim & "','" & Fields(1).Trim & "', " & _ "'" & Fields(2).Trim & "','" & Fields(3).Trim & "','" & Fields(4).Trim & "','" & Fields(5).Trim & "','" & Fields(6).Trim & "'," & _ "'" & Fields(7).Trim & "','" & Fields(8).Trim & "','" & Fields(9).Trim & "','" & Fields(10).Trim & "','" & Fields(11).Trim & "','" & Fields(12).Trim & "','" & Fields(13).Trim & "')" DbNbosa.ExecuteNonQuery(SqlInsert) End If End If MyLine = SR.ReadLine End While SR.Close() End If Next Me.DeleteFile(ListFile) Return UpdateRows Catch ex As SqlException SR.Close() Me.MoveErrorFile(FileName, StationName) Return UpdateRows End Try End Function Private Function UpdateFile_IMD2(ByVal ListFile As List(Of String), ByVal StationName As String) As Integer Dim UpdateRows As Integer = 0 Dim FieldsLength() As Integer = New Integer() {"15", "6", "20", "8", "15", "25", "25", "25", "15"} Dim FileName As String = String.Empty Dim SR As StreamReader = Nothing Try For Count As Integer = ListFile.Count - 1 To 0 Step -1 FileName = ListFile.Item(Count).ToString.Trim If My.Computer.FileSystem.GetName(FileName).Length > FileNameLength Then Me.MoveErrorFile(FileName, StationName) Else SR = New StreamReader(FileName, System.Text.Encoding.Default) SR.ReadLine() Dim MyLine As String = SR.ReadLine While Not String.IsNullOrEmpty(MyLine) UpdateRows = 1 Dim Fields() As String = Me.ExcuteFields(MyLine, FieldsLength, StationName) If Fields.Length = 9 Then If Fields(0).Trim.Length > 5 Then Dim SqlInsert As String = "Insert Into IMD2_Test(SN,Result,ProductType,WorkerID,IMD2,ProductDate,ComputerName,DepartmentName) values ('" & Fields(0).Trim & "','" & Fields(1).Trim & "', " & _ "'" & Fields(2).Trim & "','" & Fields(3).Trim & "','" & Fields(4).Trim & "','" & Fields(5).Trim & "','" & Fields(7).Trim & "','" & Fields(8).Trim & "')" DbNbosa.ExecuteNonQuery(SqlInsert) End If End If MyLine = SR.ReadLine End While SR.Close() End If Next Me.DeleteFile(ListFile) Return UpdateRows Catch ex As SqlException SR.Close() Me.MoveErrorFile(FileName, StationName) Return UpdateRows End Try End Function Private Function UpdateFile_IMD3(ByVal ListFile As List(Of String), ByVal StationName As String) As Integer Dim UpdateRows As Integer = 0 Dim FieldsLength() As Integer = New Integer() {"15", "6", "20", "8", "15", "25", "25", "25", "15"} Dim FileName As String = String.Empty Dim SR As StreamReader = Nothing Try For Count As Integer = ListFile.Count - 1 To 0 Step -1 FileName = ListFile.Item(Count).ToString.Trim If My.Computer.FileSystem.GetName(FileName).Length > FileNameLength Then Me.MoveErrorFile(FileName, StationName) Else SR = New StreamReader(FileName, System.Text.Encoding.Default) SR.ReadLine() Dim MyLine As String = SR.ReadLine While Not String.IsNullOrEmpty(MyLine) UpdateRows = 1 Dim Fields() As String = Me.ExcuteFields(MyLine, FieldsLength, StationName) If Fields.Length = 9 Then If Fields(0).Trim.Length > 5 Then Dim SqlInsert As String = "Insert Into IMD3_Test(SN,Result,ProductType,WorkerID,IMD3,ProductDate,ComputerName,DepartmentName) values ('" & Fields(0).Trim & "','" & Fields(1).Trim & "', " & _ "'" & Fields(2).Trim & "','" & Fields(3).Trim & "','" & Fields(4).Trim & "','" & Fields(5).Trim & "','" & Fields(7).Trim & "','" & Fields(8).Trim & "')" DbNbosa.ExecuteNonQuery(SqlInsert) End If End If MyLine = SR.ReadLine End While SR.Close() End If Next Me.DeleteFile(ListFile) Return UpdateRows Catch ex As SqlException SR.Close() Me.MoveErrorFile(FileName, StationName) Return UpdateRows End Try End Function Private Function UpdateFile_PdAlign(ByVal ListFile As List(Of String), ByVal StationName As String) As Integer Dim UpdateRows As Integer = 0 Dim FieldsLength() As Integer = New Integer() {"15", "20", "25", "25", "25", "8", "8", "15", "15", "15", "8", "15", "15"} Dim FileName As String = String.Empty Dim SR As StreamReader = Nothing Try For Count As Integer = ListFile.Count - 1 To 0 Step -1 FileName = ListFile.Item(Count).ToString.Trim If My.Computer.FileSystem.GetName(FileName).Length > FileNameLength Then Me.MoveErrorFile(FileName, StationName) Else SR = New StreamReader(FileName, System.Text.Encoding.Default) SR.ReadLine() Dim MyLine As String = SR.ReadLine While Not String.IsNullOrEmpty(MyLine) UpdateRows = 1 Dim Fields() As String = Me.ExcuteFields(MyLine, FieldsLength, StationName) If Fields.Length = 13 Then If Fields(0).Trim.Length > 5 Then Dim SqlInsert As String = "Insert Into PD_Align(SN,ProductType,ProductStation,ProductLot,ProductDate,WorkerID,OrderID,BadReason,Res,RL,Result,Idark) values " & _ " ('" & Fields(0).Trim & "','" & Fields(1).Trim & "','" & Fields(2).Trim & "','" & Fields(3).Trim & "','" & My.Computer.Clock.LocalTime & "'," & _ "'" & Fields(5).Trim & "','" & Fields(6).Trim & "','" & Fields(7).Trim & "','" & Fields(8).Trim & "','" & Fields(9).Trim & "'," & _ "'" & Fields(10).Trim & "','" & Fields(11).Trim & "')" DbNbosa.ExecuteNonQuery(SqlInsert) End If End If MyLine = SR.ReadLine End While SR.Close() End If Next Me.DeleteFile(ListFile) Return UpdateRows Catch ex As SqlException SR.Close() Me.MoveErrorFile(FileName, StationName) Return UpdateRows End Try End Function Private Function UpdateFile_PdTest(ByVal ListFile As List(Of String), ByVal StationName As String) As Integer Dim UpdateRows As Integer = 0 Dim FieldsLength() As Integer = New Integer() {"15", "20", "25", "25", "25", "8", "8", "15", "15", "15", "15", "8", "25"} Dim FileName As String = String.Empty Dim SR As StreamReader = Nothing Try For Count As Integer = ListFile.Count - 1 To 0 Step -1 FileName = ListFile.Item(Count).ToString.Trim If My.Computer.FileSystem.GetName(FileName).Length > FileNameLength Then Me.MoveErrorFile(FileName, StationName) Else SR = New StreamReader(FileName, System.Text.Encoding.Default) SR.ReadLine() Dim MyLine As String = SR.ReadLine While Not String.IsNullOrEmpty(MyLine) UpdateRows = 1 Dim Fields() As String = Me.ExcuteFields(MyLine, FieldsLength, StationName) If Fields.Length = 13 Then If Fields(0).Trim.Length > 5 Then Dim SqlInsert As String = "Insert Into PD_Align_Test( SN,ProductType,ProductStation,ProductLot,ProductDate,WorkerID,OrderID,BadReason,Res,RL,Idark,Result) values " & _ " ('" & Fields(0).Trim & "','" & Fields(1).Trim & "','" & Fields(2).Trim & "','" & Fields(12).Trim & "','" & My.Computer.Clock.LocalTime & "'," & _ "'" & Fields(5).Trim & "','" & Fields(6).Trim & "','" & Fields(7).Trim & "','" & Fields(8).Trim & "','" & Fields(9).Trim & "'," & _ "'" & Fields(10).Trim & "','" & Fields(11).Trim & "')" DbNbosa.ExecuteNonQuery(SqlInsert) End If End If MyLine = SR.ReadLine End While SR.Close() End If Next Me.DeleteFile(ListFile) Catch ex As SqlException SR.Close() Me.MoveErrorFile(FileName, StationName) Return UpdateRows End Try End Function Private Function UpdateFile_RosaPdTest(ByVal ListFile As List(Of String), ByVal StationName As String) As Integer Dim UpdateRows As Integer = 0 Dim FieldsLength() As Integer = New Integer() {"15", "20", "25", "25", "25", "8", "15", "15", "15", "15", "15", "15", "15", "15", "8"} Dim FileName As String = String.Empty Dim SR As StreamReader = Nothing Try For Count As Integer = ListFile.Count - 1 To 0 Step -1 FileName = ListFile.Item(Count).ToString.Trim If My.Computer.FileSystem.GetName(FileName).Length > FileNameLength Then Me.MoveErrorFile(FileName, StationName) Else SR = New StreamReader(FileName, System.Text.Encoding.Default) SR.ReadLine() Dim MyLine As String = SR.ReadLine While Not String.IsNullOrEmpty(MyLine) UpdateRows = 1 Dim Fields() As String = Me.ExcuteFields(MyLine, FieldsLength, StationName) If Fields.Length = 15 Then If Fields(0).Trim.Length > 5 Then Dim SqlInsert As String = "Insert Into PD_Align_Rosa_Test(SN, ProductType, ProductStation, ProductLot, ProductDate, WorkerID, BadReason, Res_1310, RL_1310, Power_1310, Res_1550, RL_1550, Power_1550,Idark, Result) values" & _ " ('" & Fields(0).Trim & "','" & Fields(1).Trim & "','" & Fields(2).Trim & "','" & Fields(3).Trim & "','" & Fields(4).Trim & "'," & _ "'" & Fields(5).Trim & "','" & Fields(6).Trim & "','" & Fields(7).Trim & "','" & Fields(8).Trim & "','" & Fields(9).Trim & "'," & _ "'" & Fields(10).Trim & "','" & Fields(11).Trim & "','" & Fields(12).Trim & "','" & Fields(13).Trim & "','" & Fields(14).Trim & "')" DbNbosa.ExecuteNonQuery(SqlInsert) End If End If MyLine = SR.ReadLine End While SR.Close() End If Next Me.DeleteFile(ListFile) Catch ex As SqlException SR.Close() Me.MoveErrorFile(FileName, StationName) Return UpdateRows End Try End Function Private Function UpdateFile_Ldmy(ByVal ListFile As List(Of String), ByVal StationName As String) As Integer Dim UpdateRows As Integer = 0 Dim FieldsLength() As Integer = New Integer() {"15", "20", "15", "30", "25", "25", "8", "30", "15"} Dim FileName As String = String.Empty Dim SR As StreamReader = Nothing Try For Count As Integer = ListFile.Count - 1 To 0 Step -1 FileName = ListFile.Item(Count).ToString.Trim If My.Computer.FileSystem.GetName(FileName).Length > FileNameLength Then Me.MoveErrorFile(FileName, StationName) Else SR = New StreamReader(FileName, System.Text.Encoding.Default) SR.ReadLine() Dim MyLine As String = SR.ReadLine While Not String.IsNullOrEmpty(MyLine) UpdateRows = 1 Dim Fields() As String = Me.ExcuteFields(MyLine, FieldsLength, StationName) If Fields.Length = 9 Then If Fields(0).Trim.Length > 5 Then Dim SqlInsert As String = "Insert Into LDMY(SN,ProductType,ProductStation,ProductDate,ProductLot,WorkerID,ProductOrderID,OrderID) values " & _ " ('" & Fields(0).Trim & "','" & Fields(1).Trim & "','" & Fields(2).Trim & "','" & My.Computer.Clock.LocalTime & "','" & Fields(4).Trim & "'," & _ "'" & Fields(5).Trim & "','" & Fields(7).Trim & "','" & Fields(6).Trim & "')" DbNbosa.ExecuteNonQuery(SqlInsert) End If End If MyLine = SR.ReadLine End While SR.Close() End If Next Me.DeleteFile(ListFile) Return UpdateRows Catch ex As SqlException SR.Close() Me.MoveErrorFile(FileName, StationName) Return UpdateRows End Try End Function Private Function UpdateFile_LdAlign(ByVal ListFile As List(Of String), ByVal StationName As String) As Integer Dim TableName As String = "LD" Dim UpdateRows As Integer = 0 Dim myDataAdapter As SqlDataAdapter = DbNbosa.GetSqlDataAdapter("SELECT TOP 1 * FROM LD") Dim myConnection As SqlConnection = myDataAdapter.SelectCommand.Connection Dim myDataSet = New DataSet() Dim FieldsLength() As Integer = New Integer() {"15", "20", "15", "30", "15", "15", "15", "15", "6", "30", "25"} myDataSet.CaseSensitive = True myDataAdapter.Fill(myDataSet, TableName) myDataAdapter.UpdateBatchSize = Me.UpdateBatchSize Dim FileName As String = String.Empty Dim SR As StreamReader = Nothing Try For Count As Integer = ListFile.Count - 1 To 0 Step -1 FileName = ListFile.Item(Count).ToString.Trim If My.Computer.FileSystem.GetName(FileName).Length > 50 Then Me.MoveErrorFile(FileName, StationName) Else SR = New StreamReader(FileName, System.Text.Encoding.Default) SR.ReadLine() Dim MyLine As String = SR.ReadLine While Not String.IsNullOrEmpty(MyLine) UpdateRows = 1 Dim Fields() As String = Me.ExcuteFields(MyLine, FieldsLength, StationName) If Fields.Length = 11 Then If Fields(0).Trim.Length > 5 Then Dim newRow As DataRow = myDataSet.Tables(TableName).NewRow() newRow("SN") = Fields(0).Trim newRow("ProductType") = Fields(1).Trim newRow("ProductStation") = Fields(2).Trim newRow("ProductDate") = My.Computer.Clock.LocalTime newRow("ToolCode") = Fields(4).Trim newRow("WorkerID") = Fields(5).Trim newRow("OrderID") = Fields(6).Trim newRow("Power") = Fields(7).Trim newRow("Result") = Fields(8).Trim newRow("ProductOrderID") = Fields(9).Trim newRow("BadReason") = Fields(10).Trim ' 将新数据行新增至数据集内的数据表。 myDataSet.Tables(TableName).Rows.Add(newRow) End If End If MyLine = SR.ReadLine End While SR.Close() End If Next Me.BulkUpdataToServer(ListFile, myConnection, myDataSet, TableName, UpdateRows) Return UpdateRows Catch ex As SqlException SR.Close() Me.MoveErrorFile(FileName, StationName) Return UpdateRows End Try End Function Private Function UpdateFile_LdAutoAlign(ByVal ListFile As List(Of String), ByVal StationName As String) As Integer Dim TableName As String = "LdAutoAlign" Dim UpdateRows As Integer = 0 Dim myDataAdapter As SqlDataAdapter = DbNbosa.GetSqlDataAdapter("SELECT TOP 1 * FROM LdAutoAlign where SN='1'") Dim myConnection As SqlConnection = myDataAdapter.SelectCommand.Connection Dim myDataSet = New DataSet() Dim FieldsLength() As Integer = New Integer() {"20", "20", "25", "25", "25", "15", "15", "10", "15", "15", "15", "15", "15", "15", "10", "15"} myDataSet.CaseSensitive = True myDataAdapter.Fill(myDataSet, TableName) myDataAdapter.UpdateBatchSize = Me.UpdateBatchSize Dim FileName As String = String.Empty Dim SR As StreamReader = Nothing Try For Count As Integer = ListFile.Count - 1 To 0 Step -1 FileName = ListFile.Item(Count).ToString.Trim If My.Computer.FileSystem.GetName(FileName).Length > 50 Then Me.MoveErrorFile(FileName, StationName) Else SR = New StreamReader(FileName, System.Text.Encoding.Default) SR.ReadLine() Dim MyLine As String = SR.ReadLine While Not String.IsNullOrEmpty(MyLine) UpdateRows = 1 Dim Fields() As String = Me.ExcuteFields(MyLine, FieldsLength, StationName) If Fields.Length >= 16 Then If Fields(0).Trim.Length > 5 Then Dim newRow As DataRow = myDataSet.Tables(TableName).NewRow() Dim Pdate, Ptime As DateTime Dim ComputerName As String If DateTime.TryParse(Fields(3).Trim, Pdate) = True AndAlso DateTime.TryParse(Fields(4).Trim, Ptime) = True Then If Fields(3).Trim.Substring(0, 4) <> DateTime.Now.Year Then Pdate = DateTime.Now End If If Fields(4).Trim.Substring(0, 4) <> DateTime.Now.Year Then Ptime = DateTime.Now End If Else Pdate = DateTime.Today Ptime = DateTime.Now End If If Fields(13).Length > 9 Then ComputerName = Fields(13).Trim.Substring(0, 8) Else ComputerName = Fields(13).Trim End If newRow("SN") = Fields(0).Trim newRow("ProductType") = Fields(1).Trim newRow("FlowCardId") = Fields(2).Trim newRow("ProductDate") = Pdate newRow("ProductTime") = Ptime newRow("WorkerID") = Fields(5).Trim newRow("WorkerName") = Fields(6).Trim newRow("AlignTime") = Fields(7).Trim newRow("PfMax") = Fields(8).Trim newRow("PfBeforeLaser") = Fields(9).Trim newRow("PfAfterLaser") = Fields(10).Trim newRow("AlignType") = Fields(11).Trim newRow("AlignMachineId") = Fields(12).Trim newRow("ComputerName") = ComputerName newRow("Result") = Fields(14).Trim newRow("CheckBy") = Fields(15).Trim newRow("Field1") = "null" newRow("Field2") = "null" newRow("Field3") = "null" newRow("Field4") = "null" newRow("Field5") = "null" ' 将新数据行新增至数据集内的数据表。 myDataSet.Tables(TableName).Rows.Add(newRow) End If End If MyLine = SR.ReadLine End While SR.Close() End If Next Me.BulkUpdataToServer(ListFile, myConnection, myDataSet, TableName, UpdateRows) Return UpdateRows Catch ex As SqlException SR.Close() Me.MoveErrorFile(FileName, StationName) Return UpdateRows End Try End Function Private Function UpdateFile_Hammer(ByVal ListFile As List(Of String), ByVal StationName As String) As Integer Dim UpdateRows As Integer = 0 Dim FieldsLength() As Integer = New Integer() {"15", "20", "25", "25", "25", "25", "25", "25", "25", "25", "25", "25", "30", "25", "25", "25"} Dim FileName As String = String.Empty Dim SR As StreamReader = Nothing Try For Count As Integer = ListFile.Count - 1 To 0 Step -1 FileName = ListFile.Item(Count).ToString.Trim If My.Computer.FileSystem.GetName(FileName).Length > FileNameLength Then Me.MoveErrorFile(FileName, StationName) Else SR = New StreamReader(FileName, System.Text.Encoding.Default) SR.ReadLine() Dim MyLine As String = SR.ReadLine While Not String.IsNullOrEmpty(MyLine) UpdateRows = 1 Dim Fields() As String = Me.ExcuteFields(MyLine, FieldsLength, StationName) If Fields.Length = 16 Then If Fields(0).Trim.Length > 5 Then Dim strSql As New StringBuilder strSql.Append("insert into Laser_Hammer(") strSql.Append("SN,ProductType,ProductStation,ProductDate,HammerPreValue,WorkerID,OrderID,BadReason,HammerValue,StartTime,EndTime,Interval,ProductOrderID,Result,LdWorkerID,ToolID)") strSql.Append(" values (") strSql.Append("@SN,@ProductType,@ProductStation,@ProductDate,@HammerPreValue,@WorkerID,@OrderID,@BadReason,@HammerValue,@StartTime,@EndTime,@Interval,@ProductOrderID,@Result,@LdWorkerID,@ToolID)") Dim parameters() As SqlParameter = { New SqlParameter("@SN", SqlDbType.VarChar, 15), New SqlParameter("@ProductType", SqlDbType.VarChar, 20), New SqlParameter("@ProductStation", SqlDbType.VarChar, 15), New SqlParameter("@ProductDate", SqlDbType.DateTime), New SqlParameter("@HammerPreValue", SqlDbType.VarChar, 25), New SqlParameter("@WorkerID", SqlDbType.VarChar, 20), New SqlParameter("@OrderID", SqlDbType.VarChar, 20), New SqlParameter("@BadReason", SqlDbType.VarChar, 30), New SqlParameter("@HammerValue", SqlDbType.VarChar, 15), New SqlParameter("@StartTime", SqlDbType.DateTime), New SqlParameter("@EndTime", SqlDbType.DateTime), New SqlParameter("@Interval", SqlDbType.Int, 4), New SqlParameter("@ProductOrderID", SqlDbType.VarChar, 30), New SqlParameter("@Result", SqlDbType.VarChar, 6), New SqlParameter("@LdWorkerID", SqlDbType.VarChar, 30), New SqlParameter("@ToolID", SqlDbType.VarChar, 30)} Dim st, et As DateTime If DateTime.TryParse(Fields(9), st) = True AndAlso DateTime.TryParse(Fields(10).Trim, et) = True Then If Fields(9).Trim.Substring(0, 4) <> DateTime.Now.Year Then st = DateTime.Now End If If Fields(10).Trim.Substring(0, 4) <> DateTime.Now.Year Then et = DateTime.Now End If Else st = DateTime.Now et = DateTime.Now End If parameters(0).Value = Fields(0).Trim parameters(1).Value = Fields(1).Trim parameters(2).Value = Fields(2).Trim parameters(3).Value = My.Computer.Clock.LocalTime parameters(4).Value = Fields(4).Trim parameters(5).Value = Fields(5).Trim parameters(6).Value = Fields(6).Trim parameters(7).Value = Fields(7).Trim parameters(8).Value = Fields(8).Trim parameters(9).Value = st parameters(10).Value = et parameters(11).Value = Fields(11).Trim parameters(12).Value = Fields(12).Trim parameters(13).Value = Fields(13).Trim parameters(14).Value = Fields(14).Trim parameters(15).Value = Fields(15).Trim UpdateRows = DbNbosa.ExecuteNonQuery(strSql.ToString(), parameters) End If End If MyLine = SR.ReadLine End While SR.Close() End If Next Me.DeleteFile(ListFile) Return UpdateRows Catch ex As SqlException SR.Close() Me.MoveErrorFile(FileName, StationName) Return UpdateRows End Try End Function Private Function UpdateFile_TeTest(ByVal ListFile As List(Of String), ByVal StationName As String) As Integer Dim UpdateRows As Integer = 0 Dim FieldsLength() As Integer = New Integer() {"15", "20", "15", "25", "8", "15", "15", "6", "8", "15", "15"} Dim FileName As String = String.Empty Dim SR As StreamReader = Nothing Try For Count As Integer = ListFile.Count - 1 To 0 Step -1 FileName = ListFile.Item(Count).ToString.Trim If My.Computer.FileSystem.GetName(FileName).Length > FileNameLength Then Me.MoveErrorFile(FileName, StationName) Else SR = New StreamReader(FileName, System.Text.Encoding.Default) SR.ReadLine() Dim MyLine As String = SR.ReadLine While Not String.IsNullOrEmpty(MyLine) UpdateRows = 1 Dim Fields() As String = Me.ExcuteFields(MyLine, FieldsLength, StationName) If Fields.Length = 11 Then Fields(4) = StrConv(Fields(4), VbStrConv.Narrow) If Fields(0).Trim.Length > 5 Then Dim SqlInsert As String = "Insert Into TE_Test(SN,ProductType,ProductStation,WorkerID,OrderID,TE,Result,BadReason,ProductOrderID,ProductDate) values " & _ " ('" & Fields(0).Trim & "','" & Fields(1).Trim & "','" & Fields(2).Trim & "','" & Fields(4).Trim & "','" & Fields(8).Trim & "'," & _ "'" & Fields(6).Trim & "','" & Fields(7).Trim & "','" & Fields(9).Trim & "','" & Fields(5).Trim & "','" & My.Computer.Clock.LocalTime & "')" DbNbosa.ExecuteNonQuery(SqlInsert) End If End If MyLine = SR.ReadLine End While SR.Close() End If Next Me.DeleteFile(ListFile) Return UpdateRows Catch ex As SqlException SR.Close() Me.MoveErrorFile(FileName, StationName) Return UpdateRows End Try End Function Private Function UpdateFile_SmsrTest25(ByVal ListFile As List(Of String), ByVal StationName As String) As Integer Dim UpdateRows As Integer = 0 Dim FieldsLength() As Integer = New Integer() {"15", "20", "25", "25", "8", "8", "15", "15", "15", "15", "15", "15", "15"} Dim FileName As String = String.Empty Dim SR As StreamReader = Nothing Try For Count As Integer = ListFile.Count - 1 To 0 Step -1 FileName = ListFile.Item(Count).ToString.Trim If My.Computer.FileSystem.GetName(FileName).Length > FileNameLength Then Me.MoveErrorFile(FileName, StationName) Else SR = New StreamReader(FileName, System.Text.Encoding.Default) SR.ReadLine() Dim MyLine As String = SR.ReadLine While Not String.IsNullOrEmpty(MyLine) UpdateRows = 1 Dim Fields() As String = Me.ExcuteFields(MyLine, FieldsLength, StationName) If Fields.Length = 13 Then If Fields(6).Trim.Length > 15 Then Fields(6) = Fields(6).Trim.Substring(0, 15) End If If Fields(0).Trim.Length > 5 Then Dim SqlInsert As String = "Insert Into SMSR_Test_25(SN,ProductType,ProductStation,ProductDate,WorkerID,OrderID,BadReason,SMSR,WD,WaveLength,Tempereture,Result) values" & _ " ('" & Fields(0).Trim & "','" & Fields(1).Trim & "','" & Fields(2).Trim & "','" & Fields(3).Trim & "','" & Fields(4).Trim & "'," & _ "'" & Fields(5).Trim & "','" & Fields(6).Trim & "','" & Fields(7).Trim & "','" & Fields(8).Trim & "','" & Fields(9).Trim & "','" & Fields(12).Trim & "','" & Fields(11).Trim & "')" DbNbosa.ExecuteNonQuery(SqlInsert) End If End If MyLine = SR.ReadLine End While SR.Close() End If Next Me.DeleteFile(ListFile) Return UpdateRows Catch ex As SqlException SR.Close() Me.MoveErrorFile(FileName, StationName) Return UpdateRows End Try End Function Private Function UpdateFile_SmsrTest70(ByVal ListFile As List(Of String), ByVal StationName As String) As Integer Dim UpdateRows As Integer = 0 Dim FieldsLength() As Integer = New Integer() {"15", "20", "25", "25", "8", "8", "15", "15", "15", "15", "15", "15", "15"} Dim FileName As String = String.Empty Dim SR As StreamReader = Nothing Try For Count As Integer = ListFile.Count - 1 To 0 Step -1 FileName = ListFile.Item(Count).ToString.Trim If My.Computer.FileSystem.GetName(FileName).Length > FileNameLength Then Me.MoveErrorFile(FileName, StationName) Else SR = New StreamReader(FileName, System.Text.Encoding.Default) SR.ReadLine() Dim MyLine As String = SR.ReadLine While Not String.IsNullOrEmpty(MyLine) Dim Fields() As String = Me.ExcuteFields(MyLine, FieldsLength, StationName) If Fields.Length = 13 Then If Fields(6).Trim.Length > 15 Then Fields(6) = Fields(6).Trim.Substring(0, 15) End If If Fields(0).Trim.Length > 5 Then Dim SqlInsert As String = "Insert Into SMSR_Test_70(SN,ProductType,ProductStation,ProductDate,WorkerID,OrderID,BadReason,SMSR,WD,WaveLength,Tempereture,Result) values " & _ " ('" & Fields(0).Trim & "','" & Fields(1).Trim & "','" & Fields(2).Trim & "','" & Fields(3).Trim & "','" & Fields(4).Trim & "'," & _ "'" & Fields(5).Trim & "','" & Fields(6).Trim & "','" & Fields(7).Trim & "','" & Fields(8).Trim & "','" & Fields(9).Trim & "','" & Fields(12).Trim & "','" & Fields(11).Trim & "')" DbNbosa.ExecuteNonQuery(SqlInsert) End If End If MyLine = SR.ReadLine End While SR.Close() End If Next Me.DeleteFile(ListFile) Return UpdateRows Catch ex As SqlException SR.Close() Me.MoveErrorFile(FileName, StationName) Return UpdateRows End Try End Function Private Function UpdateFile_SmsrTest(ByVal ListFile As List(Of String), ByVal StationName As String) As Integer Dim UpdateRows As Integer = 0 Try Dim ListFile25 As New List(Of String) Dim ListFile75 As New List(Of String) ListFile25.Clear() ListFile75.Clear() For Count As Integer = ListFile.Count - 1 To 0 Step -1 Dim FilePath As String = ListFile.Item(Count).ToString.Trim Dim FileName As String = My.Computer.FileSystem.GetName(FilePath) If FileName.IndexOf("25度") > 0 Then ListFile25.Add(FilePath) Else ListFile75.Add(FilePath) End If Next If ListFile25.Count > 0 Then UpdateRows = Me.UpdateFile_SmsrTest25(ListFile25, StationName) End If Threading.Thread.Sleep(1000) If ListFile75.Count > 0 Then UpdateRows = Me.UpdateFile_SmsrTest70(ListFile75, StationName) End If Me.DeleteFile(ListFile) Return UpdateRows Catch ex As SqlException Me.ExcuteException(ex) Return UpdateRows End Try End Function Private Function UpdateFile_TestBehindTc(ByVal ListFile As List(Of String), ByVal StationName As String) As Integer Dim TableName As String = "TC_Test_Next_TX" Dim UpdateRows As Integer = 0 Dim myDataAdapter As SqlDataAdapter = DbNbosa.GetSqlDataAdapter("SELECT TOP 1 * FROM TC_Test_Next_TX") Dim myConnection As SqlConnection = myDataAdapter.SelectCommand.Connection Dim myDataSet = New DataSet() Dim FieldsLength() As Integer = New Integer() {"15", "20", "15", "8", "8", "15", "15", "15", "15", "30", "25"} myDataSet.CaseSensitive = True myDataAdapter.Fill(myDataSet, TableName) myDataAdapter.UpdateBatchSize = Me.UpdateBatchSize Dim FileName As String = String.Empty Dim SR As StreamReader = Nothing Try For Count As Integer = ListFile.Count - 1 To 0 Step -1 FileName = ListFile.Item(Count).ToString.Trim If My.Computer.FileSystem.GetName(FileName).Length > FileNameLength Then Me.MoveErrorFile(FileName, StationName) Else SR = New StreamReader(FileName, System.Text.Encoding.Default) SR.ReadLine() Dim MyLine As String = SR.ReadLine While Not String.IsNullOrEmpty(MyLine) UpdateRows = 1 Dim Fields() As String = Me.ExcuteFields(MyLine, FieldsLength, StationName) If Fields.Length = 11 Then ' 呼叫 DataTable 对象的 NewRow 方法来建立一个 DataRow 对象 If Fields(0).Trim.Length > 5 Then Dim newRow As DataRow = myDataSet.Tables(TableName).NewRow() newRow("SN") = Fields(0).Trim newRow("ProductType") = Fields(1).Trim newRow("ProductStation") = Fields(2).Trim newRow("WorkerID") = Fields(3).Trim newRow("OrderID") = Fields(4).Trim newRow("PfPre") = Fields(5).Trim newRow("PfNex") = Fields(6).Trim newRow("Result") = Fields(7).Trim newRow("BadReason") = Fields(8).Trim newRow("ProductOrderID") = Fields(9).Trim newRow("ProductDate") = Fields(10).Trim ' 将新数据行新增至数据集内的数据表。 myDataSet.Tables(TableName).Rows.Add(newRow) End If End If MyLine = SR.ReadLine End While SR.Close() End If Next Me.BulkUpdataToServer(ListFile, myConnection, myDataSet, TableName, UpdateRows) Return UpdateRows Catch ex As SqlException SR.Close() Me.MoveErrorFile(FileName, StationName) Return UpdateRows End Try End Function Private Function UpdateFile_ISat(ByVal ListFile As List(Of String), ByVal StationName As String) As Integer Dim UpdateRows As Integer = 0 Dim FieldsLength() As Integer = New Integer() {"10", "30", "15", "15", "10", "10", "30", "10", "30", "30"} Dim FileName As String = String.Empty Dim SR As StreamReader = Nothing Try For Count As Integer = ListFile.Count - 1 To 0 Step -1 FileName = ListFile.Item(Count).ToString.Trim If My.Computer.FileSystem.GetName(FileName).Length > FileNameLength Then Me.MoveErrorFile(FileName, StationName) Else SR = New StreamReader(FileName, System.Text.Encoding.Default) SR.ReadLine() Dim MyLine As String = SR.ReadLine While Not String.IsNullOrEmpty(MyLine) Dim Fields() As String = Me.ExcuteFields(MyLine, FieldsLength, StationName) If Fields.Length = 10 Then UpdateRows = 1 Fields(4) = StrConv(Fields(4), VbStrConv.Narrow) Fields(5) = StrConv(Fields(5), VbStrConv.Narrow) If Fields(7).Length > 10 Then Fields(7) = Fields(7).Substring(Fields(7).Length - 10, 10) End If If Fields(1).Trim.Length > 7 Then Dim SqlInsert As String = "Insert Into RSSI(Result,SN,RSSI1,RSSI2,WorkerID,ApdWorkerID,ProductType,DepartmentID,TestDate,ComputerName) values ('" & Fields(0).Trim & "','" & Fields(1).Trim & "', " & _ "'" & Fields(2).Trim & "','" & Fields(3).Trim & "','" & Fields(4).Trim & "','" & Fields(5).Trim & "','" & Fields(6).Trim & "'," & _ "'" & Fields(7).Trim & "','" & Fields(8).Trim & "','" & Fields(9).Trim & "')" DbNbosa.ExecuteNonQuery(SqlInsert) End If End If MyLine = SR.ReadLine End While SR.Close() End If Next Me.DeleteFile(ListFile) Return UpdateRows Catch ex As SqlException SR.Close() Me.MoveErrorFile(FileName, StationName) Return UpdateRows End Try End Function Private Function UpdateFile_FourDirectTest(ByVal ListFile As List(Of String), ByVal StationName As String) As Integer Dim UpdateRows As Integer = 0 Dim FieldsLength() As Integer = New Integer() {"20", "25", "25", "25", "25", "8", "15", "15", "15", "15", "15", "10", "15", "15", "25", "15", "15"} Dim FileName As String = String.Empty Dim SR As StreamReader = Nothing Try For Count As Integer = ListFile.Count - 1 To 0 Step -1 FileName = ListFile.Item(Count).ToString.Trim If My.Computer.FileSystem.GetName(FileName).Length < 65 Then SR = New StreamReader(ListFile.Item(Count).ToString.Trim, Encoding.Default) SR.ReadLine() Dim MyLine As String = SR.ReadLine While Not String.IsNullOrEmpty(MyLine) UpdateRows = 1 Dim Fields() As String = MyLine.Split(",") If Fields.Length = 15 Then Fields(5) = StrConv(Fields(5), VbStrConv.Narrow) If Fields(0).Trim.Length > 5 Then Dim SqlInsert As String = "Insert Into ForDirection_Test( SN, ProductType, ProductStation, FlowCardId, ProductDate, WorkerId, Tc_Pf, Pf1, Pf2, Pf3, Pf4, Result, DepartmentID, ComputerName, ProductTime, Fields1, Fields2) values " & _ " ('" & Fields(0).Trim & "','" & Fields(1).Trim & "','" & Fields(2).Trim & "','" & Fields(3).Trim & "','" & Fields(4).Trim & "','" & Fields(5).Trim & "','" & Fields(6).Trim & "','" & Fields(7).Trim & "','" & Fields(8).Trim & "','" & _ "" & Fields(9).Trim & "','" & Fields(10).Trim & "','" & Fields(11).Trim & "','" & Fields(12).Trim & "','" & Fields(13).Trim & "','" & Fields(14).Trim & "','NULL','NULL')" DbNbosa.ExecuteNonQuery(SqlInsert) End If End If MyLine = SR.ReadLine End While SR.Close() End If Next Me.DeleteFile(ListFile) Return UpdateRows Catch ex As SqlException SR.Close() Me.MoveErrorFile(FileName, StationName) Return UpdateRows End Try End Function #End Region #Region "UpFile" '把文件从临时文件夹移动到备份文件夹和上传文件夹 Private Sub MoveFileToBackupAndUpLoad(ByVal StationNameList As List(Of String)) Try If My.Computer.FileSystem.DirectoryExists(Me.TempFilePath) = True Then For Each DirectoryName As String In My.Computer.FileSystem.GetDirectories(Me.TempFilePath) Dim StationName As String = Me.GetStationName(DirectoryName) If StationNameList.Contains(StationName) = True Then Dim TheBackupPath As String = Me.BackupFilePath & StationName & "\" Me.ValidateIsDirectoryExists(TheBackupPath) Dim BackupPath As String = TheBackupPath & Now.ToShortDateString & "\" Me.ValidateIsDirectoryExists(BackupPath) Dim UpLoadPath As String = Me.UpFilePath & StationName & "\" Me.ValidateIsDirectoryExists(UpLoadPath) For Each SourceFile As String In My.Computer.FileSystem.GetFiles(DirectoryName & "\") Dim FileName As String = My.Computer.FileSystem.GetName(SourceFile) Dim UpFileNamePath As String = UpLoadPath & FileName Dim BackupFileNamePath As String = BackupPath & FileName My.Computer.FileSystem.CopyFile(SourceFile, UpFileNamePath, True) Threading.Thread.Sleep(10) My.Computer.FileSystem.CopyFile(SourceFile, BackupFileNamePath, True) Threading.Thread.Sleep(10) My.Computer.FileSystem.DeleteFile(SourceFile) Next End If Next End If Catch ex As Exception Me.ExcuteException(ex) End Try End Sub Private Sub UpLocalDataToServer() Try Dim StationList As List(Of String) = DbMes.FillDataToList("Select StationName from Ex_UpFileStation") Me.MoveFileToBackupAndUpLoad(StationList) If My.Computer.FileSystem.DirectoryExists(UpFilePath) = True Then Dim DicUpDataCount As New Dictionary(Of String, Integer) For Each DirectoryName As String In My.Computer.FileSystem.GetDirectories(UpFilePath) Dim StationName As String = Me.GetStationName(DirectoryName) '根据文件夹名称获得站别名称 Dim FileList As List(Of String) = Me.GetFileList(DirectoryName) If StationList.Contains(StationName) Then If DicUpDataCount.ContainsKey(StationName) = False Then DicUpDataCount.Add(StationName, 0) Select Case StationName Case "APD耦光" DicUpDataCount(StationName) = Me.UpdateFile_Apd(FileList, StationName) Case "PD耦光" DicUpDataCount(StationName) = Me.UpdateFile_PdAlign(FileList, StationName) Case "PT耦光" DicUpDataCount(StationName) = Me.UpdateFile_PT(FileList, StationName) Case "PD测试" DicUpDataCount(StationName) = Me.UpdateFile_PdTest(FileList, StationName) Case "ROSA PD测试" DicUpDataCount(StationName) = Me.UpdateFile_RosaPdTest(FileList, StationName) Case "IMD2测试" DicUpDataCount(StationName) = Me.UpdateFile_IMD2(FileList, StationName) Case "IMD3测试" DicUpDataCount(StationName) = Me.UpdateFile_IMD3(FileList, StationName) Case "LD铆压" DicUpDataCount(StationName) = Me.UpdateFile_Ldmy(FileList, StationName) Case "LD耦光" DicUpDataCount(StationName) = Me.UpdateFile_LdAlign(FileList, StationName) Case "LD自动耦光" DicUpDataCount(StationName) = Me.UpdateFile_LdAutoAlign(FileList, StationName) Case "Hammer" DicUpDataCount(StationName) = Me.UpdateFile_Hammer(FileList, StationName) Case "TE测试" DicUpDataCount(StationName) = Me.UpdateFile_TeTest(FileList, StationName) Case "SMSR测试" DicUpDataCount(StationName) = Me.UpdateFile_SmsrTest(FileList, StationName) Case "ISat测试", "IL测试" DicUpDataCount(StationName) = Me.UpdateFile_ISat(FileList, StationName) Case "TC后测试" DicUpDataCount(StationName) = Me.UpdateFile_TestBehindTc(FileList, StationName) Case "四方向测试" DicUpDataCount(StationName) = Me.UpdateFile_FourDirectTest(FileList, StationName) Case Else End Select End If Threading.Thread.Sleep(3000) Next 'Me.ExcuteException(DicUpDataCount) End If Catch ex As Exception Me.ExcuteException(ex) End Try End Sub #End Region #End Region End Class
好例子网口号:伸出你的我的手 — 分享!
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明
网友评论
我要评论