Ticket T513951
Visible to All Users

Solution provided in T321618 doesn't work in my project

created 8 years ago

[DevExpress Support Team: CLONED FROM T321618: Web - How to display the currently logged user name and image in the header bar near the Log Off Action]
Hi Konstantin,

I have follow the blog on http://dennisgaravsky.blogspot.co.id/2016/12/displaying-currently-logged-user-name.html

but it only show user name, no image, whats wrong ? not even after i reduce photo size (see the picture attached)

this is my security user class

using System;
using System.Linq;
using System.Text;
using DevExpress.Xpo;
using DevExpress.ExpressApp;
using System.ComponentModel;
using DevExpress.ExpressApp.DC;
using DevExpress.Data.Filtering;
using DevExpress.Persistent.Base;
using System.Collections.Generic;
using DevExpress.ExpressApp.Model;
using DevExpress.Persistent.BaseImpl;
using DevExpress.Persistent.Validation;
using DevExpress.Persistent.BaseImpl.PermissionPolicy;

namespace ELS2018.Module.BusinessObjects
{
    [DefaultProperty("UserName"), XafDisplayName("Limited User")]
    [CurrentUserDisplayImage("Photo")]
    //[ImageName("BO_Contact")]
    //[DefaultProperty("DisplayMemberNameForLookupEditorsOfThisType")]
    //[DefaultListViewOptions(MasterDetailMode.ListViewOnly, false, NewItemRowPosition.None)]
    //[Persistent("DatabaseTableName")]
    // Specify more UI options using a declarative approach (https://documentation.devexpress.com/#eXpressAppFramework/CustomDocument112701).
    public class SecurityUser : PermissionPolicyUser
    { // Inherit from a different class to provide a custom primary key, concurrency and deletion behavior, etc. (https://documentation.devexpress.com/eXpressAppFramework/CustomDocument113146.aspx).
        public SecurityUser(Session session)
            : base(session)
        {
        }
        private Branch company;
        [Association("Branch-Users")]
        public Branch Company
        {
            get { return company; }
            set { SetPropertyValue("Company", ref company, value); }
        }

private String userserver;
        [XafDisplayName("Server")]
        public String UserServer
        {
            get { return userserver; }
            set { SetPropertyValue("UserServer", ref userserver, value); }
        }

private String userdatabase;
        [XafDisplayName("Database")]
        public String UserDatabase
        {
            get { return userdatabase; }
            set { SetPropertyValue("UserDatabase", ref userdatabase, value); }
        }

public virtual MediaDataObject Photo { get; set; }

[Association("Users-Customers")]
        public XPCollection<Customer> Customers
        {
            get { return GetCollection<Customer>("Customers"); }
        }

public override void AfterConstruction()
        {
            base.AfterConstruction();
            // Place your initialization code here (https://documentation.devexpress.com/eXpressAppFramework/CustomDocument112834.aspx).
        }
        //private string _PersistentProperty;
        //[XafDisplayName("My display name"), ToolTip("My hint message")]
        //[ModelDefault("EditMask", "(000)-00"), Index(0), VisibleInListView(false)]
        //[Persistent("DatabaseColumnName"), RuleRequiredField(DefaultContexts.Save)]
        //public string PersistentProperty {
        //    get { return _PersistentProperty; }
        //    set { SetPropertyValue("PersistentProperty", ref _PersistentProperty, value); }
        //}

//[Action(Caption = "My UI Action", ConfirmationMessage = "Are you sure?", ImageName = "Attention", AutoCommit = true)]
        //public void ActionMethod() {
        //    // Trigger a custom business logic for the current record in the UI (https://documentation.devexpress.com/eXpressAppFramework/CustomDocument112619.aspx).
        //    this.PersistentProperty = "Paid";
        //}
    }
}

Konstantin B (DevExpress) >

Please run the Model Editor for the ASP.NET module or application project and ensure that the  IModelApplicationWeb.CurrentUserDisplayMode property is set to CaptionAndImage.

Additionally, if you store the model differences in the database, ensure that this setting is not overridden accidentally at the database level. If this does not help, would you please create a separate ticket and attach a sample project that shows this issue?

PS: the virtual modifier is not required for the Photo property in an XPO persistent class. An example from the blog you are referring to is for Entity Framework.

ADE AAN WIRAMA >

I did choose CaptionAndImage, but its not working. I'm sure its not overridden at database level. (see Screenshot_27)

Answers approved by DevExpress Support

created 8 years ago (modified 8 years ago)

Hello Ade.

Please verify that your custom user class is selected as the SecurityStrategy.UserType property value.

Also refer to the BLOB Image Properties in XPO help topic to learn how to implement image properties.

    Comments (1)
    A A
    ADE AAN WIRAMA. 8 years ago

      Hi Michael,

      SecurityStrategy.UserType is the answer.

      Thanks !!

      Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

      Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.