using System;
using System.Web;
using CMS.CMSHelper;
using CMS.GlobalHelper;
using CMS.PortalControls;
using CMS.WebAnalytics;
public partial class CMSWebParts_BizForms_bizform : CMSAbstractWebPart
{
#region "Properties"
///
/// Gets or sets the form name of BizForm.
///
public string BizFormName
{
get
{
return ValidationHelper.GetString(GetValue("BizFormName"), "");
}
set
{
SetValue("BizFormName", value);
}
}
///
/// Gets or sets the alternative form full name (ClassName.AlternativeFormName).
///
public string AlternativeFormName
{
get
{
return ValidationHelper.GetString(GetValue("AlternativeFormName"), "");
}
set
{
SetValue("AlternativeFormName", value);
}
}
///
/// Gets or sets the site name.
///
public string SiteName
{
get
{
return ValidationHelper.GetString(GetValue("SiteName"), "");
}
set
{
SetValue("SiteName", value);
}
}
///
/// Gets or sets the value that indicates whether the WebPart use colon behind label.
///
public bool UseColonBehindLabel
{
get
{
return ValidationHelper.GetBoolean(GetValue("UseColonBehindLabel"), true);
}
set
{
SetValue("UseColonBehindLabel", value);
}
}
///
/// Gets or sets the message which is displayed after validation failed.
///
public string ValidationErrorMessage
{
get
{
return ValidationHelper.GetString(GetValue("ValidationErrorMessage"), "");
}
set
{
SetValue("ValidationErrorMessage", value);
}
}
///
/// Gets or sets the conversion track name used after successful registration.
///
public string TrackConversionName
{
get
{
return ValidationHelper.GetString(GetValue("TrackConversionName"), "");
}
set
{
if (value.Length > 400)
{
value = value.Substring(0, 400);
}
SetValue("TrackConversionName", value);
}
}
///
/// Gets or sets the conversion value used after successful registration.
///
public double ConversionValue
{
get
{
return ValidationHelper.GetDoubleSystem(GetValue("ConversionValue"), 0);
}
set
{
SetValue("ConversionValue", value);
}
}
#endregion
#region "Methods"
protected override void OnLoad(EventArgs e)
{
viewBiz.OnAfterSave += viewBiz_OnAfterSave;
base.OnLoad(e);
}
///
/// Content loaded event handler.
///
public override void OnContentLoaded()
{
base.OnContentLoaded();
SetupControl();
}
///
/// Reloads data for partial caching.
///
public override void ReloadData()
{
base.ReloadData();
SetupControl();
}
///
/// Initializes the control properties.
///
protected void SetupControl()
{
if (StopProcessing)
{
// Do nothing
viewBiz.StopProcessing = true;
}
else
{
// Set BizForm properties
viewBiz.FormName = BizFormName;
viewBiz.SiteName = SiteName;
viewBiz.UseColonBehindLabel = UseColonBehindLabel;
viewBiz.AlternativeFormFullName = AlternativeFormName;
viewBiz.ValidationErrorMessage = ValidationErrorMessage;
// Set the live site context
if (viewBiz.BasicForm != null)
{
viewBiz.BasicForm.ControlContext.ContextName = CMS.SiteProvider.ControlContext.LIVE_SITE;
}
}
}
private void viewBiz_OnAfterSave(object sender, EventArgs e)
{
if (TrackConversionName != String.Empty)
{
string siteName = CMSContext.CurrentSiteName;
if (AnalyticsHelper.AnalyticsEnabled(siteName) && AnalyticsHelper.TrackConversionsEnabled(siteName) && !AnalyticsHelper.IsIPExcluded(siteName, HTTPHelper.UserHostAddress))
{
HitLogProvider.LogConversions(CMSContext.CurrentSiteName, CMSContext.PreferredCultureCode, TrackConversionName, 0, ConversionValue);
}
}
}
#endregion
}