Quantcast
Channel: CSLA .NET
Viewing all 764 articles
Browse latest View live

PropertyHasChanged / MarkDirty

$
0
0

I'm using CSLA 4.5.501 from NuGet w/WPF.

In Rocky's eBook Creating Business Objects the MarkDirty Method says:
"By default this method not only effectively set IsSelfDirty to true, it also raises the PropertyChanged event with a property of string.Empty.  This tells the data bining to refresh the bindings on all the properties of the object, ensuring that the UI is up to date based on any changes that were committed to the object's state or metastate."

This is the behavior that I want, but when I change a text field on my model and step through in the debugger, only the Getters of the Affected properties are called.   Specifically I want a CSLA Property that accesses the metadata (IsDirty, IsValid, broken rules, etc.) to be updated in the UI when any of my read / write Properties are changed.

Has something changed since the book was written and if so, how do I get the behavior above?

Ray.


List of LoggedIn users

$
0
0

I wish to maintain a list of logged in users into a csla application. Where should I maintain it in Csla.ApplicationContext ? Or how should I maintain it?

Child DataPortal method calling a Dataportal method with TransactionScope attribute

$
0
0

I have some business objects that can be either root or child objects depending on the context.

Usually I simply call DataPortal_XXX from Child_XXX to avoid duplicate code. Is there any danger of this causing nested transactions due to the transaction scope attribute on the root dataportal function in the calling class?

I could put the "update stuff" into a private function to be safe, but I I am curious whether I need to or not.

Code:

[Transactional(TransactionalTypes.TransactionScope)]

protected override void DataPortal_Update()

 {

        // do update stuff

}

private void Child_Update()

{

        Dataportal_Update();

}

Error "Edit level mismatch in AcceptChanges" when save a Editable Root Collection

$
0
0

My project using CSLA 4. I am using a GridView to binding and update data. However when I update data after user edit on gridview. I always get an error : "Edit level mismatch in AcceptChanges"

The way I done it is:

Bars_Coll items = Bars_Coll.GetBar_Coll();

gridview.datasource = items;

after user edit a cell. I update by:

items.applyEdit();

items.Save();

This is the way that I learned from thread: http://forums.lhotka.net/forums/p/11468/53194.aspx 

Thank,

CSLA .NET Contrib 4.5.50 released

$
0
0

CslaContrib extension library to CSLA .NET 4.5.50 was published on CodePlex.
This release is version synchronized to CSLA .NET 4.5.501 and is also available on NuGet

Feature highlight

  • Fixes missing Silverlight assemblies for CslaContrib and CslaContrib.MEF packages
  • Adds SmartDateExtendedParser on CslaContrib package

 

SmartDateExtendedParser

Besides standard SmartDate parsing that converts to yesterday, today and tomorrow dates, the extended parser adds parsing for:

  • relative days, months and years (eg. "+90" will add 90 days to the current date)
  • short form date that is culture sensitive (eg. "0525" converts to "May 25 2014")
  • nearest day (eg. "20" converts to "May 20 2014" but "01" converts to Jun 01 2014)

Full specifications for SmartDateExtendedParser on attached file.

 

How to use the SmartDateExtendedParser?

 You just need to declare it once, like this:

Csla.SmartDate.CustomParser = CslaContrib.SmartDateExtendedParser.ExtendedParser;

 

CSLA

$
0
0

How to share information between multiple instances of Silverlight application in CSLA?

ReadOnlyBindingListBase AllowRemove

$
0
0

I have set AllowRemove = true but it still does not allow to remove item from the ReadOnlyBindingListBase

Is it possible?

Handy fluent-like quick rule to speed up writing your light-weight rules

$
0
0

Hi all

We've spend a considerable amount of time bringing a CSLA 3.8 project into the present with CSLA 4.5.

Our biggest challenge was the legacy rules, and while"converting" them is straight forward enough, it's a bit tedious and verbose (mostly for the small and simple ones).

PS: I'm aware of the hard work @JonnyBee has put into CSLA-Validation project to help with this special scenario of running legacy rules under CSLA 4's new rules system. Unfortunately, having to use special subclasses for our business objects made it a non-starter for us.

We found that we would regularly use the CSLA built-in Lambda rule for the convenient shorthand it offers on simplistic rules.

To make it even easier and more productive we created our own variation on the Lambda rule to make it a bit more flexible, compact and readable. Enter "QuickRule" Cool...

