/// <summary>
    /// Gets content for row with persona image and display name.
    /// </summary>
    /// <returns>Modified content of given row</returns>
    private object SetPersonaImageAndDisplayName(object sender, string sourceName, object parameter, object value)
    {
        switch (sourceName.ToLowerCSafe())
        {
        // Get content for row with persona name
        case "itemname":
        {
            LinkButton  btn = value as LinkButton;
            DataRowView drv = parameter as DataRowView;

            if ((btn == null) || (drv == null))
            {
                return(value);
            }

            var persona = PersonaInfoProvider.GetPersonaInfoById(ValidationHelper.GetInteger(drv.Row["PersonaID"], 0));

            string imgTag = mPersonaPictureImgTagGenerator.GenerateImgTag(persona, 50);

            if (imgTag != null)
            {
                btn.Text = imgTag + "<span class=\"personas-table-persona-name\">" + HTMLHelper.HTMLEncode(persona.PersonaDisplayName) + "</span>";
            }
            return(btn);
        }
        }

        return(value);
    }
    protected void Page_Init(object sender, EventArgs e)
    {
        // Request to this page has to have all three following query parameters set
        int personaId = QueryHelper.GetInteger("personaid", 0);

        // Persona has to be connected with current score
        var personaInfo = PersonaInfoProvider.GetPersonaInfoById(personaId);

        if (personaInfo == null)
        {
            RedirectToAccessDenied(GetString("general.invalidparameters"));
        }

        if (!personaInfo.CheckPermissions(PermissionsEnum.Read, CurrentSiteName, CurrentUser))
        {
            RedirectToAccessDenied(personaInfo.TypeInfo.ModuleName, "Read");
        }

        RuleInfo rule = EditedObject as RuleInfo;

        // Editing existing rule
        if (rule != null)
        {
            // Rule has to be connected with current score
            if ((rule.RuleScoreID != personaInfo.PersonaScoreID))
            {
                RedirectToAccessDenied(GetString("general.invalidparameters"));
            }
        }

        editElem.ResourceName           = ModuleName.PERSONAS;
        editElem.ScoreId                = personaInfo.PersonaScoreID;
        editElem.NewRuleUrl             = string.Format("Tab_Rules_Edit.aspx?personaid={0}", personaId);
        editElem.RedirectUrlAfterCreate = string.Format("Tab_Rules_Edit.aspx?ruleid={{%EditedObject.ID%}}&personaid={0}&saved=1", personaId);
    }
示例#3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        var personaInfo = PersonaInfoProvider.GetPersonaInfoById(Value.ToInteger(0));

        string personaPictureUrl;

        if (personaInfo == null)
        {
            lblPersonaName.Text           = GetString("general.empty");
            personaPictureUrl             = PersonasFactory.GetPersonaPictureUrlCreator().CreateDefaultPersonaPictureUrl(32);
            imgPersonaImage.AlternateText = GetString("general.empty");
        }
        else
        {
            divPersonaInfoContent.Attributes["title"] = personaInfo.PersonaDescription;
            lblPersonaName.Text           = HTMLHelper.HTMLEncode(personaInfo.PersonaDisplayName);
            personaPictureUrl             = PersonasFactory.GetPersonaPictureUrlCreator().CreatePersonaPictureUrl(personaInfo, 32);
            imgPersonaImage.AlternateText = HTMLHelper.HTMLEncode(personaInfo.PersonaDisplayName);
        }

        if (personaPictureUrl != null)
        {
            imgPersonaImage.ImageUrl = personaPictureUrl;
        }
        else
        {
            imgPersonaImage.Visible = false;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Check that the control is included in CMSPage (otherwise an exception is thrown on the Design tab)
        var page = Page as CMSPage;

        if (page == null)
        {
            return;
        }

        int personaID = QueryHelper.GetInteger("personaid", 0);

        if (personaID > 0)
        {
            PersonaInfo persona = PersonaInfoProvider.GetPersonaInfoById(personaID);
            if (persona != null)
            {
                // Display number of contacts in persona
                int personaContactCount = PersonasFactory.GetPersonaService().GetContactsForPersona(persona).Count;
                lblCount.InnerText = String.Format(GetString("personas.ui.contactcount"), personaContactCount);

                // Display ratio of the number of contacts in persona to the number of all contacts
                int totalContactCount = ContactInfoProvider.GetContacts()
                                        .OnSite(SiteContext.CurrentSiteID)
                                        .WhereNull("ContactMergedWithContactID")
                                        .Count;

                double ratio = (totalContactCount == 0) ? 0 : (double)personaContactCount / totalContactCount * 100;
                lblRatio.InnerText = String.Format(GetString("personas.ui.contactratio"), ratio);
            }
        }
    }
    /// <summary>
    /// Gets content for row with persona image and display name.
    /// </summary>
    /// <returns>Modified content of given row</returns>
    private object SetPersonaImageAndDisplayName(object sender, string sourceName, object parameter)
    {
        switch (sourceName)
        {
        // Get content for row with persona image and name
        case "PersonaNameAndImage":
        {
            var persona = PersonaInfoProvider.GetPersonaInfoById(ValidationHelper.GetInteger(parameter, 0));

            string imgTag = mPersonaPictureImgTagGenerator.GenerateImgTag(persona, 50);

            string encodedPersonaDisplayName = HTMLHelper.HTMLEncode(persona.PersonaDisplayName);

            // Show only display name of persona when persona does not have image and default image is not specified
            if (imgTag == null)
            {
                return(encodedPersonaDisplayName);
            }

            return(imgTag + "<span class=\"personas-table-persona-name\">" + encodedPersonaDisplayName + "</span>");
        }
        }

        return(parameter);
    }
示例#6
0
    /// <summary>
    /// Obtains current PersonaInfo object.
    /// </summary>
    /// <returns>Current PersonaInfo object</returns>
    private PersonaInfo GetCurrentPersonaInfo()
    {
        var personaID = ((PersonaInfo)((CMSPage)Control.Page).EditedObjectParent).PersonaID;

        return(PersonaInfoProvider.GetPersonaInfoById(personaID));
    }