using System; using System.Data; using System.Collections; using System.Web; using System.Web.UI; using CMS.GlobalHelper; using CMS.PortalControls; using CMS.Reporting; using CMS.WebAnalytics; using CMS.CMSHelper; using CMS.PortalEngine; public partial class CMSWebParts_Reporting_Chart : CMSAbstractWebPart { #region "Properties" /// /// Gets or sets chart name in format reportname;itemname. /// public string ChartName { get { return ValidationHelper.GetString(GetValue("ReportChart"), String.Empty); } set { SetValue("ReportChart", value); } } /// /// Gets or sets the XML schema of parameters dataset. /// public string ParametersXmlSchema { get { return ValidationHelper.GetString(GetValue("ParametersXmlSchema"), String.Empty); } set { SetValue("ParametersXmlSchema", value); } } /// /// Gets or sets chart name in format reportname;itemname. /// public string ParametersXmlData { get { return ValidationHelper.GetString(GetValue("ParametersXmlData"), String.Empty); } set { SetValue("ParametersXmlData", value); } } /// /// Gets or sets width of graph. /// public String Width { get { return ValidationHelper.GetString(GetValue("Width"), String.Empty); } set { SetValue("Width", value); } } /// /// Interval of time range. /// public HitsIntervalEnum RangeInterval { get { return HitsIntervalEnumFunctions.StringToHitsConversion(ValidationHelper.GetString(GetValue("Range"), "none")); } set { SetValue("Range", HitsIntervalEnumFunctions.HitsConversionToString(value)); } } /// /// Value of range interval. /// public int RangeValue { get { return ValidationHelper.GetInteger(GetValue("RangeValue"), 0); } set { SetValue("RangeValue", value); } } /// /// Gets or sets height of graph. /// public int Height { get { return ValidationHelper.GetInteger(GetValue("Height"), 0); } set { SetValue("Height", value); } } /// /// Indicates whether enable export /// public bool EnableExport { get { return ValidationHelper.GetBoolean(GetValue("EnableExport"), true); } set { SetValue("EnableExport", value); } } /// /// If true, chart subscription is enabled /// public bool EnableSubscription { get { return ValidationHelper.GetBoolean(GetValue("EnableSubscription"), false); } set { SetValue("EnableSubscription", value); } } /// /// Graph possible width of control. /// public int AreaMaxWidth { get { return ValidationHelper.GetInteger(ViewState["AreaMaxWidth"], 0); } set { ViewState["AreaMaxWidth"] = value; } } #endregion #region "Methods" /// /// Content loaded event handler. /// public override void OnContentLoaded() { base.OnContentLoaded(); SetupControl(); } /// /// Initializes the control properties. /// protected void SetupControl() { if (StopProcessing) { // Do nothing } else { string[] items = ChartName.Split(';'); if ((items != null) && (items.Length == 2)) { ucGraph.Parameter = items[0] + "." + items[1]; ucGraph.ReportItemName = items[0] + ";" + items[1]; ucGraph.CacheItemName = CacheItemName; ucGraph.CacheMinutes = CacheMinutes; ucGraph.CacheDependencies = CacheDependencies; ucGraph.Width = Width; ucGraph.Height = Height; ucGraph.ItemType = ReportItemType.Graph; ucGraph.LoadDefaultParameters(ParametersXmlData, ParametersXmlSchema); ucGraph.RangeInterval = RangeInterval; ucGraph.RangeValue = RangeValue; ucGraph.EnableExport = EnableExport; ucGraph.EnableSubscription = EnableSubscription; ucGraph.IsLiveSite = (CMSContext.ViewMode == ViewModeEnum.LiveSite); } } } /// /// Reloads data. /// public override void ReloadData() { base.ReloadData(); SetupControl(); } /// /// OnPreRender override - set visibility. /// protected override void OnPreRender(EventArgs e) { // Set visibility of current webpart with dependence on graph visibility Visible = ucGraph.Visible; if (AreaMaxWidth != 0) { ucGraph.ComputedWidth = AreaMaxWidth; } ucGraph.ReloadData(true); if (ucGraph.ComputedWidth != 0) { AreaMaxWidth = ucGraph.ComputedWidth; } base.OnPreRender(e); } #endregion }