Are you looking for a way to import and/or export Commerce Server 2007 Marketing data?
The following code samples show how to to export and import all CS2007 Marketing System data. The first sample uses the MarketingPup.Export method to extract the data and create a XML file with all content.
1: using System;
2: using System.IO;
3: using Microsoft.CommerceServer.Internal.Marketing;
4: using Microsoft.CommerceServer.Runtime.Configuration;
5:
6: namespace ExportMarketingData
7: {
8: class ExportMarketingData
9: {
10: static void Main(string[] args)
11: {
12: if (args.Length != 2)
13: {
14: Console.WriteLine("Exports a Microsoft Commerce Server site's Marketing resource to a file.");
15: Console.WriteLine("ExportMarketingData.exe [sitename] [export directory]");
16: return;
17: }
18:
19: // let Pup validate the site so we get a descriptive error if something is wrong
20: string sitename = args[0];
21:
22: // validate export directory exists
23: string exportDirectory = args[1];
24: DirectoryInfo dirInfo = new DirectoryInfo(exportDirectory);
25: if (!dirInfo.Exists)
26: {
27: Console.WriteLine("The specified output directory {0} does not exist", exportDirectory);
28: return;
29: }
30:
31: // validate export file does not exist
32: FileInfo fileInfo = new FileInfo(Path.Combine(exportDirectory, "MarketingData.xml"));
33: if (fileInfo.Exists)
34: {
35: Console.WriteLine("Cannot overwrite existing file {0}", fileInfo.FullName);
36: return;
37: }
38:
39: // do the export
40: MarketingPup pup = new MarketingPup();
41: pup.Export(sitename, "Marketing", exportDirectory, 0, 0);
42:
43: // print success
44: Console.WriteLine("Exported file {0}", fileInfo.FullName);
45: }
46: }
47: }
The second sample uses the MarketingPup.Import method to import the marketing data from a XML file.
6: namespace ImportMarketingData
8: class ImportMarketingData
14: Console.WriteLine("Imports a Microsoft Commerce Server site's Marketing resource file.");
15: Console.WriteLine("ImportMarketingData.exe [sitename] [import directory]");
19: // let Pup validates the site so we get a descriptive error if something is wrong
22: string importDirectory = args[1];
23:
24: DirectoryInfo dirInfo = new DirectoryInfo(importDirectory);
27: Console.WriteLine("The specified input directory {0} does not exist", importDirectory);
31: // do the import
32: MarketingPup pup = new MarketingPup();
33: pup.Import(sitename, "Marketing", importDirectory, 0);
34:
35: // print success
36: Console.WriteLine("Imported file {0}", dirInfo.FullName);
38: }
39: }
The code samples described here can be used to create console tools or event processing components to do bulk exports and imports to/from the CS2007 Marketing System.
I've also attached a Visual Studio solution containing two console tools to export/import marketing data.
Regards, Cris.
This posting is provided "AS IS" with no warranties, and confers no rights.