- PR -

のむごんですののむのむ

1
投稿者投稿内容
のむごん12号
会議室デビュー日: 2009/02/24
投稿数: 2
投稿日時: 2009-02-24 22:55
Imports System.Threading
Imports System.IO
Imports System.Xml

Public Class Form1
Inherits System.Windows.Forms.Form
Public cal_list As ArrayList
Public sch_list As ArrayList

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
DataGridView1.RowTemplate.Height = 15

Dim cal_list_w As New ArrayList
cal_list = cal_list_w
Dim sch_list_w As New ArrayList
sch_list = sch_list_w

Me.Text = "AutoJobControl"
Me.ControlBox = Not Me.ControlBox
Me.NotifyIcon1.Visible = True
Me.Visible = False
file_check.set_DataGrid(DataGridView1)
file_check.Log_DataGrid_add("通知", "AutoJobControlを起動しました")

'System.Threading.Thread.Sleep(30000)
Timer2_start()

If My.Settings.S_LOGOUT_FLAG = True Then
CheckBox1.Checked = True
End If

If System.IO.File.Exists(My.Settings.S_LOG_PATH) Or My.Settings.S_LOG_PATH = "" Then
TextBox1.Text = My.Settings.S_LOG_PATH
Else
Try
Dim sw As New System.IO.StreamWriter(My.Settings.S_LOG_PATH, False, System.Text.Encoding.GetEncoding(932))
sw.Close()
Catch ex As Exception
file_check.Log_DataGrid_add("異常", "ログ出力ファイルが作成できませんでした")
End Try
End If

If System.IO.File.Exists("./ini.xml") Then

Else
file_check.Log_DataGrid_add("警告", "スケジュール設定ファイルが存在しません")
End If

End Sub
'##########常駐##########
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
If e.CloseReason = CloseReason.UserClosing Then
e.Cancel = True
zyoutyu()
End If
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
zyoutyu()
End Sub
Private Sub zyoutyu()
Me.Visible = False
Me.NotifyIcon1.Visible = True
Me.NotifyIcon1.ShowBalloonTip(500)
End Sub
'##########標準画面##########
Private Sub NotifyIcon1_MouseDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles NotifyIcon1.MouseDoubleClick
normalview()
End Sub
Private Sub 基本メニュ表示ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 基本メニュ表示ToolStripMenuItem.Click
normalview()
End Sub
Private Sub normalview()
Me.Visible = True
Me.WindowState = System.Windows.Forms.FormWindowState.Normal
Me.NotifyIcon1.Visible = False
Me.Activate()
End Sub
'##########最小化##########
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.WindowState = FormWindowState.Minimized
End Sub
'##########終了##########
Private Sub プログラム終了ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles プログラム終了ToolStripMenuItem.Click
endview()
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Dim f As Dialog1 = New Dialog1()
Dim exit_flag As Boolean
If (f.ShowDialog(Me) = DialogResult.OK) Then
exit_flag = True
End If
f.Dispose()
If exit_flag = True Then
endview()
End If
End Sub
Private Sub endview()
save_set()
Me.NotifyIcon1.Visible = False
Application.Exit()
End Sub
Private Sub save_set()
My.Settings.S_LOG_PATH = TextBox1.Text
My.Settings.Save()
End Sub
'##########ログ保存先##########
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim sfd As New SaveFileDialog()
sfd.FileName = "TimerLog.log"
sfd.InitialDirectory = "C:\"
sfd.Filter = "ログファイル(*.log)|*.log"
sfd.FilterIndex = 1
sfd.Title = "保存先のファイルを選択してください"
sfd.RestoreDirectory = True
sfd.OverwritePrompt = True
sfd.CheckPathExists = True
If sfd.ShowDialog() = DialogResult.OK Then
TextBox1.Text = sfd.FileName
End If
End Sub
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
My.Settings.S_LOGOUT_FLAG = CheckBox1.CheckState
My.Settings.Save()
End Sub
'##########タイマー開始##########
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Button1.Text = "タイマ起動" Then
import_cal()
import_sch()
set_sch()
Timer2_start()
Else
Timer2_end()
End If
End Sub
Private Sub Timer2_start()
Button1.Text = "タイマ停止"
PictureBox1.Visible = True
Timer2.Enabled = True
file_check.Log_DataGrid_add("通知", "AutoJobControl監視開始")
End Sub
Private Sub Timer2_end()
Button1.Text = "タイマ起動"
PictureBox1.Visible = False
Timer2.Enabled = False
file_check.Log_DataGrid_add("通知", "AutoJobControl監視停止")
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Me.Text = "AutoJobControl-" & Now()
End Sub

Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
job_run()
End Sub
Private Sub job_run()
Shell("cmd.exe /c ""C:\work\test.bat""", AppWinStyle.NormalFocus, False)
file_check.Log_DataGrid_add("通知", "N001001起動")
End Sub

'##########JOB追加画面表示##########
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Dim I_Form2 As New Form2
I_Form2.Visible = True
End Sub
'##########設定情報インポート##########
Private Sub import_cal()
cal_list = Nothing
Dim cal_list_w As New ArrayList
cal_list = cal_list_w
Dim I_cal_import As New cal_import
I_cal_import.cal_list_import(cal_list)
End Sub
Private Sub import_sch()
sch_list = Nothing
Dim sch_list_w As New ArrayList
sch_list = sch_list_w
Dim I_xml_import As New xml_import
I_xml_import.xml_list_import(sch_list)
End Sub
'##########スケジューリング##########
Private Sub set_sch()
DataGridView2_del()
DataGridView2_add()
End Sub

'##########スケジューリング結果表示##########
Public Sub DataGridView2_add()
DataGridView2.RowTemplate.Height = 15
For i As Integer = 0 To sch_list.Count - 1
'---create a row---
Dim item As New DataGridViewRow
item.CreateCells(DataGridView1)
With item
.Cells(0).Value = "JOB000" & i
.Cells(1).Value = "日時楽2定義取込処理"
.Cells(2).Value = "ファイル監視"
.Cells(3).Value = "月次-01月24日"
End With
'---add the row---
DataGridView2.Rows.Add(item)
Next

End Sub
Public Sub DataGridView2_del()
Try
For i As Integer = 0 To DataGridView2.RowCount
DataGridView2.Rows.RemoveAt(0)
Next
Catch ex As Exception
End Try
End Sub
Private Sub DataGridView2_CellMouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DataGridView2.CellMouseDoubleClick
'Dim I_Form2 As New Form2
Label1.Text = e.RowIndex

'Try
'I_Form2.Visible = True
'Catch ex As Exception
'End Try
End Sub


End Class



[ メッセージ編集済み 編集者: のむごん12号 編集日時 2009-02-24 23:02 ]
のむごん12号
会議室デビュー日: 2009/02/24
投稿数: 2
投稿日時: 2009-02-24 23:02
Module Module1
Public Class file_check
Private Shared row As Object
Private Shared row_count As Integer
Private Shared log_DataGrid As Object
Private Shared log_col01 As String
Private Shared log_col02 As String
Private Shared log_col03 As String
Private Shared log_col04 As String

Sub New()
log_col01 = "通知"
row_count = 0
End Sub

Sub Main()

End Sub

Shared Sub set_DataGrid(ByVal r_log_DataGrid As Object)
log_DataGrid = r_log_DataGrid
End Sub

Shared Sub Log_DataGrid_add(ByVal log_col01 As String, ByVal log_col04 As String)

If row_count = 30 Then
log_DataGrid.rows.RemoveAt(0)
row_count = row_count - 1
End If

log_col02 = Year(Now) & "/" & Right("00" & Month(Now), 2) & "/" & Right("00" & Month(Now), 2)
log_col03 = Right("00" & Hour(Now), 2) & ":" & Right("00" & Minute(Now), 2) & ":" & Right("00" & Second(Now), 2)
log_DataGrid.Rows.Add(log_col01, _
log_col02, _
log_col03, _
log_col04)
If log_col01 = "異常" Then
log_DataGrid.Rows(row_count).DefaultCellStyle.BackColor = System.Drawing.Color.Pink
ElseIf log_col01 = "警告" Then
log_DataGrid.Rows(row_count).DefaultCellStyle.BackColor = System.Drawing.Color.Yellow
End If

If My.Settings.S_LOGOUT_FLAG = True Then
Log_out()
End If

log_DataGrid.CurrentCell = log_DataGrid(0, log_DataGrid.RowCount - 1)
row_count = row_count + 1
End Sub
Shared Sub Log_out()

End Sub
End Class
End Module
1

スキルアップ/キャリアアップ(JOB@IT)