Tuesday, February 16, 2010

New MemberLevel Security module

eXpand has a new module that make its easy to protect selected members from selected object instances.

It does the above by checking if in the current system has been granted a eXpand.ExpressApp.MemberLevelSecurity.Win.Security.ProtectRowMemberPermission with an allow Modifier.

Then it will allow you to protect selected members of an object as shown in the image

image

above I have protected (minus sign) boths phones but not the fax (plus sign). So a user that do not have permission will see

image

or for listviews

image

There is also a non object instance depented permission for use as suggested by K18110

image

So when you create a new role you have to add the following permision by default

role.AddPermission(new MemberAccessPermission(typeof (object), null, MemberOperation.Read,

                                              ObjectAccessModifier.Allow));

role.AddPermission(new MemberAccessPermission(typeof (object), null, MemberOperation.Write,

                                              ObjectAccessModifier.Allow));

if you do not use eXpand new project item VS template then you have to manually reference

eXpand.ExpressApp.MemberLevelSecurity.dll,eXpand.ExpressApp.MemberLevelSecurity.Win.dll

Subscribe to XAF feed
Subscribe to community feed

DiggIt!

Thursday, February 11, 2010

Exception handling module

eXpand has some time now an Exception Handling module that has not being introduced at all


To install it ExceptionHandling.dll and ExceptionHandling.Win.dll or ExceptionHandling.Web.dll have to be added to your RequiredModuleTypes collection.

For logging exceptions handling I am using Microsoft Enterprise Library Logging Application Block. I m a huge fun of how well MSEL library is designed and browsing their source code is a best resource to learn.

Visual Studio eXpand Project Item template has been updated with configuration files containing all sections required by MSEL

MSEL has a configuration tool that helps you manage the configuration files and it is included at _third_party_assemblies eXpand folder along with other require MSEL assemblies. I have use that tool to create the sections required by MSEL.

So I have setup my application to send exceptions by email and also log them in the event viewer like shown in next figure

image

image

Subscribe to XAF feed
Subscribe to community feed

DiggIt!

Monday, February 8, 2010

Developing data analysis objects with the help of IO module

After creating PivotingChart Module I was able to really control the fluent DevExpress Pivot grid options at runtime and design more complex analysis pivoting UI writing no code and save all that “configuration” at the same database record as the analysis object.

But I was still developing inside my VS and since my model was not stable yet I continuous drop the database using the DxCore addin to drop database at design time which by the way have been updated to support multiple datastores

image

and damn I lose the designed analysis UI cause it was stored in the database

Time for some IO module use

I could export my analysis objects

image

and use the following import to load the configured objects at application start up

from an embedded resource

public class Updater : ModuleUpdater

{

    public Updater(Session session, Version currentDBVersion) : base(session, currentDBVersion) { }

    public override void UpdateDatabaseAfterUpdateSchema()

    {

        base.UpdateDatabaseAfterUpdateSchema();

        var unitOfWork = new UnitOfWork(Session.DataLayer);

        new ImportEngine().ImportObjects(unitOfWork,GetType(), "Resources.Analysis.xml");

        unitOfWork.CommitChanges();

    }

}

or from a file on your disk

public class Updater : ModuleUpdater

{

    public Updater(Session session, Version currentDBVersion) : base(session, currentDBVersion) { }

    public override void UpdateDatabaseAfterUpdateSchema()

    {

        base.UpdateDatabaseAfterUpdateSchema();

        var unitOfWork = new UnitOfWork(Session.DataLayer);

        new ImportEngine().ImportObjects(unitOfWork, @"c:\Analysis.xml");

        unitOfWork.CommitChanges();

    }

}

Subscribe to XAF feed
Subscribe to community feed

DiggIt!

Wednesday, February 3, 2010

Multiple datastores support

 

THE PROBLEM
WorldCreator creates dynamic types for used within Xaf. It is doing that by compiling code templates at WorldCreator module setup method. To find those templates it has to query a persistent datastore using XPO. Now when you create a new XPO session it will check if all object types that XPObjectType table contains if are valid. So if you have used customizedtypesinfo to create runtime associations since it is called after module setup it will throw an exception complaining for invalid tables.

Saying the above you understand that there is no way to open a connection to an XPO database that has records for objects with associations that have not fully defined.

THE SOLUTION

[AttributeUsage(AttributeTargets.Assembly,AllowMultiple = true)]

public class DataStoreAttribute:Attribute

{

    readonly Type _nameSpaceType;

    readonly string _dataStoreNameSuffix;

 

    public DataStoreAttribute(Type nameSpaceType, string dataStoreNameSuffix) {

        _nameSpaceType = nameSpaceType;

        _dataStoreNameSuffix = dataStoreNameSuffix;

    }

 

    public string NameSpace {

        get { return _nameSpaceType.Namespace; }

    }

 

    public string DataStoreNameSuffix {

        get { return _dataStoreNameSuffix; }

    }

}

You can add the above attribute to your AssemblyInfo.cs file to decouple all classes inside a namespace. I have already decouple WorldCreator objects using the following line in eXpand.BaseImpl

[assembly: DataStore(typeof(PersistentAssemblyInfo),"WorldCreator")]

The first parameter is the type that will provide the namespace to decouple and the secode the datastore name suffix.

If DataStoreAttribute is applied it will create a database in the same server as your default connectionstring. But if you want you can provide your own custom connectionstring like

<connectionStrings>

    <add name="ConnectionString" connectionString="Integrated Security=SSPI;Pooling=false;Data Source=SERVER;Initial Catalog=Solution1;"/>

    <add name="WorldCreatorConnectionString" connectionString="Integrated Security=SSPI;Pooling=false;Data Source=OTHERSERVER;Initial Catalog=WorldCreator;"/>

  </connectionStrings>

Ps: Sharing objects is not supported , so you have to be sure that all classes are defined in the namespace that you are decoupling

Subscribe to XAF feed
Subscribe to community feed

DiggIt!

Monday, February 1, 2010

New Pivoting module

eXpand says hi to its new Pivoting module.

Show In Analysis action similar to show in reports (see also Devexpress example)
image

All Pivot control settings can be controled at runtime using the Pivot Settings action

image

see for example the Pivot Options View settings view

image

ModelArtifacteState module has been used to create a Show In Analysis , Pivot Settings Permissions that can be applied to the Roles you want .

[NonPersistent]

public class ShowInAnalysisPermission : ControllerStateRulePermission {

    public override string ControllerType {

        get { return typeof (ShowInAnalysisViewController).FullName; }

        set { base.ControllerType = value; }

    }

 

    public override string ToString() {

        return string.Format("{1}: {0}", ID, GetType().Name);

    }

}

[NonPersistent]

public class PivotSettingsPermission : ControllerStateRulePermission {

    public override string ControllerType {

        get { return typeof (PivotOptionsController).FullName; }

        set { base.ControllerType = value; }

    }

 

    public override string ToString() {

        return string.Format("{1}: {0}", ID, GetType().Name);

    }

}

image

In place pivot editing by using the AllowEdit model attribute

image

AnalysisControlVisibility for controlling the visibility of Pivot or Chart control

image

PivotedPropertyAttribute

You can make at runtime complex views like the above by applying it.

image

Say you have an object with an associated collection property like

[Association("OwnerShellSite-CompetitorLinks")]

[Aggregated]

[DevExpress.Xpo.DisplayName("Competitors")]

public XPCollection<CompetitorLink> OwnerCompetitorLinks {

    get { return GetCollection<CompetitorLink>("OwnerCompetitorLinks"); }

}

if you like instead of the listview that will be shown by default to display a pivot upon OwnerCompetitorLinks collection then you just create another property like

[PivotedProperty("Prices", "Name='Site price analysis'")]

public Analysis PriceAnalysis {

    get { return _priceAnalysis; }

    set { SetPropertyValue("PriceAnalysis", ref _priceAnalysis, value); }

}

and eXpand will do the rest for you!!!

You may also want to pivot on an orphan collection

[Browsable(false)]

public XPCollection<Price> CompetitorPrices {

    get {

        return new XPCollection<Price>(Session);

    }

}

then you should use a different constructor like

[PivotedProperty("CompetitorPrices", "Name='Competitor site price analysis'","PropertyWithSameTypeAsCurrentObjectInPrice")]

public Analysis CompetitorPriceAnalysis {

    get { return _competitorPriceAnalysis; }

    set { SetPropertyValue("CompetitorPriceAnalysis", ref _competitorPriceAnalysis, value); }

}

In the following video you can see how you render any collection of your object with the pivot control in the same detailview as the object using eXpand’s PivotedPropertyAttribute at RUNTIME

The modules you have to register for Pivoting with eXpand would be eXpand.ExpressApp.PivotChart.dll ,eXpand.ExpressApp.PivotChart.Win.dll

Subscribe to XAF feed
Subscribe to community feed

DiggIt!