Exemplo n.º 1
0
    public override void LoadWidget()
    {
        ASPCache         aspCache = new ASPCache(this.Page);
        StringDictionary settings = GetSettings();
        List <Ad>        ads      = AdManagementBase.DeSerializeAds(settings[AdManagemenConstants.AdCollectionKey]);

        ads.ForEach(delegate(Ad ad) { totalWeight += ad.RWeight; });

        Boolean hideForAuthenticatedUsers = true;

        Boolean.TryParse(settings[AdManagemenConstants.HideAdsForAuthZUsersKey], out hideForAuthenticatedUsers);

        adManager = new AdManagementBase(aspCache, ads);

        if (!IsPostBack)
        {
            if ((!System.Threading.Thread.CurrentPrincipal.Identity.IsAuthenticated) || (!hideForAuthenticatedUsers))
            {
                ShowAds(totalWeight);
            }
            else
            {
                adHolder.InnerHtml = AdManagemenConstants.AuthZUserMessage;
            }
        }
    }
Exemplo n.º 2
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());
        }
    }
Exemplo n.º 3
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();
    }
Exemplo n.º 4
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;
    }
Exemplo n.º 5
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();
    }