Exemple #1
0
    protected override void  OnLoad(EventArgs e)
    {
        base.OnLoad(e);

        if (!Page.IsPostBack)
        {
            CurrentIndex = 0;
            StringDictionary settings = GetSettings();
            adCollection = AdManagementBase.DeSerializeAds(settings[AdManagemenConstants.AdCollectionKey]);

            if ((adCollection == null) || (adCollection.Count < 1))
            {
                adCollection = new List <Ad>();
                Ad defaultAd = new Ad(Guid.NewGuid(), AdManagemenConstants.DefaultAdText, AdManagemenConstants.DefaultAdName, AdManagemenConstants.DefaultAdWeight);
                adCollection.Add(defaultAd);
            }
            cbAuthZAds.Checked = ((settings[AdManagemenConstants.HideAdsForAuthZUsersKey] != null) && (settings[AdManagemenConstants.HideAdsForAuthZUsersKey].ToLower() == true.ToString().ToLower())) ? true : false;
            DisplayData();
            HttpRuntime.Cache[AdManagemenConstants.SerializedAdsKey] = AdManagementBase.SerializeAds(adCollection);
        }
        else
        {
            adCollection = AdManagementBase.DeSerializeAds(HttpRuntime.Cache[AdManagemenConstants.SerializedAdsKey].ToString());
        }
    }
Exemple #2
0
    protected void doUpdate()
    {
        adCollection[CurrentIndex].TagName = txtName.Text;
        adCollection[CurrentIndex].Script  = txtTag.Text;
        int rw = 0;

        Int32.TryParse(txtWeight.Text, out rw);
        adCollection[CurrentIndex].RWeight = rw;
        HttpRuntime.Cache[AdManagemenConstants.SerializedAdsKey] = AdManagementBase.SerializeAds(adCollection);
        DisplayData();
    }
Exemple #3
0
    public override void Save()
    {
        doUpdate();
        StringDictionary settings = GetSettings();

        settings[AdManagemenConstants.AdCollectionKey]         = AdManagementBase.SerializeAds(adCollection);
        settings[AdManagemenConstants.HideAdsForAuthZUsersKey] = cbAuthZAds.Checked.ToString();
        SaveSettings(settings);
        HttpRuntime.Cache.Remove(AdManagemenConstants.WidgetSettingsKey);
        HttpRuntime.Cache.Remove(AdManagemenConstants.SerializedAdsKey);
        CurrentIndex = 0;
    }
Exemple #4
0
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        adCollection.RemoveAt(CurrentIndex);
        HttpRuntime.Cache[AdManagemenConstants.SerializedAdsKey] = AdManagementBase.SerializeAds(adCollection);
        CurrentIndex--;
        if ((adCollection.Count > 1) && (CurrentIndex < 0))
        {
            CurrentIndex = 0;
        }

        DisplayData();
    }