270 lines
12 KiB
VB.net
270 lines
12 KiB
VB.net
Imports ACC
|
|
|
|
Public NotInheritable Class SplashScreen
|
|
Dim install, installkey As Long
|
|
Dim auth As New ACC.MyAuth
|
|
'Dim Runcnt As Integer = 0
|
|
|
|
Private Sub SplashScreen1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
|
|
If My.Application.Info.Title <> "" Then
|
|
ApplicationTitle.Text = My.Application.Info.Title
|
|
Else
|
|
'응용 프로그램 제목이 없는 경우 확장명 없이 응용 프로그램 이름을 사용합니다.
|
|
ApplicationTitle.Text = System.IO.Path.GetFileNameWithoutExtension(My.Application.Info.AssemblyName)
|
|
End If
|
|
Version.Text = System.String.Format(Version.Text, My.Application.Info.Version.Major, My.Application.Info.Version.Minor, My.Application.Info.Version.Build, My.Application.Info.Version.Revision)
|
|
|
|
'저작권 정보
|
|
Copyright.Text = My.Application.Info.Copyright
|
|
Me.Show() : My.Application.DoEvents()
|
|
|
|
If Not LoadINI() Then End '//환경파일 불러오기실패시 종료한다.
|
|
If Command() <> "ARIN" AndAlso Not ReadAuth() Then '//에러났을떄는 카운터를 확인
|
|
'//사용횟수가 10번ㅇ르 초과했는지 확인
|
|
Runcnt = Me.ReadAuthcount
|
|
Dim f As New fAuth()
|
|
If (f.ShowDialog <> Windows.Forms.DialogResult.OK) Then
|
|
End
|
|
End If
|
|
'If Runcnt >= 10 Then
|
|
' Dim NewKey As String = InputBox("인증번호를 입력하세요 (인증번호는 숫자로만 이루어져 있습니다)")
|
|
' If IsNumeric(NewKey) = False Then
|
|
' MsgBox("프로그램을 재실행 하세요", MsgBoxStyle.Information, "확인")
|
|
' End
|
|
' End If
|
|
' auth.SetAuth(NewKey, My.Application.Info.DirectoryPath & "\epole.ini")
|
|
' MsgBox("프로그램을 재실행 하세요", MsgBoxStyle.Information, "확인")
|
|
' End
|
|
'Else
|
|
' MsgBox(CStr(10 - Runcnt) & "번의 사용횟수가 남았습니다", MsgBoxStyle.Critical, "실행확인")
|
|
'End If
|
|
End If
|
|
|
|
'If Command().ToUpper = "ARIN2506" Then
|
|
' UserInfo.Type = E_AuthType.Admin '//파라미터로 운영자모드 가능하게
|
|
'End If
|
|
|
|
|
|
'If Not ReadAuth() Then DemoDlg.ShowDialog()
|
|
If Not LoadReg() Then End '//레지스트리정보 실패시 종료
|
|
If Not Connect() Then End '//연결정보 실패시 종료
|
|
Me.lb_msg.Text = ""
|
|
|
|
MakeList.Show()
|
|
Me.Dispose()
|
|
End Sub
|
|
Private Function ReadAuthcount() As Integer
|
|
Dim RunCnt As Integer = 0
|
|
Dim ini As New MyINI(My.Application.Info.DirectoryPath & "\epole.ini")
|
|
Dim RegDate As String = ini.Read("main", "regdate2", "")
|
|
Dim CurDate As String = Me.auth.GetDateNumberEnc(Today.AddDays(-10))
|
|
If RegDate = "" Then '//등록일이없으면 10번카운터를 셋팅한다.
|
|
RunCnt = 1
|
|
ini.Write("main", "reg2", RunCnt) '//1일로한다.
|
|
ini.Write("main", "regdate2", Me.auth.GetDateNumberEnc(Today)) '//1일로한다.
|
|
Else
|
|
'//상요자가 숫자를 임의로 고칠수있으니 설치된 날짜랑 오늘이랑 10일이상차이나면 횟수에상관없이 사용불가로한다.
|
|
If CurDate > RegDate Then
|
|
MsgBox("프로그램을 사용할 수 없습니다" & vbCrLf & "배포업체에 문의하세요", MsgBoxStyle.Information, "확인")
|
|
Return 10
|
|
End If
|
|
RunCnt = ini.Read("main", "reg2", 10) '//없으면 10으로한다 즉 사용못하게하겠다는거다
|
|
If RunCnt < 10 Then
|
|
RunCnt += 1
|
|
ini.Write("main", "reg2", RunCnt) '//1일로한다.
|
|
End If
|
|
End If
|
|
If RunCnt >= 10 Then Return 10
|
|
Return RunCnt
|
|
End Function
|
|
|
|
Private Function ReadAuth() As Boolean
|
|
If install = 0 OrElse installkey = 0 Then
|
|
' MsgBox("인증정보가 존재하지 않습니다." & vbCrLf & vbCrLf & "홈페이지 [자료실] 에서 인증번호를 확인하세요" & vbCrLf & "062-382-0411" & vbCrLf & Common.HomePage, MsgBoxStyle.Critical, "확인")
|
|
'Process.Start(HomePage)
|
|
Return False
|
|
End If
|
|
|
|
Dim 현재날짜값 As Long = auth.GetDateNumber(Now)
|
|
|
|
If 현재날짜값 > install Then
|
|
' MsgBox("사용기간이 초과되었습니다." & vbCrLf & vbCrLf & "홈페이지 [자료실] 에서 인증번호를 확인하세요" & vbCrLf & "062-382-0411" & vbCrLf & Common.HomePage, MsgBoxStyle.Critical, "확인")
|
|
'Process.Start(HomePage)
|
|
Return False '//만기일을 초과했다면
|
|
End If
|
|
|
|
'Dim FI As New System.IO.FileInfo(My.Application.Info.DirectoryPath & "\epole.ini")
|
|
'If (auth.GetDateNumber(FI.LastAccessTimeUtc)) > Now.ToFileTimeUtc Then '//설정파일을 접근한 날짜가 오늘보다 크면 즉 오늘이 조작디었을경우다
|
|
' ' MsgBox("사용기간이 초과되었습니다." & vbCrLf & vbCrLf & "홈페이지 [자료실] 에서 인증번호를 확인하세요" & vbCrLf & "062-382-0411" & vbCrLf & Common.HomePage, MsgBoxStyle.Critical, "확인")
|
|
' 'Process.Start(HomePage)
|
|
' Return False '//만기일을 초과했다면
|
|
'End If
|
|
|
|
Dim 해쉬값 As Integer = install.GetHashCode()
|
|
If installkey.ToString <> 해쉬값 Then '//인증정보가 손상되었다면
|
|
' MsgBox("인증정보가 손상되었습니다" & vbCrLf & vbCrLf & "홈페이지 [자료실] 에서 인증번호를 확인하세요" & vbCrLf & "062-382-0411" & vbCrLf & Common.HomePage, MsgBoxStyle.Critical, "확인")
|
|
'Process.Start(HomePage)
|
|
Return False
|
|
End If
|
|
|
|
Rundate = Date.FromFileTimeUtc(install)
|
|
|
|
Return True
|
|
' MsgBox(auth.GetDateNumberEnc(Now))
|
|
End Function
|
|
|
|
Private Sub SetAuth(ByVal NewDate As Date)
|
|
Dim auth As New MyAuth
|
|
Dim Arinini As New MyINI(My.Application.Info.DirectoryPath & "\epole.ini")
|
|
Arinini.Write("main", "install2", auth.GetDateNumber(NewDate))
|
|
Arinini.Write("main", "installkey2", auth.GetDateNumberEnc(NewDate))
|
|
|
|
MsgBox("기록완료")
|
|
End Sub
|
|
|
|
|
|
|
|
Private Function LoadINI() As Boolean
|
|
|
|
Me.lb_msg.Text = "환경설정 데이터를 읽어옵니다"
|
|
Dim Arinini As New MyINI(My.Application.Info.DirectoryPath & "\epole.ini")
|
|
Dim buf() As String
|
|
|
|
If Not Arinini.Exist Then
|
|
MsgBox("환경설정파일 EPOLE.INI 가 존재하지 않습니다" & vbCrLf & "[시작-설정-프로그램설정]을 다시 실행해주세요", MsgBoxStyle.Information, "환경설정오류")
|
|
Arinini.Create()
|
|
Return True
|
|
End If
|
|
Try
|
|
Auto_Log = CType(Arinini.Read("MAIN", "log", "false"), Boolean)
|
|
Common.PICmanFile = Arinini.Read("MAIN", "PICMAN", "")
|
|
Common.MakeState = Arinini.Read("main", "makestate", "max")
|
|
Common.PoleState = Arinini.Read("main", "polestate", "max")
|
|
Common.PoleEtcState = Arinini.Read("main", "poleetcstate", "max")
|
|
Common.PicState = Arinini.Read("main", "picstate", "nor")
|
|
Common.NUMCOLOR = Arinini.Read("MAIN", "NUMCOLOR", True)
|
|
SORTNULL = Arinini.Read("MAIN", "SortNull", True)
|
|
buf = Arinini.Read("main", "viewfont", "굴림,11.25").Split(",")
|
|
Common.ViewFont.FontName = buf(0)
|
|
Common.ViewFont.FontSize = buf(1)
|
|
|
|
Me.install = Arinini.Read("main", "install2", 0)
|
|
Me.installkey = Arinini.Read("main", "installkey2", 0)
|
|
|
|
buf = Arinini.Read("main", "menufont", "굴림,9").Split(",")
|
|
Common.MenuFont.FontName = buf(0)
|
|
Common.MenuFont.FontSize = buf(1)
|
|
|
|
buf = Arinini.Read("main", "formfont", "굴림,11").Split(",")
|
|
Common.FormFont.FontName = buf(0)
|
|
Common.FormFont.FontSize = buf(1)
|
|
|
|
Common.HelpWebSite = Arinini.Read("main", "helpweb")
|
|
Common.HomePage = Arinini.Read("main", "homepage", "http://haegwang.co.kr")
|
|
Catch ex As Exception
|
|
MsgBox("환경설정 파일을 불러올수 없습니다" & vbCrLf & vbCrLf & "오류메세지=" & ex.Message.ToString _
|
|
& vbCrLf & "[시작-설정-프로그램설정]을 다시 실행해주세요", MsgBoxStyle.Critical, "오류")
|
|
End Try
|
|
Return True
|
|
End Function
|
|
Private Function LoadReg() As Boolean
|
|
Me.lb_msg.Text = "레지스트리 데이터를 읽어옵니다"
|
|
Me.Invalidate()
|
|
Try
|
|
|
|
Catch ex As Exception
|
|
MsgBox("레지스트리를 확인할 수 없습니다", MsgBoxStyle.Critical, "오류")
|
|
End Try
|
|
Return True
|
|
End Function
|
|
|
|
Private Function Connect() As Boolean
|
|
Me.lb_msg.Text = "데이터베이스확인중..."
|
|
Dim Dbpath As String = My.Application.Info.DirectoryPath & "\database"
|
|
If Not System.IO.File.Exists(DataBaseFile) Then Return False
|
|
Dim Dbini As New MyINI(Dbpath & "\patch.ini")
|
|
|
|
' Return True
|
|
|
|
'//데이터베이스 버젼을 확인한다.
|
|
Dim Cn As New OleDbConnection(My.Settings.ireaConnectionString)
|
|
Try
|
|
Cn.Open()
|
|
Catch ex As Exception
|
|
MsgBox("데이터베이스를 열수 없습니다" & vbCrLf & "데이터베이스 파일이 손상되었는지 사용중인지 확인하세요₩n" + ex.Message, MsgBoxStyle.Critical, "오류")
|
|
Return False
|
|
End Try
|
|
If Cn.State <> ConnectionState.Open Then
|
|
MsgBox("데이터베이스를 열수 없습니다" & vbCrLf & "데이터베이스 파일이 손상되었는지 사용중인지 확인하세요", MsgBoxStyle.Critical, "오류")
|
|
Return False
|
|
End If
|
|
|
|
Dim Dbversion As Short = 0
|
|
Dim ErrMsg As String = ""
|
|
|
|
Dim Cmd As New OleDbCommand("select version from dbinfo", Cn)
|
|
Try
|
|
Dbversion = ADBC.DbBase.NVL(Cmd.ExecuteScalar, 0)
|
|
Catch ex As OleDb.OleDbException
|
|
ErrMsg = ex.Message.ToString
|
|
End Try
|
|
|
|
If ErrMsg.IndexOf("dbinfo") >= 0 Then ''//테이블이 없을경우이다.
|
|
Cmd = New OleDbCommand("create table dbinfo ( version number )", Cn)
|
|
Cmd.ExecuteNonQuery() '//테이블생성
|
|
Cmd = New OleDbCommand("insert into dbinfo(version) values(0)", Cn)
|
|
Cmd.ExecuteNonQuery()
|
|
Dbversion = 0
|
|
End If
|
|
|
|
Cmd = New OleDbCommand("select count(*) from dbinfo", Cn)
|
|
Dim RowCnt As Short = Cmd.ExecuteScalar
|
|
If RowCnt = 0 Then
|
|
Cmd = New OleDbCommand("insert into dbinfo(version) values(0)", Cn)
|
|
Cmd.ExecuteNonQuery()
|
|
End If
|
|
|
|
If Dbini.Exist = False Then
|
|
MsgBox("데이터베이스 업데이트 파일이 없습니다")
|
|
Return True
|
|
End If
|
|
Me.lb_msg.Text = "데이터베이스 업그레이드"
|
|
|
|
Dim MaxVersion As Short = Dbini.Read("db", "version", "0")
|
|
For i As Short = Dbversion + 1 To MaxVersion '//순서대로 쿼리를 실행한다.
|
|
'//파일을 불러와서 파일의 내용을 ; 만날때마다 실행한다.
|
|
If System.IO.File.Exists(Dbpath & "\version" & i & ".sql") Then
|
|
Dim Fs As New System.IO.FileStream(Dbpath & "\version" & i & ".sql", IO.FileMode.Open)
|
|
Dim SR As New System.IO.StreamReader(Fs, System.Text.Encoding.Default)
|
|
Dim Str As String = SR.ReadToEnd
|
|
For Each Sql As String In Str.Split(";")
|
|
If Sql.Trim <> "" Then
|
|
Cmd = New OleDbCommand(Sql, Cn)
|
|
Try
|
|
'MsgBox("다음쿼리를 실행합니다" & Sql.Trim)
|
|
Cmd.ExecuteNonQuery() '//테이블생성
|
|
Catch ex As Exception
|
|
'//이부분은 나중에 메일로 보내도록한다.
|
|
'MsgBox("데이터베이스 업그레이드오류 버젼=" & i & vbCrLf & ex.Message.ToString & vbCrLf & Sql, MsgBoxStyle.Critical, "확인")
|
|
End Try
|
|
End If
|
|
Next
|
|
End If
|
|
Next
|
|
|
|
Cmd = New OleDbCommand("update dbinfo set version=" & MaxVersion, Cn)
|
|
Try
|
|
Cmd.ExecuteNonQuery()
|
|
Catch ex As Exception
|
|
MsgBox(ex.Message.ToString)
|
|
End Try
|
|
|
|
Cmd.Dispose()
|
|
Cn.Close()
|
|
Cn.Dispose()
|
|
Return True
|
|
|
|
|
|
End Function
|
|
End Class
|