public string ExportModule(int moduleId)
{
string strXML = "";
int partModuleId = -1, partPortalId = -1;
ModuleInfo module = ModuleController.Instance.GetModule(moduleId, PortalSettings.Current.ActiveTab.TabID, true);
switch ((string) module.ModuleSettings["Partitioning"])
{
case "1":
partModuleId = moduleId;
break;
case "2":
partPortalId = PortalSettings.Current.PortalId;
break;
}
List<StoryInfo> stories = DbController.Instance.GetStories(partModuleId, partPortalId).ToList();
if (stories.Any())
{
strXML += "<BBImageStories>";
string templateRoot = PortalSettings.Current.HomeDirectoryMapPath + "..\\..\\DesktopModules\\" + module.DesktopModule.FolderName + "\\";
string listTemplateFile = templateRoot + "js\\List\\" + (string)module.ModuleSettings["List"];
string viewTemplateFile = templateRoot + "js\\View\\" + (string)module.ModuleSettings["View"];
if (File.Exists(listTemplateFile))
{
strXML += "<ListTemplate>" +
"<Name>" + XmlUtils.XMLEncode((string) module.ModuleSettings["List"]) + "</Name>" +
"<Content>" + XmlUtils.XMLEncode(File.ReadAllText(listTemplateFile)) + "</Content>" +
"</ListTemplate>";
}
if (File.Exists(viewTemplateFile))
{
strXML += "<ViewTemplate>" +
"<Name>" + XmlUtils.XMLEncode((string)module.ModuleSettings["View"]) + "</Name>" +
"<Content>" + XmlUtils.XMLEncode(File.ReadAllText(viewTemplateFile)) + "</Content>" +
"</ViewTemplate>";
}
strXML += "<ImageWidth>" + XmlUtils.XMLEncode((string)module.ModuleSettings["Width"]) + "</ImageWidth>";
// strXML += "<Partitioning>" + XmlUtils.XMLEncode((string)module.ModuleSettings["Partitioning"]) + "</Partitioning>";
foreach (StoryInfo story in stories)
{
strXML += "<Story>";
strXML += (story.PortalId == null) ? "<PortalId>null</PortalId>" : "<PortalId>" + XmlUtils.XMLEncode(story.PortalId.ToString()) + "</PortalId>";
strXML += (story.ModuleId == null) ? "<ModuleId>null</ModuleId>" : "<ModuleId>" + XmlUtils.XMLEncode(story.ModuleId.ToString()) + "</ModuleId>";
strXML += (story.StartDate == null) ? "<StartDate>null</StartDate>" : "<StartDate>" + ((DateTime) story.StartDate).ToString("d", CultureInfo.InvariantCulture) + "</StartDate>";
strXML += (story.EndDate == null) ? "<EndDate>null</EndDate>" : "<EndDate>" + ((DateTime) story.EndDate).ToString("d", CultureInfo.InvariantCulture) + "</EndDate>";
strXML += "<StoryLangs>";
List<StoryLangInfo> storyLangs = DbController.Instance.GetStoryLangs(story.StoryId).ToList();
foreach (StoryLangInfo storyLang in storyLangs)
{
strXML += "<StoryLang>";
strXML += "<Language>" + storyLang.Language + "</Language>";
strXML += "<Title>" + XmlUtils.XMLEncode(storyLang.Title) + "</Title>";
strXML += "<Story>" + XmlUtils.XMLEncode(storyLang.Story) + "</Story>";
strXML += "</StoryLang>";
}
strXML += "</StoryLangs>";
strXML += "<Images>";
List<ImageLocInfo> images = DbController.Instance.GetImagesByForeign(story.StoryId, "STORY").ToList();
foreach (ImageLocInfo image in images)
{
strXML += "<Image>";
strXML += "<ViewOrder>" + image.ViewOrder.ToString() + "</ViewOrder>";
strXML += "<FileName>" + image.FileName + "</FileName>";
strXML += "<ImageData>" + GetImageData(image) + "</ImageData>";
List<ImageLangInfo> imageLangs = DbController.Instance.GetImageLangs(image.ImageId).ToList();
strXML += "<ImageLangs>";
foreach (ImageLangInfo imageLang in imageLangs)
{
strXML += "<ImageLang>";
strXML += "<Language>" + imageLang.Language + "</Language>";
strXML += "<ShortDescription>" + XmlUtils.XMLEncode(imageLang.ShortDescription) + "</ShortDescription>";
strXML += "<LongDescription>" + XmlUtils.XMLEncode(imageLang.LongDescription) + "</LongDescription>";
strXML += "</ImageLang>";
}
strXML += "</ImageLangs>";
strXML += "</Image>";
}
strXML += "</Images>";
strXML += "</Story>";
}
strXML += "</BBImageStories>";
}
return strXML;
}