@JonnyBee / @Rocky - Feel free to adapt / use in framework, or just let me know if I should create a pull request for it if you want it in the framework.

With it you can write things like:

// Example 1. This sample creates and adds a lambda rule (LogChangeRule)

// for the primary property PostCode

BusinessRules.AddRule( new QuickRule( LogChangeRule ).For( PostCodeProperty ) );

 

// Example 2. This sample creates and adds a lambda rule (CheckIfExistsRule)

// for the primary property PostCode, and uses it as an input property

BusinessRules.AddRule( newQuickRule( CheckIfExistsRule ).For( PostCodeProperty ).UsingIt() );

 

// Example 3. This sample creates and adds a lambda rule (MutatePostCodeToUpperCase)

// for the primary property PostCode (using the PostCode as an "input property")

// and affects the FormattedAddress property as a consequence ("affected properties")

BusinessRules.AddRule(

    newQuickRule( MutatePostCodeToUpperCase )

    .For( PostCodeProperty ).UsingIt()

    .Affects( FormattedAddressProperty ) );

 

// Example 4. This sample creates and adds a Lambda rule (MutateTotals) for the primary

// property ProductCode and uses SellingPrice and Quantity properties as input properties.

// The LineTotal and Tax properties are affected by the rule.

BusinessRules.AddRule(

    newQuickRule( MutateTotals )

    .For( ProductCodeProperty )

    .Using( SellingPriceProperty, QuantityProperty )

    .Affects( LineTotalProperty, TaxProperty ) );

 

 

Please refer to the following gist for the implementation details.

https://gist.github.com/Jaans/d305de962638022b04e5

You are welcome to use and abuse as you see fit - just don't hold me liable ;-) 


Hope that helps,

Jaans

 

 


CSLA for HTML5

$
0
0

Does CSLA support HTML5?

If yes, please give any example.

Csla.NameValueListBase for Windows Forms or safe for WPF

$
0
0

Hi

Context: Given that BusinessBindingListBase<T,C> is for supporting Windows Forms under CSLA 4, and BusinessListBase<T,C> is the Xaml (ObservableCollection) equivalent, then what about NameValueListBase<K,V> ?

It is derived from the Csla.Core.ExtendedBindingListBase<T> type, so it would seem to be intended for supporting Windows Forms?

If that is indeed correct what is the WPF/XAML/ObservableCollection equivalent, or is it safe for usage with the XAML binding?

Thanks,
Jaans 

CSLA 4.3.14

$
0
0

Hey, 

We have recently moved from CSLA 4.0.3 to CSLA 4.3.14.2. 

Everything has been working well until a colleague has mentions that they are no longer able to see what is currently within the deleted list.

On looking at the deleted list it seems to be a 'object' however i thought it was treated as a list(of T) so you can see what is current inside the deleted list.

Because of that we are unable to see what is currently in the deleted list AND to remove items from the list.

 

When trying to do ?me.deletedList in the intermediate window i get the following message. 

{"The generic type 'Csla.BusinessBindingListBase`2' was used with the wrong number of generic arguments in assembly 'Csla, Version=4.3.14.1, Culture=neutral, PublicKeyToken=93be5fdc093e4c30'.":"Csla.BusinessBindingListBase`2"}

    _HResult: -2146233054

    _message: "The generic type'Csla.BusinessBindingListBase`2' was used with the wrong number of generic arguments in assembly 'Csla, Version=4.3.14.1, Culture=neutral, PublicKeyToken=93be5fdc093e4c30'."

    Data: {System.Collections.ListDictionaryInternal}

    HelpLink: Nothing

    HResult: -2146233054

    InnerException: Nothing

    IsTransient: False

    Message: "The generic type'Csla.BusinessBindingListBase`2' was used with the wrong number of generic arguments in assembly 'Csla, Version=4.3.14.1, Culture=neutral, PublicKeyToken=93be5fdc093e4c30'."

    ResourceId: 6731

    Source: Nothing

    StackTrace: Nothing

    TargetSite: Nothing

 

    TypeName:"Csla.BusinessBindingListBase`2"

-------------------------------------------------------------

 

FieldData always mark object as dirty

$
0
0

When I call CancelEdit in an object, the UndoChanges method set the FieldData.Value property and that property always set isDirty to true. If I check the IsDirty property before close the edition form to warn the user about changes not saved, I always get IsDirty = true. So I changed the FieldData.Value property to this:

        public virtual T Value

        {

            get

            {

                return _data;

            }

            set

            {

                if (_data == null && value == null)

                    return;

                if ((_data != null && !_data.Equals(value)) || 

                    (value != null && !value.Equals(_data)))

                {

                    _data = value;

                    _isDirty = true;

                }

            }

        }

Are there any problem in changing that property the way I've done?

CSLA 4.x TransactionalDataPortal has a breaking change compared to CSLA 3.8

$
0
0

Houston we have a problem. I've been using both CSLA 4.x and 3.8 for some time now, and haven't run across this issue until now, where we are upgrading a CSLA 3.8 based project to CSLA 4.5.

This specific project executes along with other external application components from COM+ (Enterprise Services), making it sensitive to 2PC and Transaction Isolation levels.

Context: I'm referring to using the [Transactional( TransactionalTypes.TransactionScope )] attribute on the DataPortal_XYZ methods.

For most CSLA projects, the transaction starts from the DataPortal_XYZ methods and seldom goes further to include other transactions. We have combinations of both, and specifically, we let the DataPortal_XYZ methods "take-on" the transaction isolation level of the caller. This may vary in that one caller has one isolation level, and another caller may use a different one (don't you just love integration work Ick! ).

What cannot be done is to have a caller use one isolation level, and then have the subsequent DataPortal_XYZ method execute under a different isolation level, when it is enrolled in the same transaction scope of the caller (TransactionScope = Required).

The implementation of the CSLA 3.8 Transactional DataPortal code had created a new System.Transactions.TransactionScope instance using the default parameterless constructor. This default constructor assumes a Scope = Required but specficially does not specify an isolation level. There is no default here, it's unspecified.

Here is the code for the CSLA 3.8 version: http://www.lhotka.net/cslacvs/viewvc.cgi/core/branches/V3-8-x/cslacs/Csla/Server/TransactionalDataPortal.cs?revision=4288&view=markup

The implementation of the CSLA 4.5 Transactional DataPortal looks to have some refactorings and actually creates a new System.Transactions.TransactionScope instance using a constructor overload that takes both the Scope and the Isolation level as parameters. The Scope is defaulted to Required (when not expressly specified in the DataPortal_XYZ attribute), which matches the original behaviour. But, the isolation level is also specified in this overload, using a default value of Serializable and therein lies the rub, it's not unspecified/omitted.

Here is the code for the latest CSLA 4.5.x version: https://github.com/MarimerLLC/csla/blob/master/Source/Csla/Server/TransactionalDataPortal.cs

This default of Serializable is the safest (though most expensive) isolation level and makes a good default. Unfortunately, it is not the same behaviour as with CSLA 3.8, and does not allow the "flow from caller" scenario.

Please note I'm pointing out a subtle difference here.
Of course you can specify any isolation level that you want in the DataPortal_XYZ attribute (e.g. [Transactional( TransactionalTypes.TransactionScope, TransactionIsolationLevel.RepeatableRead )] but that is not the issue. The issue is that by specifying it in the first place, results that it will always be that isolation level, regardless of the isolation level flowed from caller's scope (if one is present).

With CSLA 3.8's implementation it would also have IMPLICITLY defaulted to serializable, but only if the isolation level from a caller's scope was not different, in which case it would've taken the isolation level of the caller.

With CSLA 4.5's implementation it is EXPLICITLY set to serializable by CSLA's default behavior, resulting in a transaction exception faulting the mismatch of isolation levels (the one from the callers scope not matching the one set on the DataPortal_XYZ.

It turns out the System.Transactions.IsolationLevel enumeration has an Unspecified option.
Refer: http://msdn.microsoft.com/en-au/library/system.transactions.isolationlevel.aspx

I've done some tests and if I manually create a transaction scope using the same overload as CSLA 4 but then use this "Unspecified" option is works as expected and behaves as per CSLA 3.8 allowing me to "flow" the isolation level from the caller.

Unfortunately, the ApplicationContext.DefaultTransactionIsolationLevel does not have an Unspecified enumeration either).

@Jonny / @Rocky - Would you accept this as an issue for rectification?

I really hope so, as this is a show stopper for our project development at the moment.

In mind, the fix would be to either:

  • Add a matching "Unspecified" option to the CSLA TransactionIsolationLevel enumeration and use that is the default value instead of Serializable in the method:
    private IsolationLevel GetIsolationLevel(TransactionIsolationLevel transactionIsolationLevel) {...}

    (Probably the easiest and least amount of code changes).

    alternatively,
  • Find some way call the same default parameterless constructor as CSLA 3.8 when no express values are set for the Transactional attribute on the DataPortal_XYZ methods.

 

I'd be happy to try and put a pull-request together if that would help further.
Thanks a million,

Jaans

 

 

CSLA and the new ASP.NET Web API

$
0
0

I was going through some of the examples on the new web API that is part of the asp.net mvc 4 beta release.  Does CSLA fit with the Web API model?  I'm new to ASP.NET MVC and am trying to figure out if I should consider the web API for use with CSLA.  Thanks.

Custom Proxy Factory with WinRT in v.4.5.501

$
0
0

I'm following the Using CSLA Data Portal e-book where it talks about implementing a custom proxy factory so that an app can support occasionally connected scenarios.

The SL example project shows the custom class that implements Csla.DataPortalClient.ProxyFactory. This doesn't appear to be valid interface within the Csla namespace for WinRT in v4.5.501. I do see IDataPortalProxyFactory, but this interface doesn't contain an overridable GetProxy method, which is necessary.

Are there changes in 4.5.501 that changes how I should create a custom proxy factory? Thanks.


BusinessRule - How to get context.Target to have the current values

$
0
0

I am trying to create a business rule that needs the current value of two other fields in the target object.  The target object always has the previous values when the rule executes.  Is there a working example of how to implement a business rule that interacts with the business object.

Thanks.

Joe

Anyone using AngularJS and CSLA

$
0
0

If so any help/pointers/example code as to the best way to go would be very much appreciated.

Authentication for WinRT devices joined to a domain

$
0
0

We will have tablets running Win 8.1 Pro that will be joined to the domain, and users will sign in to those devices with their network credentials; however, I don't anticipate them connecting to the network via VPN while on the road. Instead, I expect the app to hit our remote DP on the DMZ, which in turn would talk to our internal app server behind the firewall. So it is a 4-tier deployment. In in this context, will I have access to their identify when sending requests to the remote DP?

In other words, can I utilize ApplicationContext.User in the domain-joined WinRT world? Or should I expect to require the user to enter his credentials in the app itself and pass them (over https) with every call to the remote DP for authentication on the server? Thanks.

VSTO and CSLA 2.0 Error

$
0
0

I am using CSLA in a VSTO Outlook add-in project.  I am getting the following error:

Exception of type 'System.Runtime.Serialization.SerializationException'. ... 'Unable to find assembly 'CSLA, Version=2.0.0.0,. . .. '

I narrowed it down to a call to set the user on the app context with :

ApplicationContext.User = (IPrincipal) myCustomPrincipal.

I do have a custom principal object inherited from BusinessPrincipalBase.

I also noticed that when under VSTO the Thread.CurrentPrincipal is always GenericPrincipal unless I set the current principal to null first.  Wondering if anyone else has used CSLA with VSTO and specifically the security.

Thanks,
David

 

EditLevelMismatch with grandchild (SL / CSLA 4.5.500)

$
0
0

Dear Rocky, dear all,

I'm facing some EditLevelMismatch in Silverlight 5 & CSLA 4.5.500

My scenario is to have a DynamicListBase "ChildList" with children: "Child "and a grand child:  "Child" (the same type used for children).

 

I'm opening the details of a 'Child', then add a grand child (the Clone of itself), then commit the changes:

 

(Child as IEditableObject).BeginEdit(); -- Child.EditLevel = 1 which seems fine

Child.GrandChild = Child.CloneAsNew();     -- GrandChild.EditLevel = 0, due to UndoableBase.ResetChildEditLevel, as the bindingEdit is true:

      -- if (bindingEdit && targetLevel > 0 && !(child is FieldManager.FieldDataManager))

      --     targetLevel--;

(Child as IEditableObject).EndEdit(); -- UndoException in AcceptChanges(0), it seems that 1 is expected for the child.EditLevel

 

 

With CloneAsNew() being sensibely equal to:

var clone = this.Clone();

clone.ID = -1;  --reset primary key

clone.MarkNew();

clone.BusinessRules.CheckRules()

return clone;

 

Am I doing something wrong? Is this an unsupported scenario?

I just reopened your very good "Expert VB 2008 Business Objects" N-Level Undo... but I can't get it right.

Any guidance will be welcome.

Regards,

Gilles

Viewing all 764 articles
Browse latest View live