jwcolby
jwcolby at colbyconsulting.com
Mon Mar 31 09:01:26 CDT 2008
I am using the VB.Net built-in XML serializer to serialize a class to XML. I gather a bunch of data into class properties and then when the class is filled out I write it to a file. Each class represents the process of importing a single file of text data, in this case CSV data. Thus I have one XML log file per CSV file imported into a temp table. The data looks like: <?xml version="1.0" ?> - <clsCSVDataImportLogData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <pTblName>PartnerShipTax20070824</pTblName> <pStatus>FAIL</pStatus> <pCommittedID>0</pCommittedID> <pFileSpec>E:\PSM\Data\FirstAmerican\TaxRolls\PartnerShipTax20070824.txt</pF ileSpec> <pStartTime>2008-03-31T01:11:59.225625-04:00</pStartTime> <pStopTime>2008-03-31T01:14:08.8975-04:00</pStopTime> <pStartID>0</pStartID> <pStopID>0</pStopID> <pMemo>228716234 : 3/31/2008 1:11:59 AM : Move to Archive: E:\PSM\Data\FirstAmerican\TaxRolls\Archive\PartnerShipTax20070817.txt 228716250 : 3/31/2008 1:11:59 AM : Loading CSVReader3/31/2008 1:11:59 AM 228716250 : 3/31/2008 1:11:59 AM : Read File: E:\PSM\Data\FirstAmerican\TaxRolls\PartnerShipTax20070824.txt 228716265 : 3/31/2008 1:11:59 AM : File Loaded: E:\PSM\Data\FirstAmerican\TaxRolls\PartnerShipTax20070824.txt 228716265 : 3/31/2008 1:11:59 AM : Bulk Copy: tblTaxRollsUpdate 228845875 : 3/31/2008 1:14:08 AM : Bulk Copy FAILED: Maximum column length of 100,000 exceeded in column 7 in record 842,847. Set the SafetySwitch property to false if you're expecting column lengths greater than 100,000 characters to avoid this error. 228845890 : 3/31/2008 1:14:08 AM : Bulk Copy Finished: tblTaxRollsUpdate 228845890 : 3/31/2008 1:14:08 AM : RECORDS READ: 842847 228845906 : 3/31/2008 1:14:08 AM : RECORDS BULK COPIED: 840000 228845906 : 3/31/2008 1:14:08 AM : Individual table: tblPartnerShipTax20070824 IMPORT failed.</pMemo> </clsCSVDataImportLogData> I like writing the data to XML files, one xml file per import file because it allows me to go to a know location, look for a specific file, open it and scan what happened. For example this file failed to import. Knowing the file name I can go look for a matching log file and just read it. I read a bunch of files, as many as are in a process directory. As I finish filling out the class instance information I store the classes that into a collection, so at the end of the overall process I have a collection of every file that was processed. What I am trying to figure out is whether the data from each class can be stored in a common XML file? The serializer appears to build an entire file just for that class, with all the header info etc. It seems that once you get that stuff, you really just want the <pTblName> through <pMemo> written for each class. Also, is it possible to coerce the serializer to write the data type of the property into the XML file? It seems like this should be possible but I can't see how. John W. Colby Colby Consulting www.ColbyConsulting.com