Mapout-M-Storage

Export Script

De MappingDoc
Autres langues :
English • ‎français

Introduction

This page explains how to use the script that lets you mass export documents stored in MapOut / M-Storage.

It is a PHP script run on the command line that includes various options for generating PDF files with or without XML index files.

The script processes the documents found in only one folder, which means you need to run the script for each folder where you want to extract the content.

Requirements

The script runs on the Windows system where M-Storage is installed.

As the extract process is based on the information found in Mapweb / M-Storage Web's MySQL database, M-Storage Web must be installed beforehand and you will need to rebuild the database and index of each folder you want to extract the content from. To do this, please refer to the installation and user guide for Mapweb / M-Storage Web.

Minimum versions supported:

- OS: Windows 2008, 2008r2, 2012, 2012r2, 7, 8, 8.1, 10

As the script is written in php7, it won't run on Windows Server 2003 and older

- M-Storage 7.2.0.37383 minimum.

To avoid updating M-Storage, a "M-Storage.exe" executable file is provided with the script package (in the "bin" folder). Make sure you place it in the folder where M-Storage is installed. However, if the existing version is the older "Mapout.exe", you will need to fully upgrade to M-Storage.

- M-Storage Web or MapWeb: 7.1 or 7.2

MapWeb / M-Storage Web requires:

  • Apache 2.2 or 2.4
  • MySQL version 5.1 or higher

Installation Steps

The script is provided as a package including php modules and php 7.1.8 for Windows.


1 - Uncompress the package and copy the folder "MStorageExport" to Apache's "MapWebFiles".

Example: C:\Program files\Apache Software Foundation\Apache2.2\htdocs\MapWebFiles\MStorageExport


2- Update MapOut/M-Storage to 7.2.0.37383 or higher OR copy the M-Storage.exe executable to the folder where M-Storage is installed.

It is found in the package's "bin" folder.

Warning-300px.pngCaution: If M-Storage is still being used and new documents are still being added, do not replace the version installed. In this case, it is best to duplicate the full environment on another server dedicated to exporting archived content.

Usage

1 - Before extracting the first batch of documents, you will need to find the information below to build the query

  • Path to M-storage.exe supplied with the package.
  • Path where the archived content you want to export is saved.


2 - Open a DOS prompt (cmd) as an Administrator and go to MStorageExport:

Example:

cd "C:\Program files\Apache Software Foundation\Apache2.2\htdocs\MapWebFiles\MStorageExport"

Warning-300px.png All subsequent commands must be run from the same location!


3 - For online help, run this command

php718\php help.php


4 - Basic extract command

php718\php export.php


Required parameters

______Parameter______ Comment
--archive= Folder you want to export (e.g. D:\Archives\Factures). It is a folder containing files such as Spool.cpr and Passwd.txt. The folder name must NOT end with a backslash.
--dest= Destination. Full path of the PDF file that will be created, with no extension. If the folders specified don't exist, they will be created automatically. The path may include metadata (like this <xxxx>) and index data( in square brackets[[c_xxxxx]]) with prefix "c_". No extension.

Optional if --action="listCriteria"

--pgm= Full path to M-Storage.exe or Mapout.exe (according to version installed)
--action= Script action:


--action="getCommands": create TXT files using the M-Storage.exe command that will create the PDF file. This option is used to test the command quickly without creating the PDF files.


--action="generate" : generate PDF files


--action="listCriteria": list of available indexes for the selected archive


Simple command example:

php718\php export.php --archive="D:\Archives\Factures" --dest="D:\Export Archives\<NomUser>\[[c_numfac]]_[[c_numcli]]" --pgm="C:\Mapping\M-Storage\m-storage.exe" --action="getCommands"


Optional parameters

______Parameter______ Comment
--indexfile If used, an XML index file will be generated together with each PDF file and will have the same name
--xsl= Path to XSL file used to customize the structure of the XML file in order to make it compatible with a third-party document management application. When this parameter is used, XSLT transformation is enable. Example: --xsl="C:\Mapping\Storage_Alfresco.xsl"
--rupt= Break index used to generate several PDF files from the same print spooled file. For example, if the archives contain print spool files with multiple invoices, you can create one PDF per invoice instead of one PDF for the whole spool file. You can do this using parameter --rupt and there can be more than one to break on different indexes. Example: --rupt="c_numfac"
--nextpage When using one or more break indexes, some pages may not have any value for the indexes mainly because one index is found only on the first page of each document. In this case, if the --nextpage parameter is used, the next pages that do not have any value will be included in the generated PDF document.
--log= Full path to log file. If missing, the log will be added to the standard output channel.
--filterindex_egal=

--filterindex_contains=

--filterindex_begin=


--filtermeta_egal=

--filtermeta_contains=

--filtermeta_begin=

Different filtering options are supported on metadata and indexes


Usage: --filter_XXXXXX="key=value"

Supported filter types

-- filtermeta_egal : filter of type metadata is equal to value
-- filtermeta_contains : filter of type metadata contains value
-- filtermeta_begin : filter of type metadata starts with value
-- filterindex_egal : filter of type index is equal to value
-- filterindex_contains : filter of type index contains value
-- filterindex_begin : filter of type index starts with value

Example : --filterindex_egal="c_site=Paris" --filtermeta_begin="NomSpool=S2016"

