Files
Hanjeon/Epole/입력폼/OldnumPicMan.vb
2019-05-03 21:10:44 +09:00

263 lines
13 KiB
VB.net

Public Class OldnumPicMan
'Public FindDir As String = My.Application.Info.DirectoryPath & "\pic"
Private Sub OldnumPicMan_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated
End Sub
Private Sub OldnumPicMan_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
For Each SC As FarPoint.Win.Spread.Column In Me.MyFpoint1.ActiveSheet.Columns
If Not (SC.DataField = "구관리구" OrElse SC.DataField = "구전산번호" OrElse SC.DataField = "관리구" OrElse SC.DataField = "전주번호") Then
SC.Width = 0
Else
SC.Width = 60
End If
Next
End Sub
Private Sub bt_picselect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_picselect.Click
Dim A As New FolderBrowserDialog
A.RootFolder = Environment.SpecialFolder.MyComputer
A.SelectedPath = Me.lb_picdirectory.Text
If A.ShowDialog() = Windows.Forms.DialogResult.Cancel Then
MsgBox("선택이 취소되었습니다", MsgBoxStyle.Critical, "확인")
Return
End If
Me.lb_picdirectory.Text = A.SelectedPath
End Sub
Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
Me.Compare_OldImage()
End Sub
'Private Sub Addlog_same(ByVal Index As Integer, ByVal memo As String)
' ' Return
' With Me.view_same.ActiveSheet
' .RowCount += 1 '//행증가
' .Cells(.RowCount - 1, 0).Text = Index + 1
' .Cells(.RowCount - 1, 1).Text = memo
' Me.pbar_same.Value += 1
' End With
'End Sub
'Private Sub Addlog_Onot(ByVal Index As Integer)
' ' Return
' With Me.view_onot.ActiveSheet
' .RowCount += 1 '//행증가
' .Cells(.RowCount - 1, 0).Text = Index + 1
' '.Cells(.RowCount - 1, 1).Text = memo
' Me.pbar_onot.Value += 1
' End With
'End Sub
'Private Sub Addlog_nnot(ByVal Index As Integer)
' ' Return
' With Me.view_nnot.ActiveSheet
' .RowCount += 1 '//행증가
' .Cells(.RowCount - 1, 0).Text = Index + 1
' ' .Cells(.RowCount - 1, 1).Text = memo
' Me.pbar_nnot.Value += 1
' End With
'End Sub
Private Sub Addlog_G(ByVal Index As Integer, ByVal filename1 As String, ByVal filename2 As String, ByVal Msg As String)
'//정상변경시
With view_green.ActiveSheet
.RowCount += 1 '//행증가
.Cells(.RowCount - 1, 0).Text = Index + 1
.Cells(.RowCount - 1, 1).Text = filename1
.Cells(.RowCount - 1, 2).Text = filename2
.Cells(.RowCount - 1, 3).Text = Msg
'.Cells(.RowCount - 1, 4).Text = path2
'Me.pbar_modify.Value += 1
End With
End Sub
Private Sub Compare_OldImage()
Dim A As New System.Text.StringBuilder("파일명에 추가된 태그를 입력하세요.")
A.AppendLine()
A.AppendLine("입력될 태그를 파일명의 앞뒤에 붙인후 검색합니다.")
A.AppendLine()
A.AppendLine("입력방법 : 앞에붙일태그/뒤에붙일태그 ")
A.AppendLine()
A.AppendLine("예) 파일명 뒤에 _01 이 붙은것을 검색하고자할때")
A.AppendLine(" /_01 <= 입력하고 엔터")
A.AppendLine()
A.AppendLine("예) 파일명 앞에 P 가 붙은것을 검색하고자할때")
A.AppendLine(" P/ <= 입력하고 엔터")
A.AppendLine()
A.AppendLine("예) 파일명 앞에 P가 붙고 뒤에 _1이 붙은것을 검색하고자할때")
A.AppendLine(" p/_01 <= 입력하고 엔터")
Dim Itag As String = InputBox(A.ToString, "태그입력", "/_01")
If Itag = "" Then
MsgBox("태그를 반드시 입력해야합니다" & vbCrLf & "작업이 취소되었습니다", MsgBoxStyle.Critical, "Error")
Return
End If
Dim Stag() As String = Itag.Split("/")
If Stag.GetUpperBound(0) <> 1 Then
MsgBox("잘못된 태그가 입력되었습니다" & vbCrLf & "태그입력형식은 앞,뒤 를 / 로 묶은 형태입니다" & vbCrLf & vbCrLf & "예) P/_01", MsgBoxStyle.Information, "태그입력오류")
Return
End If
Dim StartTime, Endtime As Date
Dim 구관리구, 구전주번호, 파일명, 파일명2, 풀네임, 관리구, 전주번호 As String
Dim Cnt As Integer = 0
Dim IDX As Integer = 0
Me.pbar_total.Minimum = 0
Me.pbar_total.Maximum = Me.MyFpoint1.ActiveSheet.Rows.Count
Me.pbar_total.Value = 0
Me.pbar_modify.Minimum = 0
Me.pbar_modify.Maximum = Me.MyFpoint1.ActiveSheet.Rows.Count
Me.pbar_modify.Value = 0
Me.pbar_onot.Minimum = 0
Me.pbar_onot.Maximum = Me.MyFpoint1.ActiveSheet.Rows.Count
Me.pbar_onot.Value = 0
Me.pbar_nnot.Minimum = 0
Me.pbar_nnot.Maximum = Me.MyFpoint1.ActiveSheet.Rows.Count
Me.pbar_nnot.Value = 0
Me.pbar_same.Minimum = 0
Me.pbar_same.Maximum = Me.MyFpoint1.ActiveSheet.Rows.Count
Me.pbar_same.Value = 0
Me.pbar_nopic.Minimum = 0
Me.pbar_nopic.Maximum = Me.MyFpoint1.ActiveSheet.Rows.Count
Me.pbar_nopic.Value = 0
Me.view_green_Sheet1.RowCount = 0
'Me.view_nnot_Sheet1.RowCount = 0
'Me.view_onot_Sheet1.RowCount = 0
'Me.view_same_Sheet1.RowCount = 0
'//임시결과파일폴더를 생서한다 폴더경로는 그림파일 아래에
Dim 작업폴더 As String = "c:\구그림작업폴더"
Dim 신폴더명 As String = Format(Now, "yyyyMMddhhmmss").ToString
Dim 기존폴더 As String = 작업폴더 & "\" & 신폴더명 & "\변경전파일(원본)"
Dim 신규폴더 As String = 작업폴더 & "\" & 신폴더명 & "\변경된파일"
If Not System.IO.Directory.Exists(작업폴더) Then System.IO.Directory.CreateDirectory(작업폴더)
If Not System.IO.Directory.Exists(작업폴더 & "\" & 신폴더명) Then System.IO.Directory.CreateDirectory(작업폴더 & "\" & 신폴더명)
System.IO.Directory.CreateDirectory(기존폴더)
System.IO.Directory.CreateDirectory(신규폴더)
Dim 대상폴더 As New System.IO.DirectoryInfo(Me.lb_picdirectory.Text)
Dim 검색결과() As System.IO.FileInfo
'/첫번째방법 데이터셋에서 검색을 한다.
StartTime = Now
For Each DR As FarPoint.Win.Spread.Row In Me.MyFpoint1.ActiveSheet.Rows
Me.pbar_total.Value = DR.Index
구관리구 = Me.MyFpoint1.Cells(DR.Index, "구관리구").Text
구전주번호 = Me.MyFpoint1.Cells(DR.Index, "구전산번호").Text
관리구 = Me.MyFpoint1.Cells(DR.Index, "관리구").Text
전주번호 = Me.MyFpoint1.Cells(DR.Index, "전주번호").Text
'파일명 = 구관리구 & 구전주번호
'MsgBox(구관리구 & "/" & 구전주번호)
' MsgBox(관리구 & "/" & 전주번호)
If CStr(구관리구 & 구전주번호) <> "" Then '//관리구 전주번호가 있을경우에만 확인한다.
풀네임 = Me.lb_picdirectory.Text & "\" & Stag(0) & 구관리구 & 구전주번호 & Stag(1) & "." & Me.cmb_picEXT.Text
파일명 = Stag(0) & 구관리구 & 구전주번호 & Stag(1) & "." & Me.cmb_picEXT.Text
If CStr(구관리구 & 구전주번호).Trim = CStr(관리구 & 전주번호).Trim Then
Addlog_G(DR.Index, "", "", "구번호와 신번호가 동일함")
Me.pbar_same.Value += 1
ElseIf CStr(관리구 & 전주번호) <> "" Then
검색결과 = 대상폴더.GetFiles(파일명, IIf(Me.CHK_SUBDIR.Checked, 1, 0))
'Dim fILES() As String = IO.Directory.GetFiles(Me.lb_picdirectory.Text, 관리구 & 전주번호 & Itag & "." & Me.cmb_picEXT.Text, IIf(Me.CHK_SUBDIR.Checked, 1, 0))
If 검색결과.GetUpperBound(0) >= 0 Then '//구관리전산에해당하는 파일은 존재한다.
파일명2 = Me.lb_picdirectory.Text & "\" & Stag(0) & 관리구 & 전주번호 & Stag(1) & "." & Me.cmb_picEXT.Text
If Me.chk_test.Checked Then
검색결과(0).CopyTo(신규폴더 & "\" & Stag(0) & 관리구 & 전주번호 & Stag(1) & "." & Me.cmb_picEXT.Text, True)
검색결과(0).MoveTo(기존폴더 & "\" & 검색결과(0).Name)
End If
Cnt += 1
Addlog_G(DR.Index, 검색결과(0).Name, Stag(0) & 관리구 & 전주번호 & Stag(1) & "." & Me.cmb_picEXT.Text, "완료")
Me.pbar_modify.Value += 1
Else '//구관리전산번호에 해당하는 그림이없으므로 패스
Addlog_G(DR.Index, "", "", "구번호의 그림이 존재하지 않음")
Me.pbar_nopic.Value += 1
'Arin.WLog("##########구전산번호 그림이 없습니다.(" & IDX & ")" & vbCrLf & "구관리전산번호=" & 구관리구 & 구전주번호, "\구관리전산그림변경(신관리전산없음).txt")
End If
Else
Addlog_G(DR.Index, "", "", "신번호 데이터가 없습니다.")
Me.pbar_nnot.Value += 1
'Arin.WLog("##########신관리전산번호가 없습니다.(" & IDX & ")" & vbCrLf & "구관리전산번호=" & 구관리구 & 구전주번호, "\구관리전산그림변경(신관리전산없음).txt")
End If
Else
'//구관리전산번호가 없어서 넘어갓다
Addlog_G(DR.Index, "", "", "구번호 데이터가 없습니다.")
Me.pbar_onot.Value += 1
'Arin.WLog("##########구관리전산번호가 없습니다.(" & IDX & ")", "\구관리전산그림변경(구관리전산없음).txt")
End If
IDX += 1
Next
Endtime = Now
A.Remove(0, A.Length)
A.AppendLine("시작시간=" & StartTime.ToString)
A.AppendLine("종료시간=" & Endtime.ToString)
A.AppendLine()
A.AppendLine("경과시간=" & (Endtime - StartTime).ToString)
A.AppendLine()
A.AppendLine("전체=" & Me.MyFpoint1.ActiveSheet.Rows.Count)
A.AppendLine("정상변경=" & Cnt)
A.AppendLine("변경불가=" & Me.MyFpoint1.ActiveSheet.Rows.Count - Cnt)
'A.AppendLine(My.Application.Info.DirectoryPath & "\log 에서 자세한 로그를 볼 수 있습니다")
MsgBox(A.ToString, MsgBoxStyle.Information, "구그림파일 변경결과")
Process.Start("explorer.exe", 작업폴더 & "\" & 신폴더명)
' Dim aA As New Process
'Process.Start("explorer ", My.Application.Info.DirectoryPath & "\log")
End Sub
Private Sub m_allouuoolStripMenuItempMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles m_allouuoolStripMenuItem.Click
Dim A As New SaveFileDialog
A.Filter = "엑셀워크시트문서(*.XLS)|*.xls"
A.FilterIndex = 0
A.FileName = My.Application.Info.DirectoryPath & "\(구관리전산그림변경)전체목록" & Now.Year.ToString & Now.Month.ToString & Now.Day.ToString
If A.ShowDialog() <> Windows.Forms.DialogResult.OK Then Return
Me.MyFpoint1.SaveExcel(A.FileName, FarPoint.Win.Spread.Model.IncludeHeaders.ColumnHeadersCustomOnly)
My.Computer.Audio.Play(My.Application.Info.DirectoryPath & "\sound\notify.wav", AudioPlayMode.Background)
End Sub
Private Sub m_outallMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles m_outall.Click
Dim A As New SaveFileDialog
A.Filter = "엑셀워크시트문서(*.XLS)|*.xls"
A.FilterIndex = 0
A.FileName = My.Application.Info.DirectoryPath & "\(구관리전산그림변경-모든목록)실행결과"
If A.ShowDialog() <> Windows.Forms.DialogResult.OK Then Return
Me.view_green.SaveExcel(A.FileName, FarPoint.Win.Spread.Model.IncludeHeaders.ColumnHeadersCustomOnly)
My.Computer.Audio.Play(My.Application.Info.DirectoryPath & "\sound\notify.wav", AudioPlayMode.Background)
End Sub
Private Sub m_outcnuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles m_outc.Click
Dim A As New SaveFileDialog
A.Filter = "엑셀워크시트문서(*.XLS)|*.xls"
A.FilterIndex = 0
A.FileName = My.Application.Info.DirectoryPath & "\(구관리전산그림변경-현재목록)실행결과"
If A.ShowDialog() <> Windows.Forms.DialogResult.OK Then Return
Me.view_green.SaveExcel(A.FileName, FarPoint.Excel.ExcelSaveFlags.SaveAsFiltered)
My.Computer.Audio.Play(My.Application.Info.DirectoryPath & "\sound\notify.wav", AudioPlayMode.Background)
End Sub
Private Sub ToolStripButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton2.Click
Me.Close()
End Sub
End Class