Developer forum

Forum » Development » Atempting to modify the standard CsvDestinationWriter

Atempting to modify the standard CsvDestinationWriter

Michael Pedersen
Reply

I am trying to modify functionality of the standard CSVDestinationProvider (in specific naming of the output file).

what i'm doing is:

    class ExtendedCsvDestinationWriter : CsvDestinationWriter
    {
        private readonly string _path;
        private TextWriter _writer;
        protected override TextWriter Writer
        {
            get
            {
                if (_writer == null)
                {
                    _writer = new StreamWriter(_path + "/" +
                      Mapping.DestinationTable.Name + DateTime.Now.ToString("yyyyMMddHHmm") + ".csv");
                }
                return _writer;
            }
            set { _writer = value; }
        }
    }

this doesn't work since the get/set methods aren't overrideable, but what i'm trying to do should be clear.

Is there a way i can make this work without having to recreate all of the logic in CsvDestinationProvider and CsvDestinationWriter?

Note that the only change from the standard functionality is to ad a timestamp to the name of the file.

 

 


Replies

 
Jonas Krarup Dam
Reply
This post has been marked as an answer

Hi Michael.

First of all, this option of including a timestamp in the output filename has been implemented in the standard CSVProvider, and will be released with 8.4, at the end of January.

 

If you can't wait for this release, you'll have to find a different solution.

I don't see how you can (easily) change the file that is written to - a different option would be to rename the file after the export has been completed. 

You could do that in a way similar to the one shown in this video I made a while back, at around the 4 minute mark:

http://engage.dynamicweb.dk/Video-Library-1337.aspx?categoryfilter=erp#vimeo_61341984

but replace the logging with something like:

 

 

 

foreach (var aMapping in job.Mappings)
                {
                    File.Move(aMapping.DestinationTable.Name + ".csv", aMapping.DestinationTable.Name + DateTime.Now.ToString() + ".csv");
                }

 

If, for some reason, this solution is unacceptable, let me know, and we'll see what else we can come up with.

 

Regards, Jonas

 

 

 

 

Votes for this answer: 1
 
Michael Pedersen
Reply

Hi Jonas

Thanks for the quick reply.

Good to hear that the function is comming soon. My client is content with waiting  for that instead of wasting time implementing a temporary solution.

 

 

 

You must be logged in to post in the forum