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; } var persona = UIContext.EditedObjectParent as PersonaInfo; if (persona == null) { return; } // 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().Count; double ratio = (totalContactCount == 0) ? 0 : (double)personaContactCount / totalContactCount * 100; lblRatio.InnerText = String.Format(GetString("personas.ui.contactratio"), ratio); }
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> /// Updates UniGrid to display the same contacts as the ones in the given ObjectQuery (filters out contacts not related to current persona). /// </summary> private void UpdateGridWithObjectQuery() { var objectQuery = PersonasFactory.GetPersonaService().GetContactsForPersona(GetCurrentPersonaInfo()); if (Control.QueryParameters == null) { Control.QueryParameters = objectQuery.Parameters; } else { foreach (var param in objectQuery.Parameters) { Control.QueryParameters.Add(param); } } Control.WhereCondition = new WhereCondition(Control.GetFilter()).Where(objectQuery.WhereCondition).WhereCondition; }