The list of indexes available depends on each archive. The list can be found in the "criteres" table of the MySql database. All indexes have the same "c_" prefix.

Supported metadata

The list of metadata is always the same and cannot be changed. It is the list of columns in the "spools" table of the MySQL database:
Warning-300px.png Caution: case-sensitive.
Warning-300px.png It often happens that some metadata contains business process data especially with archives coming from Mapping on Windows and Unix/Linux.

  • NomSpool : SPOOLNAME au format "Saaaammjjhhmmssxxxxxxxxx". Cette donnée étant indexée, elle convient très bien à une extraction par période, par exemple avec le paramètre --filtermeta_begin="NomSpool=S201706" pour extraire les documents de juin 2017.
  • DateDuSpoolFichier : DATE au format "aaaammjj"
  • NomTravail : JOBNAME
  • NomUser : USERNAME
  • DescriptifPC
  • NumeroJob
  • FichierSpool
  • NumeroSpool
  • OUTQ : OUTQ
  • BiliothequeOUTQ
  • Reference : USERDATA
  • Format : FORMAT MapDraw / M-Designer
  • ProgrammeEdition : PROG
  • BibProgrammeEdition
  • Critere1
  • Critere2
  • Critere3
  • Critere4


Exemple de commande avancée :

Génération des documents PDF issus de l'archive D:\Archives\012018 pour lesquels le format MapDraw/M-Designer est "FACTURE", le nom du client "EXEMPLE" pour la période janvier 2018. Chaque PDF contiendra les données d'un seul client (rupture par c_numcli) et un fichier d'index non personnalisé accompagnera chaque fichier PDF. Le plan de classement des fichiers PDF générés sera dynamique et comportera la date, le nom du client et l'identifiant du spool d'impression.

php718\php export.php --action="generate" --archive="D:\Archives\012018" --filtermeta_egal="Format=FACTURE" --filterindex_contains="c_nomcli=EXEMPLE" --filtermeta_begin="NomSpool=201801" --rupt="c_numcli" --nextpage --indexfile --dest="D:\Export\[[c_date]]\[[c_nomcli]]_<NomSpool>" --pgm="D:\Mapping\M-storage\M-storage.exe"


Exemple de XML généré sans transformation XSL

 <?xml version="1.0" encoding="UTF-8"?>
 <Indexes name="Document_2503576">
   <Meta name="NomSpool">S2019052127391744561449</Meta>
   <Meta name="DateDuSpoolFichier">20190521</Meta>
   <Meta name="NomTravail">ED_BCHARG</Meta>
   <Meta name="NomUser">ADMIN2</Meta>
   <Meta name="NumeroJob">157478</Meta>
   <Meta name="FichierSpool">BR60400C</Meta>
   <Meta name="NumeroSpool">4 </Meta>
   <Meta name="OutQ">RICOH1</Meta>
   <Meta name="BibliothequeOutQ">QUSRSYS </Meta>
   <Meta name="Reference">BR60400C</Meta>
   <Meta name="Format"/>
   <Meta name="ProgrammeEdition">BR60400C</Meta>
   <Meta name="BibProgrammeEdition">MAP400</Meta>
   <Meta name="DescriptifPC">Bon Livraison Mail</Meta>
   <Meta name="Critere1"/>
   <Meta name="Critere2"/>
   <Meta name="Critere3"/>
   <Meta name="Critere4"/>
   <Index name="c_body">
     <Value page="1">c:\Vente_AvisExpedition_FR.txt</Value>
   </Index>
   <Index name="c_client">
     <Value page="1">185830</Value>
   </Index>
   <Index name="c_dosarc">
     <Value page="1">Bon Livraison BONDUES 2019</Value>
   </Index>
   <Index name="c_mois">
     <Value page="1">05</Value>
   </Index>
   <Index name="c_nomclient">
     <Value page="1">MY COMPAGNY - CUISINES & BAINS</Value>
   </Index>
   <Index name="c_numbl">
     <Value page="1">6547951</Value>
   </Index>
 </Indexes>

Exemples de XSL

Conversion XSL pour Alfresco

 <?xml version="1.0" encoding="UTF-8"?>
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0">
   <xsl:output method="xml" encoding="UTF-8" indent="yes" omit-xml-declaration="no" cdata-section-elements="field" exclude-result-prefixes="xsl xs"/>
   <xsl:template match="/">
   <xsl:text disable-output-escaping='yes'>&lt;!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"&gt;
   </xsl:text>
   <xsl:apply-templates/>
   </xsl:template>
 
   <xsl:template match="Indexes">
     <properties>
     <!-- Activation du modele mp: -->                
       <entry key="type">cm:content</entry>
       <entry key="aspects"></entry>
       <xsl:apply-templates/>
     </properties>
   </xsl:template>
 
   <xsl:template match="Meta">
     <entry>
       <xsl:attribute name="key">mp:<xsl:value-of select="translate(@name,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')"/>
       </xsl:attribute><xsl:value-of select="."/>
     </entry>
   </xsl:template>
 
   <xsl:template match="Index">
     <entry>
       <xsl:attribute name="key">mp:<xsl:value-of select="translate(@name,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')"/>
       </xsl:attribute><xsl:value-of select="Value"/>
     </entry>
   </xsl:template>
 </xsl:stylesheet>