Forum Discussion
tarleaa
14 years agoContributor
Hello Alex,
thanks for the script. However, when I run the entire project or Project Suite, I get the following error:
"Cannot create file "". The filename or extension is too long."
I receive the error at the highlighted line of the following script that I use. I call the GetLogItems() function from another file, from withing a SendEmail() function, that is why the current script does not contain the SendEmail function.
I also attached a screen shot with the error.
function GetLogItems()
{
var tempFolder = aqEnvironment.GetEnvironmentVariable("temp") + "\\" +
GetTickCount() + "\\";
if (0 != aqFileSystem.CreateFolder(tempFolder)) {
Log.Error("The " + tempFolder + " temp folder was not created");
return "";
}
if (!Log.SaveResultsAs(tempFolder, lsHTML)) {
Log.Error("Log was not exported to the " + tempFolder + " temp folder");
return "";
}
var xDoc = Sys.OleObject("MSXML2.DOMDocument.4.0");
xDoc.load(tempFolder + "root.xml");
var result = LogDataToText(xDoc.childNodes.item(1), 0, " ");
aqFileSystem.DeleteFolder(tempFolder, true);
return result;
}
function LogDataToText(logData, indentIndex, indentSymbol)
{
if ("LogData" != logData.nodeName) {
return "";
}
var result = "";
for(var i = 0; i < indentIndex; i++) {
result += indentSymbol;
}
result = result + "<br/>" + "Name: " + logData.getAttribute("name") + ", status: " +
GetTextOfStatus(logData.getAttribute("status"));
for(var i = 0; i < logData.childNodes.lenght; i++) {
result += LogDataToText(logData.childNodes.item(i), indentIndex + 1,
indentSymbol);
}
return result;
}
function GetTextOfStatus(statusIndex)
{
switch(statusIndex) {
case "0": return "OK";
case "2": return "FAILED";
default: return "UNDEFINED";
}
}
Thanks,
Andrei
thanks for the script. However, when I run the entire project or Project Suite, I get the following error:
"Cannot create file "". The filename or extension is too long."
I receive the error at the highlighted line of the following script that I use. I call the GetLogItems() function from another file, from withing a SendEmail() function, that is why the current script does not contain the SendEmail function.
I also attached a screen shot with the error.
function GetLogItems()
{
var tempFolder = aqEnvironment.GetEnvironmentVariable("temp") + "\\" +
GetTickCount() + "\\";
if (0 != aqFileSystem.CreateFolder(tempFolder)) {
Log.Error("The " + tempFolder + " temp folder was not created");
return "";
}
if (!Log.SaveResultsAs(tempFolder, lsHTML)) {
Log.Error("Log was not exported to the " + tempFolder + " temp folder");
return "";
}
var xDoc = Sys.OleObject("MSXML2.DOMDocument.4.0");
xDoc.load(tempFolder + "root.xml");
var result = LogDataToText(xDoc.childNodes.item(1), 0, " ");
aqFileSystem.DeleteFolder(tempFolder, true);
return result;
}
function LogDataToText(logData, indentIndex, indentSymbol)
{
if ("LogData" != logData.nodeName) {
return "";
}
var result = "";
for(var i = 0; i < indentIndex; i++) {
result += indentSymbol;
}
result = result + "<br/>" + "Name: " + logData.getAttribute("name") + ", status: " +
GetTextOfStatus(logData.getAttribute("status"));
for(var i = 0; i < logData.childNodes.lenght; i++) {
result += LogDataToText(logData.childNodes.item(i), indentIndex + 1,
indentSymbol);
}
return result;
}
function GetTextOfStatus(statusIndex)
{
switch(statusIndex) {
case "0": return "OK";
case "2": return "FAILED";
default: return "UNDEFINED";
}
}
Thanks,
Andrei
Related Content
- 10 years agoMia