Imports MyControlOLEDBv2 Public NotInheritable Class SplashScreen Dim install, installkey As Long Dim auth As New MyAuth 'Dim Runcnt As Integer = 0 'TODO: 프로젝트 디자이너에서 "프로젝트" 메뉴의 "속성"을 선택하여 표시된 "응용 프로그램" 탭에서 ' 이 폼을 응용 프로그램의 시작 화면으로 쉽게 설정할 수 있습니다. Private Sub SplashScreen1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load '응용 프로그램의 어셈블리 정보에 따라 런타임에 대화 상자 텍스트를 설정합니다. 'TODO: "프로젝트" 메뉴에서 선택하여 표시된 프로젝트 속성 대화 상자의 "응용 프로그램" 창에서 응용 프로그램의 ' 어셈블리 정보를 사용자 지정합니다. '응용 프로그램 제목 My.Settings.Item("ireaConnectionString") = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + My.Application.Info.DirectoryPath & "\database\database.mdb" If Command().ToUpper = "ARIN" Then Admin = True 'MsgBox(My.Settings.ireaConnectionString) 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 '//인증사용안함 191125 - '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 Not LoadReg() Then End If Not Connect() Then End Me.lb_msg.Text = "" ' LoginForm1.MdiParent = Main 'LoginForm1.TopMost = True 'LoginForm1.Show() Frm_Main.Show() Me.Dispose() 'Me.Hide() End Sub Private Function ReadAuthcount() As Integer Dim RunCnt As Integer = 0 Dim ini As New MyINI2(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 MyINI2(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 MyINI2(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"), Boolean) Common.PICmanFile = Arinini.Read("MAIN", "PICMAN") Common.MakeState = Arinini.Read("main", "makestate") Common.PoleState = Arinini.Read("main", "polestate") Common.PoleEtcState = Arinini.Read("main", "poleetcstate") Common.PicState = Arinini.Read("main", "picstate") Common.NUMCOLOR = Arinini.Read("MAIN", "NUMCOLOR", True) SORTNULL = Arinini.Read("MAIN", "SortNull", True) buf = Arinini.Read("main", "viewfont", "굴림,9").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") 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 = "데이터베이스확인중..." If Not System.IO.File.Exists(DataBaseFile) Then Return False Dim Dbpath As String = My.Application.Info.DirectoryPath & "\database" Dim Dbini As New MyINI2(Dbpath & "\patch.ini") ' Return True '//데이터베이스 버젼을 확인한다. Dim Cnn As New OleDbConnection(My.Settings.ireaConnectionString) Try Cnn.Open() Catch ex As Exception MsgBox("데이터베이스를 열수 없습니다", "데이터베이스 손상되었는지 사용중인지 확인하세요", "오류") Return False End Try If Cnn.State <> ConnectionState.Open Then MsgBox("데이터베이스를 열수 없습니다", "데이터베이스 손상되었는지 사용중인지 확인하세요", "오류") Return False End If Dim Dbversion As Short = 0 Dim ErrMsg As String = "" Dim Cmd As New OleDbCommand("select version from dbinfo", Cnn) Try Dbversion = Cmd.ExecuteScalar Catch ex As OleDb.OleDbException Dbversion = 0 ErrMsg = ex.Message.ToString End Try If ErrMsg.IndexOf("dbinfo") >= 0 Then ''//테이블이 없을경우이다. Cmd = New OleDbCommand("create table dbinfo ( version number )", Cnn) Cmd.ExecuteNonQuery() '//테이블생성 Cmd = New OleDbCommand("insert into dbinfo(version) values(0)", Cnn) Cmd.ExecuteNonQuery() Dbversion = 0 End If Cmd = New OleDbCommand("select count(*) from dbinfo", Cnn) Dim RowCnt As Short = Cmd.ExecuteScalar If RowCnt = 0 Then Cmd = New OleDbCommand("insert into dbinfo(version) values(0)", Cnn) 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, Cnn) Try 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, Cnn) Try Cmd.ExecuteNonQuery() Catch ex As Exception ' MsgBox(ex.Message.ToString) End Try Cmd.Dispose() Cnn.Close() Cnn.Dispose() Return True End Function End Class