/// ----------------------------------------------------------------------------- /// <summary> /// GetParentSkin gets the Parent Skin for a control /// </summary> /// <param name="module">The control whose Parent Skin is requested</param> /// ----------------------------------------------------------------------------- public static Skin GetParentSkin(PortalModuleBase module) { return(GetParentSkin(module as Control)); }
public static void AddModuleMessage(PortalModuleBase control, string heading, string message, ModuleMessage.ModuleMessageType moduleMessageType) { AddModuleMessage(control, heading, message, moduleMessageType, Null.NullString); }
/// ----------------------------------------------------------------------------- /// <summary> /// Executes a report and returns the results /// </summary> /// <param name="objReport">The ReportInfo object</param> /// <param name="cacheKey">The cache key for the module</param> /// <param name="bypassCache">A boolean indicating that the cache should be bypassed</param> /// <param name="hostModule">The module that is hosting the report</param> /// <param name="fromCache">A boolean indicating if the data was retrieved from the cache</param> /// <exception cref="System.ArgumentNullException"> /// The value of <paramref name="objReport" /> was null (Nothing in Visual Basic) /// </exception> /// <history> /// [anurse] 08/25/2007 Created /// </history> /// ----------------------------------------------------------------------------- public static DataTable ExecuteReport(ReportInfo objReport, string cacheKey, bool bypassCache, PortalModuleBase hostModule, ref bool fromCache) { try { fromCache = false; if (ReferenceEquals(objReport, null)) { throw new ArgumentNullException("objReport"); } if (string.IsNullOrEmpty(objReport.DataSource)) { return(null); // If there's no data source, there's no report } // Check the cache DataTable results = null; if (!bypassCache) { results = DataCache.GetCache(cacheKey) as DataTable; if (results != null) { fromCache = true; return(results); } } // Get an instance of the data source //DotNetNuke.Modules.Reports.DataSources.IDataSource dataSource = GetDataSource(objReport.DataSourceClass) as DataSources.IDataSource; var dataSource = GetDataSource(objReport.DataSourceClass); // Create an extension context var moduleFolder = string.Empty; if (hostModule != null) { moduleFolder = hostModule.TemplateSourceDirectory; } var ctxt = new ExtensionContext(moduleFolder, "DataSource", objReport.DataSource); // Load Parameters IDictionary <string, object> parameters = BuildParameters(hostModule, objReport); if (objReport.CacheDuration != 0) { // Check the app setting if (!"True".Equals( WebConfigurationManager.AppSettings[ReportsConstants.APPSETTING_AllowCachingWithParameters], StringComparison.InvariantCulture)) { parameters.Clear(); } } // Execute the report dataSource.Initialize(ctxt); results = dataSource.ExecuteReport(objReport, hostModule, parameters).ToTable(); results.TableName = "QueryResults"; // Check if the converters were run if (!dataSource.CanProcessConverters) { // If not, run them the slow way :( foreach (DataRow row in results.Rows) { foreach (DataColumn col in results.Columns) { if (!objReport.Converters.ContainsKey(col.ColumnName)) { continue; } var list = objReport.Converters[col.ColumnName]; foreach (var converter in list) { row[col] = ApplyConverter(row[col], converter.ConverterName, converter.Arguments); } } } } // Do the token replace if specified if (objReport.TokenReplace) { var localTokenReplacer = new TokenReplace(); foreach (DataColumn col in results.Columns) { // Process each column of the resultset if (col.DataType == typeof(string)) { // We want to replace the data, we don't mind that it is marked as readonly if (col.ReadOnly) { col.ReadOnly = false; } var maxLength = col.MaxLength; var resultText = ""; foreach (DataRow row in results.Rows) { resultText = localTokenReplacer.ReplaceEnvironmentTokens(Convert.ToString(row[col].ToString())); // Don't make it too long if (resultText.Length > maxLength) { resultText = resultText.Substring(0, maxLength); } row[col] = resultText; } } } } // Cache it, if not asked to bypass the cache if (!bypassCache && results != null) { DataCache.SetCache(cacheKey, results); } // Return the results return(results); } catch (DataSourceException) { throw; //Catch ex As Exception // If hostModule IsNot Nothing Then // Throw New DataSourceException("UnknownError.Text", hostModule.LocalResourceFile, ex, ex.Message) // Else // Throw // End If } }