How to get from a documentId to the actual content from the document

Hi,

I have a documentId but I want the content, or the name and filepath of the actual document(a word document), what would be the right way? I work with netserver from SIX.web.
I see some old code like beneath, but the function
Greetings,
Jos

Re: How to get from a documentId to the actual content from the document

Hi Jos
the following code will return a FileInfo for you

   
<br />public FileInfo GetDocumentFileInfo( int documentId )<br />{<br />SuperOffice.CRM.Entities.Document doc = new SuperOffice.CRM.Entities.Document.IdxDocumentId( documentId );<br />DateTime date = doc.Registered;<br />string dateDirectory = date.Year.ToString();<br />string archivePath = SuperOff­ice.Configuration.ConfigFile.Documents.ArchivePath;<br />string[] paths = archivePath.Split(';');<br />foreachstring path in paths )<br />{<br />string spath = path;<br />string userFolder = Path.Combine(path, doc.DocumentAppointment.Associate.Name);<br />if (Directory.Exists(userFolder))<br /­>{<br />string tempdoc = Path.Combine( userFolder, dateDirectory + ".1");;<br />if (Directory.Exists(tempdoc))<br />{<br />tempdoc = Path.Combine(tempdoc, doc.Name);<br />FileInfo fi = new FileInfo( tempdoc );<br />if( fi.Exists )<br />{<br />return fi;<br />}<br />}<br />tempdoc = Path.Combine(­ userFolder, dateDirectory + ".2");<br />if (Directory.Exists(tempdoc))<br />{<br />tempdoc = Path.Combine(tempdoc, doc.Name);<br />FileInfo fi = new FileInfo( tempdoc );<br />if( fi.Exists )<br />{ <br />return fi;<br />}<br />}<br />}<br />}<br />return null;<br />}<br />
 

 

Av: James Carter 18. mar 2009

Re: How to get from a documentId to the actual content from the document

same code but formatted better Smile

public

FileInfo GetDocumentFileInfo( int documentId )
{
   SuperOffice.CRM.Entities.Document doc = new SuperOffice.CRM.Entities.Document.IdxDocumentId(documentId);
   DateTime date = doc.Registered;
   string dateDirectory = date.Year.ToString();
   string archivePath = SuperOffice.Configuration.ConfigFile.Documents.ArchivePath;
   string[] paths = archivePath.Split(';');
   foreach( string path in paths )
   {
      string userFolder = Path.Combine(path, doc.DocumentAppointment.Associate.Name);
      if (Directory.Exists(userFolder))
      {
         string tempdoc = Path.Combine( userFolder, dateDirectory + ".1");
         if (Directory.Exists(tempdoc))
         {
            tempdoc = Path.Combine(tempdoc, doc.Name);
            FileInfo fi = new FileInfo( tempdoc );
            if( fi.Exists )
            {
               return fi;
            }
         }
         tempdoc = Path.Combine( userFolder, dateDirectory + ".2");
         if (Directory.Exists(tempdoc))
         {
            tempdoc = Path.Combine(tempdoc, doc.Name);
            FileInfo fi = new FileInfo( tempdoc );
            if( fi.Exists )
            { 
               return fi;
            }
         }
      }
   }
   // No, we didn't find it. 
   return null;
}

Av: James Carter 18. mar 2009

Re: How to get from a documentId to the actual content from the document

Thanks James, I will try your code!

Jos

Av: Jos Verbeek 18. mar 2009

RE: How to get from a documentId to the actual content from the document

You should use the PhysicalDocument class. It is musch easier and more right, as it will work with any document plugin.

Regards Martin.

Av: Martin Andersen 27. sep 2021