Skip to content

Commit

Permalink
added: option to specify log file name pattern
Browse files Browse the repository at this point in the history
added: an option to check updates on start
  • Loading branch information
ozok committed Jan 7, 2016
1 parent f48954c commit 977e21a
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 80 deletions.
59 changes: 29 additions & 30 deletions Interface/UnitEmailConfig.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ object EmailConfForm: TEmailConfForm
object TabSheet3: TTabSheet
Caption = 'General'
ImageIndex = 2
object CheckUpdateBtn: TCheckBox
Left = 20
Top = 3
Width = 165
Height = 17
Caption = 'Check updates on start up'
Checked = True
State = cbChecked
TabOrder = 0
end
end
object TabSheet2: TTabSheet
Caption = 'Logs'
Expand All @@ -42,14 +52,23 @@ object EmailConfForm: TEmailConfForm
Height = 13
Caption = 'Log file name format:'
end
object ComboBox1: TComboBox
object LogFilePatterList: TComboBox
Left = 128
Top = 3
Width = 236
Height = 21
Style = csDropDownList
Anchors = [akLeft, akTop, akRight]
ItemIndex = 0
TabOrder = 0
Text = 'ComboBox1'
Text = 'YYYYMMDDHHMMSS'
Items.Strings = (
'YYYYMMDDHHMMSS'
'YYYY-MM-DD-HH-MM-SS'
'MMDDYYYYHHMMSS'
'MM-DD-YYYY-HH-MM-SS'
'DDMMYYYYHHMMSS'
'DD-MM-YYYY-HH-MM-SS')
end
end
object TabSheet1: TTabSheet
Expand Down Expand Up @@ -120,16 +139,6 @@ object EmailConfForm: TEmailConfForm
Font.Style = [fsBold, fsUnderline]
ParentFont = False
end
object CancelBtn: TButton
Left = 203
Top = 248
Width = 75
Height = 25
Anchors = [akRight, akBottom]
Caption = 'Cancel'
TabOrder = 0
OnClick = CancelBtnClick
end
object FromEdit: TEdit
Left = 64
Top = 8
Expand All @@ -142,7 +151,7 @@ object EmailConfForm: TEmailConfForm
Font.Name = 'Tahoma'
Font.Style = []
ParentFont = False
TabOrder = 1
TabOrder = 0
end
object HostEdit: TEdit
Left = 64
Expand All @@ -156,7 +165,7 @@ object EmailConfForm: TEmailConfForm
Font.Name = 'Tahoma'
Font.Style = []
ParentFont = False
TabOrder = 2
TabOrder = 1
end
object PassEdit: TEdit
Left = 64
Expand All @@ -171,7 +180,7 @@ object EmailConfForm: TEmailConfForm
Font.Style = []
ParentFont = False
PasswordChar = '*'
TabOrder = 3
TabOrder = 2
end
object PortEdit: TJvSpinEdit
Left = 64
Expand All @@ -181,7 +190,7 @@ object EmailConfForm: TEmailConfForm
CheckMinValue = True
ButtonKind = bkClassic
Value = 25.000000000000000000
TabOrder = 4
TabOrder = 3
end
object ReportTypeList: TComboBox
Left = 64
Expand All @@ -190,31 +199,21 @@ object EmailConfForm: TEmailConfForm
Height = 21
Style = csDropDownList
ItemIndex = 2
TabOrder = 5
TabOrder = 4
Text = 'HTML Zipped Attachment'
Items.Strings = (
'CSV Zipped Attachment'
'HTML EMail Body'
'HTML Zipped Attachment')
end
object SaveBtn: TButton
Left = 286
Top = 248
Width = 75
Height = 25
Anchors = [akRight, akBottom]
Caption = 'Save'
TabOrder = 6
OnClick = SaveBtnClick
end
object SendTestBtn: TButton
Left = 3
Top = 248
Width = 97
Height = 25
Anchors = [akLeft, akBottom]
Caption = 'Send Test Mail'
TabOrder = 7
TabOrder = 5
OnClick = SendTestBtnClick
end
object ToEdit: TEdit
Expand All @@ -229,7 +228,7 @@ object EmailConfForm: TEmailConfForm
Font.Name = 'Tahoma'
Font.Style = []
ParentFont = False
TabOrder = 8
TabOrder = 6
end
object UserNameEdit: TEdit
Left = 64
Expand All @@ -243,7 +242,7 @@ object EmailConfForm: TEmailConfForm
Font.Name = 'Tahoma'
Font.Style = []
ParentFont = False
TabOrder = 9
TabOrder = 7
end
end
end
Expand Down
50 changes: 23 additions & 27 deletions Interface/UnitEmailConfig.pas
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ TEmailConfForm = class(TForm)
UserNameEdit: TEdit;
PassEdit: TEdit;
sLabel1: TLabel;
SaveBtn: TButton;
CancelBtn: TButton;
SendTestBtn: TButton;
IdMessage1: TIdMessage;
IdSMTP1: TIdSMTP;
Expand All @@ -57,10 +55,10 @@ TEmailConfForm = class(TForm)
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
TabSheet3: TTabSheet;
ComboBox1: TComboBox;
LogFilePatterList: TComboBox;
Label8: TLabel;
CheckUpdateBtn: TCheckBox;
procedure CancelBtnClick(Sender: TObject);
procedure SaveBtnClick(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure SendTestBtnClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
Expand Down Expand Up @@ -88,52 +86,50 @@ procedure TEmailConfForm.CancelBtnClick(Sender: TObject);
end;

procedure TEmailConfForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
MainForm.Enabled := True;
MainForm.BringToFront;
end;

procedure TEmailConfForm.FormCreate(Sender: TObject);
var
LEmailSetFile: TIniFile;
begin
LEmailSetFile := TIniFile.Create(MainForm.AppDataFolder + '\email.ini');
try
with LEmailSetFile do
begin
FromEdit.Text := ReadString('EMail', 'From', '');
ToEdit.Text := ReadString('Email', 'To', '');
HostEdit.Text := ReadString('Email', 'Host', '');
PortEdit.Text := ReadString('Email', 'Port', '25');
UserNameEdit.Text := ReadString('Email', 'User', '');
PassEdit.Text := ReadString('Email', 'Pass', '');
ReportTypeList.ItemIndex := ReadInteger('Email', 'ReportType', 2);
WriteString('EMail', 'From', FromEdit.Text);
WriteString('Email', 'To', ToEdit.Text);
WriteString('Email', 'Host', HostEdit.Text);
WriteString('Email', 'Port', PortEdit.Text);
WriteString('Email', 'User', UserNameEdit.Text);
WriteString('Email', 'Pass', PassEdit.Text);
WriteInteger('Email', 'ReportType', ReportTypeList.ItemIndex);
WriteBool('general', 'update', CheckUpdateBtn.Checked);
end;
finally
LEmailSetFile.Free;
end;

MainForm.Enabled := True;
MainForm.BringToFront;
end;

procedure TEmailConfForm.SaveBtnClick(Sender: TObject);
procedure TEmailConfForm.FormCreate(Sender: TObject);
var
LEmailSetFile: TIniFile;
begin
LEmailSetFile := TIniFile.Create(MainForm.AppDataFolder + '\email.ini');
LEmailSetFile := TIniFile.Create(MainForm.AppDataFolder + '\settings.ini');
try
with LEmailSetFile do
begin
WriteString('EMail', 'From', FromEdit.Text);
WriteString('Email', 'To', ToEdit.Text);
WriteString('Email', 'Host', HostEdit.Text);
WriteString('Email', 'Port', PortEdit.Text);
WriteString('Email', 'User', UserNameEdit.Text);
WriteString('Email', 'Pass', PassEdit.Text);
WriteInteger('Email', 'ReportType', ReportTypeList.ItemIndex);
FromEdit.Text := ReadString('EMail', 'From', '');
ToEdit.Text := ReadString('Email', 'To', '');
HostEdit.Text := ReadString('Email', 'Host', '');
PortEdit.Text := ReadString('Email', 'Port', '25');
UserNameEdit.Text := ReadString('Email', 'User', '');
PassEdit.Text := ReadString('Email', 'Pass', '');
ReportTypeList.ItemIndex := ReadInteger('Email', 'ReportType', 2);
CheckUpdateBtn.Checked := ReadBool('general', 'update', true);
end;
finally
LEmailSetFile.Free;
end;
Close;
end;

procedure TEmailConfForm.SendTestBtnClick(Sender: TObject);
Expand Down
21 changes: 10 additions & 11 deletions Interface/UnitMainForm.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ object MainForm: TMainForm
Top = 60
Width = 1008
Height = 515
ActivePage = TabSheet4
ActivePage = TabSheet5
Align = alClient
MultiLine = True
Style = tsFlatButtons
Expand Down Expand Up @@ -106,7 +106,7 @@ object MainForm: TMainForm
Caption = 'TabSheet4'
object Bevel4: TBevel
Left = 0
Top = 451
Top = 461
Width = 1000
Height = 3
Align = alBottom
Expand All @@ -117,7 +117,7 @@ object MainForm: TMainForm
Left = 0
Top = 0
Width = 1000
Height = 351
Height = 361
Align = alClient
BorderStyle = bsNone
Columns = <
Expand Down Expand Up @@ -168,7 +168,7 @@ object MainForm: TMainForm
end
object BottomPanel: TPanel
Left = 0
Top = 351
Top = 361
Width = 1000
Height = 100
Align = alBottom
Expand All @@ -193,7 +193,6 @@ object MainForm: TMainForm
AutoSize = True
BevelOuter = bvNone
TabOrder = 0
ExplicitWidth = 895
object ChangesLabel: TLabel
AlignWithMargins = True
Left = 3
Expand Down Expand Up @@ -322,9 +321,9 @@ object MainForm: TMainForm
end
object ProgressPanel: TPanel
Left = 0
Top = 454
Top = 464
Width = 1000
Height = 30
Height = 20
Align = alBottom
BevelOuter = bvNone
Caption = 'ProgressPanel'
Expand All @@ -333,7 +332,7 @@ object MainForm: TMainForm
Left = 80
Top = 0
Width = 920
Height = 30
Height = 20
Align = alClient
BackColor = clBtnFace
BorderStyle = bsNone
Expand All @@ -351,7 +350,7 @@ object MainForm: TMainForm
Left = 0
Top = 0
Width = 80
Height = 30
Height = 20
Align = alLeft
Alignment = taCenter
AutoSize = False
Expand All @@ -364,6 +363,7 @@ object MainForm: TMainForm
ParentFont = False
Layout = tlCenter
ExplicitTop = -6
ExplicitHeight = 30
end
end
end
Expand All @@ -390,7 +390,6 @@ object MainForm: TMainForm
Images = ImageList1
List = True
TabOrder = 0
ExplicitWidth = 757
object AddNewProjectBtn: TToolButton
Left = 0
Top = 0
Expand Down Expand Up @@ -678,7 +677,7 @@ object MainForm: TMainForm
Left = 408
Top = 312
Bitmap = {
494C01010D006800C40030003000FFFFFFFF2000FFFFFFFFFFFFFFFF424D3600
494C01010D006800CC0030003000FFFFFFFF2000FFFFFFFFFFFFFFFF424D3600
0000000000003600000028000000C0000000C000000001002000000000000040
0200000000000000000000000000000000000000000000000000000000000000
000000000002000000080000000C0000000C0000000C0000000D0000000D0000
Expand Down
8 changes: 4 additions & 4 deletions Interface/UnitMainForm.pas
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ procedure TMainForm.FormShow(Sender: TObject);
else
begin
CheckUpdate := not CheckIfArgumentExists('/nocheckupdate');
if CheckUpdate then
if CheckUpdate or EmailConfForm.CheckUpdateBtn.Checked then
begin
UpdateThread.Execute(nil);
end;
Expand Down Expand Up @@ -1549,11 +1549,11 @@ procedure TMainForm.OperationThreadRun(Sender: TIdThreadComponent);
// a csv file should always be saved.
case EmailConfForm.ReportTypeList.ItemIndex of
0:
LLogFilePath := AppDataFolder + '\logs\' + FormatDateTime('ddmmyyyyhhnnss', Now) + '.csv';
LLogFilePath := AppDataFolder + '\logs\' + FormatDateTime(EmailConfForm.LogFilePatterList.Text, Now) + '.csv';
1:
LLogFilePath := AppDataFolder + '\logs\' + FormatDateTime('ddmmyyyyhhnnss', Now) + '.html';
LLogFilePath := AppDataFolder + '\logs\' + FormatDateTime(EmailConfForm.LogFilePatterList.Text, Now) + '.html';
2:
LLogFilePath := AppDataFolder + '\logs\' + FormatDateTime('ddmmyyyyhhnnss', Now) + '.html';
LLogFilePath := AppDataFolder + '\logs\' + FormatDateTime(EmailConfForm.LogFilePatterList.Text, Now) + '.html';
end;

if FStop then
Expand Down
Loading

0 comments on commit 977e21a

Please sign in to comment.