Re: Fwd: Code Optimization Help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Joseph Crawford wrote:
Ok so finally i implemented my logging class into my mail merge object, this is the results

Word -> Application Opened.
Word -> Document1 Document Added.
Word -> header.doc Document Saved.
Word -> header.doc Document Closed.
Word -> Document2 Document Added.
Word -> ds.doc Document Saved.
Word -> ds.doc Document Closed.
Word -> Has_Site.dot Document Opened.
Word -> Opening Header Source.
F:/htdocs/csaf/data/mailmerge/header.doc File Exists

I threw in a file_exists check to make sure the script was actually seeing the file and had the correct path. It does. This is very strange because nothing happens, it's like i hit a never ending loop but php never times out either. I have my php timeout to 30 seconds yet this has run in excess of 5 minutes now.

if you run php on the cmdline there will be no timeout.
I am helping you blind here btw (I know nothing about COM) but I suggest
you try is_readable() as well as file_exists() - maybe the current user
(that php/Word is running at) is not allowed to read the file?



The expected results for the log would look something like this
Word -> Application Opened.
Word -> Document1 Document Added.
Word -> header.doc Document Saved.
Word -> header.doc Document Closed.
Word -> Document2 Document Added.
Word -> ds.doc Document Saved.
Word -> ds.doc Document Closed.
Word -> Has_Site.dot Document Opened.
Word -> Opening Header Source.
F:/htdocs/csaf/data/mailmerge/header.doc File Exists
Word -> Opening Data Source.
Word -> Executing Merge.
Word -> Has_Site.doc Document Saved.
Word -> Has_Site.doc Document Closed.
Word -> Merge Successful.


The code that is hanging is below

private function CreateDocument($template) {
$this->obj->Documents->Open($this->mm_data_dir.'/'.$template.'.dot');
Logger::log('Word -> '.$this->obj->ActiveDocument->Name().' Document Opened.');

Logger::log('Word -> Opening Header Source.');
if(file_exists($this->mm_data_dir.'/header.doc')) {
Logger::log($this->mm_data_dir.'/header.doc File Exists');
}
// THIS IS THE LINE THAT HANGS, THE FILE EXISTS AND IS POPULATED THE FILE CONTENTS CAN BE SEEN HERE
http://codebowl.dontexist.net/bugs/MailMerge/3.jpg$this->obj->ActiveDocument->MailMerge->OpenHeaderSource($this->mm_data_dir.'/header.doc');
Logger::log('Word -> Opening Data Source.');
$this->obj->ActiveDocument->MailMerge->OpenDataSource($this->mm_data_dir.'/ds.doc');
Logger::log('Word -> Executing Merge.');
$this->obj->ActiveDocument->MailMerge->Execute();
$this->obj->ActiveDocument->SaveAs($this->mm_data_dir.'/'.$template.'.doc');
Logger::log('Word -> '.$this->obj->ActiveDocument->Name().' Saved.'); Logger::log('Word -> '.$this->obj->ActiveDocument->Name().' Document Closed.');
$this->obj->ActiveDocument->Close();
}

Any help with this would be appreciated. I am not sure why it is choosing to hang today ;( I have been going through the COM object API documentation and i dont see myself doing anything i shouldnt be doing.

You can see the full code here
http://pastebin.com/369068
that is if it hasnt expired, if so send a reply and i will post again ;)
Thanks in advance


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux