Paste: Sssh
Author: | Sssh |
Mode: | vbscript |
Date: | Thu, 24 Mar 2016 21:51:14 |
Plain Text |
; RT_360645013_157_54_GreenDotPrePro_Staging (aOcsBankCustomerInputFilePreProcessor) (Def Version:54) (Implem Version:2)
uses wUITypes, aOcsBankPersoCustomerOffer, aOcsInputFileProcessing, aOcsInputFileSplittingParameters,
aOcsBankInputFileSplittingTool, aListOfInstances, aOcsPReader, OcsPrimaryTypes,
aOcsDMEDecipherKeyDesc, OcsHsmInterface, aOcsGrammarHsmInterface, aOcsDMETranscipherKeyInstance,
aOcsTransportKeyDef, aOcsDMETranscipherKeyDesc, aOcsBankInputFileImportTool
const cKeyName =
const cKeyNotFoundMsg =
const cSplitFolder =
const cSplitParamsName =
const cTrigram =
;globals
var alertMessage : Text
var AlertFile : Int4
var AlertFileName : CString
memory FromImportTool : aOcsBankInputFileImportTool override
function LoadInputFile(fromFile : CString) return aOcsPReader
uses Motor, aOcsPReaderByBlock, aClassDef, wUtil
if wUtil.FGETSIZE(fromFile) > 4 * 1024 * 1024
_Result = Motor.NewInst(MetaModelEntity(aOcsPReaderByBlock).Id)
else
new(_Result)
endIf
_Result.LoadFile(fromFile)
endFunc
function GetInputFileParams return aOcsInputFileSplittingParameters
forEach _Result in OQL Select * from x in aOcsInputFileSplittingParameters where Upcase(x.Name) =
cSplitParamsName
break
endFor
endFunc
procedure AppendTextToFile(inOut theText : Text, disposeText : Boolean, inFile : Int4)
uses MotorTypes, aTextType, wUtil
var ThetextHeader : tpTextHeader absolute theText
var lenWritten : Int4
;LW 01/02/2014 check data in theText before attempting to write
if not theText.type.IsBlank(@theText)
wUtil.F_SEEK(inFile, wUtil.F_SIZE(inFile))
wUtil.F_BLOCKWRITE(inFile, @ThetextHeader.Content, ThetextHeader.TextLength,
lenWritten)
if lenWritten <> ThetextHeader.TextLength
;RF: The file failed to write, bring up err\w fname
endIf
if disposeText
theText.type.Blank(@theText)
endIf
endIf
;End LW 01/02/2014 check data in theText before attempting to write
endProc
function GetEmbossSplitFileName(FromInputFile : tFileName, keySequence : CString,
inOut errMsg : CString) return CString
uses aOcsPersonaliser, wUtil, OcsPersonaliserInfo, aTextType, OcsASCIIEbcdicUtils
var curPos : Int4
var detailContent : Text
var ElementToFind : CString
var EmbossFileCount : Int4
var embossseq_number : CString
var embossseq_numberText : Text
var ListOfFiles : aListOfInstances
var MyFile : tFileName
var tempFile : aOcsPReader
ElementToFind =
new(ListOfFiles)
wUtil.FindFiles(OcsPersonaliserInfo.BankPersoCenter.CPSDataDirectory +
if ListOfFiles.count > 0
EmbossFileCount = 0
forEach MyFile in ListOfFiles
if Pos(ElementToFind, MyFile) > 0
new(tempFile)
tempFile = self.LoadInputFile(OcsPersonaliserInfo.BankPersoCenter.CPSDataDirectory +
curPos = 0
while (curPos >= 0) and (curPos < tempFile.Text_Length)
detailContent = tempFile.Text_CopyText(curPos, curPos + 3000 - 1)
embossseq_numberText = detailContent.type.CopyText(1723, 1734, @detailContent)
embossseq_number = OcsASCIIEbcdicUtils.EBCDICtoASCIIString(embossseq_numberText.type.AsCString(@embossseq_numberText),
HP_EBCDIC)
if keySequence = embossseq_number
_Result = MyFile
break
endIf
embossseq_number =
curPos += 3000
endWhile
dispose(tempFile)
;_Result = MyFile
EmbossFileCount++
if _Result <>
break
endIf
endIf
endFor
endIf
if EmbossFileCount <> 1 ; there is an error
;NO MATCH
;Trigger file for CS
AlertFileName = OcsPersonaliserInfo.BankPersoCenter.CPSDataDirectory +
;RF prepare data to write to file
WriteLn(alertMessage,
if EmbossFileCount = 0
errMsg =
WriteLn(alertMessage,
elseIf EmbossFileCount > 1
errMsg =
WriteLn(alertMessage,
WriteLn(alertMessage,
WriteLn(alertMessage,
AlertFile = wUtil.F_OPEN(1, AlertFileName)
if AlertFile = 0
wUtil.CreateDirsIfNecessary(AlertFileName)
AlertFile = wUtil.F_CREATE(1, AlertFileName)
endIf
self.AppendTextToFile(alertMessage, True, AlertFile)
wUtil.F_CLOSE(AlertFile)
endIf
endIf
dispose(ListOfFiles)
endFunc
function GetMergedFileName(Param : CString, inOut ListOfOkFiles : aListOfInstances,
inOut ErrorMsg : CString) return Boolean
uses aOcsPersonaliser, wUtil, OcsPersonaliserInfo
var ListOfFiles : aListOfInstances
var MyFile : CString
var Counter : Int4
var ElementToFind : CString
ElementToFind = wUtil.FGETNAME(Param)
new(ListOfFiles)
wUtil.FindFiles(OcsPersonaliserInfo.BankPersoCenter.CPSDataDirectory +
if ListOfFiles.count > 0
Counter = 0
forEach MyFile in ListOfFiles
if Pos(ElementToFind, MyFile) > 0
ListOfOkFiles.append(MyFile)
Counter++
endIf
endFor
endIf
if Counter > 0
_Result = True
else
_Result = False
ErrorMsg =
endIf
dispose(ListOfFiles)
endFunc
function Decipher(Data : CString) return CString
uses OcsByteArray, aOcsKeyTransportKeyDef, OCSCryptoDLL, aOcsBankCustomerOfferSchedule,
OcsBankHSMUtilities
const cKeyName =
const cKeyNotFoundMsg =
var COS : aOcsBankCustomerOfferSchedule
var CipheredData : tVarByteArray
var DecipherKeyDef : aOcsTransportKeyDef
var DecipherKeys : aListOfInstances
var DecryptionKey : aOcsDMEDecipherKeyDesc
var DmeType : tDMEType
var ErrorMsg : CString
var Padding : CString
var hsm : aOcsGrammarHsmInterface
var theKeyInstance : aOcsDMETranscipherKeyInstance
;Get the COS
forEach COS in OQL Select * from x in aOcsBankCustomerOfferSchedule where Upcase(x.Name) =
break
endFor
OcsByteArray.LoadFromHexCString(Data, CipheredData)
forEach DecipherKeyDef in OQL Select * from x in aOcsKeyTransportKeyDef where Upcase(x.FullName) =
cKeyName
break
endFor
if DecipherKeyDef <> Nil
new(DecryptionKey)
DecryptionKey.KeyLabel = DecipherKeyDef
DecryptionKey.DecipherAlgo = cDecipherTripleDESCBC
DecipherKeys = DecryptionKey.ProduceDecipherKeyInstances(Nil, Nil, Nil, Nil,
Nil, self.UseCryptoTestEquipment, ErrorMsg)
if DecipherKeys <> Nil
theKeyInstance = DecipherKeys.GetObjectAt(0)
if theKeyInstance <> Nil
if theKeyInstance.KCVValue =
if DecipherKeys.RemoveObject(theKeyInstance)
theKeyInstance.KCVValue =
DecipherKeys.AppendObject(theKeyInstance)
endIf
endIf
theKeyInstance.ICVValue =
endIf
;if member(ForBatch, aOcsBankInputFileProcessing)
DmeType = cEMV
hsm = OcsBankHSMUtilities.GetDecryptionHsmInterface(DmeType, self.UseCryptoTestEquipment,
COS, ErrorMsg)
if hsm <> Nil
if hsm.DecipherGrammarData(CipheredData, DecipherKeys, cPadding80, ErrorMsg)
_Result = OcsByteArray.AsHexString(CipheredData)
endIf
endIf
;ASU 2012/11/14 - Bug 2706 - avoid memory leak
dispose(DecipherKeys)
endIf
else
ErrorMsg = cKeyNotFoundMsg
endIf
if ErrorMsg <>
endIf
endFunc
function ComputeDetailFirst2Last3(inOut InFile : Int4, FromDetail : Text, inOut ErrorMsg : CString,
UPC : CString, GreenDotSku : CString) return Boolean
uses aTextType, OcsASCIIEbcdicUtils
var Line : Text
var TempText : Text
var TempCstring : CString
var CvC1 : CString
;
;Card Number
TempText = FromDetail.type.CopyText(13, 31, @FromDetail)
TempCstring = OcsASCIIEbcdicUtils.EBCDICtoASCIIString(TempText.type.AsCString(@TempText),
HP_EBCDIC)
WriteLn(Line, TempCstring)
;Expiration Date
TempText = FromDetail.type.CopyText(883, 890, @FromDetail)
TempCstring = OcsASCIIEbcdicUtils.EBCDICtoASCIIString(TempText.type.AsCString(@TempText),
HP_EBCDIC)
;Put correct format
TempCstring = Copy(TempCstring, 5, 2) +
WriteLn(Line, TempCstring)
;Cardholder name
TempText = FromDetail.type.CopyText(87, 112, @FromDetail)
TempCstring = OcsASCIIEbcdicUtils.EBCDICtoASCIIString(TempText.type.AsCString(@TempText),
HP_EBCDIC)
WriteLn(Line, TempCstring)
;Last for name
TempText = FromDetail.type.CopyText(13, 31, @FromDetail)
TempCstring = OcsASCIIEbcdicUtils.EBCDICtoASCIIString(TempText.type.AsCString(@TempText),
HP_EBCDIC)
WriteLn(Line, Copy(TempCstring, 13, 4))
;CVC2
TempText = FromDetail.type.CopyText(1395, 1410, @FromDetail)
TempCstring = OcsASCIIEbcdicUtils.EBCDICtoASCIIString(TempText.type.AsCString(@TempText),
HP_EBCDIC)
WriteLn(Line, self.Decipher(TempCstring))
;BIN
TempText = FromDetail.type.CopyText(3000, 3004, @FromDetail)
TempCstring = OcsASCIIEbcdicUtils.EBCDICtoASCIIString(TempText.type.AsCString(@TempText),
HP_EBCDIC)
WriteLn(Line, TempCstring)
;External ID
TempText = FromDetail.type.CopyText(3005, 3014, @FromDetail)
TempCstring = OcsASCIIEbcdicUtils.EBCDICtoASCIIString(TempText.type.AsCString(@TempText),
HP_EBCDIC)
WriteLn(Line, TempCstring)
;Track 1 & 2
;
;
TempText = FromDetail.type.CopyText(1379, 1394, @FromDetail)
TempCstring = OcsASCIIEbcdicUtils.EBCDICtoASCIIString(TempText.type.AsCString(@TempText),
HP_EBCDIC)
CvC1 = self.Decipher(TempCstring)
;Track 1
TempText = FromDetail.type.CopyText(1143, 1221, @FromDetail)
TempCstring = OcsASCIIEbcdicUtils.EBCDICtoASCIIString(TempText.type.AsCString(@TempText),
HP_EBCDIC)
WriteLn(Line, TempCstring + CvC1)
;Track 2
TempText = FromDetail.type.CopyText(1222, 1410, @FromDetail)
TempCstring = OcsASCIIEbcdicUtils.EBCDICtoASCIIString(TempText.type.AsCString(@TempText),
HP_EBCDIC)
WriteLn(Line, TempCstring + CvC1)
;GD PrtSequence
TempText = FromDetail.type.CopyText(3015, 3026, @FromDetail)
TempCstring = OcsASCIIEbcdicUtils.EBCDICtoASCIIString(TempText.type.AsCString(@TempText),
HP_EBCDIC)
WriteLn(Line, TempCstring)
;UPC
WriteLn(Line, UPC)
;Green Dot Sku
WriteLn(Line, GreenDotSku)
self.AppendTextToFile(Line, True, InFile)
_Result = True
endFunc
function sequenceError(seq1 : String, seq2 : String) return Boolean
var s1a : String
var s1b : String
var s2a : String
var s2b : String
var s1ai : Int4
var s1bi : Int4
var s2ai : Int4
var s2bi : Int4
;string1 is s1a+s1b and string2 is s2a+s2b
; separate two halves of both s1 and s2
s1a = Copy(seq1, 1, 6)
s1b = Copy(seq1, 7, 6)
s2a = Copy(seq2, 1, 6)
s2b = Copy(seq2, 7, 6)
; converting halves to integers
s1ai = SaI(s1a)
s1bi = SaI(s1b)
s2ai = SaI(s2a)
s2bi = SaI(s2b)
if (s1ai = s2ai) and (s2bi = s1bi + 1)
_Result = False ; Typical ideal case
elseif (s1bi = 999999) and (s2bi = 0) and (s2ai = s1ai + 1)
_Result = False ; This happens once every 10 million records
else
_Result = True ; There IS a sequence error
endIf
endFunc
function PreProcessFile(FromInputFile : tFileName, FirstComplementaryInputFile : tFileName,
SecondComplementaryInputFile : tFileName, FromCustomerOffer : aOcsBankPersoCustomerOffer,
inOut CustomIdentifier : CString, var WithInputFileProcessing : aOcsInputFileProcessing,
inOut ErrorMsg : CString) return Boolean override
uses OcsTechArchi, OcsASCIIEbcdicUtils, wUtil, OcsDocUtil, aStringByStringHashTable,
aTextType, OcsPersonaliserInfo, aOcsPersonaliser, aHashTableIterator
var curLine : String
var curLine2 : String
var curLine2Text : Text
var curLineText : Text
var CurPos : Int4
var CurPos2 : Int4
var CurPosEmboss : Int4
var CurPosPrint : Int4
var CurrentSeq : Int4
var DetailContent : Text
var EmbossSplitFile : CString
var EndPos : Int4
var FileCardseq_number : CString
var FileCardseq_numberText : Text
var FileCounterDet : Int4
var FileSize : Int4
var LastRecordIncorrect : Boolean
var fileIterator : Int4
var FileIteratorID : Int4
var First1Line : Text
var First2Last3File : Int4
var First2Line : Text
var firstLinePos : Int4
var folderToProcessTrigram : CString
var GreenDotSku : CString
var GUIFile : aOcsPReader
var InFileConter : Int4
var key : CString
var Last1Line : Text
var Last2Line : Text
var Last3Line : Text
var LastCharPos : Int4
var LastEndLine : Int4
var BadSequences : aListOfInstances
var ListOfErrorText : Text
var ListOfOkFiles : aListOfInstances
var ListOfSplittedIF : aListOfInstances
var MainIFT : aOcsPReader
var MergedEmbossPrintCandidate : tFileName
var MergedEmbossPrintCandidateReader : aOcsPReader
var MergedEmbossPrintFile : CString
var MergedFile : Int4
var MovedFile : CString
var MyBatchHeader : Text
var MyBatchTrailer : Text
var MyErrorGUI : CString
var MyFileHeader : Text
var MyFileTrailer : Text
var myPrintFileIter : aHashTableIterator
var NbatchHeader : Int4
var NbHeader : Int4
var numberofdetails : Int4
var numberofdetailsEmbossFile : Int4
var numberofdetailsPrintFile : Int4
var OriginalEmbossFileName : CString
var Params : aOcsInputFileSplittingParameters
var PrevBatchPos : Int4
var PrevLineEnd : Int4
var prev_seq_num : Int4
var prev_seq_string : CString
var PrintDetailFromHash : CString
var PrintFile : aOcsPReader
var PrintFileElements : aStringByStringHashTable
var PrintFileElementsList : aListOfInstances
var PrintFileMatch : Boolean
var PrintFileProductCode : CString
var ProductCodeType : CString
var QACounter : Int4
var QAFile : Int4
var QAFileTemp : CString
var QA_Qty : CString
var QA_QtyInt : Int4
var QtyForEmbossPrintFileSplit : Int4
var seq_num : Int4
var seq_string : String
var seq_text : Text
var SplitEmbossFile : aOcsPReader
var SplittedIF : tFileName
var SplittlingEngine : aOcsBankInputFileSplittingTool
var StartPos : Int4
var TempFirst2Last3File : CString
var TempMergedFile : CString
var TestQty : Int4
var UPC : CString
if OcsTechArchi.OpenDebug <> Nil
endIf
if self.FromImportTool.IsForProductionDebug and (OcsTechArchi.OpenDebug <> Nil)
endIf
;
;
;Quantity for the Emboss/Print File Split
QtyForEmbossPrintFileSplit = 5
;////////////////////////////////////////////////////////////////////////////////////
;///////////////////////////EMBOSS FILE Treatment///////////////////////////////////
;//////////////////////////////////////////////////////////////////////////////////
if (Copy(wUtil.FGETNAME(FromInputFile), 1, 3) =
1, 3) =
;Get the splitting Parameters
Params = self.GetInputFileParams
if Params = Nil
ErrorMsg =
_Result = False
else
new(SplittlingEngine)
new(ListOfSplittedIF)
OriginalEmbossFileName = wUtil.FGETNAME(FromInputFile)
SplittlingEngine.InputFileSplittingParameters = Params
SplittlingEngine.MainInputFile = FromInputFile
SplittlingEngine.SplitInputFile
ListOfSplittedIF = SplittlingEngine.SplittedInputFiles
new(BadSequences)
forEach SplittedIF in ListOfSplittedIF
MainIFT = self.LoadInputFile(SplittedIF)
CurPos = 0
BadSequences.purge
LastRecordIncorrect = False
ProductCodeType =
;Count Number of details
numberofdetails = 0
NbHeader = 0
NbatchHeader = 0
while (CurPos >= 0) and (CurPos < MainIFT.Text_Length)
MainIFT.Text_Readln(curLine, CurPos)
curLine = OcsASCIIEbcdicUtils.EBCDICtoASCIIString(curLine, HP_EBCDIC)
if curLine[1] =
;is a file header
NbHeader++
NbatchHeader++
elseif curLine[1] =
;is a batch header
;Get Product Type
ProductCodeType = DelBeginEndSpace(Copy(curLine, 34, 26))
NbatchHeader++
elseif curLine[1] =
numberofdetails++
endIf
CurPos += 2745
endWhile
CurPos = 0
seq_num = 0
CurrentSeq = 0
;Check Sequence
while (CurPos >= 0) and (CurPos < MainIFT.Text_Length)
MainIFT.Text_Readln(curLine, CurPos) ;! This increments CurPos by 255 !
curLine = OcsASCIIEbcdicUtils.EBCDICtoASCIIString(curLine, HP_EBCDIC)
if curLine[1] =
;is a file hearder
elseif curLine[1] =
ProductCodeType = DelBeginEndSpace(Copy(curLine, 34, 26))
;is a batch header
elseif curLine[1] =
;Detail Level
CurrentSeq++
prev_seq_num = seq_num
prev_seq_string = seq_string
;#RF get the seq number
CurPos2 = CurPos - 255 + 1723 ; note that Text_Readln mutated CurPos
MainIFT.Text_Readln(seq_string, CurPos2)
seq_string = Copy(seq_string, 1, 12)
seq_string = OcsASCIIEbcdicUtils.EBCDICtoASCIIString(seq_string,
HP_EBCDIC)
;Check Sequence and if nok load error into list and flag IF
;Do not report adjacent sequence errors
if LastRecordIncorrect
LastRecordIncorrect = False
elseif (CurrentSeq > 1) and self.sequenceError(prev_seq_string,
seq_string)
LastRecordIncorrect = True
BadSequences.append(seq_num) ;remember this sequence number
;prepare data to write to file
Write(alertMessage,
Write(alertMessage, CurrentSeq - 1)
Write(alertMessage,
WriteLn(alertMessage, CurrentSeq)
WriteLn(alertMessage,
WriteLn(alertMessage,
WriteLn(alertMessage,
WriteLn(alertMessage,
;now, write this text to the alert file
AlertFileName = wUtil.FGETDIR(SplittedIF) +
OriginalEmbossFileName +
AlertFile = wUtil.F_OPEN(1, AlertFileName) ;write in 1 byte blocks
;RF If the file didn
if AlertFile = 0
wUtil.CreateDirsIfNecessary(AlertFileName)
AlertFile = wUtil.F_CREATE(1, AlertFileName)
endIf
self.AppendTextToFile(alertMessage, True, AlertFile)
wUtil.F_CLOSE(AlertFile)
endIf
prev_seq_num = seq_num
endIf
CurPos += 2745
endWhile
;move the file
MovedFile = wUtil.FGETDIR(SplittedIF) +
wUtil.CreateDirsIfNecessary(MovedFile)
if OcsTechArchi.MOVEFILE(SplittedIF, MovedFile)
endIf
dispose(MainIFT)
endFor
dispose(BadSequences)
dispose(ListOfSplittedIF)
;Tweak to avoid fake errors. The splitting moves the files to .Input\Failed\Imported
;but the external processing is expecting a file in Input\Failed so it can move at the end of the processing
if OcsTechArchi.MOVEFILE(OcsPersonaliserInfo.BankPersoCenter.CPSDataDirectory +
wUtil.FGETEXT(FromInputFile), OcsPersonaliserInfo.BankPersoCenter.CPSDataDirectory +
endIf
_Result = True
endIf
;
;////////////////////////////////////////////////////////////////////////////////////
;//////////////////////PRINT FILE Treatment/////////////////////////////////////////
;//////////////////////////////////////////////////////////////////////////////////
;
elseif Copy(wUtil.FGETNAME(FromInputFile), 1, 2) =
;Initiate Lists and Hash tables
new(PrintFileElements)
new(PrintFileElementsList)
PrintFileElementsList.initForRecords(-1, sizeof(CString))
;
;Get the product Code
PrintFileProductCode =
PrintFileProductCode = Copy(wUtil.FGETNAME(FromInputFile), 4, 4)
PrintFile = self.LoadInputFile(FromInputFile)
;
;Initiate Values for loops
CurPosPrint = 0
CurPosEmboss = 0
numberofdetailsPrintFile = 0
numberofdetailsEmbossFile = 0
PrintFileMatch = True
;Go throught the Print file, get the number of details and the detail content into the hashtable.
while (CurPosPrint >= 0) and (CurPosPrint < PrintFile.Text_Length) and (PrintFileMatch =
True)
PrintFile.Text_Readln(curLine, CurPosPrint)
key =
key = Copy(curLine, 16, 12)
PrintFileElements.AppendString(curLine +
PrintFileElementsList.append(key)
numberofdetailsPrintFile++
EmbossSplitFile = self.GetEmbossSplitFileName(FromInputFile, key, ErrorMsg)
if ErrorMsg <>
;Emboss file not found
PrintFileMatch = False
endIf
endWhile
dispose(PrintFile)
;//////////////////////////////////
;///End of Print File Treatment///
;////////////////////////////////
;
;
;
;//////////////////////////////////
;Merge emboss & print file treatment
;////////////////////////////////
;
;Load the Emboss File
if PrintFileMatch = True
SplitEmbossFile = self.LoadInputFile(OcsPersonaliserInfo.BankPersoCenter.CPSDataDirectory +
;
FileCounterDet = 0
InFileConter = 0
CurPosEmboss = 0
curLine =
;Create Merge File File name
TempMergedFile = OcsPersonaliserInfo.BankPersoCenter.CPSDataDirectory +
wUtil.CreateDirsIfNecessary(TempMergedFile)
MergedFile = wUtil.F_CREATE(1, TempMergedFile)
;curLine =
;Loop in file to count details and get the FileCardSequence see if it match those of the previous PrintFile (in the hash table now)
while (CurPosEmboss >= 0) and (CurPosEmboss < SplitEmbossFile.Text_Length) and
(PrintFileMatch = True)
;SplitEmbossFile.Text_Readln(curLine, CurPosEmboss)
;curLine = OcsASCIIEbcdicUtils.EBCDICtoASCIIString(curLine, HP_EBCDIC)
DetailContent = SplitEmbossFile.Text_CopyText(CurPosEmboss, CurPosEmboss +
3000 - 1)
curLine = DetailContent.type.Copy(255, 0, @DetailContent)
curLine = OcsASCIIEbcdicUtils.EBCDICtoASCIIString(curLine, HP_EBCDIC)
fileIterator++
switch curLine[1]
when
MyFileHeader = DetailContent
self.AppendTextToFile(MyFileHeader, True, MergedFile)
endWhen
when
MyBatchHeader = DetailContent
self.AppendTextToFile(MyBatchHeader, True, MergedFile)
endWhen
when
FileCounterDet++
numberofdetailsEmbossFile++
FileCardseq_numberText = DetailContent.type.CopyText(1723, 1734,
@DetailContent)
FileCardseq_number = OcsASCIIEbcdicUtils.EBCDICtoASCIIString(FileCardseq_numberText.type.AsCString(@FileCardseq_numberText),
HP_EBCDIC)
if PrintFileElements.GetStringFromString(PrintDetailFromHash, FileCardseq_number)
;We have a match
Write(DetailContent, OcsASCIIEbcdicUtils.ASCIIToEBCDICString(PrintDetailFromHash,
HP_EBCDIC))
self.AppendTextToFile(DetailContent, True, MergedFile)
PrintFileElements.DeleteString(FileCardseq_number)
else
;No Match
PrintFileMatch = False
Write(self.FromImportTool.Report,
FileCardseq_number &&
endIf
endWhen
when
MyBatchTrailer = DetailContent
self.AppendTextToFile(MyBatchTrailer, True, MergedFile)
endWhen
when
MyFileTrailer = DetailContent
self.AppendTextToFile(MyFileTrailer, True, MergedFile)
endWhen
endSwitch
CurPosEmboss += 3000
endWhile
;Close the file
InFileConter = 0
wUtil.F_CLOSE(MergedFile)
dispose(SplitEmbossFile)
endIf
;
if PrintFileMatch = True
if PrintFileElements.Count > 0
PrintFileMatch = False
Write(self.FromImportTool.Report,
FromInputFile &&
endIf
endIf
;Clean Mem
dispose(PrintFileElements)
dispose(PrintFileElementsList)
;
;////////////////////////////////////////////////////////////////////////////////////
;////////////////////////GUI FILE Treatment/////////////////////////////////////////
;//////////////////////////////////////////////////////////////////////////////////
;
elseif wUtil.FGETEXT(FromInputFile) =
;
;
;Open the GUI File, check the info and get the required infof for the first 2 last three report
;
;
;Note that we do not loop in the GUI file as it seems that there will be just a detail line
;
;Init just in case
if OcsTechArchi.OpenDebug <> Nil
endIf
;
;folderToProcessTrigram =
folderToProcessTrigram = OcsPersonaliserInfo.BankPersoCenter.CPSDataDirectory +
;
CurPos = 0
;Load the file in the memory
GUIFile = self.LoadInputFile(FromInputFile)
;Start ready the first line
GUIFile.Text_Readln(curLine, CurPos)
;Get the end of the first line
PrevLineEnd = GUIFile.Text_EndOfLine(CurPos)
;Set the second line cursor
CurPos = PrevLineEnd + 1
;
;Get the data required for the First 2 last 3 report
UPC = GUIFile.CopyString(CurPos + 102, CurPos + 122, vtASCII)
GreenDotSku = GUIFile.CopyString(CurPos + 216, CurPos + 236, vtASCII)
StartPos = CurPos
EndPos = GUIFile.Len
QA_Qty = GUIFile.CopyString(StartPos + 572, EndPos, vtASCII)
QA_QtyInt = SaI(DelBeginEndSpace(QA_Qty))
;QA_QtyInt = SaI(
;
QA_QtyInt = SaI(DelBeginEndSpace(Copy(QA_Qty, 1, 4)))
new(ListOfOkFiles)
ListOfOkFiles.initForRecords(-1, sizeof(CString))
MyErrorGUI =
; Try to get the correspond Emboss + Print File
if self.GetMergedFileName(wUtil.FGETNAME(FromInputFile), ListOfOkFiles, MyErrorGUI)
_Result = True
;Gui file
MovedFile = folderToProcessTrigram +
wUtil.FGETEXT(FromInputFile)
wUtil.CreateDirsIfNecessary(MovedFile)
if OcsTechArchi.COPYFILE(FromInputFile, MovedFile, False,
;MOVEFILE(FromInputFile, MovedFile)
else
ErrorMsg =
_Result = False
endIf
;
;Don
if _Result <> False
;
;
; We have a loop but in theory there should be only one element
;In this loop we will create the First2Last3 report, split the emboss+print file and move them to the computing trigram
forEach MergedEmbossPrintCandidate in ListOfOkFiles
;
CurPosEmboss = 0
curLine =
numberofdetailsEmbossFile = 0
;
;Load the Emboss File
MergedEmbossPrintCandidateReader = self.LoadInputFile(OcsPersonaliserInfo.BankPersoCenter.CPSDataDirectory +
;
;////////////////////////////////////////////////////////////////////////////////////
;////////////////////////////////QA Treatment////////////////////////////////////////
;/////////////////////////////////////////////////////////////////////////////////
;Create QA File name
QACounter = 0
QAFileTemp = OcsPersonaliserInfo.BankPersoCenter.CPSDataDirectory +
MergedEmbossPrintCandidate
wUtil.CreateDirsIfNecessary(QAFileTemp)
QAFile = wUtil.F_CREATE(1, QAFileTemp)
while (CurPosEmboss >= 0) and (CurPosEmboss < MergedEmbossPrintCandidateReader.Text_Length)
DetailContent = MergedEmbossPrintCandidateReader.Text_CopyText(CurPosEmboss,
CurPosEmboss + 3000 - 1)
curLine = DetailContent.type.Copy(255, 0, @DetailContent)
curLine = OcsASCIIEbcdicUtils.EBCDICtoASCIIString(curLine, HP_EBCDIC)
if (curLine[1] =
(curLine[1] =
self.AppendTextToFile(DetailContent, True, QAFile)
CurPosEmboss += 3000
elseif curLine[1] =
QACounter++
;Get Sequence
DetailContent = MergedEmbossPrintCandidateReader.Text_CopyText(CurPosEmboss,
CurPosEmboss + 3046 - 1)
FileCardseq_numberText = DetailContent.type.CopyText(1723, 1734,
@DetailContent)
if QACounter = QA_QtyInt
;if QA_QtyInt = 600
; Write(DetailContent, OcsASCIIEbcdicUtils.ASCIIToEBCDICString(
; QA_Qty +
;else
Write(DetailContent, OcsASCIIEbcdicUtils.ASCIIToEBCDICString(
QA_Qty, HP_EBCDIC))
;endIf
else
;Not QA card then just add the card sequence
Write(DetailContent, OcsASCIIEbcdicUtils.ASCIIToEBCDICString(
HP_EBCDIC))
endIf
self.AppendTextToFile(DetailContent, True, QAFile)
;details size is now 3037 because of the merging
CurPosEmboss += 3046
endIf
endWhile
wUtil.F_CLOSE(QAFile)
dispose(MergedEmbossPrintCandidateReader)
;Load the Emboss File with QA
MergedEmbossPrintCandidateReader = self.LoadInputFile(OcsPersonaliserInfo.BankPersoCenter.CPSDataDirectory +
;////////////////////////////////////////////////////////////////////////////////////
;////////////////////////////////File Split////////////////////////////////////////
;/////////////////////////////////////////////////////////////////////////////////
CurPosEmboss = 0
curLine =
;Step 1 Get the Headers and trailers and count details
while (CurPosEmboss >= 0) and (CurPosEmboss < MergedEmbossPrintCandidateReader.Text_Length)
DetailContent = MergedEmbossPrintCandidateReader.Text_CopyText(CurPosEmboss,
CurPosEmboss + 3000 - 1)
curLine = DetailContent.type.Copy(255, 0, @DetailContent)
curLine = OcsASCIIEbcdicUtils.EBCDICtoASCIIString(curLine, HP_EBCDIC)
if (curLine[1] =
(curLine[1] =
;MyFileHeader
if curLine[1] =
MyFileHeader = DetailContent
elseif curLine[1] =
MyFileTrailer = DetailContent
elseif curLine[1] =
MyBatchHeader = DetailContent
elseif curLine[1] =
MyBatchTrailer = DetailContent
endIf
;Header and trailer size are 3000
CurPosEmboss += 3000
else
;Count number of detail for latter treatment
numberofdetailsEmbossFile++
;details size is now 3052 because of the QA
CurPosEmboss += 3052
endIf
endWhile
;
;Step 2 Get the 2 first and Last three details
InFileConter = 0
CurPosEmboss = 0
while (CurPosEmboss >= 0) and (CurPosEmboss < MergedEmbossPrintCandidateReader.Text_Length)
DetailContent = MergedEmbossPrintCandidateReader.Text_CopyText(CurPosEmboss,
CurPosEmboss + 3000 - 1)
curLine = DetailContent.type.Copy(255, 0, @DetailContent)
curLine = OcsASCIIEbcdicUtils.EBCDICtoASCIIString(curLine, HP_EBCDIC)
if (curLine[1] =
(curLine[1] =
;Header and trailer size are 3000
CurPosEmboss += 3000
else
;Get the detail number
InFileConter++
;details size is now 3037 because of the merging
if InFileConter = 1
First1Line = MergedEmbossPrintCandidateReader.Text_CopyText(CurPosEmboss,
CurPosEmboss + 3052 - 1)
elseif InFileConter = 2
First2Line = MergedEmbossPrintCandidateReader.Text_CopyText(CurPosEmboss,
CurPosEmboss + 3052 - 1)
elseif InFileConter = numberofdetailsEmbossFile - 2
Last1Line = MergedEmbossPrintCandidateReader.Text_CopyText(CurPosEmboss,
CurPosEmboss + 3052 - 1)
elseif InFileConter = numberofdetailsEmbossFile - 1
Last2Line = MergedEmbossPrintCandidateReader.Text_CopyText(CurPosEmboss,
CurPosEmboss + 3052 - 1)
elseif InFileConter = numberofdetailsEmbossFile
Last3Line = MergedEmbossPrintCandidateReader.Text_CopyText(CurPosEmboss,
CurPosEmboss + 3052 - 1)
endIf
CurPosEmboss += 3052
endIf
endWhile
;
;
;
;;Step 3 Compute the First2Last3 report
;
;
TempFirst2Last3File = OcsPersonaliserInfo.BankPersoCenter.CPSDataDirectory +
cTrigram +
wUtil.CreateDirsIfNecessary(TempFirst2Last3File)
First2Last3File = wUtil.F_CREATE(1, TempFirst2Last3File)
;
;/////////
;Detail 1
;/////////
;
if self.ComputeDetailFirst2Last3(First2Last3File, First1Line, ErrorMsg,
UPC, GreenDotSku)
endIf
;/////////
;Detail 2
;/////////
;
if self.ComputeDetailFirst2Last3(First2Last3File, First2Line, ErrorMsg,
UPC, GreenDotSku)
endIf
;/////////
;Detail n-2
;/////////
;
if self.ComputeDetailFirst2Last3(First2Last3File, Last1Line, ErrorMsg,
UPC, GreenDotSku)
endIf
;/////////
;Detail n-1
;/////////
;
if self.ComputeDetailFirst2Last3(First2Last3File, Last2Line, ErrorMsg,
UPC, GreenDotSku)
endIf
;/////////
;Detail n
;/////////
;
if self.ComputeDetailFirst2Last3(First2Last3File, Last3Line, ErrorMsg,
UPC, GreenDotSku)
endIf
;;///
;WClose file;
wUtil.F_CLOSE(First2Last3File)
;;
;Step 4 Compute Files
;
fileIterator = 1
FileCounterDet = 0
InFileConter = 0
CurPosEmboss = 0
curLine =
while (CurPosEmboss >= 0) and (CurPosEmboss < MergedEmbossPrintCandidateReader.Text_Length)
DetailContent = MergedEmbossPrintCandidateReader.Text_CopyText(CurPosEmboss,
CurPosEmboss + 3000 - 1)
curLine = DetailContent.type.Copy(255, 0, @DetailContent)
curLine = OcsASCIIEbcdicUtils.EBCDICtoASCIIString(curLine, HP_EBCDIC)
if curLine[1] =
DetailContent = MergedEmbossPrintCandidateReader.Text_CopyText(CurPosEmboss,
CurPosEmboss + 3052 - 1)
;To get the curent detail number of the main file
FileCounterDet++
;get the current the detail number within a split
InFileConter++
;Create a new file if it a the first detail witin a split
if InFileConter = 1
;SubSplit File name
;SubSplit File name
TempMergedFile = OcsPersonaliserInfo.BankPersoCenter.CPSDataDirectory +
wUtil.CreateDirsIfNecessary(TempMergedFile)
;Create file
MergedFile = wUtil.F_CREATE(1, TempMergedFile)
;Count File
fileIterator++
;Put the header and trailer
self.AppendTextToFile(MyFileHeader, True, MergedFile)
self.AppendTextToFile(MyBatchHeader, True, MergedFile)
endIf
;Add line
self.AppendTextToFile(DetailContent, True, MergedFile)
;if we reach the split max quantity or the end of the file close the file
if (InFileConter = QtyForEmbossPrintFileSplit) or (FileCounterDet =
numberofdetailsEmbossFile)
;Add the trailers
self.AppendTextToFile(MyBatchTrailer, True, MergedFile)
self.AppendTextToFile(MyFileTrailer, True, MergedFile)
;Reset the in split counter
InFileConter = 0
;Close the file
wUtil.F_CLOSE(MergedFile)
;
;Movefile To Input
MovedFile = folderToProcessTrigram +
wUtil.CreateDirsIfNecessary(MovedFile)
if OcsTechArchi.MOVEFILE(TempMergedFile, MovedFile)
else
ErrorMsg =
_Result = False
endIf
endIf
CurPosEmboss += 3052
else
CurPosEmboss += 3000
endIf
endWhile
endFor
;Treatment OK
if _Result <> False
_Result = True
endIf
endIf
else
ErrorMsg = MyErrorGUI
_Result = False
endIf
dispose(ListOfOkFiles)
endIf
endFunc
New Annotation