| 2263 |
kivins |
1 |
//---------------------------------------------------------------------------
|
|
|
2 |
|
|
|
3 |
#include <vcl.h>
|
|
|
4 |
#include <FileCtrl.hpp>
|
|
|
5 |
#pragma hdrstop
|
|
|
6 |
|
|
|
7 |
#include "UdTransfer.h"
|
|
|
8 |
#include "UdTransferManager.h"
|
|
|
9 |
|
|
|
10 |
namespace
|
|
|
11 |
{
|
|
|
12 |
const char * REG_BASE_KEY = "\\Software\\ERG\\TxnTestManager\\UD Transfer";
|
|
|
13 |
const char * REG_DURATION_TYPE = "DurationType";
|
|
|
14 |
const char * REG_DURATION = "Duration";
|
|
|
15 |
const char * REG_FREQUENCY_TYPE = "FrequencyType";
|
|
|
16 |
const char * REG_FREQUENCY = "Frequency";
|
|
|
17 |
const char * REG_RECURRING = "Recurring";
|
|
|
18 |
const char * REG_RAMP_TEST_TYPE = "RampTestType";
|
|
|
19 |
const char * REG_RAMP_GRADIENT = "RampGradient";
|
|
|
20 |
const char * REG_SOURCE_PATH = "SourcePath";
|
|
|
21 |
const char * REG_DESTINATION = "Destination";
|
|
|
22 |
|
|
|
23 |
const char * REG_RENAME = "RenameSentFiles";
|
|
|
24 |
const char * REG_IGNORESENT = "IgnoreSentFiles";
|
|
|
25 |
const char * REG_MAXDEVICES = "MaxDeviceSimulators";
|
|
|
26 |
const char * REG_DEVICEID = "StartingDeviceId";
|
|
|
27 |
const char * REG_DEVICETYPE = "DeviceType";
|
|
|
28 |
const char * REG_CONNECTTIMEOUT = "DeviceConnectTimeout";
|
|
|
29 |
|
|
|
30 |
const char * SENT_STRING = "sent_";
|
|
|
31 |
|
|
|
32 |
static int MAX_DEVICES = 400;
|
|
|
33 |
|
|
|
34 |
static Variant vInteger(1);
|
|
|
35 |
static Variant vDouble(double(1));
|
|
|
36 |
static Variant vString(AnsiString("1"));
|
|
|
37 |
}
|
|
|
38 |
|
|
|
39 |
//---------------------------------------------------------------------------
|
|
|
40 |
#pragma package(smart_init)
|
|
|
41 |
#pragma link "AdvDirectoryEdit"
|
|
|
42 |
#pragma link "AdvEdBtn"
|
|
|
43 |
#pragma link "AdvEdit"
|
|
|
44 |
#pragma link "AdvPageControl"
|
|
|
45 |
#pragma resource "*.dfm"
|
|
|
46 |
TUdTransferForm *UdTransferForm;
|
|
|
47 |
//---------------------------------------------------------------------------
|
|
|
48 |
__fastcall TUdTransferForm::TUdTransferForm(TComponent* Owner)
|
|
|
49 |
: TForm(Owner), m_Registry(NULL), m_manager(NULL)
|
|
|
50 |
{
|
|
|
51 |
m_Registry = new TRegistry;
|
|
|
52 |
m_Registry->RootKey = HKEY_CURRENT_USER;
|
|
|
53 |
if (! m_Registry->OpenKey(REG_BASE_KEY, true) )
|
|
|
54 |
{
|
|
|
55 |
m_Registry->CloseKey();
|
|
|
56 |
delete m_Registry;
|
|
|
57 |
m_Registry = NULL;
|
|
|
58 |
}
|
|
|
59 |
}
|
|
|
60 |
//---------------------------------------------------------------------------
|
|
|
61 |
|
|
|
62 |
__fastcall TUdTransferForm::~TUdTransferForm()
|
|
|
63 |
{
|
|
|
64 |
if( m_Registry != NULL ) m_Registry->CloseKey();
|
|
|
65 |
delete m_Registry;
|
|
|
66 |
m_Registry = NULL;
|
|
|
67 |
m_manager = NULL;
|
|
|
68 |
}
|
|
|
69 |
//---------------------------------------------------------------------------
|
|
|
70 |
|
|
|
71 |
int __fastcall TUdTransferForm::ShowForm( UdTransferManager * manager )
|
|
|
72 |
{
|
|
|
73 |
m_manager = manager;
|
|
|
74 |
InitialiseValuesFromRegistry();
|
|
|
75 |
|
|
|
76 |
return ShowModal();
|
|
|
77 |
}
|
|
|
78 |
//---------------------------------------------------------------------------
|
|
|
79 |
|
|
|
80 |
void __fastcall TUdTransferForm::InitialiseValuesFromRegistry()
|
|
|
81 |
{
|
|
|
82 |
int duration = 0;
|
|
|
83 |
int durationType = 1;
|
|
|
84 |
int frequency = 0;
|
|
|
85 |
int frequencyType = 1;
|
|
|
86 |
int rampTestType = 0;
|
|
|
87 |
double rampGradient = 1;
|
|
|
88 |
bool recurringUpload = false;
|
|
|
89 |
AnsiString sourcePath = "";
|
|
|
90 |
AnsiString destination = "";
|
|
|
91 |
bool renameSent = false;
|
|
|
92 |
bool ignoreSent = false;
|
|
|
93 |
int maxDevices = 100;
|
|
|
94 |
int deviceId = 1;
|
|
|
95 |
AnsiString deviceType = "SIM";
|
|
|
96 |
int connectTimeOut = 5;
|
|
|
97 |
|
|
|
98 |
if( m_Registry != NULL )
|
|
|
99 |
{
|
|
|
100 |
try {
|
|
|
101 |
// Previous transfer settings
|
|
|
102 |
|
|
|
103 |
if( m_Registry->ValueExists(REG_RECURRING) )
|
|
|
104 |
{
|
|
|
105 |
recurringUpload = m_Registry->ReadBool(REG_RECURRING);
|
|
|
106 |
}
|
|
|
107 |
if( m_Registry->ValueExists(REG_DURATION_TYPE) &&
|
|
|
108 |
m_Registry->ValueExists(REG_DURATION) )
|
|
|
109 |
{
|
|
|
110 |
duration = m_Registry->ReadInteger(REG_DURATION);
|
|
|
111 |
durationType = m_Registry->ReadInteger(REG_DURATION_TYPE);
|
|
|
112 |
}
|
|
|
113 |
if( m_Registry->ValueExists(REG_FREQUENCY_TYPE) &&
|
|
|
114 |
m_Registry->ValueExists(REG_FREQUENCY) )
|
|
|
115 |
{
|
|
|
116 |
frequency = m_Registry->ReadInteger(REG_FREQUENCY);
|
|
|
117 |
frequencyType = m_Registry->ReadInteger(REG_FREQUENCY_TYPE);
|
|
|
118 |
}
|
|
|
119 |
if( m_Registry->ValueExists(REG_RAMP_TEST_TYPE) )
|
|
|
120 |
{
|
|
|
121 |
rampTestType = m_Registry->ReadInteger(REG_RAMP_TEST_TYPE);
|
|
|
122 |
}
|
|
|
123 |
if( m_Registry->ValueExists(REG_SOURCE_PATH) )
|
|
|
124 |
{
|
|
|
125 |
sourcePath = m_Registry->ReadString(REG_SOURCE_PATH);
|
|
|
126 |
}
|
|
|
127 |
if( m_Registry->ValueExists(REG_DESTINATION) )
|
|
|
128 |
{
|
|
|
129 |
destination = m_Registry->ReadString(REG_DESTINATION);
|
|
|
130 |
}
|
|
|
131 |
if( m_Registry->ValueExists(REG_RAMP_GRADIENT) )
|
|
|
132 |
{
|
|
|
133 |
rampGradient = m_Registry->ReadFloat(REG_RAMP_GRADIENT);
|
|
|
134 |
}
|
|
|
135 |
|
|
|
136 |
// General settings
|
|
|
137 |
|
|
|
138 |
if( m_Registry->ValueExists(REG_RENAME) )
|
|
|
139 |
{
|
|
|
140 |
renameSent = m_Registry->ReadBool(REG_RENAME);
|
|
|
141 |
}
|
|
|
142 |
if( m_Registry->ValueExists(REG_IGNORESENT) )
|
|
|
143 |
{
|
|
|
144 |
ignoreSent = m_Registry->ReadBool(REG_IGNORESENT);
|
|
|
145 |
}
|
|
|
146 |
if( m_Registry->ValueExists(REG_MAXDEVICES) )
|
|
|
147 |
{
|
|
|
148 |
maxDevices = m_Registry->ReadInteger(REG_MAXDEVICES);
|
|
|
149 |
}
|
|
|
150 |
if( m_Registry->ValueExists(REG_DEVICEID) )
|
|
|
151 |
{
|
|
|
152 |
deviceId = m_Registry->ReadInteger(REG_DEVICEID);
|
|
|
153 |
}
|
|
|
154 |
if( m_Registry->ValueExists(REG_DEVICETYPE) )
|
|
|
155 |
{
|
|
|
156 |
deviceType = m_Registry->ReadString(REG_DEVICETYPE);
|
|
|
157 |
}
|
|
|
158 |
if( m_Registry->ValueExists(REG_CONNECTTIMEOUT) )
|
|
|
159 |
{
|
|
|
160 |
connectTimeOut = m_Registry->ReadInteger(REG_CONNECTTIMEOUT);
|
|
|
161 |
}
|
|
|
162 |
}
|
|
|
163 |
catch( EReadError & e ) { } // Ignore
|
|
|
164 |
catch( ERegistryException & e ) { }
|
|
|
165 |
}
|
|
|
166 |
|
|
|
167 |
// Set default or loaded values
|
|
|
168 |
|
|
|
169 |
cbRecurring->Checked = recurringUpload;
|
|
|
170 |
edUploadDuration->Text = IntToStr(duration);
|
|
|
171 |
coDurationType->ItemIndex = durationType;
|
|
|
172 |
edUploadFrequency->Text = IntToStr(frequency);
|
|
|
173 |
coFrequencyType->ItemIndex = frequencyType;
|
|
|
174 |
coRampTestType->ItemIndex = rampTestType;
|
|
|
175 |
edGradient->Text = FloatToStr(rampGradient);
|
|
|
176 |
edSourcePath->Text = sourcePath;
|
|
|
177 |
edDestination->Text = destination;
|
|
|
178 |
|
|
|
179 |
dtScheduleDate->Date = TDateTime::CurrentDate();
|
|
|
180 |
dtScheduleTime->Time = TDateTime::CurrentTime();
|
|
|
181 |
|
|
|
182 |
cbRename->Checked = renameSent;
|
|
|
183 |
cbIgnoreSent->Checked = ignoreSent;
|
|
|
184 |
coMaxDevices->Text = maxDevices;
|
|
|
185 |
edStartingDeviceId->Text = IntToHex( deviceId, 8 );
|
|
|
186 |
edDeviceType->Text = deviceType.SubString(0, 6);
|
|
|
187 |
edDeviceTimeout->Text = IntToStr(connectTimeOut);
|
|
|
188 |
|
|
|
189 |
coRampTestTypeChange( NULL );
|
|
|
190 |
rbStartNowClick( NULL );
|
|
|
191 |
SetDefaultBatchSize();
|
|
|
192 |
}
|
|
|
193 |
//---------------------------------------------------------------------------
|
|
|
194 |
|
|
|
195 |
void __fastcall TUdTransferForm::coRampTestTypeChange(TObject *Sender)
|
|
|
196 |
{
|
|
|
197 |
bool rampEnabled = false;
|
|
|
198 |
|
|
|
199 |
lblRatioDescription->Hide();
|
|
|
200 |
lblGradient->Hide();
|
|
|
201 |
edGradient->Hide();
|
|
|
202 |
|
|
|
203 |
switch( coRampTestType->ItemIndex )
|
|
|
204 |
{
|
|
|
205 |
case RampTestByDemand:
|
|
|
206 |
lblGradient->Show();
|
|
|
207 |
edGradient->Show();
|
|
|
208 |
rampEnabled = true;
|
|
|
209 |
break;
|
|
|
210 |
|
|
|
211 |
case RampTestByRatio:
|
|
|
212 |
lblRatioDescription->Show();
|
|
|
213 |
rampEnabled = true;
|
|
|
214 |
break;
|
|
|
215 |
};
|
|
|
216 |
|
|
|
217 |
rbStartNow->Enabled = rampEnabled;
|
|
|
218 |
rbSchedule->Enabled = rampEnabled;
|
|
|
219 |
dtScheduleDate->Enabled = rampEnabled && rbSchedule->Checked;
|
|
|
220 |
dtScheduleTime->Enabled = rampEnabled && rbSchedule->Checked;
|
|
|
221 |
}
|
|
|
222 |
//---------------------------------------------------------------------------
|
|
|
223 |
|
|
|
224 |
void __fastcall TUdTransferForm::btnOkClick(TObject *Sender)
|
|
|
225 |
{
|
|
|
226 |
if( ValidateInputs() )
|
|
|
227 |
{
|
|
|
228 |
// Store current values in the registry
|
|
|
229 |
|
|
|
230 |
m_Registry->WriteBool(REG_RECURRING, cbRecurring->Checked);
|
|
|
231 |
m_Registry->WriteInteger(REG_DURATION, edUploadDuration->Text.ToInt());
|
|
|
232 |
m_Registry->WriteInteger(REG_DURATION_TYPE, coDurationType->ItemIndex);
|
|
|
233 |
m_Registry->WriteInteger(REG_FREQUENCY, edUploadFrequency->Text.ToInt());
|
|
|
234 |
m_Registry->WriteInteger(REG_FREQUENCY_TYPE, coFrequencyType->ItemIndex);
|
|
|
235 |
m_Registry->WriteInteger(REG_RAMP_TEST_TYPE, coRampTestType->ItemIndex);
|
|
|
236 |
m_Registry->WriteString(REG_SOURCE_PATH, edSourcePath->Text);
|
|
|
237 |
m_Registry->WriteString(REG_DESTINATION, edDestination->Text);
|
|
|
238 |
if( coRampTestType->ItemIndex == RampTestByDemand )
|
|
|
239 |
{
|
|
|
240 |
m_Registry->WriteFloat(REG_RAMP_GRADIENT, edGradient->Text.ToDouble());
|
|
|
241 |
}
|
|
|
242 |
|
|
|
243 |
// Store settings values. No need to validate the majority of these; if they are
|
|
|
244 |
// invalid we will fall back to default values
|
|
|
245 |
|
|
|
246 |
try {
|
|
|
247 |
m_Registry->WriteBool(REG_RENAME, cbRename->Checked);
|
|
|
248 |
m_Registry->WriteBool(REG_IGNORESENT, cbIgnoreSent->Checked);
|
|
|
249 |
m_Registry->WriteInteger(REG_MAXDEVICES, coMaxDevices->Text.ToIntDef(100));
|
|
|
250 |
m_Registry->WriteInteger(REG_DEVICEID, StrToInt(AnsiString("$" + edStartingDeviceId->Text)));
|
|
|
251 |
m_Registry->WriteString(REG_DEVICETYPE, edDeviceType->Text);
|
|
|
252 |
m_Registry->WriteInteger(REG_CONNECTTIMEOUT, edDeviceTimeout->Text.ToIntDef(5));
|
|
|
253 |
}
|
|
|
254 |
catch( EConvertError & e ) { }
|
|
|
255 |
|
|
|
256 |
// Add the task to the manager
|
|
|
257 |
|
|
|
258 |
UdTransferTask task;
|
|
|
259 |
task.batchSize = edBatchSize->Text.ToInt();
|
|
|
260 |
task.duration = edUploadDuration->Text.ToInt();
|
|
|
261 |
task.frequency = edUploadFrequency->Text.ToInt();
|
|
|
262 |
task.recurring = cbRecurring->Checked;
|
|
|
263 |
task.sourcePath = edSourcePath->Text;
|
|
|
264 |
task.destination = edDestination->Text;
|
|
|
265 |
task.rampType = (RampTestType)coRampTestType->ItemIndex;
|
|
|
266 |
task.gradient = 0;
|
|
|
267 |
if( task.rampType == RampTestByDemand )
|
|
|
268 |
{
|
|
|
269 |
task.gradient = edGradient->Text.ToDouble();
|
|
|
270 |
}
|
|
|
271 |
|
|
|
272 |
switch( coDurationType->ItemIndex )
|
|
|
273 |
{
|
|
|
274 |
case 1: task.duration *= 60; break;
|
|
|
275 |
case 2: task.duration *= 60 * 60; break;
|
|
|
276 |
}
|
|
|
277 |
switch( coFrequencyType->ItemIndex )
|
|
|
278 |
{
|
|
|
279 |
case 1: task.frequency *= 60; break;
|
|
|
280 |
case 2: task.frequency *= 60 * 60; break;
|
|
|
281 |
}
|
|
|
282 |
|
|
|
283 |
TDateTime rampTime = TDateTime::CurrentDateTime();
|
|
|
284 |
if( rbSchedule->Checked )
|
|
|
285 |
{
|
|
|
286 |
rampTime = dtScheduleDate->DateTime + dtScheduleTime->Time;
|
|
|
287 |
}
|
|
|
288 |
task.rampTime = rampTime;
|
|
|
289 |
|
|
|
290 |
if( m_manager != NULL )
|
|
|
291 |
{
|
|
|
292 |
m_manager->AddNewTask( task );
|
|
|
293 |
}
|
|
|
294 |
|
|
|
295 |
ModalResult = mrOk;
|
|
|
296 |
}
|
|
|
297 |
}
|
|
|
298 |
//---------------------------------------------------------------------------
|
|
|
299 |
|
|
|
300 |
void __fastcall TUdTransferForm::btnDefaultClick(TObject *Sender)
|
|
|
301 |
{
|
|
|
302 |
SetDefaultBatchSize();
|
|
|
303 |
cbRecurring->Checked = false;
|
|
|
304 |
coRampTestType->ItemIndex = RampTestDisabled;
|
|
|
305 |
edGradient->Text = "1.0";
|
|
|
306 |
|
|
|
307 |
rbStartNowClick(NULL);
|
|
|
308 |
coRampTestTypeChange(NULL);
|
|
|
309 |
}
|
|
|
310 |
//---------------------------------------------------------------------------
|
|
|
311 |
|
|
|
312 |
void __fastcall TUdTransferForm::SetDefaultBatchSize()
|
|
|
313 |
{
|
|
|
314 |
// Get the number of .devud files in the source path and
|
|
|
315 |
// set this as the default batch size.
|
|
|
316 |
|
|
|
317 |
if( edSourcePath->Text.IsEmpty() )
|
|
|
318 |
{
|
|
|
319 |
edBatchSize->Text = "0";
|
|
|
320 |
return;
|
|
|
321 |
}
|
|
|
322 |
|
|
|
323 |
int count = 0;
|
|
|
324 |
TSearchRec sr;
|
|
|
325 |
|
|
|
326 |
if( FindFirst( edSourcePath->Text + "\\*.devud", faReadOnly, sr ) == 0 )
|
|
|
327 |
{
|
|
|
328 |
do
|
|
|
329 |
{
|
|
|
330 |
if( (sr.Attr & faDirectory) == 0 )
|
|
|
331 |
{
|
|
|
332 |
if( !(cbIgnoreSent->Checked && (sr.Name.Pos(SENT_STRING) == 1)) )
|
|
|
333 |
{
|
|
|
334 |
++count;
|
|
|
335 |
}
|
|
|
336 |
}
|
|
|
337 |
} while( FindNext(sr) == 0 );
|
|
|
338 |
FindClose(sr);
|
|
|
339 |
}
|
|
|
340 |
|
|
|
341 |
edBatchSize->Text = IntToStr(count);
|
|
|
342 |
}
|
|
|
343 |
//---------------------------------------------------------------------------
|
|
|
344 |
|
|
|
345 |
bool __fastcall TUdTransferForm::ValidateInputs()
|
|
|
346 |
{
|
|
|
347 |
// All required values must have entries
|
|
|
348 |
|
|
|
349 |
bool valid = ValidateEditControl( edSourcePath, "Source Path", vString );
|
|
|
350 |
if( valid ) valid = ValidateEditControl( edDestination, "Destination", vString );
|
|
|
351 |
if( valid ) valid = ValidateEditControl( edBatchSize, "Batch Size", vInteger );
|
|
|
352 |
if( valid ) valid = ValidateEditControl( edUploadDuration, "Upload Duration", vInteger );
|
|
|
353 |
if( valid ) valid = ValidateEditControl( edUploadFrequency, "Upload Frequency", vInteger );
|
|
|
354 |
if( coRampTestType->ItemIndex == RampTestByDemand )
|
|
|
355 |
{
|
|
|
356 |
if( valid ) valid = ValidateEditControl( edGradient, "Ramp Gradient", vDouble );
|
|
|
357 |
}
|
|
|
358 |
|
|
|
359 |
// Scheduled ramp time must be in the future
|
|
|
360 |
|
|
|
361 |
if( valid && rbSchedule->Checked )
|
|
|
362 |
{
|
|
|
363 |
TDateTime time = dtScheduleDate->DateTime + dtScheduleTime->Time;
|
|
|
364 |
if( time < TDateTime::CurrentDateTime() )
|
|
|
365 |
{
|
|
|
366 |
AnsiString error =
|
|
|
367 |
"The scheduled ramp time has already past. Use 'Start Now!' if you wish to start the ramp test immediately.";
|
|
|
368 |
MessageDlg(error, mtError, TMsgDlgButtons() << mbOK, 0);
|
|
|
369 |
valid = false;
|
|
|
370 |
}
|
|
|
371 |
}
|
|
|
372 |
|
|
|
373 |
// Source path must be valid and contain some files to transfer
|
|
|
374 |
|
|
|
375 |
if( valid && !DirectoryExists(edSourcePath->Text) )
|
|
|
376 |
{
|
|
|
377 |
AnsiString error =
|
|
|
378 |
"The source path '" + edSourcePath->Text + "' does not exist.";
|
|
|
379 |
MessageDlg(error, mtError, TMsgDlgButtons() << mbOK, 0);
|
|
|
380 |
valid = false;
|
|
|
381 |
edSourcePath->SetFocus();
|
|
|
382 |
}
|
|
|
383 |
|
|
|
384 |
if( valid && (edBatchSize->Text.ToInt() <= 0) )
|
|
|
385 |
{
|
|
|
386 |
AnsiString error =
|
|
|
387 |
"The specified source path does not contain any UD files to transfer, or the transfer batch\n";
|
|
|
388 |
error += "size has been set to zero. Do you want to continue anyway?";
|
|
|
389 |
|
|
|
390 |
if( MessageDlg(error, mtWarning, TMsgDlgButtons() << mbNo << mbYes, 0) == mrNo )
|
|
|
391 |
{
|
|
|
392 |
valid = false;
|
|
|
393 |
edBatchSize->SetFocus();
|
|
|
394 |
}
|
|
|
395 |
}
|
|
|
396 |
|
|
|
397 |
// Duration must be greater than zero for ramp up by ratio calculation
|
|
|
398 |
|
|
|
399 |
if( (coRampTestType->ItemIndex == RampTestByRatio) &&
|
|
|
400 |
(edUploadDuration->Text.ToInt() == 0) )
|
|
|
401 |
{
|
|
|
402 |
AnsiString error =
|
|
|
403 |
"An upload duration must be specified for Ramp Up by Ratio tests.";
|
|
|
404 |
MessageDlg(error, mtError, TMsgDlgButtons() << mbOK, 0);
|
|
|
405 |
valid = false;
|
|
|
406 |
edUploadDuration->SetFocus();
|
|
|
407 |
}
|
|
|
408 |
|
|
|
409 |
// User input max device simulators must be less than the absolute maximum
|
|
|
410 |
|
|
|
411 |
if( coMaxDevices->Text.ToIntDef(100) > MAX_DEVICES )
|
|
|
412 |
{
|
|
|
413 |
AnsiString error =
|
|
|
414 |
"The maximum defined device simulators exceeds the known safe value.\n";
|
|
|
415 |
error += "Please select a value between 0 and " + IntToStr(MAX_DEVICES) + ".";
|
|
|
416 |
MessageDlg(error, mtError, TMsgDlgButtons() << mbOK, 0 );
|
|
|
417 |
|
|
|
418 |
PageControl->ActivePageIndex = 1;
|
|
|
419 |
coMaxDevices->SetFocus();
|
|
|
420 |
valid = false;
|
|
|
421 |
}
|
|
|
422 |
|
|
|
423 |
return valid;
|
|
|
424 |
}
|
|
|
425 |
//---------------------------------------------------------------------------
|
|
|
426 |
|
|
|
427 |
bool __fastcall TUdTransferForm::ValidateEditControl( TCustomEdit * ctrl, const AnsiString & name,
|
|
|
428 |
const Variant & dataType )
|
|
|
429 |
{
|
|
|
430 |
AnsiString details = "";
|
|
|
431 |
|
|
|
432 |
bool valid = !ctrl->Text.IsEmpty();
|
|
|
433 |
if( valid )
|
|
|
434 |
{
|
|
|
435 |
// Ensure the control has a value of the specified data type
|
|
|
436 |
|
|
|
437 |
if( dataType.VType == varInteger )
|
|
|
438 |
{
|
|
|
439 |
try {
|
|
|
440 |
ctrl->Text.ToInt();
|
|
|
441 |
}
|
|
|
442 |
catch( EConvertError & e )
|
|
|
443 |
{
|
|
|
444 |
details = e.Message;
|
|
|
445 |
valid = false;
|
|
|
446 |
}
|
|
|
447 |
}
|
|
|
448 |
else if( dataType.VType == varDouble )
|
|
|
449 |
{
|
|
|
450 |
try {
|
|
|
451 |
ctrl->Text.ToDouble();
|
|
|
452 |
}
|
|
|
453 |
catch( EConvertError & e )
|
|
|
454 |
{
|
|
|
455 |
details = e.Message;
|
|
|
456 |
valid = false;
|
|
|
457 |
}
|
|
|
458 |
}
|
|
|
459 |
}
|
|
|
460 |
|
|
|
461 |
if( !valid )
|
|
|
462 |
{
|
|
|
463 |
AnsiString error = "A valid entry has not been provided for " + name + ".";
|
|
|
464 |
if( !details.IsEmpty() ) error += "\n" + details + ".";
|
|
|
465 |
|
|
|
466 |
MessageDlg(error, mtError, TMsgDlgButtons() << mbOK, 0);
|
|
|
467 |
|
|
|
468 |
PageControl->ActivePageIndex = 0;
|
|
|
469 |
ctrl->SetFocus();
|
|
|
470 |
}
|
|
|
471 |
|
|
|
472 |
return valid;
|
|
|
473 |
}
|
|
|
474 |
|
|
|
475 |
//---------------------------------------------------------------------------
|
|
|
476 |
|
|
|
477 |
void __fastcall TUdTransferForm::rbStartNowClick(TObject *Sender)
|
|
|
478 |
{
|
|
|
479 |
rbStartNow->Checked = true;
|
|
|
480 |
rbSchedule->Checked = false;
|
|
|
481 |
|
|
|
482 |
dtScheduleDate->Enabled = false;
|
|
|
483 |
dtScheduleTime->Enabled = false;
|
|
|
484 |
}
|
|
|
485 |
//---------------------------------------------------------------------------
|
|
|
486 |
|
|
|
487 |
void __fastcall TUdTransferForm::rbScheduleClick(TObject *Sender)
|
|
|
488 |
{
|
|
|
489 |
rbSchedule->Checked = true;
|
|
|
490 |
rbStartNow->Checked = false;
|
|
|
491 |
|
|
|
492 |
dtScheduleDate->Enabled = true;
|
|
|
493 |
dtScheduleTime->Enabled = true;
|
|
|
494 |
}
|
|
|
495 |
//---------------------------------------------------------------------------
|
|
|
496 |
|
|
|
497 |
void __fastcall TUdTransferForm::edSourcePathChange(TObject *Sender)
|
|
|
498 |
{
|
|
|
499 |
SetDefaultBatchSize();
|
|
|
500 |
}
|
|
|
501 |
//---------------------------------------------------------------------------
|
|
|
502 |
|
|
|
503 |
void __fastcall TUdTransferForm::cbIgnoreSentClick(TObject *Sender)
|
|
|
504 |
{
|
|
|
505 |
// Reload batch size and this may impact on it
|
|
|
506 |
SetDefaultBatchSize();
|
|
|
507 |
}
|
|
|
508 |
//---------------------------------------------------------------------------
|
|
|
509 |
|