コード例 #1
0
    protected object GetDisplay(object dataItem, string propertyName)
    {
        if (string.IsNullOrEmpty(CurUserId))
        {
            var userServ = ApplicationContext.Current.Services.Get <IUserService>();
            if (userServ != null)
            {
                CurUserId = userServ.UserId;
            }
        }
        var view = dataItem as ComponentView;

        if (view != null)
        {
            if (view.IsVirtualComponent)
            {
                object ActUserId;
                object ActType;
                object value;
                if (view.VirtualComponentProperties.TryGetValue("UserId", out ActUserId) &&
                    view.VirtualComponentProperties.TryGetValue("Type", out ActType))
                {
                    if (ActType.Equals(ActivityType.atPersonal) && ActUserId.ToString() != CurUserId)
                    {
                        return((propertyName == "Description" || propertyName == "Category")
                             ? GetActivityTypeName("Activity_Personal_Name", "Personal")
                             : string.Empty);
                    }

                    if (view.VirtualComponentProperties.TryGetValue(propertyName, out value))
                    {
                        return(value);
                    }
                }
            }
            else
            {
                return(DataBinder.Eval(dataItem, propertyName));
            }
        }
        return(string.Empty);
    }