<blockquote> sub xmlFileData { use OLE; my ($path, $file, $caller) = @_; my $sPath = $path; $sPath =~ s/\///g; my $xml = ""; my $xmlFSO = CreateObject OLE "Scripting.FileSystemObject"; if ($Application->{"cxml_".$sPath.$file} && ($Application->{"cxml_ +".$sPath.$file."_dlm"} - time) > (5 * 60 * 60) && !$Session->{'forceF +iles'}) { #refreshed < n minutes ago, consider fresh } else { my $Conn = CreateObject OLE "ADODB.Connection"; my $RS = $Server->CreateObject("ADODB.Recordset"); $Conn->Open("PROVIDER=SQLOLEDB;DATA SOURCE=$Session->{'sqlServer +'};UID=$Session->{'sqlUser'};PWD=$Session->{'sqlPass'};DATABASE=$Sess +ion->{'dbName'}"); if ($Conn) { #CONN OK if ($Session->{'forceFiles'} && $Application->{"cxmlF_".$sPath +.$file."_dlm"}) { if ($Application->{"cxmlF_".$sPath.$file."_dlm"} ne $xmlFSO- +>GetFile($Server->MapPath("$path/$file"))->{'DateLastModified'}) { my $sql = "UPDATE XMLFileData SET Active='0' WHERE Path='$path' AND FileName='$file';"; $RS = $Conn->Execute($sql); } } if ($Session->{'cacheData'}) { my $sqlDLM = ""; my $sqlBody = ""; my $dumpFile = 0; my $setSQL = 0; my $sql = "SELECT LastModify, Body FROM XMLFileData WHERE Active='1' AND Path='$path' AND FileName='$file';"; if ($Session->{'trackDB'}){lg("DB","xmlFileData($sql)");} $RS = $Conn->Execute($sql); if ($RS) { if (!$RS->EOF()) { $sqlDLM = $RS->Fields('LastModify')->{Value}; $sqlBody = $RS->Fields('Body')->{Value}; $RS->Close; } } if ($sqlDLM) { if ($sqlDLM eq $Application->{"cxml_".$sPath.$file."_dlm"} +) { #SQL_dlm=App_dlm USE APP $xml = "<app/>"; } else { #SQL_dlm!=App_dlm USE SQL SET APP DUMP FILE $xml = "<sql/>"; $Application->Lock(); $Application->{"cxml_".$sPath.$file."_dlm"} = $sqlDLM; $Application->{"cxml_".$sPath.$file} = $sqlBody; + $Application->Unlock(); $dumpFile++; } } else { if ($Application->{"cxml_".$sPath.$file} && !($Session->{' +forceFiles'} && $xmlFSO->GetFile($Server->MapPath("$path/$file"))->{' +DateLastModified'} ne $Application->{"cxmlF_".$sPath.$file."_dlm"})) { #SQL=N App=Y USE APP SET SQL $setSQL++; } else { #SQL=N App=N if ($xmlFSO->FileExists($Server->MapPath("$path/$file")) +) { $xml = "<file/>"; #SQL=N App=N File=Y USE File SET SQL SET APP $Application->Lock(); my $xmlHandle = $xmlFSO->OpenTextFile($Server->MapPath +("$path/$file"),1); $Application->{"cxml_".$sPath.$file} = $xmlHandle->Rea +dAll(); $Application->{"cxml_".$sPath.$file."_dlm"} = $Applica +tion->{"cxmlF_".$sPath.$file."_dlm"} = $xmlFSO->GetFile($Server->MapP +ath("$path/$file"))->{'DateLastModified'}; $Application->Unlock(); $xmlHandle->Close(); $setSQL++; } else { #SQL=N App=N File=N Hope for the Best and Some better error reporting } } } if ($dumpFile) { #uncomment this stuff when ability to modify is on. my $fFSO = CreateObject OLE "Scripting.FileSystemObject"; my $fHandle = $fFSO->OpenTextFile($Server->MapPath("$path/ +$file"), 2, True); $fHandle->WriteLine($Application->{"cxml_".$sPath.$file}); $fHandle->Close(); $fHandle = undef; $fFSO = undef; } if ($setSQL) { my $sql = "INSERT INTO XMLFileData (Active, LastModify, Path, FileName, Body) VALUES ('1', {fn NOW()}, '$path', '$file', '".$Appli +cation->{"cxml_".$sPath.$file}."')"; if ($Session->{'trackDB'}){lg("DB","xmlFileData($sql)");} $RS = $Conn->Execute($sql); } $xml = $Application->{"cxml_".$sPath.$file}; } else { #No Cache,. don't be retarded,. turn it back on. } } else { #CONN BAD } } return $xml; }
In reply to Re: problems with xml data being returned
by grashoper
in thread problems with xml data being returned
by grashoper
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |