class PrisonFileImport extends RunBaseBatch
{
DialogField dialogImport;
Dialog dialog;
CustTable custTable;
container contain;
AsciiIo importFile;
str fileNameOnly;
FilenameOpen fileNameOpen;
#define.CurrentVersion(1)
#define.Version1(1)
#localmacro.CurrentList
filenameOpen
#endmacro
}
|
public boolean
canGoBatch()
{
boolean
ret;
ret = super();
return
ret;
}
|
protected Object dialog()
{
;
Dialog = super();
//Set a
title for dialog
dialog.caption("@CIT263");
dialogImport = dialog.addField(extendedTypeStr(FilenameOpen),"@CIT238","@CIT239");
return
dialog;
}
|
public boolean
getFromDialog()
{
// Retrieve
values from Dialog
fileNameOpen = dialogImport.value();
return
super();
}
|
public container
pack()
{
return [#CurrentVersion,#CurrentList];
}
|
public void
processData()
{
TextIo txIoRead;
FileIOPermission fioPermission;
container
containFromRead;
int record,iConLength;
str sOneRecord;
int customersUpdated = 0;
int customersNotFound = 0;
//str Y,N;
str prisonFlag;
CustAccount custAccount;
#File
;
// Assert
permission.
fioPermission = new FileIOPermission(fileNameOpen
,#IO_READ);
fioPermission.assert();
// Open the
same file for reading.
txIoRead = new
TextIo(fileNameOpen ,#IO_READ);
// Read the
entire file into a container.
containFromRead = txIoRead.read();
// Loop
through the container of file records.
while
(containFromRead)
{
sOneRecord = "";
iConLength = conLen(containFromRead);
// Loop
through the token in the current record.
for
(record=1; record <= iConLength;
record++)
{
if
(record > 1)
{
sOneRecord += " ";
}
sOneRecord += conPeek(containFromRead ,record);
}
custAccount = subStr(sOneRecord,1,10);
prisonFlag = subStr(sOneRecord,12,1);
custTable =
CustTable::find(custAccount,true);
ttsBegin;
if(custTable)
{
if
(prisonFlag=="Y")
{
custTable.PrisonFlag =
NoYes::Yes;
}
else
if (prisonFlag=="N")
{
custTable.PrisonFlag =
NoYes::No;
}
custTable.update();
customersUpdated++;
}
else
{
customersNotFound++;
}
ttsCommit;
// Read
the next record from the container.
containFromRead = txIoRead.read();
}
info("@CIT261"
+ int2str(customersupdated));
info("@CIT262"
+ int2str(customersNotFound));
// Close the
test file.
txIoRead = null;
//
revertAssert is not really necessary here,
// because
the job (or method) is ending.
CodeAccessPermission::revertAssert();
}
|
public void
run()
{
//super();
this.processData();
}
|
public boolean
unpack(container packedClass)
{
Version
version = RunBase::getVersion(packedClass);
;
switch (version)
{
case #CurrentVersion:
[version,#CurrentList] = packedClass;
break;
default:
return false;
}
return true;
}
|
public static
void main(Args _args)
{
prisonFileImport prisonFileImport = new prisonFileImport();
if
(prisonFileImport.prompt())
{
prisonFileImport.run();
}
}
|
Wednesday, 26 July 2017
Text File import/ Export
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment