Files
Tongsin/Epole/dialogForm/SplashScreen.vb
2019-02-23 23:02:52 +09:00

275 lines
12 KiB
VB.net

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 '//환경파일 불러오기실패시 종료한다.
ReadAuth()
If Command().ToUpper = "ARIN2506" Then
UserInfo.Type = E_AuthType.Dev '//파라미터로 운영자모드 가능하게
End If
My.Settings("ireaConnectionString") = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\DataBase\irea.mdb"
'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 ReadAuth() As Boolean
'//먼저파일에 있는 키를 체크한다.
Dim Key1 As String = ini.Read("main", "key1", "")
Dim key2 As String = ini.Read("main", "key2", "")
Dim KeyCnt As String = ini.Read("main", "keycount", "11" & CStr(11).GetHashCode) '//없으면 최대로한다.
If key2 = "" Then UserInfo.Permission = "A" '//아무것도 없으면 1번메뉴만 실행가능하게한다.
Try
If IsNumeric(KeyCnt.Substring(2)) = False Then
UserInfo.Cnt = 11
UserInfo.Type = E_AuthType.Demo
UserInfo.Permission = "A"
Return False
End If
Catch ex As Exception
UserInfo.Cnt = 11
UserInfo.Type = E_AuthType.Demo
UserInfo.Permission = "A"
Return False
End Try
'//둘다비어있으면 데모상태로한다.
If Key1 = "" AndAlso key2 = "" Then
UserInfo.Type = E_AuthType.Demo
If CStr(11).GetHashCode = KeyCnt.Substring(2) Then '//가져온 카운트랑 10이랑같으면 다썻다는 말이다.
UserInfo.Cnt = 11
Else '//아니라면 아직 무료횟수가 남았다는ㄱ다
Dim Cnt As Integer = KeyCnt.Substring(0, 2) '//02 라고치자
Cnt += 1 '//하나증가해서 기록한다.
ini.Write("main", "keycount", Format(Cnt, "00") & Format(Cnt, "00").GetHashCode)
UserInfo.Cnt = Cnt
End If
Return False
End If
Dim auth As New CEpole.Auth
If Key1.IndexOf("%") = -1 Then Key1 = "0%" & Key1
If Not auth.check_key1(Key1) OrElse Not auth.Check_key2(key2) Then '//키중에 오류가있다면 사용불가로한다.
UserInfo.Cnt = 11
UserInfo.Type = E_AuthType.Demo
UserInfo.Permission = "A"
Return False
End If
'//여기까지왓다면 둘다 정상이란소리다. :
'//IP가 맞는지 확인
Dim Cip() As String = GetFirstIP.Split(".")
Dim Cipsum As Short = 0
Dim IPok As Boolean = False
For Each a As String In Cip
Try
Cipsum += Val(a)
Catch ex As Exception
IPok = True
'//아이피에 문제가잇다 이거는 메일보낸다. 그리고 사용은 가능하게한다.
End Try
Next
'If IPok = False Then
' If Cipsum <> Val(Key1.Split("%")(0)) Then '//인증코드의 아이피의 합과 현재아이피의 합이 틀리다면
' UserInfo.Cnt = 11 '//데모상태로 전환한다.
' UserInfo.Type = E_AuthType.Demo
' UserInfo.Permission = "A"
' Return False
' End If
'End If
'//권한정보셋팅
UserInfo.Permission = key2.Split("%")(0).ToCharArray
Dim k() As String = Key1.Split("%")
'//닐짜비교()
Dim Curdate As Date = Today
Dim UserDate As Date = CDate(k(1).Substring(0, 4) & "-" & k(1).Substring(4, 2) & "-" & k(1).Substring(6, 2))
If curdate > UserDate Then '//지정된날짜가 오늘보다 컷을경우 즉 기간을 오버했다는것이다. 사용불가이다.
UserInfo.Cnt = 11
UserInfo.Type = E_AuthType.Demo
Return False
Else '//정상사용자이다
UserInfo.ExpireDate = UserDate.ToShortDateString
UserInfo.Type = E_AuthType.Normal
Return True
End If
End Function
Private Sub SetAuth(ByVal NewDate As Date)
Dim auth As New ACC.MyAuth
Dim Arinini As New MyINI(My.Application.Info.DirectoryPath & "\epole.ini")
Arinini.Write("main", "install", auth.GetDateNumber(NewDate))
Arinini.Write("main", "installkey", 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"), 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", "install", 0)
Me.installkey = Arinini.Read("main", "installkey", 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 = "데이터베이스확인중..."
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 & "데이터베이스 파일이 손상되었는지 사용중인지 확인하세요", 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