/// <summary>
/// import color code
/// </summary>
class CFSImportColorCode
{
/// <summary>
/// main
/// </summary>
/// <param name = “_args”>_args</param>
public static void main(Args _args)
{
AsciiStreamIo file;
Array fileLines;
FileUploadTemporaryStorageResult fileUpload;
CFSEcoResColorCode colorCode;
CFSImportColorCode importColorCode = new CFSImportColorCode();
Counter counter = 0;
EcoResColorName color;
#OCCRetryCount
try
{
//Upload a file
fileUpload = File::GetFileFromUser() as FileUploadTemporaryStorageResult;
file = AsciiStreamIo::constructForRead(fileUpload.openResult());
if (file)
{
if (file.status())
{
throw error(“@SYS52680”);
}
file.inFieldDelimiter(‘;’); //separator
file.inRecordDelimiter(‘\r\n’);
}
//Read a CSV File
container rec;
ttsbegin;
while (!file.status())
{
counter++;
rec = file.read();
if (conLen(rec))
{
color = conPeek(rec, 2);
colorCode = CFSEcoResColorCode::find(color);
if(!colorCode.RecId)
{
colorCode.clear();
colorCode.Name = color;
colorCode.Code = conPeek(rec, 1);
colorCode.insert();
}
}
}
ttscommit;
info(“Operation complete.”);
}
catch (Exception::Deadlock)
{
retry;
}
catch (Exception::UpdateConflict)
{
if (appl.ttsLevel() == 0)
{
if (xSession::currentRetryCount() >= #RetryNum)
{
throw Exception::UpdateConflictNotRecovered;
}
else
{
retry;
}
}
else
{
throw Exception::UpdateConflict;
}
}
}
}
标签:Exception,fileUpload,++,colorCode,color,file,rec,import,365 From: https://www.cnblogs.com/lingdanglfw/p/17391929.html