/// ----------------------------------------------------------------------------- /// <summary> /// ImportModule implements the IPortable ImportModule Interface /// </summary> /// <remarks> /// </remarks> /// <param name="ModuleID">The Id of the module to be imported</param> /// <param name="Content">The content to be imported</param> /// <param name="Version">The version of the module to be imported</param> /// <param name="UserId">The Id of the user performing the import</param> /// <history> /// [anurse] 06/16/2006 Created /// </history> /// ----------------------------------------------------------------------------- public void ImportModule(int ModuleID, string Content, string Version, int UserId) { // Check Access and Version var objUser = UserController.Instance.GetCurrentUserInfo(); if (ReferenceEquals(objUser, null) || !objUser.IsSuperUser) { return; } var objNewReport = new ReportInfo(); var xmlDoc = new XmlDocument(); xmlDoc.LoadXml(string.Format("<content>{0}</content>", Content)); var xmlRoot = xmlDoc.DocumentElement; objNewReport.Title = XmlUtils.GetNodeValue(xmlRoot, "title", string.Empty); objNewReport.Description = XmlUtils.GetNodeValue(xmlRoot, "description", string.Empty); objNewReport.CreatedOn = DateTime.Now; objNewReport.CreatedBy = UserId; var ver = new Version(Version); if (ver.Major == 4) { var sQuery = XmlUtils.GetNodeValue(xmlRoot, "query", string.Empty); if (ver.Minor < 4) { var queryBytes = Convert.FromBase64String(sQuery); sQuery = Encoding.Default.GetString(queryBytes); } objNewReport.DataSource = "DotNetNuke.Modules.Reports.DataSources.DNNDataSource"; objNewReport.DataSourceSettings.Add("Query", sQuery); } else { // Load converters foreach (XmlElement xmlElement in xmlRoot.SelectNodes("converters/converter")) { var newConverter = new ConverterInstanceInfo(); newConverter.ConverterName = xmlElement.GetAttribute("name"); newConverter.FieldName = xmlElement.GetAttribute("field"); newConverter.Arguments = xmlElement.InnerText.Split(','); ConverterUtils.AddConverter(objNewReport.Converters, newConverter); } var dsElement = (XmlElement)xmlRoot.SelectSingleNode("datasource"); objNewReport.DataSource = dsElement.GetAttribute("type"); objNewReport.DataSourceClass = dsElement.GetAttribute("class"); objNewReport.DataSourceSettings = ReadSettingsDictionary(dsElement); } // Can't do this because Import/Export module does not have a TabModuleID //Dim visElement As XmlElement = DirectCast(xmlRoot.SelectSingleNode("visualizer"), XmlElement) //objNewReport.CacheDuration = XmlUtils.GetNodeValue(xmlRoot, "cacheDuration", String.Empty) //objNewReport.Visualizer = visElement.GetAttribute("name") //objNewReport.VisualizerSettings = ReadSettingsDictionary(visElement) UpdateReportDefinition(ModuleID, objNewReport); ClearCachedResults(ModuleID); }